Article View: comp.mail.mh
Article #1945Re: Hierarchical folders in MH
From: Craig Leres
Date: Fri, 15 Dec 1989 05:46
Date: Fri, 15 Dec 1989 05:46
87 lines
2504 bytes
2504 bytes
Peter Marvit writes:
> I have a patch which will allow recursve folder creation. I've sent it on
> to John Romnie to be incorporated into the "official" MH6.6. If readers of
> this list want the patch ahead of time, mail me. More than 5 requests
> means I'll post it.
>
> Oh, it may have to wait till after 2 Jan, since I'm leaving on vacation in
> two days ;-)
Well perhaps while we're waiting for you to post your version people
will be interested in looking at mine...
Craig
------ sbr/makedir.c
/* @(#) $Header: makedir.c,v 1.3 89/12/14 21:13:03 leres Exp $ (LBL) */
/* makedir.c - make a directory */
#include "../h/mh.h"
#include <stdio.h>
#include <errno.h>
extern int errno;
makedir(dir)
register char *dir;
{
register int i, pid;
register char *cp;
char temp[BUFSIZ];
m_update();
(void) fflush(stdout);
#ifdef BSD42
if (getuid() == geteuid()) {
errno = 0;
if ((i = mkdir(dir, 0755)) < 0 && errno == ENOENT) {
/* Attempt to create higher level directories */
cp = strcpy(temp, dir);
if (*cp == '/')
++cp;
while (cp = index(cp, '/')) {
*cp = '\0';
errno = 0;
if ((i = mkdir(temp, 0755)) < 0 &&
errno != EEXIST)
break;
*cp++ = '/';
}
if (i >= 0)
i = mkdir(temp, 0755);
}
if (i < 0) {
advise(dir, "unable to create directory");
return(0);
}
} else
#endif BSD42
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);
}
Technical Details
Message-ID:
<4466@helios.ee.lbl.gov>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!helios.ee.lbl.gov!ace.ee.lbl.gov!leresReferences:
<7529@dime.cs.umass.edu> <8912141813.AA18891@hplpm.HPL.HP.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!helios.ee.lbl.gov!ace.ee.lbl.gov!leres From: leres@ace.ee.lbl.gov (Craig Leres) Newsgroups: comp.mail.mh Subject: Re: Hierarchical folders in MH Message-ID: <4466@helios.ee.lbl.gov> Date: 15 Dec 89 05:46:48 GMT References: <7529@dime.cs.umass.edu> <8912141813.AA18891@hplpm.HPL.HP.COM> Sender: usenet@helios.ee.lbl.gov Reply-To: leres@helios.ee.lbl.gov (Craig Leres) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 87 X-Local-Date: 14 Dec 89 21:46:48 PST