mirror of git://git.suckless.org/ubase
mountpoint: -q should not print errors
This commit is contained in:
parent
7f42fe77c3
commit
78ddef361c
25
mountpoint.c
25
mountpoint.c
|
@ -42,20 +42,29 @@ main(int argc, char *argv[])
|
||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (stat(argv[0], &st1) < 0)
|
if (stat(argv[0], &st1) < 0) {
|
||||||
|
if (qflag)
|
||||||
|
return 1;
|
||||||
eprintf("stat %s:", argv[0]);
|
eprintf("stat %s:", argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (xflag) {
|
if (xflag) {
|
||||||
if (!S_ISBLK(st1.st_mode))
|
if (!S_ISBLK(st1.st_mode)) {
|
||||||
|
if (qflag)
|
||||||
|
return 1;
|
||||||
eprintf("stat: %s: not a block device\n",
|
eprintf("stat: %s: not a block device\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
|
}
|
||||||
printf("%u:%u\n", major(st1.st_rdev),
|
printf("%u:%u\n", major(st1.st_rdev),
|
||||||
minor(st1.st_rdev));
|
minor(st1.st_rdev));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!S_ISDIR(st1.st_mode))
|
if (!S_ISDIR(st1.st_mode)) {
|
||||||
|
if (qflag)
|
||||||
|
return 1;
|
||||||
eprintf("stat %s: not a directory\n", argv[0]);
|
eprintf("stat %s: not a directory\n", argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (dflag) {
|
if (dflag) {
|
||||||
printf("%u:%u\n", major(st1.st_dev),
|
printf("%u:%u\n", major(st1.st_dev),
|
||||||
|
@ -64,11 +73,17 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = setmntent("/proc/mounts", "r");
|
fp = setmntent("/proc/mounts", "r");
|
||||||
if (!fp)
|
if (!fp) {
|
||||||
|
if (qflag)
|
||||||
|
return 1;
|
||||||
eprintf("setmntent %s:", "/proc/mounts");
|
eprintf("setmntent %s:", "/proc/mounts");
|
||||||
|
}
|
||||||
while ((me = getmntent(fp)) != NULL) {
|
while ((me = getmntent(fp)) != NULL) {
|
||||||
if (stat(me->mnt_dir, &st2) < 0)
|
if (stat(me->mnt_dir, &st2) < 0) {
|
||||||
|
if (qflag)
|
||||||
|
return 1;
|
||||||
eprintf("stat %s:", me->mnt_dir);
|
eprintf("stat %s:", me->mnt_dir);
|
||||||
|
}
|
||||||
if (st1.st_dev == st2.st_dev &&
|
if (st1.st_dev == st2.st_dev &&
|
||||||
st1.st_ino == st2.st_ino)
|
st1.st_ino == st2.st_ino)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue