add (bad) chown

This commit is contained in:
K. Lange 2018-11-27 20:26:33 +09:00
parent eff00f21c4
commit c0229ae597
1 changed files with 26 additions and 0 deletions

26
apps/chown.c Normal file
View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
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;
}