A toy operating system written in C.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
freywaros/src/user/app/mkdir/mkdir.c

28 lines
698 B

#include "src/lib/syscall.h"
#include "src/lib/util.h"
#include "src/user/syscall.h"
#include <stdint.h>
#define BLOCK_SIZE 65536
#define PRINT_S(s) write(1, s, sizeof(s) - 1);
#define PRINT_D(s) write(1, s, string_length(s));
exit_code_t main(uint64_t argc, const char **argv) {
if (argc < 2) {
PRINT_S("mkdir: requires target(s)\n");
return EXIT_CODE_GENERAL_FAILURE;
}
for (uint64_t i = 1; i < argc; i++) {
uint64_t fd = open(argv[i], OPEN_DIRECTORY | OPEN_CREATE | OPEN_EXCLUSIVE);
if (fd == (uint64_t)-1) {
PRINT_S("mkdir: could not create directory\n");
return EXIT_CODE_GENERAL_FAILURE;
} else {
close(fd);
}
}
return EXIT_CODE_OK;
}