commit 7d414e2c5dac0812818b15c1af61117dedb14d9a
parent 7cb95b3a048ccf26ebbc65197c2310efe0a5d73c
Author: qorg11 <qorg@vxempire.xyz>
Date: Wed, 8 Jul 2020 07:33:43 +0200
Mount and whoami
Diffstat:
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/mount.c b/src/mount.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <sys/mount.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* Do NOT use this unironically for now, this only supports ext4, and
+ * you cannot specify another filesystem unless you change the source
+ * code. */
+
+int
+main(int argc, char *argv[]) {
+ 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);
+ if(fd == -1)
+ {
+ fprintf(stderr,"error mounting: %i\n",errno);
+ }
+}
diff --git a/src/whoami.c b/src/whoami.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include <unistd.h>
+int
+main(void)
+{
+ printf("%s\n",getlogin());
+ return 0;
+}