Update fsdb(8) to reflect new structure of fsck_ffs(8).

The cleanup of fsck_ffs(8) in commit c0bfa109b9 broke fsdb(8).
This commit adds the one-line update needed in fsdb(8) to make it
work with the new fsck_ffs(8) structure.

Reported by: Chuck Silvers
Tested by:   Chuck Silvers
MFC after:   3 days
This commit is contained in:
Kirk McKusick 2022-02-23 15:39:52 -08:00
parent e3d92d4cb8
commit c5d476c98c
4 changed files with 41 additions and 40 deletions

View file

@ -490,6 +490,7 @@ struct inostat *inoinfo(ino_t inum);
void IOstats(char *what);
int linkup(ino_t orphan, ino_t parentdir, char *name);
int makeentry(ino_t parent, ino_t ino, const char *name);
int openfilesys(char *dev);
void panic(const char *fmt, ...) __printflike(1, 2);
void pass1(void);
void pass1b(void);

View file

@ -76,7 +76,6 @@ static void usage(void) __dead2;
static intmax_t argtoimax(int flag, const char *req, const char *str, int base);
static int checkfilesys(char *filesys);
static int setup_bkgrdchk(struct statfs *mntp, int sbrdfailed, char **filesys);
static int openfilesys(char *dev);
static int chkdoreload(struct statfs *mntp);
static struct statfs *getmntpt(const char *);
@ -715,44 +714,6 @@ setup_bkgrdchk(struct statfs *mntp, int sbreadfailed, char **filesys)
return (1);
}
/*
* Open a device or file to be checked by fsck.
*/
static int
openfilesys(char *dev)
{
struct stat statb;
int saved_fsreadfd;
if (stat(dev, &statb) < 0) {
pfatal("CANNOT STAT %s: %s\n", dev, strerror(errno));
return (0);
}
if ((statb.st_mode & S_IFMT) != S_IFCHR &&
(statb.st_mode & S_IFMT) != S_IFBLK) {
if (bkgrdflag != 0 && (statb.st_flags & SF_SNAPSHOT) == 0) {
pfatal("BACKGROUND FSCK LACKS A SNAPSHOT\n");
exit(EEXIT);
}
if (bkgrdflag != 0) {
cursnapshot = statb.st_ino;
} else {
pfatal("%s IS NOT A DISK DEVICE\n", dev);
if (reply("CONTINUE") == 0)
return (0);
}
}
saved_fsreadfd = fsreadfd;
if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
fsreadfd = saved_fsreadfd;
pfatal("CANNOT OPEN %s: %s\n", dev, strerror(errno));
return (0);
}
if (saved_fsreadfd != -1)
close(saved_fsreadfd);
return (1);
}
static int
chkdoreload(struct statfs *mntp)
{

View file

@ -210,6 +210,44 @@ setup(char *dev)
return (0);
}
/*
* Open a device or file to be checked by fsck.
*/
int
openfilesys(char *dev)
{
struct stat statb;
int saved_fsreadfd;
if (stat(dev, &statb) < 0) {
pfatal("CANNOT STAT %s: %s\n", dev, strerror(errno));
return (0);
}
if ((statb.st_mode & S_IFMT) != S_IFCHR &&
(statb.st_mode & S_IFMT) != S_IFBLK) {
if (bkgrdflag != 0 && (statb.st_flags & SF_SNAPSHOT) == 0) {
pfatal("BACKGROUND FSCK LACKS A SNAPSHOT\n");
exit(EEXIT);
}
if (bkgrdflag != 0) {
cursnapshot = statb.st_ino;
} else {
pfatal("%s IS NOT A DISK DEVICE\n", dev);
if (reply("CONTINUE") == 0)
return (0);
}
}
saved_fsreadfd = fsreadfd;
if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
fsreadfd = saved_fsreadfd;
pfatal("CANNOT OPEN %s: %s\n", dev, strerror(errno));
return (0);
}
if (saved_fsreadfd != -1)
close(saved_fsreadfd);
return (1);
}
/*
* Read in the super block and its summary info.
*/
@ -331,6 +369,7 @@ void
sblock_init(void)
{
fsreadfd = -1;
fswritefd = -1;
fsmodified = 0;
lfdir = 0;

View file

@ -111,7 +111,7 @@ main(int argc, char *argv[])
fsys = argv[0];
sblock_init();
if (!setup(fsys))
if (openfilesys(fsys) == 0 || readsb(0) == 0 || setup(fsys) == 0)
errx(1, "cannot set up file system `%s'", fsys);
if (fswritefd < 0)
nflag++;