#include "uucp.h"
#include "sysdep.h"
#include <errno.h>
int
mkdir (zdir, imode)
const char *zdir;
int imode;
{
struct stat s;
const char *azargs[3];
int aidescs[3];
pid_t ipid;
if (stat (zdir, &s) == 0)
{
errno = EEXIST;
return -1;
}
(void) umask ((~ imode) & (S_IRWXU | S_IRWXG | S_IRWXO));
azargs[0] = UUDIR_PROGRAM;
azargs[1] = zdir;
azargs[2] = NULL;
aidescs[0] = SPAWN_NULL;
aidescs[1] = SPAWN_NULL;
aidescs[2] = SPAWN_NULL;
ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL,
TRUE, FALSE, (const char *) NULL,
(const char *) NULL, (const char *) NULL);
(void) umask (0);
if (ipid < 0)
return -1;
if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0)
{
errno = EACCES;
return -1;
}
return 0;
}