add a missing section header table index conversion
[tangerine.git] / compiler / clib / chmod.c
blobb64b2ab205c15e71ba50ab831e4590668f4a0edb
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/dos.h>
7 #include <proto/dos.h>
9 #include <errno.h>
10 #include <sys/stat.h>
12 #include "__errno.h"
14 ULONG prot_u2a(mode_t protect);
16 int chmod(const char *path, mode_t mode)
18 if (!SetProtection(path, prot_u2a(mode)))
20 errno = IoErr2errno(IoErr());
21 return -1;
24 return 0;
28 /* taken from emul_handler */
29 ULONG prot_u2a(mode_t protect)
31 ULONG aprot = FIBF_SCRIPT;
33 /* The following three (AROS) flags are low-active! */
34 if (!(protect & S_IRUSR))
35 aprot |= FIBF_READ;
36 if (!(protect & S_IWUSR))
37 aprot |= FIBF_WRITE;
38 if (!(protect & S_IXUSR))
39 aprot |= FIBF_EXECUTE;
41 /* The following flags are high-active again. */
42 if ((protect & S_IRGRP))
43 aprot |= FIBF_GRP_READ;
44 if ((protect & S_IWGRP))
45 aprot |= FIBF_GRP_WRITE;
46 if ((protect & S_IXGRP))
47 aprot |= FIBF_GRP_EXECUTE;
48 if ((protect & S_IROTH))
49 aprot |= FIBF_OTR_READ;
50 if ((protect & S_IWOTH))
51 aprot |= FIBF_OTR_WRITE;
52 if ((protect & S_IXOTH))
53 aprot |= FIBF_OTR_EXECUTE;
55 return aprot;