diff options
| author | Paul Eggert | 2012-07-11 00:05:21 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-11 00:05:21 -0700 |
| commit | bb3522608f97ac2450f5501164b11adda94e9b5f (patch) | |
| tree | 4ba437ab0789a2c0f31fa716a4b9b8204b222e58 /src | |
| parent | 249685df40653f6d48c2c75412ff2fc24ee2d958 (diff) | |
| download | emacs-bb3522608f97ac2450f5501164b11adda94e9b5f.tar.gz emacs-bb3522608f97ac2450f5501164b11adda94e9b5f.zip | |
Assume mkdir, rmdir.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/sysdep.c | 126 |
2 files changed, 4 insertions, 126 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 140cd54d8cd..0dc0f010066 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -20,6 +20,10 @@ | |||
| 20 | 20 | ||
| 21 | 2012-07-11 Paul Eggert <eggert@cs.ucla.edu> | 21 | 2012-07-11 Paul Eggert <eggert@cs.ucla.edu> |
| 22 | 22 | ||
| 23 | Assume mkdir, rmdir. | ||
| 24 | * sysdep.c (mkdir) [!HAVE_MKDIR]: Remove. | ||
| 25 | * sysdep.c (rmdir) [!HAVE_RMDIR]: Remove. | ||
| 26 | |||
| 23 | Assume rename. | 27 | Assume rename. |
| 24 | * sysdep.c (rename) [!HAVE_RENAME]: Remove. | 28 | * sysdep.c (rename) [!HAVE_RENAME]: Remove. |
| 25 | 29 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 274e000e9f3..7d0855b543c 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2075,132 +2075,6 @@ set_file_times (int fd, const char *filename, | |||
| 2075 | return fdutimens (fd, filename, timespec); | 2075 | return fdutimens (fd, filename, timespec); |
| 2076 | } | 2076 | } |
| 2077 | 2077 | ||
| 2078 | /* mkdir and rmdir functions, for systems which don't have them. */ | ||
| 2079 | |||
| 2080 | #ifndef HAVE_MKDIR | ||
| 2081 | /* | ||
| 2082 | * Written by Robert Rother, Mariah Corporation, August 1985. | ||
| 2083 | * | ||
| 2084 | * If you want it, it's yours. All I ask in return is that if you | ||
| 2085 | * figure out how to do this in a Bourne Shell script you send me | ||
| 2086 | * a copy. | ||
| 2087 | * sdcsvax!rmr or rmr@uscd | ||
| 2088 | * | ||
| 2089 | * Severely hacked over by John Gilmore to make a 4.2BSD compatible | ||
| 2090 | * subroutine. 11Mar86; hoptoad!gnu | ||
| 2091 | * | ||
| 2092 | * Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir, | ||
| 2093 | * subroutine didn't return EEXIST. It does now. | ||
| 2094 | */ | ||
| 2095 | |||
| 2096 | /* | ||
| 2097 | * Make a directory. | ||
| 2098 | */ | ||
| 2099 | int | ||
| 2100 | mkdir (char *dpath, int dmode) | ||
| 2101 | { | ||
| 2102 | pid_t cpid; | ||
| 2103 | int status, fd; | ||
| 2104 | struct stat statbuf; | ||
| 2105 | |||
| 2106 | if (stat (dpath, &statbuf) == 0) | ||
| 2107 | { | ||
| 2108 | errno = EEXIST; /* Stat worked, so it already exists */ | ||
| 2109 | return -1; | ||
| 2110 | } | ||
| 2111 | |||
| 2112 | /* If stat fails for a reason other than non-existence, return error */ | ||
| 2113 | if (errno != ENOENT) | ||
| 2114 | return -1; | ||
| 2115 | |||
| 2116 | synch_process_alive = 1; | ||
| 2117 | switch (cpid = fork ()) | ||
| 2118 | { | ||
| 2119 | |||
| 2120 | case -1: /* Error in fork */ | ||
| 2121 | return (-1); /* Errno is set already */ | ||
| 2122 | |||
| 2123 | case 0: /* Child process */ | ||
| 2124 | /* | ||
| 2125 | * Cheap hack to set mode of new directory. Since this | ||
| 2126 | * child process is going away anyway, we zap its umask. | ||
| 2127 | * FIXME, this won't suffice to set SUID, SGID, etc. on this | ||
| 2128 | * directory. Does anybody care? | ||
| 2129 | */ | ||
| 2130 | status = umask (0); /* Get current umask */ | ||
| 2131 | status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ | ||
| 2132 | fd = emacs_open ("/dev/null", O_RDWR, 0); | ||
| 2133 | if (fd >= 0) | ||
| 2134 | { | ||
| 2135 | dup2 (fd, 0); | ||
| 2136 | dup2 (fd, 1); | ||
| 2137 | dup2 (fd, 2); | ||
| 2138 | } | ||
| 2139 | execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); | ||
| 2140 | _exit (-1); /* Can't exec /bin/mkdir */ | ||
| 2141 | |||
| 2142 | default: /* Parent process */ | ||
| 2143 | wait_for_termination (cpid); | ||
| 2144 | } | ||
| 2145 | |||
| 2146 | if (synch_process_death != 0 || synch_process_retcode != 0 | ||
| 2147 | || synch_process_termsig != 0) | ||
| 2148 | { | ||
| 2149 | errno = EIO; /* We don't know why, but */ | ||
| 2150 | return -1; /* /bin/mkdir failed */ | ||
| 2151 | } | ||
| 2152 | |||
| 2153 | return 0; | ||
| 2154 | } | ||
| 2155 | #endif /* not HAVE_MKDIR */ | ||
| 2156 | |||
| 2157 | #ifndef HAVE_RMDIR | ||
| 2158 | int | ||
| 2159 | rmdir (char *dpath) | ||
| 2160 | { | ||
| 2161 | int cpid, status, fd; | ||
| 2162 | struct stat statbuf; | ||
| 2163 | |||
| 2164 | if (stat (dpath, &statbuf) != 0) | ||
| 2165 | { | ||
| 2166 | /* Stat just set errno. We don't have to */ | ||
| 2167 | return -1; | ||
| 2168 | } | ||
| 2169 | |||
| 2170 | synch_process_alive = 1; | ||
| 2171 | switch (cpid = fork ()) | ||
| 2172 | { | ||
| 2173 | |||
| 2174 | case -1: /* Error in fork */ | ||
| 2175 | return (-1); /* Errno is set already */ | ||
| 2176 | |||
| 2177 | case 0: /* Child process */ | ||
| 2178 | fd = emacs_open ("/dev/null", O_RDWR, 0); | ||
| 2179 | if (fd >= 0) | ||
| 2180 | { | ||
| 2181 | dup2 (fd, 0); | ||
| 2182 | dup2 (fd, 1); | ||
| 2183 | dup2 (fd, 2); | ||
| 2184 | } | ||
| 2185 | execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); | ||
| 2186 | _exit (-1); /* Can't exec /bin/rmdir */ | ||
| 2187 | |||
| 2188 | default: /* Parent process */ | ||
| 2189 | wait_for_termination (cpid); | ||
| 2190 | } | ||
| 2191 | |||
| 2192 | if (synch_process_death != 0 || synch_process_retcode != 0 | ||
| 2193 | || synch_process_termsig != 0) | ||
| 2194 | { | ||
| 2195 | errno = EIO; /* We don't know why, but */ | ||
| 2196 | return -1; /* /bin/rmdir failed */ | ||
| 2197 | } | ||
| 2198 | |||
| 2199 | return 0; | ||
| 2200 | } | ||
| 2201 | #endif /* !HAVE_RMDIR */ | ||
| 2202 | |||
| 2203 | |||
| 2204 | #ifndef HAVE_STRSIGNAL | 2078 | #ifndef HAVE_STRSIGNAL |
| 2205 | char * | 2079 | char * |
| 2206 | strsignal (int code) | 2080 | strsignal (int code) |