parent
7bc0b81051
commit
bfb74dd57a
@ -1,14 +1,14 @@ |
||||
#include "src/lib/string.h" |
||||
#include "src/lib/util.h" |
||||
#include "src/user/syscall.h" |
||||
|
||||
exit_code_t main(uint64_t argc, const char **argv) { |
||||
for (uint64_t i = 1; i < argc; i++) { |
||||
if (i > 1) { |
||||
write(1, " ", 1); |
||||
OUT_S(" "); |
||||
} |
||||
write(1, argv[i], string_length(argv[i])); |
||||
OUT_D(argv[i]); |
||||
} |
||||
write(1, "\n", 1); |
||||
OUT_S("\n"); |
||||
|
||||
return EXIT_CODE_OK; |
||||
} |
||||
|
||||
@ -1,28 +1,23 @@ |
||||
#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"); |
||||
ERR_S("mkdir: requires target(s)\n"); |
||||
return EXIT_CODE_GENERAL_FAILURE; |
||||
} |
||||
|
||||
exit_code_t code = EXIT_CODE_OK; |
||||
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; |
||||
ERR_S("mkdir: could not create directory\n"); |
||||
code = EXIT_CODE_GENERAL_FAILURE; |
||||
} else { |
||||
close(fd); |
||||
} |
||||
} |
||||
|
||||
return EXIT_CODE_OK; |
||||
return code; |
||||
} |
||||
|
||||
Loading…
Reference in new issue