int dos_mkdir(char *dname,mode_t mode) { int ret = mkdir(dos_to_unix(dname,False),mode); if(!ret) return(dos_chmod(dname,mode)); else return ret; }
FILE *file_open_noarch(char *name, char *mode) { FILE *stream; #if TARGET!=UNIX if(clear_archive_bit&&(mode[0]=='w'||mode[0]=='a'||mode[1]=='+'||mode[2]=='+')) dos_chmod(name, STD_FATTR_NOARCH); #endif if((stream=file_open(name, mode))==NULL) error(M_CANTOPEN, name); return(stream); }
/******************************************************************* chmod a file - but preserve some bits ********************************************************************/ int file_chmod(connection_struct *conn,char *fname,int dosmode,SMB_STRUCT_STAT *st) { SMB_STRUCT_STAT st1; int mask=0; mode_t tmp; mode_t unixmode; if (!st) { st = &st1; if (dos_stat(fname,st)) return(-1); } if (S_ISDIR(st->st_mode)) dosmode |= aDIR; if (dos_mode(conn,fname,st) == dosmode) return(0); unixmode = unix_mode(conn,dosmode,fname); /* preserve the s bits */ mask |= (S_ISUID | S_ISGID); /* preserve the t bit */ #ifdef S_ISVTX mask |= S_ISVTX; #endif /* possibly preserve the x bits */ if (!MAP_ARCHIVE(conn)) mask |= S_IXUSR; if (!MAP_SYSTEM(conn)) mask |= S_IXGRP; if (!MAP_HIDDEN(conn)) mask |= S_IXOTH; unixmode |= (st->st_mode & mask); /* if we previously had any r bits set then leave them alone */ if ((tmp = st->st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) { unixmode &= ~(S_IRUSR|S_IRGRP|S_IROTH); unixmode |= tmp; } /* if we previously had any w bits set then leave them alone whilst adding in the new w bits, if the new mode is not rdonly */ if (!IS_DOS_READONLY(dosmode)) { unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)); } return(dos_chmod(fname,unixmode)); }
FILE *file_create(char *name, char *mode) { if(file_exists(name)) { if(!yes_on_all_queries&&!overwrite_existing) { msg_cprintf(0, M_EXISTS, name); if(!query_action(REPLY_YES, QUERY_OVERWRITE, M_QUERY_OVERWRITE)) error(M_CANTOPEN, name); } #if TARGET!=UNIX if(clear_archive_bit&&(mode[0]=='w'||mode[0]=='a'||mode[1]=='+'||mode[2]=='+')) dos_chmod(name, STD_FATTR_NOARCH); #endif } return(file_open(name, mode)); }