7 const char chown_usage[] = "chown [-R] user-name file [file ...]\n"
8 "\n\tThe group list is kept in the file /etc/groups.\n\n"
9 "\t-R:\tRecursively change the mode of all files and directories\n"
10 "\t\tunder the argument directory.";
13 parse_user_name(const char * s, struct FileInfo * i)
16 char * dot = strchr(s, '.');
24 if ( (p = getpwnam(s)) == 0 ) {
25 fprintf(stderr, "%s: no such user.\n", s);
28 i->userID = p->pw_uid;
31 struct group * g = getgrnam(++dot);
33 fprintf(stderr, "%s: no such group.\n", dot);
36 i->groupID = g->gr_gid;
43 chown_main(struct FileInfo * i, int argc, char * * argv)
47 while ( argc >= 3 && strcmp("-R", argv[1]) == 0 ) {
53 if ( (status = parse_user_name(argv[1], i)) != 0 )
60 i->complainInPostProcess = 1;
62 return monadic_main(i, argc, argv);