[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Mon Sep 27 23:36:20 MDT 2010
The branch, master has been updated
via 94dc2c1 s3: Lift smbd_messaging_context() from open_sockets_smbd()
via 790ad3d s3: Remove two calls to procid_self()
via 886b5b6 s3: Remove talloc_autofree_context() from myhostname()
via 49b4d2e s3: Remove some remaining files.c globals to sconn
via d26d79b s3: Remove talloc_autofree_context() from files.c
via eadc4b5 s3: Lift smbd_server_conn from file_find_fd
via 54f7b70 s3: Remove smbd_server_conn from file_fsp
via 3009178 s3: Slightly simplify file_fnum
via e578114 s3: Remove smbd_server_conn from file_sync_all
via e2222fc s3: Remove smbd_server_conn from file_find_subpath
via 75c6e0e s3: Lift smbd_server_conn from file_find_di_first
via b448e42 s3: Lift smbd_server_conn from file_find_dif
via fb86869 s3: Remove smbd_server_conn from files_forall
via 9fc9ff9 s3: Remove smbd_server_conn from file_close_user
via 25ca1cd s3: Remove smbd_server_conn from file_close_pid
via 6a1c4ba s3: Remove smbd_server_conn from file_close_conn
via c5d2799 s3: Remove smbd_server_conn from file_new and file_free
via 5276608 s3: Lift smbd_server_conn from file_fnum
via 5e26e4d s3: Move "Files" to smbd_server_connection
via f83e7d8 s3: Remove "server_fd" global variable
via 93adf70 s3: Remove talloc_autofree_context() from receive_unexpected()
from 491102c s4:gensec_tstream: remove plain socket handling
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 94dc2c106ba6d33f3b66e0427b5d9ad04aeacc4f
Author: Volker Lendecke <vl at samba.org>
Date: Tue Aug 31 23:17:11 2010 +0200
s3: Lift smbd_messaging_context() from open_sockets_smbd()
commit 790ad3d1a4d494f8e98883aa4e1c16777170e874
Author: Volker Lendecke <vl at samba.org>
Date: Tue Aug 31 23:16:50 2010 +0200
s3: Remove two calls to procid_self()
commit 886b5b67ee65a867bf8e4c345bc600dd7527de2a
Author: Volker Lendecke <vl at samba.org>
Date: Sun Sep 26 22:05:43 2010 -0700
s3: Remove talloc_autofree_context() from myhostname()
No destructor needed, so we can as well use the NULL context
commit 49b4d2e652c189fff2fa4b3a94aed2ba0477cc76
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 06:06:02 2010 +0200
s3: Remove some remaining files.c globals to sconn
commit d26d79b6401783449ca7d38005a59938325d1995
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 05:50:22 2010 +0200
s3: Remove talloc_autofree_context() from files.c
commit eadc4b5b780ffdb99b7d4b48592af6c72f682bf8
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 04:54:29 2010 +0200
s3: Lift smbd_server_conn from file_find_fd
commit 54f7b702125d08f7754881ffbb4ad624c2a1634b
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 04:49:00 2010 +0200
s3: Remove smbd_server_conn from file_fsp
commit 3009178ee5fc054c284568768d5acdf0208a25f4
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 04:46:18 2010 +0200
s3: Slightly simplify file_fnum
req==NULL should never happen, see the comment
commit e57811440ad7b407cdd51dfcf3476072d461bcb7
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 04:13:22 2010 +0200
s3: Remove smbd_server_conn from file_sync_all
commit e2222fc19c6595deed22d8f55daf62692fd786e0
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 04:12:15 2010 +0200
s3: Remove smbd_server_conn from file_find_subpath
commit 75c6e0e5c7c17ab3ea78e09c226e2fb3472d1e40
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 04:05:25 2010 +0200
s3: Lift smbd_server_conn from file_find_di_first
commit b448e42de4070410eddbe2fa0085b9328a301159
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 04:00:31 2010 +0200
s3: Lift smbd_server_conn from file_find_dif
commit fb8686962a542c70a2104247a77b48cacd8a9663
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 03:53:00 2010 +0200
s3: Remove smbd_server_conn from files_forall
commit 9fc9ff9bfac604007440776d06b71eba5b5005e5
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 03:46:12 2010 +0200
s3: Remove smbd_server_conn from file_close_user
commit 25ca1cd1a85ca5bd99acfd2f54067c397d8fcb13
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 03:42:36 2010 +0200
s3: Remove smbd_server_conn from file_close_pid
commit 6a1c4bad131ceec025e7c8d40fdda3f01ce734c1
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 03:40:11 2010 +0200
s3: Remove smbd_server_conn from file_close_conn
commit c5d27995434910075185e6b290ca933a7ea8afa6
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 03:38:14 2010 +0200
s3: Remove smbd_server_conn from file_new and file_free
commit 52766081519ecca9ffd90b11719201537ff0c1ed
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 02:37:59 2010 +0200
s3: Lift smbd_server_conn from file_fnum
commit 5e26e4d30feca67ae8377006c3b1acc4d6c6aa5f
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 02:29:36 2010 +0200
s3: Move "Files" to smbd_server_connection
commit f83e7d8f8c91a1670dfd9f8322c3cf83c95c2b18
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 02:15:18 2010 +0200
s3: Remove "server_fd" global variable
commit 93adf70d1a2a3371562606dbda36016e9a15eeaf
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 27 01:44:06 2010 +0200
s3: Remove talloc_autofree_context() from receive_unexpected()
This is freed in this routine a few lines down
-----------------------------------------------------------------------
Summary of changes:
source3/include/proto.h | 16 +++--
source3/lib/util.c | 4 +-
source3/libsmb/unexpected.c | 4 +-
source3/modules/vfs_acl_common.c | 3 +-
source3/modules/vfs_aio_fork.c | 8 ++-
source3/modules/vfs_hpuxacl.c | 6 +-
source3/smbd/close.c | 2 +-
source3/smbd/files.c | 142 ++++++++++++++++++++++---------------
source3/smbd/globals.c | 16 ----
source3/smbd/globals.h | 17 +++--
source3/smbd/open.c | 7 +-
source3/smbd/oplock.c | 2 +-
source3/smbd/oplock_linux.c | 2 +-
source3/smbd/process.c | 17 ++---
source3/smbd/reply.c | 9 ++-
source3/smbd/server.c | 37 +++++-----
source3/smbd/server_exit.c | 9 +--
source3/smbd/trans2.c | 4 +-
18 files changed, 162 insertions(+), 143 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c55bf83..5cdb956 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4751,16 +4751,20 @@ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
files_struct **result);
void file_close_conn(connection_struct *conn);
-void file_close_pid(uint16 smbpid, int vuid);
-void file_init(void);
-void file_close_user(int vuid);
+void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid,
+ int vuid);
+bool file_init(struct smbd_server_connection *sconn);
+void file_close_user(struct smbd_server_connection *sconn, int vuid);
struct files_struct *files_forall(
+ struct smbd_server_connection *sconn,
struct files_struct *(*fn)(struct files_struct *fsp,
void *private_data),
void *private_data);
-files_struct *file_find_fd(int fd);
-files_struct *file_find_dif(struct file_id id, unsigned long gen_id);
-files_struct *file_find_di_first(struct file_id id);
+files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd);
+files_struct *file_find_dif(struct smbd_server_connection *sconn,
+ struct file_id id, unsigned long gen_id);
+files_struct *file_find_di_first(struct smbd_server_connection *sconn,
+ struct file_id id);
files_struct *file_find_di_next(files_struct *start_fsp);
bool file_find_subpath(files_struct *dir_fsp);
void file_sync_all(connection_struct *conn);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 90fcb37..36d9661 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2050,9 +2050,7 @@ char *myhostname(void)
{
static char *ret;
if (ret == NULL) {
- /* This is cached forever so
- * use talloc_autofree_context() ctx. */
- ret = get_myname(talloc_autofree_context());
+ ret = get_myname(NULL);
}
return ret;
}
diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c
index 17ebcd2..6daf61f 100644
--- a/source3/libsmb/unexpected.c
+++ b/source3/libsmb/unexpected.c
@@ -189,8 +189,8 @@ struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
struct tdb_wrap *tdb2;
struct receive_unexpected_state state;
- tdb2 = tdb_wrap_open(talloc_autofree_context(),
- lock_path("unexpected.tdb"), 0, 0, O_RDONLY, 0);
+ tdb2 = tdb_wrap_open(talloc_tos(), lock_path("unexpected.tdb"), 0, 0,
+ O_RDONLY, 0);
if (!tdb2) return NULL;
state.matched_packet = NULL;
diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index e759dc2..dbf3a09 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -806,7 +806,8 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
/* Ensure we have this file open with DELETE access. */
id = vfs_file_id_from_sbuf(conn, &local_fname.st);
- for (fsp = file_find_di_first(id); fsp; file_find_di_next(fsp)) {
+ for (fsp = file_find_di_first(conn->sconn, id); fsp;
+ file_find_di_next(fsp)) {
if (fsp->access_mask & DELETE_ACCESS &&
fsp->delete_on_close) {
/* We did open this for delete,
diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index 02b1394..90d06b1 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -442,7 +442,8 @@ static struct files_struct *close_fsp_fd(struct files_struct *fsp,
return NULL;
}
-static NTSTATUS create_aio_child(struct aio_child_list *children,
+static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
+ struct aio_child_list *children,
size_t map_size,
struct aio_child **presult)
{
@@ -480,7 +481,7 @@ static NTSTATUS create_aio_child(struct aio_child_list *children,
if (result->pid == 0) {
close(fdpair[0]);
result->sockfd = fdpair[1];
- files_forall(close_fsp_fd, NULL);
+ files_forall(sconn, close_fsp_fd, NULL);
aio_child_loop(result->sockfd, result->map);
}
@@ -538,7 +539,8 @@ static NTSTATUS get_idle_child(struct vfs_handle_struct *handle,
if (child == NULL) {
DEBUG(10, ("no idle child found, creating new one\n"));
- status = create_aio_child(children, 128*1024, &child);
+ status = create_aio_child(handle->conn->sconn, children,
+ 128*1024, &child);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("create_aio_child failed: %s\n",
nt_errstr(status)));
diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c
index 5a54f79..62a35b1 100644
--- a/source3/modules/vfs_hpuxacl.c
+++ b/source3/modules/vfs_hpuxacl.c
@@ -189,7 +189,8 @@ SMB_ACL_T hpuxacl_sys_acl_get_fd(vfs_handle_struct *handle,
*/
/* For all I see, the info should already be in the fsp
* parameter, but get it again to be safe --- necessary? */
- files_struct *file_struct_p = file_find_fd(fsp->fh->fd);
+ files_struct *file_struct_p = file_find_fd(fsp->conn->sconn,
+ fsp->fh->fd);
if (file_struct_p == NULL) {
errno = EBADF;
return NULL;
@@ -328,7 +329,8 @@ int hpuxacl_sys_acl_set_fd(vfs_handle_struct *handle,
*/
/* For all I see, the info should already be in the fsp
* parameter, but get it again to be safe --- necessary? */
- files_struct *file_struct_p = file_find_fd(fsp->fh->fd);
+ files_struct *file_struct_p = file_find_fd(fsp->conn->sconn,
+ fsp->fh->fd);
if (file_struct_p == NULL) {
errno = EBADF;
return -1;
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index fad9601..c25d7e1 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -1117,7 +1117,7 @@ void msg_close_file(struct messaging_context *msg_ctx,
TALLOC_FREE(sm_str);
}
- fsp = file_find_dif(e.id, e.share_file_id);
+ fsp = file_find_dif(smbd_server_conn, e.id, e.share_file_id);
if (!fsp) {
DEBUG(10,("msg_close_file: failed to find file.\n"));
return;
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index d1b5fb1..19a22e2 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -28,11 +28,13 @@
Return a unique number identifying this fsp over the life of this pid.
****************************************************************************/
-static unsigned long get_gen_count(void)
+static unsigned long get_gen_count(struct smbd_server_connection *sconn)
{
- if ((++file_gen_counter) == 0)
- return ++file_gen_counter;
- return file_gen_counter;
+ sconn->file_gen_counter += 1;
+ if (sconn->file_gen_counter == 0) {
+ sconn->file_gen_counter += 1;
+ }
+ return sconn->file_gen_counter;
}
/****************************************************************************
@@ -42,6 +44,7 @@ static unsigned long get_gen_count(void)
NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
files_struct **result)
{
+ struct smbd_server_connection *sconn = conn->sconn;
int i;
files_struct *fsp;
NTSTATUS status;
@@ -51,13 +54,14 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
reuse a file descriptor from an earlier smb connection. This code
increases the chance that the errant client will get an error rather
than causing corruption */
- if (first_file == 0) {
- first_file = (sys_getpid() ^ (int)time(NULL)) % real_max_open_files;
+ if (sconn->first_file == 0) {
+ sconn->first_file = (sys_getpid() ^ (int)time(NULL));
+ sconn->first_file %= sconn->real_max_open_files;
}
/* TODO: Port the id-tree implementation from Samba4 */
- i = bitmap_find(file_bmap, first_file);
+ i = bitmap_find(sconn->file_bmap, sconn->first_file);
if (i == -1) {
DEBUG(0,("ERROR! Out of file structures\n"));
/* TODO: We have to unconditionally return a DOS error here,
@@ -90,13 +94,13 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
fsp->fh->fd = -1;
fsp->conn = conn;
- fsp->fh->gen_id = get_gen_count();
+ fsp->fh->gen_id = get_gen_count(sconn);
GetTimeOfDay(&fsp->open_time);
- first_file = (i+1) % real_max_open_files;
+ sconn->first_file = (i+1) % (sconn->real_max_open_files);
- bitmap_set(file_bmap, i);
- files_used++;
+ bitmap_set(sconn->file_bmap, i);
+ sconn->files_used += 1;
fsp->fnum = i + FILE_HANDLE_OFFSET;
SMB_ASSERT(fsp->fnum < 65536);
@@ -113,10 +117,10 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
TALLOC_FREE(fsp->fh);
}
- DLIST_ADD(Files, fsp);
+ DLIST_ADD(sconn->files, fsp);
DEBUG(5,("allocated file structure %d, fnum = %d (%d used)\n",
- i, fsp->fnum, files_used));
+ i, fsp->fnum, sconn->files_used));
if (req != NULL) {
req->chain_fsp = fsp;
@@ -127,7 +131,7 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
at the start of the list and we search from
a cache hit to the *end* of the list. */
- ZERO_STRUCT(fsp_fi_cache);
+ ZERO_STRUCT(sconn->fsp_fi_cache);
conn->num_files_open++;
@@ -143,7 +147,7 @@ void file_close_conn(connection_struct *conn)
{
files_struct *fsp, *next;
- for (fsp=Files;fsp;fsp=next) {
+ for (fsp=conn->sconn->files; fsp; fsp=next) {
next = fsp->next;
if (fsp->conn == conn) {
close_file(NULL, fsp, SHUTDOWN_CLOSE);
@@ -155,11 +159,12 @@ void file_close_conn(connection_struct *conn)
Close all open files for a pid and a vuid.
****************************************************************************/
-void file_close_pid(uint16 smbpid, int vuid)
+void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid,
+ int vuid)
{
files_struct *fsp, *next;
- for (fsp=Files;fsp;fsp=next) {
+ for (fsp=sconn->files;fsp;fsp=next) {
next = fsp->next;
if ((fsp->file_pid == smbpid) && (fsp->vuid == vuid)) {
close_file(NULL, fsp, SHUTDOWN_CLOSE);
@@ -171,7 +176,7 @@ void file_close_pid(uint16 smbpid, int vuid)
Initialise file structures.
****************************************************************************/
-void file_init(void)
+bool file_init(struct smbd_server_connection *sconn)
{
int request_max_open_files = lp_max_open_files();
int real_lim;
@@ -183,36 +188,38 @@ void file_init(void)
*/
real_lim = set_maxfiles(request_max_open_files + MAX_OPEN_FUDGEFACTOR);
- real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR;
+ sconn->real_max_open_files = real_lim - MAX_OPEN_FUDGEFACTOR;
- if (real_max_open_files + FILE_HANDLE_OFFSET + MAX_OPEN_PIPES > 65536)
- real_max_open_files = 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES;
+ if (sconn->real_max_open_files + FILE_HANDLE_OFFSET + MAX_OPEN_PIPES
+ > 65536)
+ sconn->real_max_open_files =
+ 65536 - FILE_HANDLE_OFFSET - MAX_OPEN_PIPES;
- if(real_max_open_files != request_max_open_files) {
+ if(sconn->real_max_open_files != request_max_open_files) {
DEBUG(1, ("file_init: Information only: requested %d "
"open files, %d are available.\n",
- request_max_open_files, real_max_open_files));
+ request_max_open_files, sconn->real_max_open_files));
}
- SMB_ASSERT(real_max_open_files > 100);
+ SMB_ASSERT(sconn->real_max_open_files > 100);
- file_bmap = bitmap_talloc(talloc_autofree_context(),
- real_max_open_files);
+ sconn->file_bmap = bitmap_talloc(sconn, sconn->real_max_open_files);
- if (!file_bmap) {
- exit_server("out of memory in file_init");
+ if (!sconn->file_bmap) {
+ return false;
}
+ return true;
}
/****************************************************************************
Close files open by a specified vuid.
****************************************************************************/
-void file_close_user(int vuid)
+void file_close_user(struct smbd_server_connection *sconn, int vuid)
{
files_struct *fsp, *next;
- for (fsp=Files;fsp;fsp=next) {
+ for (fsp=sconn->files; fsp; fsp=next) {
next=fsp->next;
if (fsp->vuid == vuid) {
close_file(NULL, fsp, SHUTDOWN_CLOSE);
@@ -225,13 +232,14 @@ void file_close_user(int vuid)
*/
struct files_struct *files_forall(
+ struct smbd_server_connection *sconn,
struct files_struct *(*fn)(struct files_struct *fsp,
void *private_data),
void *private_data)
{
struct files_struct *fsp, *next;
- for (fsp = Files; fsp; fsp = next) {
+ for (fsp = sconn->files; fsp; fsp = next) {
struct files_struct *ret;
next = fsp->next;
ret = fn(fsp, private_data);
@@ -246,15 +254,15 @@ struct files_struct *files_forall(
Find a fsp given a file descriptor.
****************************************************************************/
-files_struct *file_find_fd(int fd)
+files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd)
{
int count=0;
files_struct *fsp;
- for (fsp=Files;fsp;fsp=fsp->next,count++) {
+ for (fsp=sconn->files; fsp; fsp=fsp->next,count++) {
if (fsp->fh->fd == fd) {
if (count > 10) {
- DLIST_PROMOTE(Files, fsp);
+ DLIST_PROMOTE(sconn->files, fsp);
}
return fsp;
}
@@ -267,17 +275,18 @@ files_struct *file_find_fd(int fd)
Find a fsp given a device, inode and file_id.
****************************************************************************/
-files_struct *file_find_dif(struct file_id id, unsigned long gen_id)
+files_struct *file_find_dif(struct smbd_server_connection *sconn,
+ struct file_id id, unsigned long gen_id)
{
int count=0;
files_struct *fsp;
- for (fsp=Files;fsp;fsp=fsp->next,count++) {
+ for (fsp=sconn->files; fsp; fsp=fsp->next,count++) {
/* We can have a fsp->fh->fd == -1 here as it could be a stat open. */
if (file_id_equal(&fsp->file_id, &id) &&
fsp->fh->gen_id == gen_id ) {
if (count > 10) {
- DLIST_PROMOTE(Files, fsp);
+ DLIST_PROMOTE(sconn->files, fsp);
}
/* Paranoia check. */
if ((fsp->fh->fd == -1) &&
@@ -305,27 +314,28 @@ files_struct *file_find_dif(struct file_id id, unsigned long gen_id)
calls.
****************************************************************************/
-files_struct *file_find_di_first(struct file_id id)
+files_struct *file_find_di_first(struct smbd_server_connection *sconn,
+ struct file_id id)
{
files_struct *fsp;
- if (file_id_equal(&fsp_fi_cache.id, &id)) {
+ if (file_id_equal(&sconn->fsp_fi_cache.id, &id)) {
/* Positive or negative cache hit. */
- return fsp_fi_cache.fsp;
+ return sconn->fsp_fi_cache.fsp;
}
- fsp_fi_cache.id = id;
+ sconn->fsp_fi_cache.id = id;
- for (fsp=Files;fsp;fsp=fsp->next) {
+ for (fsp=sconn->files;fsp;fsp=fsp->next) {
if (file_id_equal(&fsp->file_id, &id)) {
/* Setup positive cache. */
- fsp_fi_cache.fsp = fsp;
+ sconn->fsp_fi_cache.fsp = fsp;
return fsp;
}
}
/* Setup negative cache. */
- fsp_fi_cache.fsp = NULL;
+ sconn->fsp_fi_cache.fsp = NULL;
return NULL;
}
@@ -366,7 +376,7 @@ bool file_find_subpath(files_struct *dir_fsp)
dlen = strlen(d_fullname);
- for (fsp=Files;fsp;fsp=fsp->next) {
+ for (fsp=dir_fsp->conn->sconn->files; fsp; fsp=fsp->next) {
char *d1_fullname;
if (fsp == dir_fsp) {
@@ -403,7 +413,7 @@ void file_sync_all(connection_struct *conn)
{
files_struct *fsp, *next;
- for (fsp=Files;fsp;fsp=next) {
+ for (fsp=conn->sconn->files; fsp; fsp=next) {
next=fsp->next;
if ((conn == fsp->conn) && (fsp->fh->fd != -1)) {
sync_file(conn, fsp, True /* write through */);
@@ -417,7 +427,9 @@ void file_sync_all(connection_struct *conn)
void file_free(struct smb_request *req, files_struct *fsp)
{
- DLIST_REMOVE(Files, fsp);
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+
+ DLIST_REMOVE(sconn->files, fsp);
TALLOC_FREE(fsp->fake_file_handle);
@@ -442,11 +454,11 @@ void file_free(struct smb_request *req, files_struct *fsp)
/* Ensure this event will never fire. */
TALLOC_FREE(fsp->update_write_time_event);
- bitmap_clear(file_bmap, fsp->fnum - FILE_HANDLE_OFFSET);
- files_used--;
+ bitmap_clear(sconn->file_bmap, fsp->fnum - FILE_HANDLE_OFFSET);
+ sconn->files_used--;
DEBUG(5,("freed files structure %d (%d used)\n",
- fsp->fnum, files_used));
+ fsp->fnum, sconn->files_used));
fsp->conn->num_files_open--;
@@ -463,8 +475,8 @@ void file_free(struct smb_request *req, files_struct *fsp)
}
/* Closing a file can invalidate the positive cache. */
- if (fsp == fsp_fi_cache.fsp) {
- ZERO_STRUCT(fsp_fi_cache);
+ if (fsp == sconn->fsp_fi_cache.fsp) {
+ ZERO_STRUCT(sconn->fsp_fi_cache);
}
/* Drop all remaining extensions. */
@@ -484,15 +496,16 @@ void file_free(struct smb_request *req, files_struct *fsp)
Get an fsp from a 16 bit fnum.
****************************************************************************/
-static struct files_struct *file_fnum(uint16 fnum)
+static struct files_struct *file_fnum(struct smbd_server_connection *sconn,
+ uint16 fnum)
{
files_struct *fsp;
int count=0;
- for (fsp=Files;fsp;fsp=fsp->next, count++) {
+ for (fsp=sconn->files; fsp; fsp=fsp->next, count++) {
if (fsp->fnum == fnum) {
if (count > 10) {
- DLIST_PROMOTE(Files, fsp);
+ DLIST_PROMOTE(sconn->files, fsp);
}
return fsp;
}
@@ -508,12 +521,25 @@ files_struct *file_fsp(struct smb_request *req, uint16 fid)
{
files_struct *fsp;
- if ((req != NULL) && (req->chain_fsp != NULL)) {
+ if (req == NULL) {
+ /*
+ * We should never get here. req==NULL could in theory
+ * only happen from internal opens with a non-zero
+ * root_dir_fid. Internal opens just don't do that, at
+ * least they are not supposed to do so. And if they
+ * start to do so, they better fake up a smb_request
+ * from which we get the right smbd_server_conn. While
+ * this should never happen, let's return NULL here.
+ */
--
Samba Shared Repository
More information about the samba-cvs
mailing list