diff options
| author | Jim Blandy | 1993-08-03 07:02:38 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-08-03 07:02:38 +0000 |
| commit | 23524fb9509369fc89f843fbbad0a3de06bb0d1d (patch) | |
| tree | f2c693e47dee82feb407d2bb98bfb1d0a3aa6c8a | |
| parent | d50a54c0f1638025b2a08d8a827fe787ea2a039f (diff) | |
| download | emacs-23524fb9509369fc89f843fbbad0a3de06bb0d1d.tar.gz emacs-23524fb9509369fc89f843fbbad0a3de06bb0d1d.zip | |
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
configure to edit.
* sysdep.c [not HAVE_MKDIR] (mkdir): New function, taken from tar,
for use on systems lacking the mkdir function.
[not HAVE_RMDIR] (rmdir): New function, taken from tar, for use on
systems lacking the rmdir function.
| -rw-r--r-- | src/config.in | 3 | ||||
| -rw-r--r-- | src/sysdep.c | 112 |
2 files changed, 114 insertions, 1 deletions
diff --git a/src/config.in b/src/config.in index 7b19feef5a9..dafb759749a 100644 --- a/src/config.in +++ b/src/config.in | |||
| @@ -113,8 +113,9 @@ and this notice must be preserved on all copies. */ | |||
| 113 | #undef HAVE_XRMSETDATABASE | 113 | #undef HAVE_XRMSETDATABASE |
| 114 | #undef HAVE_XSCREENRESOURCESTRING | 114 | #undef HAVE_XSCREENRESOURCESTRING |
| 115 | 115 | ||
| 116 | #undef HAVE_MKDIR | ||
| 117 | #undef HAVE_RMDIR | ||
| 116 | #undef HAVE_RANDOM | 118 | #undef HAVE_RANDOM |
| 117 | |||
| 118 | #undef HAVE_BCOPY | 119 | #undef HAVE_BCOPY |
| 119 | 120 | ||
| 120 | #undef HAVE_AIX_SMT_EXP | 121 | #undef HAVE_AIX_SMT_EXP |
diff --git a/src/sysdep.c b/src/sysdep.c index 3cc0a8cf801..d765fa79ec2 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -3091,6 +3091,118 @@ readdirver (dirp) | |||
| 3091 | #endif /* VMS */ | 3091 | #endif /* VMS */ |
| 3092 | 3092 | ||
| 3093 | #endif /* NONSYSTEM_DIR_LIBRARY */ | 3093 | #endif /* NONSYSTEM_DIR_LIBRARY */ |
| 3094 | |||
| 3095 | |||
| 3096 | /* mkdir and rmdir functions, for systems which don't have them. */ | ||
| 3097 | |||
| 3098 | #ifndef HAVE_MKDIR | ||
| 3099 | /* | ||
| 3100 | * Written by Robert Rother, Mariah Corporation, August 1985. | ||
| 3101 | * | ||
| 3102 | * If you want it, it's yours. All I ask in return is that if you | ||
| 3103 | * figure out how to do this in a Bourne Shell script you send me | ||
| 3104 | * a copy. | ||
| 3105 | * sdcsvax!rmr or rmr@uscd | ||
| 3106 | * | ||
| 3107 | * Severely hacked over by John Gilmore to make a 4.2BSD compatible | ||
| 3108 | * subroutine. 11Mar86; hoptoad!gnu | ||
| 3109 | * | ||
| 3110 | * Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir, | ||
| 3111 | * subroutine didn't return EEXIST. It does now. | ||
| 3112 | */ | ||
| 3113 | |||
| 3114 | /* | ||
| 3115 | * Make a directory. | ||
| 3116 | */ | ||
| 3117 | int | ||
| 3118 | mkdir (dpath, dmode) | ||
| 3119 | char *dpath; | ||
| 3120 | int dmode; | ||
| 3121 | { | ||
| 3122 | int cpid, status; | ||
| 3123 | struct stat statbuf; | ||
| 3124 | |||
| 3125 | if (stat (dpath, &statbuf) == 0) | ||
| 3126 | { | ||
| 3127 | errno = EEXIST; /* Stat worked, so it already exists */ | ||
| 3128 | return -1; | ||
| 3129 | } | ||
| 3130 | |||
| 3131 | /* If stat fails for a reason other than non-existence, return error */ | ||
| 3132 | if (errno != ENOENT) | ||
| 3133 | return -1; | ||
| 3134 | |||
| 3135 | switch (cpid = fork ()) | ||
| 3136 | { | ||
| 3137 | |||
| 3138 | case -1: /* Error in fork() */ | ||
| 3139 | return (-1); /* Errno is set already */ | ||
| 3140 | |||
| 3141 | case 0: /* Child process */ | ||
| 3142 | /* | ||
| 3143 | * Cheap hack to set mode of new directory. Since this | ||
| 3144 | * child process is going away anyway, we zap its umask. | ||
| 3145 | * FIXME, this won't suffice to set SUID, SGID, etc. on this | ||
| 3146 | * directory. Does anybody care? | ||
| 3147 | */ | ||
| 3148 | status = umask (0); /* Get current umask */ | ||
| 3149 | status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ | ||
| 3150 | execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); | ||
| 3151 | _exit (-1); /* Can't exec /bin/mkdir */ | ||
| 3152 | |||
| 3153 | default: /* Parent process */ | ||
| 3154 | while (cpid != wait (&status)); /* Wait for kid to finish */ | ||
| 3155 | } | ||
| 3156 | |||
| 3157 | if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) | ||
| 3158 | { | ||
| 3159 | errno = EIO; /* We don't know why, but */ | ||
| 3160 | return -1; /* /bin/mkdir failed */ | ||
| 3161 | } | ||
| 3162 | |||
| 3163 | return 0; | ||
| 3164 | } | ||
| 3165 | #endif /* not HAVE_MKDIR */ | ||
| 3166 | |||
| 3167 | #ifndef HAVE_RMDIR | ||
| 3168 | int | ||
| 3169 | rmdir (dpath) | ||
| 3170 | char *dpath; | ||
| 3171 | { | ||
| 3172 | int cpid, status; | ||
| 3173 | struct stat statbuf; | ||
| 3174 | |||
| 3175 | if (stat (dpath, &statbuf) != 0) | ||
| 3176 | { | ||
| 3177 | /* Stat just set errno. We don't have to */ | ||
| 3178 | return -1; | ||
| 3179 | } | ||
| 3180 | |||
| 3181 | switch (cpid = fork ()) | ||
| 3182 | { | ||
| 3183 | |||
| 3184 | case -1: /* Error in fork() */ | ||
| 3185 | return (-1); /* Errno is set already */ | ||
| 3186 | |||
| 3187 | case 0: /* Child process */ | ||
| 3188 | execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); | ||
| 3189 | _exit (-1); /* Can't exec /bin/mkdir */ | ||
| 3190 | |||
| 3191 | default: /* Parent process */ | ||
| 3192 | while (cpid != wait (&status)); /* Wait for kid to finish */ | ||
| 3193 | } | ||
| 3194 | |||
| 3195 | if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) | ||
| 3196 | { | ||
| 3197 | errno = EIO; /* We don't know why, but */ | ||
| 3198 | return -1; /* /bin/mkdir failed */ | ||
| 3199 | } | ||
| 3200 | |||
| 3201 | return 0; | ||
| 3202 | } | ||
| 3203 | #endif /* !HAVE_RMDIR */ | ||
| 3204 | |||
| 3205 | |||
| 3094 | 3206 | ||
| 3095 | /* Functions for VMS */ | 3207 | /* Functions for VMS */ |
| 3096 | #ifdef VMS | 3208 | #ifdef VMS |