1 | // SPDX-License-Identifier: GPL-3.0-or-later |
---|---|
2 | |
3 | #include "mosapi.h" |
4 | |
5 | void do_touch(const char *path) |
6 | { |
7 | fd_t fd = syscall_vfs_openat(AT_FDCWD, file_path: path, flags: OPEN_READ | OPEN_WRITE | OPEN_CREATE); |
8 | if (IS_ERR_VALUE(fd)) |
9 | fprintf(stderr, format: "failed to touch file '%s'\n", path); |
10 | syscall_io_close(fd); |
11 | } |
12 | |
13 | int main(int argc, char **argv) |
14 | { |
15 | if (argc < 2) |
16 | { |
17 | fputs(s: "usage: touch <file>...\n", stderr); |
18 | return 1; |
19 | } |
20 | |
21 | for (int i = 1; i < argc; i++) |
22 | do_touch(path: argv[i]); |
23 | |
24 | return 0; |
25 | } |
26 |