From c0229ae597756a0a58ab6bbcd996c68b89db6732 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Tue, 27 Nov 2018 20:26:33 +0900 Subject: [PATCH] add (bad) chown --- apps/chown.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 apps/chown.c diff --git a/apps/chown.c b/apps/chown.c new file mode 100644 index 00000000..95df6c01 --- /dev/null +++ b/apps/chown.c @@ -0,0 +1,26 @@ +/* vim: tabstop=4 shiftwidth=4 noexpandtab + * This file is part of ToaruOS and is released under the terms + * of the NCSA / University of Illinois License - see LICENSE.md + * Copyright (C) 2018 K. Lange + * + * chown - bad implementation thereof + */ +#include +#include +#include +#include + +int main(int argc, char * argv[]) { + if (argc != 3) { + fprintf(stderr, "usage: chown UID FILE\n"); + return 1; + } + + int uid = atoi(argv[1]); + + if (chown(argv[2], uid, uid)) { + fprintf(stderr, "chown: %s: %s\n", argv[2], strerror(errno)); + return 1; + } + return 0; +}