[hackers] [ubase] mountpoint: -q should not print errors || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 10 May 2015 14:41:29 +0200 (CEST)

commit 78ddef361c0a87e1a76c0ff15e75de63b8954818
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun May 10 14:16:58 2015 +0200

    mountpoint: -q should not print errors

diff --git a/mountpoint.c b/mountpoint.c
index 1007a27..8f205a2 100644
--- a/mountpoint.c
+++ b/mountpoint.c
_AT_@ -42,20 +42,29 @@ main(int argc, char *argv[])
         if (argc < 1)
                 usage();
 
- if (stat(argv[0], &st1) < 0)
+ if (stat(argv[0], &st1) < 0) {
+ if (qflag)
+ return 1;
                 eprintf("stat %s:", argv[0]);
+ }
 
         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",
                                 argv[0]);
+ }
                 printf("%u:%u\n", major(st1.st_rdev),
                        minor(st1.st_rdev));
                 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]);
+ }
 
         if (dflag) {
                 printf("%u:%u\n", major(st1.st_dev),
_AT_@ -64,11 +73,17 @@ main(int argc, char *argv[])
         }
 
         fp = setmntent("/proc/mounts", "r");
- if (!fp)
+ if (!fp) {
+ if (qflag)
+ return 1;
                 eprintf("setmntent %s:", "/proc/mounts");
+ }
         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);
+ }
                 if (st1.st_dev == st2.st_dev &&
                     st1.st_ino == st2.st_ino)
                         break;
Received on Sun May 10 2015 - 14:41:29 CEST

This archive was generated by hypermail 2.3.0 : Sun May 10 2015 - 14:48:11 CEST