summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c2
-rw-r--r--source3/smbd/files.c33
-rw-r--r--source3/smbd/nttrans.c2
-rw-r--r--source3/smbd/open.c16
-rw-r--r--source3/smbd/oplock.c4
-rw-r--r--source3/smbd/reply.c2
-rw-r--r--source3/smbd/trans2.c4
7 files changed, 36 insertions, 27 deletions
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