00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifdef HAVE_CONFIG_H
00019 #include <config.h>
00020 #endif
00021
00022 #ifndef HAVE_RMDIR
00023
00024 #ifdef HAVE_SYS_TYPES_H
00025 #include <sys/types.h>
00026 #endif
00027 #include <sys/stat.h>
00028
00029 #include <errno.h>
00030 #ifndef errno
00031 extern int errno;
00032 #endif
00033
00034 #ifdef STAT_MACROS_BROKEN
00035 #undef S_ISDIR
00036 #endif
00037
00038 #if !defined(S_ISDIR) && defined(S_IFDIR)
00039 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
00040 #endif
00041
00042 #include "safe-stat.h"
00043
00044
00045
00046
00047
00048
00049 int
00050 rmdir (dpath)
00051 char *dpath;
00052 {
00053 int cpid, status;
00054 struct stat statbuf;
00055
00056 if (SAFE_STAT (dpath, &statbuf) != 0)
00057 return -1;
00058
00059 if (!S_ISDIR (statbuf.st_mode))
00060 {
00061 errno = ENOTDIR;
00062 return -1;
00063 }
00064
00065 cpid = fork ();
00066 switch (cpid)
00067 {
00068 case -1:
00069 return -1;
00070
00071 case 0:
00072 execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
00073 _exit (1);
00074
00075 default:
00076
00077
00078
00079 while (wait (&status) != cpid)
00080 ;
00081
00082 if (status & 0xFFFF)
00083 {
00084
00085
00086
00087 errno = EIO;
00088 return -1;
00089 }
00090 return 0;
00091 }
00092 }
00093
00094 #endif