Commit | Line | Data |
---|---|---|
82492b51 KB |
1 | /*- |
2 | * Copyright (c) 1980 The Regents of the University of California. | |
3 | * All rights reserved. | |
e4a6aa87 | 4 | * |
ad787160 C |
5 | * This module is believed to contain source code proprietary to AT&T. |
6 | * Use and redistribution is subject to the Berkeley Software License | |
7 | * Agreement and your Software Agreement with AT&T (Western Electric). | |
161423a6 RE |
8 | */ |
9 | ||
82492b51 | 10 | #ifndef lint |
ad787160 | 11 | static char sccsid[] = "@(#)chmod_.c 5.2 (Berkeley) 4/12/91"; |
82492b51 KB |
12 | #endif /* not lint */ |
13 | ||
161423a6 | 14 | /* |
e4a6aa87 DW |
15 | * chmod - change file mode bits |
16 | * | |
17 | * synopsis: | |
18 | * integer function chmod (fname, mode) | |
19 | * character*(*) fname, mode | |
20 | */ | |
21 | ||
22 | #include "../libI77/f_errno.h" | |
05ec41e3 DW |
23 | #include <sys/param.h> |
24 | #ifndef MAXPATHLEN | |
25 | #define MAXPATHLEN 128 | |
26 | #endif | |
e4a6aa87 DW |
27 | |
28 | long chmod_(name, mode, namlen, modlen) | |
29 | char *name, *mode; | |
30 | long namlen, modlen; | |
31 | { | |
05ec41e3 | 32 | char nambuf[MAXPATHLEN]; |
e4a6aa87 DW |
33 | char modbuf[32]; |
34 | int retcode; | |
35 | ||
36 | if (namlen >= sizeof nambuf || modlen >= sizeof modbuf) | |
37 | return((long)(errno=F_ERARG)); | |
38 | g_char(name, namlen, nambuf); | |
39 | g_char(mode, modlen, modbuf); | |
40 | if (nambuf[0] == '\0') | |
41 | return((long)(errno=ENOENT)); | |
42 | if (modbuf[0] == '\0') | |
43 | return((long)(errno=F_ERARG)); | |
44 | if (fork()) | |
45 | { | |
46 | if (wait(&retcode) == -1) | |
47 | return((long)errno); | |
48 | return((long)retcode); | |
49 | } | |
50 | else | |
51 | execl("/bin/chmod", "chmod", modbuf, nambuf, (char *)0); | |
52 | } |