/* * Copyright (c) 1997 David Brownlee (abs@mono.org). Licence at end of file. * Attempt to find ffs filesystems in the event of a lost disklabel. * * This program itself will not modify any data on a disk, but using * disklabel and fsck _can_ cause loss of data - you have been warned! * * Compile with 'cc -Wall -O -o ffs_find ffs_find.c'. * * To use, run 'ffs_find /dev/rXXNc' (eg rsd0c, rsd1c, or rwd0c etc), note the * possible filesystems, disklabel appropriately and try to fsck. * (May want to use /dev/rXXNd on i386). * * It reports possible filesystems by checking for two 'superblock like' * blocks fs.fs_sblkno blocks apart. * * Caveats: * It can find false positives. (It should check more rigorously). * It assumes 512 byte blocks. * It assumes the first & second superblocks of a filesystem are intact, * and at offsets of fs.fs_sblkno and fs.fs_sblkno*2 respectively. * The 'trick' with sbplus is not particularly palatable, * * Comments/suggestions welcome! */ #include #include #include #include #ifdef __FreeBSD__ #include #include #else #include BLOCKSIZE) memmove(&sblock.data,((char *)&sblock.data)+BLOCKSIZE, SB_SIZE-BLOCKSIZE); ++blockno; } while(fread(((char *)&sblock.data)+SB_SIZE-BLOCKSIZE,BLOCKSIZE,1,fds)); return(0); }