Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | |||
6 | int |
||
7 | chmod(const char *filename, int pmode) |
||
8 | { |
||
9 | int dmode; |
||
10 | unsigned attr = _chmod(filename, 0, 0); |
||
11 | |||
12 | if (attr == -1) |
||
13 | return -1; |
||
14 | |||
15 | if(pmode & S_IWUSR) /* Only implemented toggle is write/nowrite */ |
||
16 | dmode = 0; /* Normal file */ |
||
17 | else |
||
18 | dmode = 1; /* Readonly file */ |
||
19 | |||
20 | /* Must clear the directory and volume bits, otherwise 214301 fails. |
||
21 | Unused bits left alone (some network redirectors use them). */ |
||
22 | if (_chmod(filename, 1, (attr & 0xffe6) | dmode) == -1) |
||
23 | return -1; |
||
24 | return 0; |
||
25 | } |
||
26 |