blob: 496762226da128e551b50f53e047548a3eaa052a (
plain)
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
|
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
if (argc != 3) {
printf("usage: chmod <octal-mode> <path>\n");
return 1;
}
unsigned mode;
int rc = sscanf(argv[1], "%o", &mode);
if (rc != 1) {
perror("sscanf");
return 1;
}
rc = chmod(argv[2], mode);
if (rc < 0) {
perror("chmod");
return 1;
}
return 0;
}
|