From 44eb44a9e89f713e7927093b25547d6532b4b728 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 27 Nov 1999 20:02:27 +0000 Subject: [PATCH] Make fsck even more char/blk dev tolerant. --- sbin/fsck/preen.c | 24 ++++++++---------------- sbin/fsck/setup.c | 5 +++-- sbin/fsck_ffs/preen.c | 24 ++++++++---------------- sbin/fsck_ffs/setup.c | 5 +++-- sbin/fsck_ifs/preen.c | 24 ++++++++---------------- sbin/fsck_ifs/setup.c | 5 +++-- sbin/quotacheck/preen.c | 24 ++++++++---------------- 7 files changed, 41 insertions(+), 70 deletions(-) diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index aedb5921cd9..fc6dd23c430 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -309,24 +309,16 @@ blockcheck(origname) printf("Can't stat %s: %s\n", newname, strerror(errno)); return (origname); } - if ((stblock.st_mode & S_IFMT) == S_IFBLK || - (stblock.st_mode & S_IFMT) == S_IFCHR) { + switch(stblock.st_mode & S_IFMT) { + case S_IFCHR: + case S_IFBLK: if (stslash.st_dev == stblock.st_rdev) hotroot++; - raw = newname; - if (stat(raw, &stchar) < 0) { - printf("Can't stat %s: %s\n", raw, strerror(errno)); - return (origname); - } - if ((stchar.st_mode & S_IFMT) == S_IFCHR) { - if (stslash.st_dev == stchar.st_rdev) - hotroot++; - return (raw); - } else { - printf("%s is not a character device\n", raw); - return (origname); - } - } else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) { + return(newname); + case S_IFDIR: + if (retried) + break; + len = strlen(origname) - 1; if (len > 0 && origname[len] == '/') /* remove trailing slash */ diff --git a/sbin/fsck/setup.c b/sbin/fsck/setup.c index 7444d37536c..0df8e98d3c2 100644 --- a/sbin/fsck/setup.c +++ b/sbin/fsck/setup.c @@ -87,8 +87,9 @@ setup(dev) printf("Can't stat %s: %s\n", dev, strerror(errno)); return (0); } - if ((statb.st_mode & S_IFMT) != S_IFCHR) { - pfatal("%s is not a character device", dev); + if ((statb.st_mode & S_IFMT) != S_IFCHR && + (statb.st_mode & S_IFMT) != S_IFBLK) { + pfatal("%s is not a disk device", dev); if (reply("CONTINUE") == 0) return (0); } diff --git a/sbin/fsck_ffs/preen.c b/sbin/fsck_ffs/preen.c index aedb5921cd9..fc6dd23c430 100644 --- a/sbin/fsck_ffs/preen.c +++ b/sbin/fsck_ffs/preen.c @@ -309,24 +309,16 @@ blockcheck(origname) printf("Can't stat %s: %s\n", newname, strerror(errno)); return (origname); } - if ((stblock.st_mode & S_IFMT) == S_IFBLK || - (stblock.st_mode & S_IFMT) == S_IFCHR) { + switch(stblock.st_mode & S_IFMT) { + case S_IFCHR: + case S_IFBLK: if (stslash.st_dev == stblock.st_rdev) hotroot++; - raw = newname; - if (stat(raw, &stchar) < 0) { - printf("Can't stat %s: %s\n", raw, strerror(errno)); - return (origname); - } - if ((stchar.st_mode & S_IFMT) == S_IFCHR) { - if (stslash.st_dev == stchar.st_rdev) - hotroot++; - return (raw); - } else { - printf("%s is not a character device\n", raw); - return (origname); - } - } else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) { + return(newname); + case S_IFDIR: + if (retried) + break; + len = strlen(origname) - 1; if (len > 0 && origname[len] == '/') /* remove trailing slash */ diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 7444d37536c..0df8e98d3c2 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -87,8 +87,9 @@ setup(dev) printf("Can't stat %s: %s\n", dev, strerror(errno)); return (0); } - if ((statb.st_mode & S_IFMT) != S_IFCHR) { - pfatal("%s is not a character device", dev); + if ((statb.st_mode & S_IFMT) != S_IFCHR && + (statb.st_mode & S_IFMT) != S_IFBLK) { + pfatal("%s is not a disk device", dev); if (reply("CONTINUE") == 0) return (0); } diff --git a/sbin/fsck_ifs/preen.c b/sbin/fsck_ifs/preen.c index aedb5921cd9..fc6dd23c430 100644 --- a/sbin/fsck_ifs/preen.c +++ b/sbin/fsck_ifs/preen.c @@ -309,24 +309,16 @@ blockcheck(origname) printf("Can't stat %s: %s\n", newname, strerror(errno)); return (origname); } - if ((stblock.st_mode & S_IFMT) == S_IFBLK || - (stblock.st_mode & S_IFMT) == S_IFCHR) { + switch(stblock.st_mode & S_IFMT) { + case S_IFCHR: + case S_IFBLK: if (stslash.st_dev == stblock.st_rdev) hotroot++; - raw = newname; - if (stat(raw, &stchar) < 0) { - printf("Can't stat %s: %s\n", raw, strerror(errno)); - return (origname); - } - if ((stchar.st_mode & S_IFMT) == S_IFCHR) { - if (stslash.st_dev == stchar.st_rdev) - hotroot++; - return (raw); - } else { - printf("%s is not a character device\n", raw); - return (origname); - } - } else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) { + return(newname); + case S_IFDIR: + if (retried) + break; + len = strlen(origname) - 1; if (len > 0 && origname[len] == '/') /* remove trailing slash */ diff --git a/sbin/fsck_ifs/setup.c b/sbin/fsck_ifs/setup.c index 7444d37536c..0df8e98d3c2 100644 --- a/sbin/fsck_ifs/setup.c +++ b/sbin/fsck_ifs/setup.c @@ -87,8 +87,9 @@ setup(dev) printf("Can't stat %s: %s\n", dev, strerror(errno)); return (0); } - if ((statb.st_mode & S_IFMT) != S_IFCHR) { - pfatal("%s is not a character device", dev); + if ((statb.st_mode & S_IFMT) != S_IFCHR && + (statb.st_mode & S_IFMT) != S_IFBLK) { + pfatal("%s is not a disk device", dev); if (reply("CONTINUE") == 0) return (0); } diff --git a/sbin/quotacheck/preen.c b/sbin/quotacheck/preen.c index aedb5921cd9..fc6dd23c430 100644 --- a/sbin/quotacheck/preen.c +++ b/sbin/quotacheck/preen.c @@ -309,24 +309,16 @@ blockcheck(origname) printf("Can't stat %s: %s\n", newname, strerror(errno)); return (origname); } - if ((stblock.st_mode & S_IFMT) == S_IFBLK || - (stblock.st_mode & S_IFMT) == S_IFCHR) { + switch(stblock.st_mode & S_IFMT) { + case S_IFCHR: + case S_IFBLK: if (stslash.st_dev == stblock.st_rdev) hotroot++; - raw = newname; - if (stat(raw, &stchar) < 0) { - printf("Can't stat %s: %s\n", raw, strerror(errno)); - return (origname); - } - if ((stchar.st_mode & S_IFMT) == S_IFCHR) { - if (stslash.st_dev == stchar.st_rdev) - hotroot++; - return (raw); - } else { - printf("%s is not a character device\n", raw); - return (origname); - } - } else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) { + return(newname); + case S_IFDIR: + if (retried) + break; + len = strlen(origname) - 1; if (len > 0 && origname[len] == '/') /* remove trailing slash */ -- 2.45.2