chown.c 595 B

1234567891011121314151617181920212223242526
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2018 K. Lange
  5. *
  6. * chown - bad implementation thereof
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <unistd.h>
  11. #include <errno.h>
  12. int main(int argc, char * argv[]) {
  13. if (argc != 3) {
  14. fprintf(stderr, "usage: chown UID FILE\n");
  15. return 1;
  16. }
  17. int uid = atoi(argv[1]);
  18. if (chown(argv[2], uid, uid)) {
  19. fprintf(stderr, "chown: %s: %s\n", argv[2], strerror(errno));
  20. return 1;
  21. }
  22. return 0;
  23. }