void quot(char *name, char *mp) { int fd; get_inode(-1, NULL, 0); /* flush cache */ inituser(); initfsizes(); if ((fd = open(name,0)) < 0 || lseek(fd,SBOFF,0) != SBOFF || read(fd,superblock,SBSIZE) != SBSIZE) { warn("%s", name); close(fd); return; } if (((struct fs *)superblock)->fs_magic != FS_MAGIC) { warnx("%s: not a BSD filesystem",name); close(fd); return; } printf("%s:",name); if (mp) printf(" (%s)",mp); putchar('\n'); (*func)(fd,(struct fs *)superblock,name); close(fd); }
void quot(char *name, char *mp) { int fd; struct fs *fs; get_inode(-1, NULL, 0); /* flush cache */ inituser(); initfsizes(); if ((fd = open(name,0)) < 0) { warn("%s", name); close(fd); return; } switch (sbget(fd, &fs, -1)) { case 0: break; case ENOENT: warn("Cannot find file system superblock"); close(fd); return; default: warn("Unable to read file system superblock"); close(fd); return; } printf("%s:",name); if (mp) printf(" (%s)",mp); putchar('\n'); (*func)(fd, fs, name); close(fd); }
void quot(char *name, char *mp) { int i, fd; struct fs *fs; get_inode(-1, NULL, 0); /* flush cache */ inituser(); initfsizes(); /* * XXX this is completely broken. Of course you can't read a * directory, well, not anymore. How to fix this, though... */ if ((fd = open(name, 0)) < 0) { warn("%s", name); return; } for (i = 0; sblock_try[i] != -1; i++) { if (lseek(fd, sblock_try[i], 0) != sblock_try[i]) { close(fd); return; } if (read(fd, superblock, SBLOCKSIZE) != SBLOCKSIZE) { close(fd); return; } fs = (struct fs *)superblock; if ((fs->fs_magic == FS_UFS1_MAGIC || (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_sblockloc == sblock_try[i])) && fs->fs_bsize <= MAXBSIZE && fs->fs_bsize >= sizeof(struct fs)) break; } if (sblock_try[i] == -1) { warnx("%s: not a BSD filesystem", name); close(fd); return; } ffs_oldfscompat(fs); printf("%s:", name); if (mp) printf(" (%s)", mp); putchar('\n'); (*func)(fd, fs, name); close(fd); }
void quot(char *name, char *mp) { int i, fd; struct fs *fs; get_inode(-1, NULL, 0); /* flush cache */ inituser(); initfsizes(); if ((fd = open(name,0)) < 0) { warn("%s", name); close(fd); return; } for (i = 0; sblock_try[i] != -1; i++) { if (lseek(fd, sblock_try[i], 0) != sblock_try[i]) { close(fd); return; } if (read(fd, superblock, SBLOCKSIZE) != SBLOCKSIZE) { close(fd); return; } fs = (struct fs *)superblock; if ((fs->fs_magic == FS_UFS1_MAGIC || (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_sblockloc == sblock_try[i])) && fs->fs_bsize <= MAXBSIZE && fs->fs_bsize >= sizeof(struct fs)) break; } if (sblock_try[i] == -1) { warnx("%s: not a BSD filesystem",name); close(fd); return; } printf("%s:",name); if (mp) printf(" (%s)",mp); putchar('\n'); (*func)(fd, fs, name); close(fd); }