2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
10 #include <sys/types.h>
15 ULONG
prot_u2a(mode_t protect
);
17 /*****************************************************************************
29 Change permission bits of a specified file.
32 path - Pathname of the file
33 mode - Bit mask created by ORing zero or more of the following
36 S_ISUID - set user id on execution
37 S_ISGID - set group id on execution
38 S_ISVTX - sticky bit (restricted deletion flag)
39 S_IRUSR - allow owner to read
40 S_IWUSR - allow owner to write
41 S_IXUSR - allow owner to execute/search directory
42 S_IRGRP - allow group to read
43 S_IWGRP - allow group to write
44 S_IXGRP - allow group to execute/search directory
45 S_IROTH - allow others to read
46 S_IWOTH - allow others to write
47 S_IXOTH - allow others to execute/search directory
50 0 on success and -1 on error. If an error occurred, the global
51 variable errno is set.
58 S_ISUID and S_ISGID are silently ignored.
64 Permission bit masks are converted to their respective dos.library
67 S_ISVTX to FIBF_SCRIPT
69 !S_IWUSR to FIBF_WRITE
70 !S_IXUSR to FIBF_EXECUTE
71 S_IRGRP to FIBF_GRP_READ
72 S_IWGRP to FIBF_GRP_WRITE
73 S_IXGRP to FIBF_GRP_EXECUTE
74 S_IROTH to FIBF_OTR_READ
75 S_IWOTH to FIBF_OTR_WRITE
76 S_IXOTH to FIBF_OTR_EXECUTE
78 ******************************************************************************/
80 if (!path
) /*safety check */
86 path
= __path_u2a(path
);
90 if (!SetProtection(path
, prot_u2a(mode
)))
92 errno
= IoErr2errno(IoErr());
100 /* taken from emul_handler */
101 ULONG
prot_u2a(mode_t protect
)
105 /* The following three (AROS) flags are low-active! */
106 if (!(protect
& S_IRUSR
))
108 if (!(protect
& S_IWUSR
))
110 if (!(protect
& S_IXUSR
))
111 aprot
|= FIBF_EXECUTE
;
113 /* The following flags are high-active again. */
114 if ((protect
& S_IRGRP
))
115 aprot
|= FIBF_GRP_READ
;
116 if ((protect
& S_IWGRP
))
117 aprot
|= FIBF_GRP_WRITE
;
118 if ((protect
& S_IXGRP
))
119 aprot
|= FIBF_GRP_EXECUTE
;
120 if ((protect
& S_IROTH
))
121 aprot
|= FIBF_OTR_READ
;
122 if ((protect
& S_IWOTH
))
123 aprot
|= FIBF_OTR_WRITE
;
124 if ((protect
& S_IXOTH
))
125 aprot
|= FIBF_OTR_EXECUTE
;
127 if ((protect
& S_ISVTX
))
128 aprot
|= FIBF_SCRIPT
;