[hackers] [ubase] mount: implement some error status codes for mount -a || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 15 Mar 2014 18:51:52 +0100

commit 781cf0ed524180dc255ef651d6a216f58f39ff58
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat Mar 15 17:10:23 2014 +0100

    mount: implement some error status codes for mount -a
    
    see mount man page:
    32: all failed.
    64: some failed.
    
    Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>

diff --git a/mount.c b/mount.c
index 41f42f5..6a4c2e9 100644
--- a/mount.c
+++ b/mount.c
_AT_@ -76,7 +76,7 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
- int aflag = 0, i;
+ int aflag = 0, oflag = 0, status = EXIT_SUCCESS, i;
         unsigned long flags = 0;
         char *types = NULL, data[512] = "";
         char *files[] = { "/proc/mounts", "/etc/fstab", NULL };
_AT_@ -153,7 +153,7 @@ mountsingle:
                 eprintf("mount:");
         if(fp)
                 endmntent(fp);
- return EXIT_SUCCESS;
+ return status;
 
 mountall:
         if(!(fp = setmntent("/etc/fstab", "r")))
_AT_@ -161,10 +161,15 @@ mountall:
         while((me = getmntent(fp))) {
                 flags = 0;
                 parseopts(me->mnt_opts, &flags, data, datasiz);
- if(mount(me->mnt_fsname, me->mnt_dir, me->mnt_type, flags, data) < 0)
+ if(mount(me->mnt_fsname, me->mnt_dir, me->mnt_type, flags, data) < 0) {
                         weprintf("mount:");
+ if(status != 64)
+ status = 32; /* all failed */
+ } else {
+ status = 64; /* some failed */
+ }
         }
         endmntent(fp);
 
- return EXIT_SUCCESS;
+ return status;
 }
Received on Sat Mar 15 2014 - 18:51:52 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 15 2014 - 19:00:19 CET