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. old style tic files, they were not full 3d.
Fixes for Sparc systems. Fixes for Sparc systems.
The nodelist information now also holds the Txx flags. The nodelist information now also holds the Txx flags.
The mkdirs function now needs a mode parameter for directory
creation.
lang: lang:
Changed language prompts 6, 71, 429. Changed language prompts 6, 71, 429.

View File

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

View File

@ -1,11 +1,10 @@
/***************************************************************************** /*****************************************************************************
* *
* File ..................: mbcico/openfile.c * $Id$
* Purpose ...............: Fidonet mailer * Purpose ...............: Fidonet mailer
* Last modification date : 12-May-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2002
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -170,7 +169,7 @@ FILE *openfile(char *fname, time_t remtime, off_t remsize, off_t *resofs, int(*r
* and try again. * and try again.
*/ */
if ((infp = fopen(infpath,opentype)) == NULL) { if ((infp = fopen(infpath,opentype)) == NULL) {
mkdirs(infpath); mkdirs(infpath, 0770);
if ((infp = fopen(infpath, opentype)) == NULL) { if ((infp = fopen(infpath, opentype)) == NULL) {
WriteError("$Cannot open local file \"%s\" for \"%s\"", infpath,opentype); WriteError("$Cannot open local file \"%s\" for \"%s\"", infpath,opentype);
free(infpath); 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. * Create a fake filename, mkdirs() likes that.
*/ */
sprintf(fname, "%s/foo", dname); sprintf(fname, "%s/foo", dname);
(void)mkdirs(fname); (void)mkdirs(fname, 0770);
if ((dp = opendir(dname)) == NULL) { if ((dp = opendir(dname)) == NULL) {
Syslog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname)); Syslog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname));
return 0; return 0;

View File

@ -85,7 +85,7 @@ int Add_BBS()
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName); sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName); sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
mkdirs(temp2); mkdirs(temp2, 0755);
if (file_cp(temp1, temp2) != 0) { if (file_cp(temp1, temp2) != 0) {
WriteError("$Copy to %s failed", temp2); 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 we need a .TIC file, start creating it.
*/ */
if (nodes.Tic) { if (nodes.Tic) {
mkdirs(ticfile); mkdirs(ticfile, 0770);
if ((fp = fopen(ticfile, "a+")) != NULL) { if ((fp = fopen(ticfile, "a+")) != NULL) {
fprintf(fp, "Area %s\r\n", TIC.TicIn.Area); fprintf(fp, "Area %s\r\n", TIC.TicIn.Area);
fprintf(fp, "Origin %s\r\n", TIC.TicIn.Origin); 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; later = time(NULL) + 86400;
sprintf(linebuf, "%s/stat/%s.temp", CFG.www_root, Name); sprintf(linebuf, "%s/stat/%s.temp", CFG.www_root, Name);
mkdirs(linebuf); mkdirs(linebuf, 0755);
if ((fa = fopen(linebuf, "w")) == NULL) { if ((fa = fopen(linebuf, "w")) == NULL) {
WriteError("$Can't create %s", linebuf); 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) { if ((unarc = unpacker(File)) == NULL) {
Syslog('+', "No known archive: %s", File); Syslog('+', "No known archive: %s", File);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File); sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File);
mkdirs(temp2); mkdirs(temp2, 0755);
if (file_cp(temp, temp2)) { if (file_cp(temp, temp2)) {
WriteError("Can't copy file to %s", temp2); WriteError("Can't copy file to %s", temp2);
if (!do_quiet) if (!do_quiet)

View File

@ -114,7 +114,7 @@ void Check(void)
if (access(area.Path, R_OK) == -1) { if (access(area.Path, R_OK) == -1) {
Syslog('!', "No dir: %s", area.Path); Syslog('!', "No dir: %s", area.Path);
sprintf(newdir, "%s/foobar", area.Path); sprintf(newdir, "%s/foobar", area.Path);
mkdirs(newdir); mkdirs(newdir, 0755);
} }
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i); 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) { if ((unarc = unpacker(temp)) == NULL) {
Syslog('+', "Unknown archive format %s", temp); Syslog('+', "Unknown archive format %s", temp);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName); sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName);
mkdirs(temp2); mkdirs(temp2, 0755);
if (file_cp(temp, temp2)) { if (file_cp(temp, temp2)) {
WriteError("Can't copy file to %s", temp2); WriteError("Can't copy file to %s", temp2);
Doit = FALSE; Doit = FALSE;
@ -292,7 +292,7 @@ void ImportFiles(int Area)
if ((unarc = unpacker(temp)) == NULL) { if ((unarc = unpacker(temp)) == NULL) {
Syslog('+', "Unknown archive format %s", temp); Syslog('+', "Unknown archive format %s", temp);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName); sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName);
mkdirs(temp2); mkdirs(temp2, 0755);
if (file_cp(temp, temp2)) { if (file_cp(temp, temp2)) {
WriteError("Can't copy file to %s", temp2); WriteError("Can't copy file to %s", temp2);
Doit = FALSE; Doit = FALSE;

View File

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

View File

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

View File

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

View File

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

View File

@ -106,7 +106,7 @@ void ReadExitinfo()
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, sUnixName); sprintf(temp, "%s/%s/exitinfo", CFG.bbs_usersdir, sUnixName);
mkdirs(temp); mkdirs(temp, 0770);
if ((pExitinfo = fopen(temp,"r+b")) == NULL) if ((pExitinfo = fopen(temp,"r+b")) == NULL)
InitExitinfo(); InitExitinfo();
else { 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"); temp = xstrcat(temp, (char *)"/foobar");
if (access(s, R_OK)) { if (access(s, R_OK)) {
if (yes_no((char *)"Path doesn't exist, create")) if (yes_no((char *)"Path doesn't exist, create"))
if (! mkdirs(temp)) if (! mkdirs(temp, 0775))
errmsg((char *)"Can't create path"); 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 = xstrcpy(s);
temp = xstrcat(temp, (char *)".jhr"); temp = xstrcat(temp, (char *)".jhr");
if (access(temp, W_OK)) { if (access(temp, W_OK)) {
if (mkdirs(s)) { if (mkdirs(s, 0770)) {
if (yes_no((char *)"Messagebase doesn't exist, create")) { if (yes_no((char *)"Messagebase doesn't exist, create")) {
if (Msg_Open(s)) if (Msg_Open(s))
Msg_Close(); Msg_Close();

View File

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

View File

@ -93,7 +93,7 @@ int CountMsgarea(void)
msgs.Ftncode = CHRS_DEFAULT_FTN; msgs.Ftncode = CHRS_DEFAULT_FTN;
strcpy(msgs.Origin, CFG.origin); strcpy(msgs.Origin, CFG.origin);
fwrite(&msgs, sizeof(msgs), 1, fil); fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base); mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base)) if (Msg_Open(msgs.Base))
Msg_Close(); Msg_Close();
memset(&syscon, 0, sizeof(syscon)); memset(&syscon, 0, sizeof(syscon));
@ -118,7 +118,7 @@ int CountMsgarea(void)
msgs.Rfccode = CHRS_DEFAULT_RFC; msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN; msgs.Ftncode = CHRS_DEFAULT_FTN;
fwrite(&msgs, sizeof(msgs), 1, fil); fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base); mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base)) if (Msg_Open(msgs.Base))
Msg_Close(); Msg_Close();
for (i = 1; i <= CFG.toss_systems; i++) for (i = 1; i <= CFG.toss_systems; i++)
@ -142,7 +142,7 @@ int CountMsgarea(void)
msgs.Rfccode = CHRS_DEFAULT_RFC; msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN; msgs.Ftncode = CHRS_DEFAULT_FTN;
fwrite(&msgs, sizeof(msgs), 1, fil); fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base); mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base)) if (Msg_Open(msgs.Base))
for (i = 1; i <= CFG.toss_systems; i++) for (i = 1; i <= CFG.toss_systems; i++)
fwrite(&syscon, sizeof(syscon), 1, fil); 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. * Create a fake filename, mkdirs() likes that.
*/ */
sprintf(fname, "%s/foo", dname); sprintf(fname, "%s/foo", dname);
(void)mkdirs(fname); (void)mkdirs(fname, 0770);
if ((dp = opendir(dname)) == NULL) { if ((dp = opendir(dname)) == NULL) {
tasklog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname)); tasklog('o' ,"\"%s\" cannot be opened, proceed",MBSE_SS(dname));
return 0; return 0;

View File

@ -260,7 +260,7 @@ int file_exist(char *path, int mode)
/* /*
* 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;
@ -274,7 +274,7 @@ 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);
last = errno; last = errno;
*q = '/'; *q = '/';
p = q+1; p = q+1;

View File

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