1 | #include "mosapi.h" |
---|---|
2 | |
3 | int main(int argc, char *argv[]) |
4 | { |
5 | if (argc < 2) |
6 | { |
7 | printf(format: "Usage: %s <file> contents...\n", argv[0]); |
8 | return 1; |
9 | } |
10 | |
11 | const char *path = argv[1]; |
12 | fd_t fd = open(path, flags: OPEN_READ | OPEN_WRITE | OPEN_CREATE); |
13 | if (IS_ERR_VALUE(fd)) |
14 | { |
15 | printf(format: "Failed to open %s\n", path); |
16 | return 1; |
17 | } |
18 | |
19 | for (int i = 2; i < argc; i++) |
20 | { |
21 | const char *buf = argv[i]; |
22 | size_t len = strlen(str: buf); |
23 | if (syscall_io_write(fd, buffer: buf, size: len) != len) |
24 | { |
25 | printf(format: "Failed to write to %s\n", path); |
26 | return 1; |
27 | } |
28 | } |
29 | |
30 | syscall_io_close(fd); |
31 | return 0; |
32 | } |
33 |