[d03537]: busyelks / be1 / chmod.c Maximize Restore History

Download this file

chmod.c    47 lines (40 with data), 753 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Copyright (c) 1993 by David I. Bell
* Permission is granted to use, distribute, or modify this source,
* provided that this copyright notice remains intact.
*
* Most simple built-in commands are here.
*/
#include "../sash.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <pwd.h>
#include <grp.h>
#include <utime.h>
#include <errno.h>
void
chmod_main(argc, argv)
char **argv;
{
char *cp;
int mode;
mode = 0;
cp = argv[1];
while (isoctal(*cp))
mode = mode * 8 + (*cp++ - '0');
if (*cp) {
fprintf(stderr, "Mode must be octal\n");
exit(1);
}
argc--;
argv++;
while (argc-- > 1) {
if (chmod(argv[1], mode) < 0)
perror(argv[1]);
argv++;
}
exit(0);
}