k9core

Coreutils for *nix operating systems
git clone git://bvnf.space/k9core.git
Log | Files | Refs | LICENSE

commit 791fbd7815f3950c2715d435e812e15f22cea219
parent 25063680dc66013d98d541104f0d50c4967c18dc
Author: aabacchus <ben@bvnf.space>
Date:   Tue, 14 Sep 2021 19:18:14 +0100

nouserland: standardize return values and error messages

Diffstat:
Msrc/nouserland/mount.c | 7++++---
Msrc/nouserland/umount.c | 6++++--
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/nouserland/mount.c b/src/nouserland/mount.c @@ -18,13 +18,13 @@ main(int argc, char *argv[]) { int c = getopt(argc, argv,"t:"); if(argc < 2) { - printf("./mount source destination\n"); + printf("usage: mount source destination\n"); return 1; } if(getuid() != 0) { - fprintf(stderr,"Only root can run this\n"); + fprintf(stderr,"mount: must be root\n"); return 1; } char filesystem[10] = "ext4"; @@ -39,7 +39,8 @@ main(int argc, char *argv[]) { int fd = mount(argv[source],argv[destination],filesystem,0,NULL); if(fd == -1) { - fprintf(stderr,"error mounting: %i = %s\n",errno,strerror(errno)); + fprintf(stderr,"mount: %s\n",strerror(errno)); + return 1; } return 0; } diff --git a/src/nouserland/umount.c b/src/nouserland/umount.c @@ -17,12 +17,14 @@ main(int argc, char *argv[]) } if(argc == 1) { - printf("give a directory\n"); + printf("usage: umount mountpoint\n"); return 1; } int fd = umount2(argv[destination],options); if(fd == -1) { - fprintf(stderr,"error umounting: %i = %s\n",errno,strerror(errno)); + fprintf(stderr,"umount: %s: %s\n",argv[destination],strerror(errno)); + return 1; } + return 0; }