Add mkfifo and sleep commands

This commit is contained in:
Mark 2020-07-06 21:55:15 +03:00
parent dbb0e221e1
commit 2bfc1734ef
3 changed files with 45 additions and 1 deletions

View File

@ -21,9 +21,12 @@ BINS=$(O)/bin/ls \
$(O)/bin/table \
$(O)/bin/uname \
$(O)/bin/wr \
$(O)/bin/mkfifo \
$(O)/bin/sleep \
$(O)/sbin/lspci \
$(O)/sbin/insmod \
$(O)/sbin/reboot
$(O)/sbin/reboot \
$(O)/sbin/acpid
all: mkdirs $(BINS)

17
progs/base/bin/mkfifo.c Normal file
View File

@ -0,0 +1,17 @@
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "usage: %s FILENAME\n", argv[0]);
return -1;
}
if (mknod(argv[1], 0644 | S_IFIFO, 0) != 0) {
perror(argv[1]);
return -1;
}
return 0;
}

24
progs/base/bin/sleep.c Normal file
View File

@ -0,0 +1,24 @@
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "usage: %s SEC\n", argv[0]);
return -1;
}
int res;
struct timespec t;
t.tv_sec = atoi(argv[1]);
t.tv_nsec = 0;
if ((res = nanosleep(&t, NULL)) != 0) {
perror("sleep");
return -1;
}
return 0;
}