Index: scan_ffs.c =================================================================== RCS file: /cvs/src/sbin/scan_ffs/scan_ffs.c,v retrieving revision 1.8 diff -u -r1.8 scan_ffs.c --- scan_ffs.c 3 Jul 2002 22:32:33 -0000 1.8 +++ scan_ffs.c 12 Nov 2002 22:21:55 -0000 @@ -30,17 +30,20 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include +#include #include + +#include #include + #include #include #include #include #include #include -#include +/* #include */ #define SBCOUNT 64 /* XXX - Should be configurable */ @@ -53,7 +56,7 @@ ufsscan(int fd, daddr_t beg, daddr_t end, int flags) { static char lastmount[MAXMNTLEN]; - static u_int8_t buf[SBSIZE * SBCOUNT]; + static u_int8_t buf[SBLOCKSIZE * SBCOUNT]; struct fs *sb; daddr_t blk, lastblk; int n; @@ -61,43 +64,43 @@ lastblk = -1; memset(lastmount, 0, MAXMNTLEN); - for (blk = beg; blk <= ((end<0)?blk:end); blk += (SBCOUNT*SBSIZE/512)){ - memset(buf, 0, SBSIZE * SBCOUNT); + for (blk = beg; blk <= ((end<0)?blk:end); blk += (SBCOUNT*SBLOCKSIZE/512)){ + memset(buf, 0, SBLOCKSIZE * SBCOUNT); if (lseek(fd, (off_t)blk * 512, SEEK_SET) < 0) err(1, "lseek"); - if (read(fd, buf, SBSIZE * SBCOUNT) < 0) + if (read(fd, buf, SBLOCKSIZE * SBCOUNT) < 0) err(1, "read"); - for (n = 0; n < (SBSIZE * SBCOUNT); n += 512){ + for (n = 0; n < (SBLOCKSIZE * SBCOUNT); n += 512){ sb = (struct fs*)(&buf[n]); - if (sb->fs_magic == FS_MAGIC) { + if (sb->fs_magic == FS_UFS1_MAGIC) { if (flags & FLAG_VERBOSE) printf("block %d id %x,%x size %d\n", blk + (n/512), sb->fs_id[0], sb->fs_id[1], sb->fs_size); - if (((blk+(n/512)) - lastblk) == (SBSIZE/512)) { + if (((blk+(n/512)) - lastblk) == (SBLOCKSIZE/512)) { if (flags & FLAG_LABELS ) { printf("X: %d %d 4.2BSD %d %d %d # %s\n", (daddr_t)((off_t)sb->fs_size * sb->fs_fsize / 512), - blk+(n/512)-(2*SBSIZE/512), + blk+(n/512)-(2*SBLOCKSIZE/512), sb->fs_fsize, sb->fs_bsize, - sb->fs_cpg, lastmount); + sb->fs_old_cpg, lastmount); } else { printf("ffs at %d size %lld " "mount %s time %s", - blk+(n/512)-(2*SBSIZE/512), + blk+(n/512)-(2*SBLOCKSIZE/512), (long long)(off_t)sb->fs_size * sb->fs_fsize, - lastmount, ctime(&sb->fs_time)); + lastmount, ctime(&sb->fs_old_time)); } if (flags & FLAG_SMART) { off_t size = (off_t)sb->fs_size * sb->fs_fsize; - if ((n + size) < (SBSIZE * SBCOUNT)) + if ((n + size) < (SBLOCKSIZE * SBCOUNT)) n += size; else { blk += (size/512 - @@ -161,7 +164,8 @@ if (argc != 1) usage(1); - fd = opendev(argv[0], O_RDONLY, OPENDEV_PART, NULL); + /* XXX fd = opendev(argv[0], O_RDONLY, OPENDEV_PART, NULL); */ + fd = open(argv[0], O_RDONLY, NULL); if (fd < 0) err(1, "%s", argv[1]);