home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/chmod,v $
- * $Date: 1996/10/30 21:59:01 $
- * $Revision: 1.2 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: chmod,v $
- * Revision 1.2 1996/10/30 21:59:01 unixlib
- * Massive changes made by Nick Burret and Peter Burwood.
- *
- * Revision 1.1 1996/04/19 21:35:27 simon
- * Initial revision
- *
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id: chmod,v 1.2 1996/10/30 21:59:01 unixlib Rel $";
-
- #include <errno.h>
-
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- #include <sys/os.h>
-
- int
- chmod (const char *file, mode_t mode)
- {
- int r[6];
- _kernel_oserror *e;
- char *f;
-
- f = __uname ((char *)file, 0);
-
- if (e = os_file (5, f, r))
- {
- __seterr (e);
- return (-1);
- }
- if (!r[0])
- {
- errno = ENOENT;
- return (-1);
- }
-
- r[5] = (r[5] & 0xFFFFFF00) | ((mode & 0400) >> 8) | ((mode & 0200) >> 6) |
- ((mode & 0004) << 2) | ((mode & 0002) << 4);
-
- if (e = os_file (1, f, r))
- {
- __seterr (e);
- return (-1);
- }
-
- return (0);
- }
-