diff --git a/sbin/fsck/fsck.8 b/sbin/fsck/fsck.8 index a358007e7e58..edef23e33891 100644 --- a/sbin/fsck/fsck.8 +++ b/sbin/fsck/fsck.8 @@ -65,9 +65,9 @@ Filesystems with pass number 1 (normally just the root filesystem) are checked one at a time. When pass 1 completes, all remaining filesystems are checked, running one process per disk drive. -The disk drive containing each filesystem is inferred from the longest prefix +The disk drive containing each filesystem is inferred from the shortest prefix of the device name that ends in a digit; the remaining characters are assumed -to be the partition designator. +to be the partition and slice designator. .Pp The options are as follows: .Bl -tag -width indent diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index bd72d6bc9b2c..e00e84e3bbc0 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -259,12 +259,17 @@ finddisk(name) size_t len = 0; struct diskentry *d; - for (len = strlen(name), p = name + len - 1; p >= name; --p) - if (isdigit(*p)) { - len = p - name + 1; - break; - } - if (p < name) + p = strrchr(name, '/'); + if (p == NULL) + p = name; + else + p++; + for (; *p && !isdigit(*p); p++) + continue; + for (; *p && isdigit(*p); p++) + continue; + len = p - name; + if (len == 0) len = strlen(name); TAILQ_FOREACH(d, &diskh, d_entries)