:On Tue, 12 Mar 2002, Terry Lambert wrote: : :> #define blkmap(fs, map, loc) \ :> (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag))) :> :> looks a little suspect, doesn't it? "& 0" for 8 is probably :> correct, but "& 1" for 4 and "& 2" for 2 and "& 4" for 1 is :> probably not right... maybe: :> :> #define blkmap(fs, map, loc) \ :> (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & 0xff & ((0xff >> (NBBY - :> (fs)->fs_frag))^0xff)) :> :> Would be more right? After all, it's the high bits of the low :> bits you want to save, not the low bits of the low bits... :> :> -- Terry : :FWIW, I didn't mean to ignore this message, I was going to look it over :carefully before commenting. However, Sid Meier told me that I needed to :spend some time taking over the world, so I was unable to. : :If anyone familiar with FFS wants to check it out, please be my guest, :otherwise I'll try to get to it soon. : :Mike "Silby" Silbersack
That doesn't look like '& 0' for 8 to me. NBBY is 8, fs_frag of 8, results in 0xFF >> 0 which is 0xFF, not 0. The original code looks correct. Try this: -Matt Matthew Dillon <[EMAIL PROTECTED]> /* * BLKMAP.C * * #define blkmap(fs, map, loc) \ (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag))) * * bno = block number (in fragment-sized blocks) * frag = fragment ratio N:1 * */ #include <stdio.h> #define NBBY 8 int main(int ac, char **av) { int bno; for (bno = 0; bno < 32; ++bno) { int frag; if ((bno & 15) == 0) printf("BLOCK\t8:1\t\t\t4:1\t\t\t2:1\t\t\t1:1\n"); printf("%5d", bno); for (frag = 8; frag >= 1; frag >>= 1) { printf("\t([%d] >> %d) & 0x%02x", bno / NBBY, bno % NBBY, 0xFF >> (NBBY - frag) ); } printf("\n"); } return(0); } To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message