1 /* makedir.c - make a directory */
3 static char ident[] = "@(#)$Id: makedir.c,v 1.13 1992/12/15 00:20:22 jromine Exp $";
6 #if defined (BSD42) || defined (hpux)
7 /* Modified to try recursive create. Really, this should be broken
8 * out into a subr so that SYS5 systems can do this too. I don't
9 * have a SYS5 machine around to test anymore, so someone else will
10 * have to send me the code.
17 #if defined (BSD42) || defined (hpux) || defined(SVR4) || \
18 defined(ncr) || defined (_AIX) || defined(AUX)
20 #include <sys/param.h>
22 #endif /* BSD42 ... */
24 #include <sys/types.h>
27 #if defined(SVR4) || defined(ncr)
38 #if defined (BSD42) || defined (hpux) || defined (SYS5DIR)
40 char path[MAXPATHLEN];
44 (void) fflush (stdout);
46 #if defined (BSD42) || defined (hpux) || defined (SYS5DIR)
47 if (getuid () == geteuid ()) {
48 c = strcpy(path, dir);
50 while ((c = index((c + 1), '/')) != NULL) {
52 if (access(path, X_OK)) {
54 advise (dir, "unable to create directory");
57 if (mkdir(path, 0775)) {
58 advise (dir, "unable to create directory");
65 if (mkdir (dir, 0755) == NOTOK) {
66 advise (dir, "unable to create directory");
71 #endif /* BSD42 or hpux or SYS5DIR */
72 switch (pid = vfork ()) {
74 advise ("fork", "unable to");
78 (void) setgid (getgid ());
79 (void) setuid (getuid ());
81 execl ("/bin/mkdir", "mkdir", dir, NULLCP);
82 execl ("/usr/bin/mkdir", "mkdir", dir, NULLCP);
83 fprintf (stderr, "unable to exec ");
88 if (pidXwait (pid, "mkdir"))
93 if ((cp = m_find ("folder-protect")) == NULL)
95 (void) chmod (dir, atooi (cp));