1 /*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)chmod_.c 5.2 (Berkeley) 04/12/91";
10 #endif /* not lint */
11
12 /*
13 * chmod - change file mode bits
14 *
15 * synopsis:
16 * integer function chmod (fname, mode)
17 * character*(*) fname, mode
18 */
19
20 #include "../libI77/f_errno.h"
21 #include <sys/param.h>
22 #ifndef MAXPATHLEN
23 #define MAXPATHLEN 128
24 #endif
25
chmod_(name,mode,namlen,modlen)26 long chmod_(name, mode, namlen, modlen)
27 char *name, *mode;
28 long namlen, modlen;
29 {
30 char nambuf[MAXPATHLEN];
31 char modbuf[32];
32 int retcode;
33
34 if (namlen >= sizeof nambuf || modlen >= sizeof modbuf)
35 return((long)(errno=F_ERARG));
36 g_char(name, namlen, nambuf);
37 g_char(mode, modlen, modbuf);
38 if (nambuf[0] == '\0')
39 return((long)(errno=ENOENT));
40 if (modbuf[0] == '\0')
41 return((long)(errno=F_ERARG));
42 if (fork())
43 {
44 if (wait(&retcode) == -1)
45 return((long)errno);
46 return((long)retcode);
47 }
48 else
49 execl("/bin/chmod", "chmod", modbuf, nambuf, (char *)0);
50 }
51