added mode parameter to mkdirs

This commit is contained in:
Michiel Broek 2002-01-19 13:04:55 +00:00
parent b6ff90ffeb
commit 2bdbf7a494
21 changed files with 30 additions and 29 deletions

View File

@ -4272,6 +4272,8 @@ v0.33.19 26-Oct-2001
old style tic files, they were not full 3d.
Fixes for Sparc systems.
The nodelist information now also holds the Txx flags.
The mkdirs function now needs a mode parameter for directory
creation.
lang:
Changed language prompts 6, 71, 429.

View File

@ -361,7 +361,7 @@ int main(int argc, char *argv[])
p = xstrcpy(inbound);
p = xstrcat(p,(char *)"/tmp/fooinb");
mkdirs(p);
mkdirs(p, 0700);
free(p);
maxrc=0;

View File

@ -1,11 +1,10 @@
/*****************************************************************************
*
* File ..................: mbcico/openfile.c
* $Id$
* Purpose ...............: Fidonet mailer
* Last modification date : 12-May-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
* Copyright (C) 1997-2002
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -170,7 +169,7 @@ FILE *openfile(char *fname, time_t remtime, off_t remsize, off_t *resofs, int(*r
* and try again.
*/
if ((infp = fopen(infpath,opentype)) == NULL) {
mkdirs(infpath);
mkdirs(infpath, 0770);
if ((infp = fopen(infpath, opentype)) == NULL) {
WriteError("$Cannot open local file \"%s\" for \"%s\"", infpath,opentype);
free(infpath);

View File

@ -71,7 +71,7 @@ static int scan_dir(int (*fn)(faddr *, char, int, char *), char *dname, int ispo
* Create a fake filename, mkdirs() likes that.
*/
sprintf(fname, "%s/foo", dname);
(void)mkdirs(fname);
(void)mkdirs(fname, 0770);
if ((dp = opendir(dname)) == NULL) {
Syslog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname));
return 0;

View File

@ -85,7 +85,7 @@ int Add_BBS()
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
mkdirs(temp2);
mkdirs(temp2, 0755);
if (file_cp(temp1, temp2) != 0) {
WriteError("$Copy to %s failed", temp2);

View File

@ -162,7 +162,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
* If we need a .TIC file, start creating it.
*/
if (nodes.Tic) {
mkdirs(ticfile);
mkdirs(ticfile, 0770);
if ((fp = fopen(ticfile, "a+")) != NULL) {
fprintf(fp, "Area %s\r\n", TIC.TicIn.Area);
fprintf(fp, "Origin %s\r\n", TIC.TicIn.Origin);

View File

@ -173,7 +173,7 @@ FILE *newpage(char *Name, char *Title)
later = time(NULL) + 86400;
sprintf(linebuf, "%s/stat/%s.temp", CFG.www_root, Name);
mkdirs(linebuf);
mkdirs(linebuf, 0755);
if ((fa = fopen(linebuf, "w")) == NULL) {
WriteError("$Can't create %s", linebuf);

View File

@ -82,7 +82,7 @@ void AdoptFile(int Area, char *File, char *Description)
if ((unarc = unpacker(File)) == NULL) {
Syslog('+', "No known archive: %s", File);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File);
mkdirs(temp2);
mkdirs(temp2, 0755);
if (file_cp(temp, temp2)) {
WriteError("Can't copy file to %s", temp2);
if (!do_quiet)

View File

@ -114,7 +114,7 @@ void Check(void)
if (access(area.Path, R_OK) == -1) {
Syslog('!', "No dir: %s", area.Path);
sprintf(newdir, "%s/foobar", area.Path);
mkdirs(newdir);
mkdirs(newdir, 0755);
}
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);

View File

@ -103,7 +103,7 @@ void ImportFiles(int Area)
if ((unarc = unpacker(temp)) == NULL) {
Syslog('+', "Unknown archive format %s", temp);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName);
mkdirs(temp2);
mkdirs(temp2, 0755);
if (file_cp(temp, temp2)) {
WriteError("Can't copy file to %s", temp2);
Doit = FALSE;
@ -292,7 +292,7 @@ void ImportFiles(int Area)
if ((unarc = unpacker(temp)) == NULL) {
Syslog('+', "Unknown archive format %s", temp);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName);
mkdirs(temp2);
mkdirs(temp2, 0755);
if (file_cp(temp, temp2)) {
WriteError("Can't copy file to %s", temp2);
Doit = FALSE;

View File

@ -483,7 +483,7 @@ void Index(void)
Syslog('!', "Create dir: %s", area.Path);
newdir = xstrcpy(area.Path);
newdir = xstrcat(newdir, (char *)"/");
mkdirs(newdir);
mkdirs(newdir, 0755);
free(newdir);
newdir = NULL;
}

View File

@ -108,7 +108,7 @@ void Kill(void)
Syslog('!', "Create dir: %s", area.Path);
newdir = xstrcpy(area.Path);
newdir = xstrcat(newdir, (char *)"/");
mkdirs(newdir);
mkdirs(newdir, 0755);
free(newdir);
newdir = NULL;
}

View File

@ -309,7 +309,7 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath)
FILE *fp1, *fp2;
int i, Insert, Done = FALSE, Found = FALSE;
mkdirs(DestPath);
mkdirs(DestPath, 0755);
if (file_cp(FromPath, DestPath)) {
WriteError("Can't move file in place");
return FALSE;
@ -445,7 +445,7 @@ int CheckFDB(int Area, char *Path)
*/
if (access(Path, W_OK) == -1) {
sprintf(temp, "%s/foobar", Path);
if (mkdirs(temp))
if (mkdirs(temp, 0755))
Syslog('+', "Created directory %s", Path);
}

View File

@ -50,7 +50,7 @@ void mover(char *fn)
sprintf(To, "%s/%s", CFG.badtic, fn);
Syslog('!', "Moving %s to %s", From, To);
if (mkdirs(To)) {
if (mkdirs(To, 0770)) {
if (file_mv(From, To) != 0)
WriteError("$Failed to move %s to %s", From, To);
}

View File

@ -106,7 +106,7 @@ void ReadExitinfo()
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, sUnixName);
mkdirs(temp);
mkdirs(temp, 0770);
if ((pExitinfo = fopen(temp,"r+b")) == NULL)
InitExitinfo();
else {

View File

@ -575,7 +575,7 @@ char *edit_pth(int y, int x, int l, char *line, char *help)
temp = xstrcat(temp, (char *)"/foobar");
if (access(s, R_OK)) {
if (yes_no((char *)"Path doesn't exist, create"))
if (! mkdirs(temp))
if (! mkdirs(temp, 0775))
errmsg((char *)"Can't create path");
}
}
@ -602,7 +602,7 @@ char *edit_jam(int y, int x, int l, char *line, char *help)
temp = xstrcpy(s);
temp = xstrcat(temp, (char *)".jhr");
if (access(temp, W_OK)) {
if (mkdirs(s)) {
if (mkdirs(s, 0770)) {
if (yes_no((char *)"Messagebase doesn't exist, create")) {
if (Msg_Open(s))
Msg_Close();

View File

@ -81,7 +81,7 @@ int CountFilearea(void)
fclose(fil);
chmod(ffile, 0640);
sprintf(ffile, "%s/foobar", area.Path);
mkdirs(ffile);
mkdirs(ffile, 0755);
return 1;
} else
return -1;

View File

@ -93,7 +93,7 @@ int CountMsgarea(void)
msgs.Ftncode = CHRS_DEFAULT_FTN;
strcpy(msgs.Origin, CFG.origin);
fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base);
mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base))
Msg_Close();
memset(&syscon, 0, sizeof(syscon));
@ -118,7 +118,7 @@ int CountMsgarea(void)
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base);
mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base))
Msg_Close();
for (i = 1; i <= CFG.toss_systems; i++)
@ -142,7 +142,7 @@ int CountMsgarea(void)
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base);
mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base))
for (i = 1; i <= CFG.toss_systems; i++)
fwrite(&syscon, sizeof(syscon), 1, fil);

View File

@ -71,7 +71,7 @@ static int scan_dir(int (*fn)(faddr *, char, int, char *), char *dname, int ispo
* Create a fake filename, mkdirs() likes that.
*/
sprintf(fname, "%s/foo", dname);
(void)mkdirs(fname);
(void)mkdirs(fname, 0770);
if ((dp = opendir(dname)) == NULL) {
tasklog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname));
return 0;

View File

@ -260,7 +260,7 @@ int file_exist(char *path, int mode)
/*
* 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;
@ -274,7 +274,7 @@ int mkdirs(char *name)
oldmask = umask(000);
while ((q = strchr(p, '/'))) {
*q = '\0';
rc = mkdir(buf, 0775);
rc = mkdir(buf, mode);
last = errno;
*q = '/';
p = q+1;

View File

@ -30,7 +30,7 @@ void TouchSema(char *);
void RemoveSema(char *);
int IsSema(char *);
int file_exist(char *, int);
int mkdirs(char *);
int mkdirs(char *, mode_t);
long file_size(char *);
time_t file_time(char *);
char *ascfnode(fidoaddr, int);