ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 781cf0ed524180dc255ef651d6a216f58f39ff58
parent c444139aeaf9c1c2847537b32b7e99d1b4299247
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 15 Mar 2014 17:10:23 +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@codemadness.org>

Diffstat:
Mmount.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/mount.c b/mount.c @@ -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 }; @@ -153,7 +153,7 @@ mountsingle: eprintf("mount:"); if(fp) endmntent(fp); - return EXIT_SUCCESS; + return status; mountall: if(!(fp = setmntent("/etc/fstab", "r"))) @@ -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; }