k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 69d0fae90cf105481cfb6f55af4584dc49d140e8
parent 8065fedd7016eb4cbaa09e10d148fcc0414a22d5
Author: qorg11 <qorg@vxempire.xyz>
Date:   Wed,  8 Jul 2020 10:58:34 +0200

Added stuff to mount.c

Diffstat:
Msrc/mount.c | 21+++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/mount.c b/src/mount.c @@ -1,28 +1,45 @@ #include <stdio.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 * code. */ +/* Update: now this supports filetype with -t flag. But I still don't + * recommend it to mounting something that it's not extx + */ + int main(int argc, char *argv[]) { + int c = getopt(argc, argv,"t:"); if(argc < 2) { printf("./mount source destination\n"); return 1; } - + if(getuid() != 0) { fprintf(stderr,"Only root can run this\n"); return 1; } - int fd = mount(argv[1],argv[2],"ext4",0,NULL); + 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,"error mounting: %i\n",errno); } + }