diff options
Diffstat (limited to 'sys/ufs/ffs/ffs_subr.c')
-rw-r--r-- | sys/ufs/ffs/ffs_subr.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 601a4cf..7d7de14 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_subr.c 8.5 (Berkeley) 3/21/95 - * $Id: ffs_subr.c,v 1.18 1998/02/06 12:14:14 eivind Exp $ + * $Id: ffs_subr.c,v 1.19 1998/02/13 00:20:36 bde Exp $ */ #include <sys/param.h> @@ -191,6 +191,30 @@ ffs_isblock(fs, cp, h) } /* + * check if a block is free + */ +int +ffs_isfreeblock(fs, cp, h) + struct fs *fs; + unsigned char *cp; + ufs_daddr_t h; +{ + + switch ((int)fs->fs_frag) { + case 8: + return (cp[h] == 0); + case 4: + return ((cp[h >> 1] & (0x0f << ((h & 0x1) << 2))) == 0); + case 2: + return ((cp[h >> 2] & (0x03 << ((h & 0x3) << 1))) == 0); + case 1: + return ((cp[h >> 3] & (0x01 << (h & 0x7))) == 0); + default: + panic("ffs_isfreeblock"); + } +} + +/* * take a block out of the map */ void |