Mercurial > emacs
comparison src/fileio.c @ 9188:c17b2a49b6ec
(check_writable, check_executable) [__HURD__]: Use eaccess.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 29 Sep 1994 23:20:43 +0000 |
parents | 1d95c81487a3 |
children | a309baaa249f |
comparison
equal
deleted
inserted
replaced
9187:8cf9181c119e | 9188:c17b2a49b6ec |
---|---|
2175 static int | 2175 static int |
2176 check_executable (filename) | 2176 check_executable (filename) |
2177 char *filename; | 2177 char *filename; |
2178 { | 2178 { |
2179 #ifdef __HURD__ | 2179 #ifdef __HURD__ |
2180 mach_port_t file; | 2180 return (eaccess (filename, 1) >= 0); |
2181 int access_mode; | |
2182 | |
2183 file = path_lookup (filename, 0, 0); | |
2184 if (file == MACH_PORT_NULL) | |
2185 /* File can't be opened. */ | |
2186 access_mode = 0; | |
2187 else | |
2188 { | |
2189 file_access (file, &access_mode); | |
2190 mach_port_deallocate (mach_task_self (), file); | |
2191 } | |
2192 return !!(access_mode & O_EXEC); | |
2193 #else | 2181 #else |
2194 /* Access isn't quite right because it uses the real uid | 2182 /* Access isn't quite right because it uses the real uid |
2195 and we really want to test with the effective uid. | 2183 and we really want to test with the effective uid. |
2196 But Unix doesn't give us a right way to do it. */ | 2184 But Unix doesn't give us a right way to do it. */ |
2197 return (access (filename, 1) >= 0); | 2185 return (access (filename, 1) >= 0); |
2203 static int | 2191 static int |
2204 check_writable (filename) | 2192 check_writable (filename) |
2205 char *filename; | 2193 char *filename; |
2206 { | 2194 { |
2207 #ifdef __HURD__ | 2195 #ifdef __HURD__ |
2208 mach_port_t file; | 2196 return (eaccess (filename, 2) >= 0); |
2209 int access_mode; | |
2210 | |
2211 file = path_lookup (filename, 0, 0); | |
2212 if (file == MACH_PORT_NULL) | |
2213 /* File can't be opened. */ | |
2214 access_mode = 0; | |
2215 else | |
2216 { | |
2217 file_access (file, &access_mode); | |
2218 mach_port_deallocate (mach_task_self (), file); | |
2219 } | |
2220 return !!(access_mode & O_WRITE); | |
2221 #else | 2197 #else |
2222 /* Access isn't quite right because it uses the real uid | 2198 /* Access isn't quite right because it uses the real uid |
2223 and we really want to test with the effective uid. | 2199 and we really want to test with the effective uid. |
2224 But Unix doesn't give us a right way to do it. | 2200 But Unix doesn't give us a right way to do it. |
2225 Opening with O_WRONLY could work for an ordinary file, | 2201 Opening with O_WRONLY could work for an ordinary file, |