From c43b0ac7672b0d8fce8b1ea0a0dbe4383d60485e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 28 Aug 2022 12:33:36 +0200 Subject: user/libc: unlink() --- src/user/app/shell/builtins.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'src/user/app') diff --git a/src/user/app/shell/builtins.c b/src/user/app/shell/builtins.c index 1be9b5b..5af11e4 100644 --- a/src/user/app/shell/builtins.c +++ b/src/user/app/shell/builtins.c @@ -192,32 +192,9 @@ static void cmd_rm(int argc, char **argv) { eprintf("no arguments"); return; } - const size_t buflen = PATH_MAX; - char *buf = malloc(buflen); for (int i = 1; i < argc; i++) { - handle_t h; - long ret; - size_t abslen; - char *path = argv[i]; - if (*path == '\0') { - eprintf("ignoring empty argument"); - continue; - } - abslen = absolutepath(buf, path, buflen); - if (!abslen) { - eprintf("invalid path %s", path); - continue; - } - h = _syscall_open(buf, abslen - 1, 0); - if (h < 0) { - eprintf("couldn't open %s (err %u)", path, -h); - continue; - } - ret = _syscall_remove(h); - if (ret < 0) { - eprintf("couldn't remove %s (err %u)", path, -ret); - continue; - } + if (unlink(argv[i]) < 0) + perror(argv[i]); } } -- cgit v1.2.3