Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can't get Superblock Info

7 views
Skip to first unread message

Mateusz_madi

unread,
Sep 22, 2012, 2:10:03 PM9/22/12
to
Hi after checking Marc Rochkind book i tried to read some superblock records, but got only 0 and wrong info, below is program:

00032 #include "defs.h"
00033 #include <sys/param.h>
00034 #include <ufs/ffs/fs.h>
00035 #include <ufs/ufs/dinode.h>
00036
00037 #define DEVICE "/dev/ad0s1g"
00038
00039 int main(int argc, char *argv[])
00040 {
00041 int fd;
00042 long inumber;
00043 char sb_buf[((sizeof(struct fs) / DEV_BSIZE) + 1) * DEV_BSIZE];
00044 struct fs *superblock = (struct fs *)sb_buf;
00045 struct dinode *d;
00046 ssize_t nread;
00047 off_t fsbo, fsba;
00048 char *inode_buf;
00049 size_t inode_buf_size;
00050
00056
00057 fd = open(DEVICE, O_RDONLY) ;
00058 lseek(fd, SBLOCKSIZE * DEV_BSIZE, SEEK_SET);
00059 nread = read(fd, sb_buf, sizeof(sb_buf)) {

00073 printf("Superblock info for %s:\n", DEVICE);
00074 printf("\tlast time written = %s", ctime(&superblock->fs_time));
00075 printf("\tnumber of blocks in fs = %ld\n", (long)superblock->fs_size);
00076 printf("\tnumber of data blocks in fs = %ld\n", (long)superblock->fs_dsize);
00077 printf("\tsize of basic blocks in fs = %ld\n", (long)superblock->fs_bsize);
00078 printf("\tsize of frag blocks in fs = %ld\n", (long)superblock->fs_fsize);
00079 printf("\tname mounted on = %s\n", superblock->fs_fsmnt);
}
0 new messages