1*47944Sbostic /*-
2*47944Sbostic * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic * All rights reserved.
411928Sdlw *
5*47944Sbostic * %sccs.include.proprietary.c%
623006Skre */
723006Skre
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)chmod_.c 5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic
1223006Skre /*
1311928Sdlw * chmod - change file mode bits
1411928Sdlw *
1511928Sdlw * synopsis:
1611928Sdlw * integer function chmod (fname, mode)
1711928Sdlw * character*(*) fname, mode
1811928Sdlw */
1911928Sdlw
2011928Sdlw #include "../libI77/f_errno.h"
2112142Sdlw #include <sys/param.h>
2212142Sdlw #ifndef MAXPATHLEN
2312142Sdlw #define MAXPATHLEN 128
2412142Sdlw #endif
2511928Sdlw
chmod_(name,mode,namlen,modlen)2611928Sdlw long chmod_(name, mode, namlen, modlen)
2711928Sdlw char *name, *mode;
2811928Sdlw long namlen, modlen;
2911928Sdlw {
3012142Sdlw char nambuf[MAXPATHLEN];
3111928Sdlw char modbuf[32];
3211928Sdlw int retcode;
3311928Sdlw
3411928Sdlw if (namlen >= sizeof nambuf || modlen >= sizeof modbuf)
3511928Sdlw return((long)(errno=F_ERARG));
3611928Sdlw g_char(name, namlen, nambuf);
3711928Sdlw g_char(mode, modlen, modbuf);
3811928Sdlw if (nambuf[0] == '\0')
3911928Sdlw return((long)(errno=ENOENT));
4011928Sdlw if (modbuf[0] == '\0')
4111928Sdlw return((long)(errno=F_ERARG));
4211928Sdlw if (fork())
4311928Sdlw {
4411928Sdlw if (wait(&retcode) == -1)
4511928Sdlw return((long)errno);
4611928Sdlw return((long)retcode);
4711928Sdlw }
4811928Sdlw else
4911928Sdlw execl("/bin/chmod", "chmod", modbuf, nambuf, (char *)0);
5011928Sdlw }
51