diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 13 | ||||
-rw-r--r-- | source3/include/smb.h | 1 | ||||
-rw-r--r-- | source3/include/smb_macros.h | 4 | ||||
-rw-r--r-- | source3/lib/substitute.c | 1 | ||||
-rw-r--r-- | source3/printing/printfsp.c | 1 | ||||
-rw-r--r-- | source3/smbd/close.c | 2 | ||||
-rw-r--r-- | source3/smbd/files.c | 33 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 2 | ||||
-rw-r--r-- | source3/smbd/open.c | 16 | ||||
-rw-r--r-- | source3/smbd/oplock.c | 4 | ||||
-rw-r--r-- | source3/smbd/reply.c | 2 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 4 |
12 files changed, 47 insertions, 36 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index dfa76b3995..4564ac832c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -201,9 +201,9 @@ int smbrun(char *cmd,char *outfile,BOOL shared); /*The following definitions come from lib/substitute.c */ +void standard_sub_basic(char *str); void standard_sub_conn(connection_struct *conn, char *str); void standard_sub_snum(int snum, char *str); -void standard_sub_basic(char *str); void standard_sub_vuser(char *str, user_struct *vuser); void standard_sub_vsnum(char *str, user_struct *vuser, int snum); @@ -355,6 +355,7 @@ void *memdup(void *p, size_t size); char *myhostname(void); char *lock_path(char *name); char *parent_dirname(const char *path); +int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6); /*The following definitions come from lib/util_array.c */ @@ -1173,7 +1174,7 @@ void wins_write_database(BOOL background); /*The following definitions come from nmbd/nmbd_workgroupdb.c */ struct work_record *find_workgroup_on_subnet(struct subnet_record *subrec, - fstring name); + const char *name); struct work_record *create_workgroup_on_subnet(struct subnet_record *subrec, fstring name, int ttl); void update_workgroup_ttl(struct work_record *work, int ttl); @@ -1579,6 +1580,11 @@ int cups_printername_ok(char *name); void sysv_printer_fn(void (*fn)(char *, char *)); int sysv_printername_ok(char *name); +/*The following definitions come from printing/printfsp.c */ + +files_struct *print_fsp_open(connection_struct *conn,char *jobname); +void print_fsp_end(files_struct *fsp); + /*The following definitions come from printing/printing.c */ BOOL print_backend_init(void); @@ -1601,8 +1607,6 @@ int print_queue_snum(char *qname); BOOL print_queue_pause(int snum); BOOL print_queue_resume(int snum); BOOL print_queue_purge(int snum); -files_struct *print_fsp_open(connection_struct *conn,char *jobname); -void print_fsp_end(files_struct *fsp); /*The following definitions come from profile/profile.c */ @@ -3019,6 +3023,7 @@ void file_close_conn(connection_struct *conn); void file_init(void); void file_close_user(int vuid); files_struct *file_find_dit(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval); +files_struct *file_find_fsp(files_struct *orig_fsp); files_struct *file_find_di_first(SMB_DEV_T dev, SMB_INO_T inode); files_struct *file_find_di_next(files_struct *start_fsp); files_struct *file_find_print(void); diff --git a/source3/include/smb.h b/source3/include/smb.h index 854200e4cb..7fef3f40b7 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -490,7 +490,6 @@ typedef struct files_struct int oplock_type; int sent_oplock_break; unsigned int num_posix_locks; - BOOL open; BOOL can_lock; BOOL can_read; BOOL can_write; diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index cc9f158af8..e7d05189cd 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -73,7 +73,7 @@ #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) /* these are useful macros for checking validity of handles */ -#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory) +#define OPEN_FSP(fsp) ((fsp) && !(fsp)->is_directory) #define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) @@ -150,7 +150,7 @@ #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ w->wr_discard = True, -1) /* Macro to test if an error has been cached for this fnum */ -#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \ +#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \ (fsp)->wbmpx_ptr->wr_discard) /* Macro to turn the cached error into an error packet */ #define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__) diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index 6f6d2a9c16..c43c133d6a 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -200,7 +200,6 @@ void standard_sub_basic(char *str) static void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str) { char *p, *s, *home; - fstring pidstr; struct passwd *pass; for (s=str; (p=strchr(s, '%'));s=p) { diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c index 72cd006e20..41635561a6 100644 --- a/source3/printing/printfsp.c +++ b/source3/printing/printfsp.c @@ -56,7 +56,6 @@ files_struct *print_fsp_open(connection_struct *conn,char *jobname) fsp->vuid = current_user.vuid; fsp->size = 0; fsp->pos = -1; - fsp->open = True; fsp->can_lock = True; fsp->can_read = False; fsp->can_write = True; diff --git a/source3/smbd/close.c b/source3/smbd/close.c index ec28ff3540..03f6aaf81a 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -72,8 +72,8 @@ void close_filestruct(files_struct *fsp) flush_write_cache(fsp, CLOSE_FLUSH); - fsp->open = False; fsp->is_directory = False; + fsp->stat_open = False; conn->num_files_open--; if(fsp->wbmpx_ptr) { diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 6c0465097b..e644f52669 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -120,7 +120,7 @@ void file_close_conn(connection_struct *conn) for (fsp=Files;fsp;fsp=next) { next = fsp->next; - if (fsp->conn == conn && fsp->open) { + if (fsp->conn == conn) { close_file(fsp,False); } } @@ -173,7 +173,7 @@ void file_close_user(int vuid) for (fsp=Files;fsp;fsp=next) { next=fsp->next; - if ((fsp->vuid == vuid) && fsp->open) { + if (fsp->vuid == vuid) { close_file(fsp,False); } } @@ -191,8 +191,7 @@ files_struct *file_find_dit(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval files_struct *fsp; for (fsp=Files;fsp;fsp=fsp->next,count++) { - if (fsp->open && - fsp->fd != -1 && + if (fsp->fd != -1 && fsp->dev == dev && fsp->inode == inode && (tval ? (fsp->open_time.tv_sec == tval->tv_sec) : True ) && @@ -208,6 +207,22 @@ files_struct *file_find_dit(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval } /**************************************************************************** + Check if an fsp still exists. +****************************************************************************/ + +files_struct *file_find_fsp(files_struct *orig_fsp) +{ + files_struct *fsp; + + for (fsp=Files;fsp;fsp=fsp->next) { + if (fsp == orig_fsp) + return fsp; + } + + return NULL; +} + +/**************************************************************************** Find the first fsp given a device and inode. ****************************************************************************/ @@ -216,8 +231,7 @@ files_struct *file_find_di_first(SMB_DEV_T dev, SMB_INO_T inode) files_struct *fsp; for (fsp=Files;fsp;fsp=fsp->next) { - if (fsp->open && - fsp->fd != -1 && + if ( fsp->fd != -1 && fsp->dev == dev && fsp->inode == inode ) return fsp; @@ -235,8 +249,7 @@ files_struct *file_find_di_next(files_struct *start_fsp) files_struct *fsp; for (fsp = start_fsp->next;fsp;fsp=fsp->next) { - if (fsp->open && - fsp->fd != -1 && + if ( fsp->fd != -1 && fsp->dev == start_fsp->dev && fsp->inode == start_fsp->inode ) return fsp; @@ -253,7 +266,7 @@ files_struct *file_find_print(void) files_struct *fsp; for (fsp=Files;fsp;fsp=fsp->next) { - if (fsp->open && fsp->print_file) return fsp; + if (fsp->print_file) return fsp; } return NULL; @@ -269,7 +282,7 @@ void file_sync_all(connection_struct *conn) for (fsp=Files;fsp;fsp=next) { next=fsp->next; - if (fsp->open && (conn == fsp->conn) && (fsp->fd != -1)) { + if ((conn == fsp->conn) && (fsp->fd != -1)) { conn->vfs_ops.fsync(fsp->fd); } } diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index ca9522ecfc..b4ae0f61a9 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -1708,7 +1708,7 @@ static int call_nt_transact_notify_change(connection_struct *conn, if(!fsp) return(ERROR(ERRDOS,ERRbadfid)); - if((!fsp->open) || (!fsp->is_directory) || (conn != fsp->conn)) + if((!fsp->is_directory) || (conn != fsp->conn)) return(ERROR(ERRDOS,ERRbadfid)); /* diff --git a/source3/smbd/open.c b/source3/smbd/open.c index d2368aa44d..353e20df8a 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -90,8 +90,7 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn, int accmode = (flags & O_ACCMODE); SMB_STRUCT_STAT sbuf; - fsp->open = False; - fsp->fd = 0; + fsp->fd = -1; fsp->oplock_type = NO_OPLOCK; errno = EPERM; @@ -155,7 +154,6 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn, fsp->vuid = current_user.vuid; fsp->size = 0; fsp->pos = -1; - fsp->open = True; fsp->can_lock = True; fsp->can_read = ((flags & O_WRONLY)==0); fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0); @@ -508,6 +506,7 @@ files_struct *open_file_shared(connection_struct *conn,char *fname,int share_mod SMB_INO_T inode = 0; int num_share_modes = 0; BOOL all_current_opens_are_level_II = False; + BOOL fsp_open = False; files_struct *fsp = NULL; int open_mode=0; uint16 port = 0; @@ -524,7 +523,6 @@ files_struct *open_file_shared(connection_struct *conn,char *fname,int share_mod if(!fsp) return NULL; - fsp->open = False; fsp->fd = -1; DEBUG(10,("open_file_shared: fname = %s, share_mode = %x, ofun = %x, mode = %o, oplock request = %d\n", @@ -638,14 +636,14 @@ files_struct *open_file_shared(connection_struct *conn,char *fname,int share_mod DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o\n", flags,flags2,(int)mode)); - fsp->open = open_file(fsp,conn,fname,flags|(flags2&~(O_TRUNC)),mode); + fsp_open = open_file(fsp,conn,fname,flags|(flags2&~(O_TRUNC)),mode); - if (!fsp->open && (flags == O_RDWR) && (errno != ENOENT) && fcbopen) { - if((fsp->open = open_file(fsp,conn,fname,O_RDONLY,mode)) == True) + if (!fsp_open && (flags == O_RDWR) && (errno != ENOENT) && fcbopen) { + if((fsp_open = open_file(fsp,conn,fname,O_RDONLY,mode)) == True) flags = O_RDONLY; } - if (!fsp->open) { + if (!fsp_open) { if(file_existed) unlock_share_entry(conn, dev, inode); file_free(fsp); @@ -790,7 +788,6 @@ files_struct *open_file_stat(connection_struct *conn, fsp->vuid = current_user.vuid; fsp->size = 0; fsp->pos = -1; - fsp->open = True; fsp->can_lock = False; fsp->can_read = False; fsp->can_write = False; @@ -915,7 +912,6 @@ files_struct *open_directory(connection_struct *conn, fsp->vuid = current_user.vuid; fsp->size = 0; fsp->pos = -1; - fsp->open = True; fsp->can_lock = True; fsp->can_read = False; fsp->can_write = False; diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index e794d2d923..28ab29d027 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -1304,10 +1304,10 @@ BOOL attempt_close_oplocked_file(files_struct *fsp) DEBUG(5,("attempt_close_oplocked_file: checking file %s.\n", fsp->fsp_name)); - if (fsp->open && EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !fsp->sent_oplock_break && (fsp->fd != -1)) { + if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !fsp->sent_oplock_break && (fsp->fd != -1)) { /* Try and break the oplock. */ if (oplock_break(fsp->dev, fsp->inode, &fsp->open_time, True)) { - if(!fsp->open) /* Did the oplock break close the file ? */ + if(file_find_fsp(fsp) == NULL) /* Did the oplock break close the file ? */ return True; } } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index baff8f2ac8..a020f5eb3b 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2751,7 +2751,7 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size, * We can only use CHECK_FSP if we know it's not a directory. */ - if(!fsp || !fsp->open || (fsp->conn != conn)) + if(!fsp || (fsp->conn != conn)) return(ERROR(ERRDOS,ERRbadfid)); if(HAS_CACHED_ERROR(fsp)) { diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 7a5276aa42..a30038a431 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1296,7 +1296,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QFILEINFO: level = %d\n", info_level)); - if(fsp && fsp->open && (fsp->is_directory || fsp->stat_open)) { + if(fsp && (fsp->is_directory || fsp->stat_open)) { /* * This is actually a QFILEINFO on a directory * handle (returned from an NT SMB). NT5.0 seems @@ -1579,7 +1579,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn, fsp = file_fsp(params,0); info_level = SVAL(params,2); - if(fsp && fsp->open && (fsp->is_directory || fsp->stat_open)) { + if(fsp && (fsp->is_directory || fsp->stat_open)) { /* * This is actually a SETFILEINFO on a directory * handle (returned from an NT SMB). NT5.0 seems |