Message ID | 1463566368-12396-3-git-send-email-lede@daniel.thecshore.com |
---|---|
State | Superseded |
Headers | show |
On 18/05/16 11:12, lede@daniel.thecshore.com wrote: > + if (!strncmp(pr->id->name, "vfat", 4)) { > + ckfs = e2fsck; > + } else if (!strncmp(pr->id->name, "ext", 3)) { > + ckfs = dosfsck; Is this the wrong way round?
On 16-05-18 07:05 AM, Conor O'Gorman wrote: > On 18/05/16 11:12, lede@daniel.thecshore.com wrote: >> + if (!strncmp(pr->id->name, "vfat", 4)) { >> + ckfs = e2fsck; >> + } else if (!strncmp(pr->id->name, "ext", 3)) { >> + ckfs = dosfsck; > Is this the wrong way round? Do you mean you mean you think ext should be tested first? ckfs = x is obvious correction because we're setting the ckfs to the command to do the filesystem check. Otherwise I'm not sure what you're asking... Perhaps your problem is with the C idiom (!strncmp is correct because strncmp returns 0 on a match (which == false for the if)). I have no other guesses as to what you're getting at. Regards, Daniel
Hi, >>> + if (!strncmp(pr->id->name, "vfat", 4)) { "If fs name starts with vfat ..." >>> + ckfs = e2fsck; "... then use the ext4 checker". >>> + } else if (!strncmp(pr->id->name, "ext", 3)) { "... else if fs name starts with ext ..." >>> + ckfs = dosfsck; "... then use the dosfs checker". >> Is this the wrong way round? > > Do you mean you mean you think ext should be tested first? That certainly looks swapped to me as well. ~ Jo
Citeren Daniel Dickinson <lede@daniel.thecshore.com>: > On 16-05-18 07:05 AM, Conor O'Gorman wrote: >> On 18/05/16 11:12, lede@daniel.thecshore.com wrote: >>> + if (!strncmp(pr->id->name, "vfat", 4)) { >>> + ckfs = e2fsck; >>> + } else if (!strncmp(pr->id->name, "ext", 3)) { >>> + ckfs = dosfsck; >> Is this the wrong way round? > > Do you mean you mean you think ext should be tested first? > > > ckfs = x is obvious correction because we're setting the ckfs to the > command to do the filesystem check. > > Otherwise I'm not sure what you're asking... > > Perhaps your problem is with the C idiom (!strncmp is correct because > strncmp returns 0 on a match (which == false for the if)). > > I have no other guesses as to what you're getting at. I guess "vfat" should be checked with dosfsck and "ext" with e2fsck.
On 16-05-18 07:17 AM, Arjen de Korte wrote: > Citeren Daniel Dickinson <lede@daniel.thecshore.com>: > > > I guess "vfat" should be checked with dosfsck and "ext" with e2fsck. > Ah, the old you see what you expect to see psychology thing - I missed that. Regards, Daniel
diff --git a/block.c b/block.c index 71ffd0b..c2adf3c 100644 --- a/block.c +++ b/block.c @@ -628,24 +628,30 @@ static void check_filesystem(struct blkid_struct_probe *pr) pid_t pid; struct stat statbuf; const char *e2fsck = "/usr/sbin/e2fsck"; + const char *dosfsck = "/sbin/dosfsck"; + const char *ckfs; /* UBIFS does not need stuff like fsck */ if (!strncmp(pr->id->name, "ubifs", 5)) return; - if (strncmp(pr->id->name, "ext", 3)) { + if (!strncmp(pr->id->name, "vfat", 4)) { + ckfs = e2fsck; + } else if (!strncmp(pr->id->name, "ext", 3)) { + ckfs = dosfsck; + } else { ULOG_ERR("check_filesystem: %s is not supported\n", pr->id->name); return; } - if (stat(e2fsck, &statbuf) < 0) { + if (stat(ckfs, &statbuf) < 0) { ULOG_ERR("check_filesystem: %s not found\n", e2fsck); return; } pid = fork(); if (!pid) { - execl(e2fsck, e2fsck, "-p", pr->dev, NULL); + execl(ckfs, ckfs, "-p", pr->dev, NULL); exit(-1); } else if (pid > 0) { int status;