home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / unixlib / !UnixLib / src / unix / c / chmod < prev    next >
Encoding:
Text File  |  1994-09-30  |  669 b   |  41 lines

  1. static char sccs_id[] = "@(#) chmod.c 1.2 " __DATE__ " HJR";
  2.  
  3. /* chmod.c (c) Copyright 1990 H.Rogers */
  4.  
  5. #include <errno.h>
  6.  
  7. #include "sys/types.h"
  8. #include "sys/unix.h"
  9. #include "sys/os.h"
  10.  
  11. int
  12. chmod (char *file, register int mode)
  13. {
  14.   int r[6];
  15.   os_error *e;
  16.  
  17.   file = __uname (file, 0);
  18.  
  19.   if (e = os_file (5, file, r))
  20.     {
  21.       __seterr (e);
  22.       return (-1);
  23.     }
  24.   if (!r[0])
  25.     {
  26.       errno = ENOENT;
  27.       return (-1);
  28.     }
  29.  
  30.   r[5] = (r[5] & 0xFFFFFF00) | ((mode & 0400) >> 8) | ((mode & 0200) >> 6) |
  31.     ((mode & 0004) << 2) | ((mode & 0002) << 4);
  32.  
  33.   if (e = os_file (1, file, r))
  34.     {
  35.       __seterr (e);
  36.       return (-1);
  37.     }
  38.  
  39.   return (0);
  40. }
  41.