diff --git a/TODO b/TODO index 5336dad..111b922 100644 --- a/TODO +++ b/TODO @@ -19,8 +19,8 @@ test tar Other: + *mount ps - mount umount sysctl ping diff --git a/builder/config.h b/builder/config.h index d578eb5..8d808b1 100644 --- a/builder/config.h +++ b/builder/config.h @@ -6,8 +6,8 @@ const char *objects[] = { "coreutils", "networking", "procps", - "sysutils", "findutils", + "sysutils", "sysutils-linux", "miscutils", "shell" @@ -19,6 +19,6 @@ const char *objects[] = { /* Need by spark */ #define LDFLAGS "-lm" -#define CFLAGS "-Wall", "-Werror", "-Wextra", "-pedantic", "-flto", "-Os", "-s", "-I../libmu", "-I../", "--std", "c99", LDFLAGS +#define CFLAGS "-Wall", "-Werror", "-Wextra", "-pedantic", "-flto", "-Os", "-s", "-I../libmu", "-I../", LDFLAGS #define CC "cc" #endif diff --git a/config.h b/config.h index e462d79..8f3075d 100644 --- a/config.h +++ b/config.h @@ -15,6 +15,7 @@ /* mount config */ #define MOUNT_CFG "/etc/fstab" +#define MOUNT_DEF_FS "ext4" /* nologin sleep */ #define NOLOGIN_SLEEP 60 diff --git a/sysutils/rev.c b/coreutils/rev.c similarity index 100% rename from sysutils/rev.c rename to coreutils/rev.c diff --git a/coreutils/who.c b/coreutils/who.c deleted file mode 100644 index c8b1310..0000000 --- a/coreutils/who.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include -#include - -int time_to_str(char *buf, size_t len, struct utmpx *usr) { - time_t t = usr->ut_tv.tv_sec; - struct tm *tmp = localtime(&t); - - if (tmp) - strftime(buf, len, "%F %H:%M", tmp); - - else - return 1; - - return 0; -} - -int main(void) { - setutxent(); - - struct utmpx *usr; - while ((usr = getutxent())) { - if (usr->ut_type == USER_PROCESS) { - char time_buf[20]; - if (time_to_str(time_buf, sizeof(time_buf), usr)) - continue; - - printf("%s\t%s\t%s\t(%s)\n", usr->ut_user, usr->ut_line, time_buf, usr->ut_host); - } - } - - endutxent(); -} diff --git a/example/fstab b/example/fstab new file mode 100644 index 0000000..8df91af --- /dev/null +++ b/example/fstab @@ -0,0 +1,2 @@ +#[SRC] [DST] [FS TYPE] [OPTIONS] +/dev/sda1 /boot ext4 rw diff --git a/procps/kill.c b/procps/kill.c index b615ca2..826fc82 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -27,10 +27,8 @@ SIG signals[] = { {"PIPE", SIGPIPE}, {"ALRM", SIGALRM}, {"TERM", SIGTERM}, - {"STKFLT", SIGSTKFLT}, {"CHLD", SIGCHLD}, - {"STOP", SIGSTOP}, - {"POLL", SIGPOLL} + {"STOP", SIGSTOP} }; diff --git a/sysutils/mount.c b/sysutils/mount.c new file mode 100644 index 0000000..e749aed --- /dev/null +++ b/sysutils/mount.c @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include +#include "config.h" + +int do_mount(const char *src, const char *dst, const char *fs_type, unsigned long opt) { +#if defined(__linux__) + int ret = mount(src, dst, fs_type, opt, NULL); + +#elif defined(__plainos__) + int ret = mount(src, dst, fs_type, opt); + +#else + int ret = -1; + +#endif + + if (ret < 0) { + fprintf(stderr, "mount: %s: %s\n", src, strerror(errno)); + return 1; + } + + return 0; +} + +void parse_fstab(void) { + FILE *fp = fopen(MOUNT_CFG, "r"); + if (fp == NULL) { + fprintf(stderr, "mount: %s\n", strerror(errno)); + exit(1); + } + + char *buf = NULL; + size_t len = 0; + + while (getline(&buf, &len, fp) != EOF) { + if (buf[0] == '#') + continue; + } + + free(buf); +} + +int main(int argc, char **argv) { + char *fs_type = MOUNT_DEF_FS; + + int opt; + while ((opt = getopt(argc, argv, "t:ao")) != -1) { + switch (opt) { + case 'a': + parse_fstab(); + break; + + case 't': + fs_type = optarg; + break; + + case 'o': + break; + + default: + printf("mount [DEVICE] [NODE]\n\t[-t Fs type (default %s)] [-o Options]\n\t[-a Mount all fs in /etc/fstab]\n\nOptions:\n\tremount - Remount a mounted filesystem\n\tro - Read only\n", MOUNT_DEF_FS); + return 0; + } + } + + argc -= optind; + argv += optind; + + if (argc == 2) + return do_mount(argv[0], argv[1], fs_type, 0); + + else if (argc == 1) + return do_mount(fs_type, argv[0], fs_type, 0); + + return 0; +}