mirror of
https://github.com/nilfs-dev/nilfs-utils.git
synced 2026-01-26 13:43:15 +00:00
bin/*: improve error message on failure of nilfs_open()
The error message on failure of nilfs_open() function has two issues
in commands lscp, lssu, mkcp, chcp, rmcp, and dumpseg:
1) When device name is omitted, a null pointer is passed to a string
type field of the error message and a broken message is printed as
below:
lssu: (null): cannot open NILFS
2) Description of errno is not shown in the error message.
This fixes these issues.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
This commit is contained in:
parent
106bdc1ebc
commit
fc2fe67724
@ -139,7 +139,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RDWR | NILFS_OPEN_GCLK);
|
||||
if (nilfs == NULL) {
|
||||
fprintf(stderr, "%s: %s: cannot open NILFS\n", progname, dev);
|
||||
fprintf(stderr, "%s: cannot open NILFS on %s: %m\n",
|
||||
progname, dev ? : "device");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -218,7 +218,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RAW);
|
||||
if (nilfs == NULL) {
|
||||
fprintf(stderr, "%s: %s: cannot open NILFS\n", progname, dev);
|
||||
fprintf(stderr, "%s: cannot open NILFS on %s: %m\n",
|
||||
progname, dev ? : "device");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -401,8 +401,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RDONLY);
|
||||
if (nilfs == NULL) {
|
||||
fprintf(stderr, "%s: %s: cannot open NILFS\n",
|
||||
progname, dev);
|
||||
fprintf(stderr, "%s: cannot open NILFS on %s: %m\n",
|
||||
progname, dev ? : "device");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@ -382,8 +382,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
nilfs = nilfs_open(dev, NULL, open_flags);
|
||||
if (nilfs == NULL) {
|
||||
fprintf(stderr, "%s: %s: cannot open NILFS\n",
|
||||
progname, dev);
|
||||
fprintf(stderr, "%s: cannot open NILFS on %s: %m\n",
|
||||
progname, dev ? : "device");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +123,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RDWR | NILFS_OPEN_GCLK);
|
||||
if (nilfs == NULL) {
|
||||
fprintf(stderr, "%s: %s: cannot open NILFS\n", progname, dev);
|
||||
fprintf(stderr, "%s: cannot open NILFS on %s: %m\n",
|
||||
progname, dev ? : "device");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +193,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
nilfs = nilfs_open(dev, NULL, NILFS_OPEN_RDWR);
|
||||
if (nilfs == NULL) {
|
||||
fprintf(stderr, "%s: %s: cannot open NILFS\n", progname, dev);
|
||||
fprintf(stderr, "%s: cannot open NILFS on %s: %m\n",
|
||||
progname, dev ? : "device");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user