k9core

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

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

nouserland: clang-format

Diffstat:
Msrc/nouserland/mount.c | 59++++++++++++++++++++++++++++-------------------------------
Msrc/nouserland/umount.c | 42++++++++++++++++++++----------------------
2 files changed, 48 insertions(+), 53 deletions(-)

diff --git a/src/nouserland/mount.c b/src/nouserland/mount.c @@ -1,9 +1,9 @@ +#include <errno.h> +#include <getopt.h> #include <stdio.h> +#include <string.h> #include <sys/mount.h> #include <unistd.h> -#include <getopt.h> -#include <errno.h> -#include <string.h> /* Do NOT use this unironically for now, this only supports ext4, and * you cannot specify another filesystem unless you change the source @@ -14,33 +14,30 @@ */ int -main(int argc, char *argv[]) { - int c = getopt(argc, argv,"t:"); - if(argc < 2) - { - printf("usage: mount source destination\n"); - return 1; - } +main(int argc, char *argv[]) +{ + int c = getopt(argc, argv, "t:"); + if(argc < 2) { + printf("usage: mount source destination\n"); + return 1; + } - if(getuid() != 0) - { - fprintf(stderr,"mount: must be root\n"); - return 1; - } - char filesystem[10] = "ext4"; - int source = 1; - int destination = 2; - if(c == 't') - { - strcpy(filesystem,optarg); - source++; - destination++; - } - int fd = mount(argv[source],argv[destination],filesystem,0,NULL); - if(fd == -1) - { - fprintf(stderr,"mount: %s\n",strerror(errno)); - return 1; - } - return 0; + if(getuid() != 0) { + fprintf(stderr, "mount: must be root\n"); + return 1; + } + char filesystem[10] = "ext4"; + int source = 1; + int destination = 2; + if(c == 't') { + strcpy(filesystem, optarg); + source++; + destination++; + } + int fd = mount(argv[source], argv[destination], filesystem, 0, NULL); + if(fd == -1) { + fprintf(stderr, "mount: %s\n", strerror(errno)); + return 1; + } + return 0; } diff --git a/src/nouserland/umount.c b/src/nouserland/umount.c @@ -1,30 +1,28 @@ -#include <stdio.h> -#include <sys/mount.h> #include <errno.h> #include <getopt.h> +#include <stdio.h> #include <string.h> +#include <sys/mount.h> int main(int argc, char *argv[]) { - int c = getopt(argc, argv, "f"); - int options = 0; /* No options by default */ - int destination = 1; - if(c == 'f') - { - options = MNT_FORCE; - destination++; - } - if(argc == 1) - { - printf("usage: umount mountpoint\n"); - return 1; - } - int fd = umount2(argv[destination],options); - if(fd == -1) - { - fprintf(stderr,"umount: %s: %s\n",argv[destination],strerror(errno)); - return 1; - } - return 0; + int c = getopt(argc, argv, "f"); + int options = 0; /* No options by default */ + int destination = 1; + if(c == 'f') { + options = MNT_FORCE; + destination++; + } + if(argc == 1) { + printf("usage: umount mountpoint\n"); + return 1; + } + int fd = umount2(argv[destination], options); + if(fd == -1) { + fprintf( + stderr, "umount: %s: %s\n", argv[destination], strerror(errno)); + return 1; + } + return 0; }