added mode parameter to mkdirs

This commit is contained in:
Michiel Broek 2002-01-19 11:54:34 +00:00
parent c9d9504f4d
commit b6ff90ffeb
5 changed files with 11 additions and 12 deletions

View File

@ -52,7 +52,7 @@ int attach(faddr noden, char *ofile, int mode, char flavor)
* Check if outbound directory exists and
* create if it doesn't exist.
*/
mkdirs(ofile);
mkdirs(ofile, 0770);
/*
* Attach file to .flo

View File

@ -459,7 +459,7 @@ int file_exist(char *path, int mode);
long file_size(char *path);
long file_crc(char *path, int);
time_t file_time(char *path);
int mkdirs(char *name);
int mkdirs(char *name, mode_t);
int diskfree(int);

View File

@ -222,7 +222,7 @@ time_t file_time(char *path)
/*
* Make directory tree, the name must end with a /
*/
int mkdirs(char *name)
int mkdirs(char *name, mode_t mode)
{
char buf[PATH_MAX], *p, *q;
int rc, last = 0, oldmask;
@ -236,7 +236,8 @@ int mkdirs(char *name)
oldmask = umask(000);
while ((q = strchr(p, '/'))) {
*q = '\0';
rc = mkdir(buf, 0775);
rc = mkdir(buf, mode);
Syslog('-', "mkdir(%s) rc=%d", buf, rc);
last = errno;
*q = '/';
p = q+1;
@ -257,7 +258,6 @@ int mkdirs(char *name)
/*
* Check free diskspace on most filesystems. Exclude check on floppyies,
* CD's and /boot partition. The amount of needed space is given in MBytes.
* Currently only Linux is supported.
*/
int diskfree(int needed)
{
@ -292,7 +292,7 @@ int diskfree(int needed)
*/
if (strncmp((char *)"/dev/fd", dev, 7) && strncmp((char *)"/boot", fs, 5) &&
(!strncmp((char *)"ext2", type, 4) || !strncmp((char *)"reiserfs", type, 8) ||
!strncmp((char *)"ufs", type, 3) ||
!strncmp((char *)"ufs", type, 3) || !strncmp((char *)"ffs", type, 3) ||
!strncmp((char *)"vfat", type, 4) || !strncmp((char *)"msdos", type, 5))) {
if (statfs(fs, &sfs) == 0) {
temp = (unsigned long)(sfs.f_bsize / 512L);

View File

@ -1,11 +1,10 @@
/*****************************************************************************
*
* File ..................: nodelock.c
* $Id$
* Purpose ...............: Node locking
* Last modification date : 18-Mar-2000
*
*****************************************************************************
* Copyright (C) 1997-2000
* Copyright (C) 1997-2002
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -51,7 +50,7 @@ int nodelock(faddr *addr)
mypid = getpid();
sprintf(tmp, "aa%d", mypid);
tfn = xstrcat(tfn, tmp);
mkdirs(tfn);
mkdirs(tfn, 0770);
if ((fp = fopen(tfn,"w")) == NULL) {
WriteError("$Can't open tmp file for bsy lock (%s) \"%s\"",ascfnode(addr, 0x1f), tfn);
@ -61,7 +60,7 @@ int nodelock(faddr *addr)
fprintf(fp,"%10d\n", mypid);
fclose(fp);
chmod(tfn, 0444);
chmod(tfn, 0440);
if (link(tfn, fn) == 0) {
unlink(tfn);
free(tfn);

View File

@ -85,7 +85,7 @@ FILE *openpkt(FILE *pkt, faddr *addr, char flavor)
pktroute.domain = xstrcpy(addr->domain);
pktroute.name = NULL;
Name = pktname(addr,flavor);
mkdirs(Name);
mkdirs(Name, 0770);
if ((pktfp = fopen(Name, "r+")) == NULL)
pktfp = fopen(Name,"w");