diff options
Diffstat (limited to 'progs')
-rw-r--r-- | progs/hello/hello.c | 8 | ||||
-rw-r--r-- | progs/mkdir/mkdir.c | 17 | ||||
-rw-r--r-- | progs/mount/mount.c | 25 | ||||
-rw-r--r-- | progs/tty/tty.c | 10 |
4 files changed, 60 insertions, 0 deletions
diff --git a/progs/hello/hello.c b/progs/hello/hello.c new file mode 100644 index 0000000..e11e06e --- /dev/null +++ b/progs/hello/hello.c @@ -0,0 +1,8 @@ +#include <unistd.h> +#include <stdlib.h> + +__attribute__((force_align_arg_pointer)) +int main() { + write(1, ":3\n", 3); + exit(0); +} \ No newline at end of file diff --git a/progs/mkdir/mkdir.c b/progs/mkdir/mkdir.c new file mode 100644 index 0000000..cbf5cdf --- /dev/null +++ b/progs/mkdir/mkdir.c @@ -0,0 +1,17 @@ +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <sys/stat.h> + +int main(int argc, char *argv[]) { + if (!argv[1]) { + write(1, "you IDIOT, you forgot to include the file name, MORON\n", 55); + exit(1); + } + struct stat st = {0}; + + if (stat(argv[1], &st) == -1) { + mkdir(argv[1], 0700); + } + exit(0); +} \ No newline at end of file diff --git a/progs/mount/mount.c b/progs/mount/mount.c new file mode 100644 index 0000000..296dd42 --- /dev/null +++ b/progs/mount/mount.c @@ -0,0 +1,25 @@ +#include <unistd.h> +#include <stdlib.h> +#include <sys/mount.h> +#include <string.h> +#include <stdio.h> +#include <errno.h> + +int main(int argc, char *argv[]) { + if (argc != 4) { + fprintf(stderr, "usag: %s <source> <target> <filesystem type>\n", argv[0]); + return EXIT_FAILURE; + } + + const char *source = argv[1]; + const char *target = argv[2]; + const char *fstype = argv[3]; + + if (mount(source, target, fstype, 0, NULL) == -1) { + fprintf(stderr, "mount failed: %s\n", strerror(errno)); + return EXIT_FAILURE; + } + + printf("Mounted %s on %s with type %s\n", source, target, fstype); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/progs/tty/tty.c b/progs/tty/tty.c new file mode 100644 index 0000000..d906121 --- /dev/null +++ b/progs/tty/tty.c @@ -0,0 +1,10 @@ +#include <unistd.h> +#include <stdlib.h> + +__attribute__((force_align_arg_pointer)) +int main() { + char *tty = ttyname(1); + write(1, tty, sizeof(tty)); + write(1, "\n", 1); + exit(0); +} \ No newline at end of file |