aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2022-02-23 23:39:52 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2022-02-23 23:40:58 +0000
commitc5d476c98c2275966f68c7b81dab2421b143f5a9 (patch)
treeaa15e50980ed4aa3f003c334943d4dc06f62be47 /sbin/fsck_ffs
parente3d92d4cb811006688bb18ba35bfbe6e1f119893 (diff)
downloadsrc-c5d476c98c2275966f68c7b81dab2421b143f5a9.tar.gz
src-c5d476c98c2275966f68c7b81dab2421b143f5a9.zip
Update fsdb(8) to reflect new structure of fsck_ffs(8).
The cleanup of fsck_ffs(8) in commit c0bfa109b942659f6 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
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r--sbin/fsck_ffs/fsck.h1
-rw-r--r--sbin/fsck_ffs/main.c39
-rw-r--r--sbin/fsck_ffs/setup.c39
3 files changed, 40 insertions, 39 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 690a98038884..daa346826eff 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -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);
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 9ea5f5b91110..2724893a5b9a 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -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)
{
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index bbb8a854e999..66f4f59004cb 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -211,6 +211,44 @@ badsb:
}
/*
+ * 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.
*/
int
@@ -331,6 +369,7 @@ void
sblock_init(void)
{
+ fsreadfd = -1;
fswritefd = -1;
fsmodified = 0;
lfdir = 0;