|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 1998 (0x7ce)
Types: TextFile
Names: »makedir.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
└─⟦3658e588a⟧ »EurOpenD3/mail/mh/mh-6.7.tar.Z«
└─⟦c75e36ecb⟧
└─⟦this⟧ »mh-6.7/sbr/makedir.c«
/* makedir.c - make a directory */
#if defined (BSD42) || defined (hpux)
/* Modified to try recursive create. Really, this should be broken
* out into a subr so that SYS5 systems can do this too. I don't
* have a SYS5 machine around to test anymore, so someone else will
* have to send me the code.
*/
#endif
#include "../h/mh.h"
#include <stdio.h>
#if defined (BSD42) || defined (hpux)
#include <errno.h>
#include <sys/param.h>
#include <sys/file.h>
#endif BDS42
#ifdef SYS5DIR
#include <sys/types.h>
#include <sys/stat.h>
#endif SYS5DIR
extern int errno;
makedir (dir)
register char *dir;
{
int pid;
register char *cp;
#if defined (BSD42) || defined (hpux)
register char *c;
char path[MAXPATHLEN];
#endif BSD42
m_update ();
(void) fflush (stdout);
#if defined (BSD42) || defined (hpux) || defined (SYS5DIR)
if (getuid () == geteuid ()) {
c = strcpy(path, dir);
while ((c = index((c + 1), '/')) != NULL) {
*c = (char)0;
if (access(path, X_OK)) {
if (errno != ENOENT){
advise (dir, "unable to create directory");
return 0;
}
if (mkdir(path, 0775)) {
advise (dir, "unable to create directory");
return 0;
}
}
*c = '/';
}
if (mkdir (dir, 0755) == NOTOK) {
advise (dir, "unable to create directory");
return 0;
}
}
else
#endif BSD42 or hpux or SYS5DIR
switch (pid = vfork ()) {
case NOTOK:
advise ("fork", "unable to");
return 0;
case OK:
(void) setgid (getgid ());
(void) setuid (getuid ());
execl ("/bin/mkdir", "mkdir", dir, NULLCP);
execl ("/usr/bin/mkdir", "mkdir", dir, NULLCP);
fprintf (stderr, "unable to exec ");
perror ("mkdir");
_exit (-1);
default:
if (pidXwait (pid, "mkdir"))
return 0;
break;
}
if ((cp = m_find ("folder-protect")) == NULL)
cp = foldprot;
(void) chmod (dir, atooi (cp));
return 1;
}