2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
10 #include <sys/types.h>
14 ULONG
prot_u2a(mode_t protect
);
16 /*****************************************************************************
28 Change permission bits of a specified file.
31 path - Pathname of the file
32 mode - Bit mask created by ORing zero or more of the following
35 S_ISUID - set user id on execution
36 S_ISGID - set group id on execution
37 S_ISVTX - sticky bit (restricted deletion flag)
38 S_IRUSR - allow owner to read
39 S_IWUSR - allow owner to write
40 S_IXUSR - allow owner to execute/search directory
41 S_IRGRP - allow group to read
42 S_IWGRP - allow group to write
43 S_IXGRP - allow group to execute/search directory
44 S_IROTH - allow others to read
45 S_IWOTH - allow others to write
46 S_IXOTH - allow others to execute/search directory
49 0 on success and -1 on error. If an error occurred, the global
50 variable errno is set.
57 S_ISUID and S_ISGID are silently ignored.
63 Permission bit masks are converted to their respective dos.library
66 S_ISVTX to FIBF_SCRIPT
68 !S_IWUSR to FIBF_WRITE
69 !S_IXUSR to FIBF_EXECUTE
70 S_IRGRP to FIBF_GRP_READ
71 S_IWGRP to FIBF_GRP_WRITE
72 S_IXGRP to FIBF_GRP_EXECUTE
73 S_IROTH to FIBF_OTR_READ
74 S_IWOTH to FIBF_OTR_WRITE
75 S_IXOTH to FIBF_OTR_EXECUTE
77 ******************************************************************************/
79 if (!path
) /*safety check */
85 path
= __path_u2a(path
);
89 if (!SetProtection(path
, prot_u2a(mode
)))
91 errno
= __stdc_ioerr2errno(IoErr());
99 /* taken from emul_handler */
100 ULONG
prot_u2a(mode_t protect
)
104 /* The following three (AROS) flags are low-active! */
105 if (!(protect
& S_IRUSR
))
107 if (!(protect
& S_IWUSR
))
109 if (!(protect
& S_IXUSR
))
110 aprot
|= FIBF_EXECUTE
;
112 /* The following flags are high-active again. */
113 if ((protect
& S_IRGRP
))
114 aprot
|= FIBF_GRP_READ
;
115 if ((protect
& S_IWGRP
))
116 aprot
|= FIBF_GRP_WRITE
;
117 if ((protect
& S_IXGRP
))
118 aprot
|= FIBF_GRP_EXECUTE
;
119 if ((protect
& S_IROTH
))
120 aprot
|= FIBF_OTR_READ
;
121 if ((protect
& S_IWOTH
))
122 aprot
|= FIBF_OTR_WRITE
;
123 if ((protect
& S_IXOTH
))
124 aprot
|= FIBF_OTR_EXECUTE
;
126 if ((protect
& S_ISVTX
))
127 aprot
|= FIBF_SCRIPT
;