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 * Check if outbound directory exists and
* create if it doesn't exist. * create if it doesn't exist.
*/ */
mkdirs(ofile); mkdirs(ofile, 0770);
/* /*
* Attach file to .flo * Attach file to .flo

View File

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

View File

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

View File

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

View File

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