[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu Jun 14 21:23:06 MDT 2012


The branch, master has been updated
       via  b27f888 s3:vfs: change files_struct.fnum from int to uint64_t
       via  67108c8 s3:smbd: change trans2.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  d056fd1 s3:smbd: change smb2_write.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  bde0298 s3:smbd: change smb2_setinfo.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  1e0eb24 s3:smbd: change smb2_read.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  632560b s3:smbd: change smb2_notify.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  ec111bd s3:smbd: change smb2_lock.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  7738b57 s3:smbd: change smb2_ioctl.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  cf380e1 s3:smbd: change smb2_getinfo.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  66117c3 s3:smbd: change smb2_flush.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  d82f1fa s3:smbd: change smb2_find.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  5922580 s3:smbd: change smb2_close.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  78b9e1a s3:smbd: change smb2_break.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  65ea1e4 s3:smbd: change reply.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  3d7befa s3:smbd: change pipes.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  cd37c68 s3:smbd: change oplock.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  cdfc301 s3:smbd: change open.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  b4f6ef4 s3:smbd: change nttrans.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  93dd5a8 s3:smbd: change files.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  cb1c185 s3:smbd: change fake_file.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  ee6580c s3:smbd: change blocking.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  4d66d9f s3:smbd: change aio.c to use fsp_fnum_dbg() for logging fsp->fnum.
       via  eae8740 s3:vfs_default: use fsp_fnum_dbg() for fsp->fnum logging.
       via  959c10e s3:locking: change locking.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  7472380 s3:locking: change brlock.c to use fsp_fnum_dbg() for fsp->fnum logging.
       via  3309a52 s3:lib: add a utility function "fsp_fnum_dbg" for logging the fnum of an fsp
       via  0635af0 s3:lib: elaborate the comment for fsp_str_debug a bit.
       via  bbf519d s3:lib: remove part of a comment for fsp_str_dbg that does not apply any more.
       via  b8e943e s3:smbd: change FNUM_FIELD_INVALID from -1 to 0
       via  5d2af68 s3:smbd: use FNUM_FIELD_INVALID instead of literal -1
       via  63bfc70a s3:include: define FNUM_FIELD_INVALID - the invalid value for the fnum
       via  a7dccea s3:files: factor fsp_free() out of file_free()
       via  7aa9ad5 s3:files: reorder file_free() a bit
       via  82a96d2 s3:smbd: refactor fsp_new() out of file_new()
      from  98bd0d1 waf: Update to newer upstream snapshot.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b27f88898aa604d70d212c524549bb2cfc929170
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:34:46 2012 +0200

    s3:vfs: change files_struct.fnum from int to uint64_t
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Jun 15 05:22:41 CEST 2012 on sn-devel-104

commit 67108c8e7eb89ca69247f7865e9a9885fbd441eb
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:31:43 2012 +0200

    s3:smbd: change trans2.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit d056fd14c88bb2eeccada13265473bbf52c1682b
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:28:17 2012 +0200

    s3:smbd: change smb2_write.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit bde02985e60932cb037e0a32682c26a0edef12d6
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:26:39 2012 +0200

    s3:smbd: change smb2_setinfo.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 1e0eb242705e4396b5d8c7ff4b32b83932071ea5
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:25:29 2012 +0200

    s3:smbd: change smb2_read.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 632560b4d83fd71120752861629d8df8f8e002bc
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:23:11 2012 +0200

    s3:smbd: change smb2_notify.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit ec111bd050506e22b43bf8178919086a91846281
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:22:27 2012 +0200

    s3:smbd: change smb2_lock.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 7738b574c2f0bd15aca2133abd7aeeb73d6356c3
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:20:08 2012 +0200

    s3:smbd: change smb2_ioctl.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit cf380e168deefbed83aa1f72fabb6d23cb710981
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:18:55 2012 +0200

    s3:smbd: change smb2_getinfo.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 66117c3312432e73bb2f3d79a810aad353507632
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:16:44 2012 +0200

    s3:smbd: change smb2_flush.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit d82f1fada2ed1af00a7e42a4311b7ad4788c0356
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:13:59 2012 +0200

    s3:smbd: change smb2_find.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 59225808fa30bdebcc3491fc42ff2484727ce9ac
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:13:06 2012 +0200

    s3:smbd: change smb2_close.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 78b9e1afef96b7dc2abd1a3a535d95bf941f688d
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:11:58 2012 +0200

    s3:smbd: change smb2_break.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 65ea1e427d16eb12cdd12a693e74de69d2c7de58
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 13:10:33 2012 +0200

    s3:smbd: change reply.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 3d7befa8f0d1809273ff5089c1c0a968f7f29794
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:57:25 2012 +0200

    s3:smbd: change pipes.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit cd37c68fad18deaedebec9d200b2c75ba72788b6
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:55:59 2012 +0200

    s3:smbd: change oplock.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit cdfc301da9607ab9a0dbbd4ad89c5531ceab95fd
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:54:28 2012 +0200

    s3:smbd: change open.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit b4f6ef4e956f3d61aaa3cf83b690530e92c51d4d
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:52:52 2012 +0200

    s3:smbd: change nttrans.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 93dd5a80cd7a87d654d4b4c8295c1fd381df5c8b
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:50:14 2012 +0200

    s3:smbd: change files.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit cb1c18516ce2c7fa1b728a6a4fa37c3823e84694
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:48:59 2012 +0200

    s3:smbd: change fake_file.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit ee6580c67f87a47f614266f8cf4f904cae23056e
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:47:54 2012 +0200

    s3:smbd: change blocking.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 4d66d9f6dd197bd9e86b9be48bc3cf4ea9e3c160
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:41:09 2012 +0200

    s3:smbd: change aio.c to use fsp_fnum_dbg() for logging fsp->fnum.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit eae8740ebef61a1ecb42260fafc17f453aae2f3c
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:37:21 2012 +0200

    s3:vfs_default: use fsp_fnum_dbg() for fsp->fnum logging.
    
    Note: it is actually wrong to access the fsp->fnum at all here,
    since the fnum is part of the smb layer that should not be used
    in the vfs layer. But this is subject be separated more cleanly
    in later commits. This change only unifies the logging of fsp->fnum.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 959c10e612894ff60ba6f32ff6d1c3488c520299
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:25:43 2012 +0200

    s3:locking: change locking.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 7472380e13b4f6b512627241245747e44b105fb0
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 14 12:14:32 2012 +0200

    s3:locking: change brlock.c to use fsp_fnum_dbg() for fsp->fnum logging.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 3309a5298835bf5bb379a62ca67c0d9577dbe65b
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jun 13 17:58:54 2012 +0200

    s3:lib: add a utility function "fsp_fnum_dbg" for logging the fnum of an fsp
    
    This is to unify logging of an files_struct.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 0635af0a0808374c0e34582b153c0bbbbfac16d2
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jun 13 17:43:18 2012 +0200

    s3:lib: elaborate the comment for fsp_str_debug a bit.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit bbf519de37cb5b08c34cbb48c5a8e09b7c6e67b9
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jun 13 17:40:22 2012 +0200

    s3:lib: remove part of a comment for fsp_str_dbg that does not apply any more.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit b8e943e7245e94601b54e0659db3d74d2a944a1f
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jun 13 17:18:59 2012 +0200

    s3:smbd: change FNUM_FIELD_INVALID from -1 to 0
    
    This is in preparation for changing the type of files_struct.fnum
    to unit64_t.
    
    This can safely be done, since all checks have been converted to
    using FNUM_FIELD_INVALID and fsp->fnum is only ever set to either
    FNUM_FIELD_INVALID or some i + FILE_HANDLE_OFFSET with i >= 0 and
    FILE_HANDLE_OFFSET > 0.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 5d2af68a25534bd84601f3ac40853ef9fcb21edb
Author: Michael Adam <obnox at samba.org>
Date:   Tue Jun 12 17:56:43 2012 +0200

    s3:smbd: use FNUM_FIELD_INVALID instead of literal -1
    
    This is in preparation of changing fnum to uint64_t
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 63bfc70a2ad391c7d0f0ce8d7c637ca2b5ba5645
Author: Michael Adam <obnox at samba.org>
Date:   Tue Jun 12 14:35:39 2012 +0200

    s3:include: define FNUM_FIELD_INVALID - the invalid value for the fnum
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit a7dccea0c5be8742c9e60c5caf6e832679e19f31
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 7 16:31:14 2012 +0200

    s3:files: factor fsp_free() out of file_free()
    
    To be reused in the durable reconnect code.
    
    Pair-Programmed-With: Volker Lendecke <vl at samba.org>

commit 7aa9ad5bb9ce33c7e664582b5014917e84153314
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 7 16:27:24 2012 +0200

    s3:files: reorder file_free() a bit
    
    Pair-Programmed-With: Volker Lendecke <vl at samba.org>
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>

commit 82a96d243214a748fa38bd10894309c3f6e6a20b
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jun 7 16:13:36 2012 +0200

    s3:smbd: refactor fsp_new() out of file_new()
    
    Pair-Programmed-With: Volker Lendecke <vl at samba.org>
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h       |    1 +
 source3/include/smb.h         |    2 +
 source3/include/vfs.h         |    2 +-
 source3/lib/filename_util.c   |   32 ++++++++++-
 source3/locking/brlock.c      |    8 +-
 source3/locking/locking.c     |   16 +++---
 source3/modules/vfs_default.c |   16 +++--
 source3/smbd/aio.c            |    4 +-
 source3/smbd/blocking.c       |   29 +++++-----
 source3/smbd/fake_file.c      |    4 +-
 source3/smbd/files.c          |  124 +++++++++++++++++++++++++---------------
 source3/smbd/nttrans.c        |    8 ++-
 source3/smbd/open.c           |    8 +-
 source3/smbd/oplock.c         |   10 ++--
 source3/smbd/pipes.c          |    6 +-
 source3/smbd/posix_acls.c     |    2 +-
 source3/smbd/proto.h          |    3 +
 source3/smbd/reply.c          |  100 ++++++++++++++++----------------
 source3/smbd/smb2_break.c     |   14 ++--
 source3/smbd/smb2_close.c     |    4 +-
 source3/smbd/smb2_find.c      |    4 +-
 source3/smbd/smb2_flush.c     |    4 +-
 source3/smbd/smb2_getinfo.c   |    8 +-
 source3/smbd/smb2_ioctl.c     |    4 +-
 source3/smbd/smb2_lock.c      |   12 ++--
 source3/smbd/smb2_notify.c    |    4 +-
 source3/smbd/smb2_read.c      |   12 ++--
 source3/smbd/smb2_setinfo.c   |    7 +-
 source3/smbd/smb2_write.c     |   12 ++--
 source3/smbd/trans2.c         |   40 +++++++------
 30 files changed, 288 insertions(+), 212 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index d1d7131..463d980 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1630,6 +1630,7 @@ NTSTATUS create_synthetic_smb_fname_split(TALLOC_CTX *ctx,
 					  struct smb_filename **smb_fname_out);
 const char *smb_fname_str_dbg(const struct smb_filename *smb_fname);
 const char *fsp_str_dbg(const struct files_struct *fsp);
+const char *fsp_fnum_dbg(const struct files_struct *fsp);
 NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
 			   const struct smb_filename *smb_fname_in,
 			   struct smb_filename **smb_fname_out);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index fdaf8c5..1c05459 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -675,6 +675,8 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
 #define TID_FIELD_INVALID 0
 #define CNUM_OFFSET 1 /* shift for bitmap index */
 
+#define FNUM_FIELD_INVALID 0
+
 /* 
  * Size of buffer to use when moving files across filesystems. 
  */
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 3062aa1..723eb6c 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -185,7 +185,7 @@ struct fd_handle {
 
 typedef struct files_struct {
 	struct files_struct *next, *prev;
-	int fnum;
+	uint64_t fnum;
 	struct connection_struct *conn;
 	struct fd_handle *fh;
 	unsigned int num_smb_operations;
diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c
index 85d9fb5..9a6ab2b 100644
--- a/source3/lib/filename_util.c
+++ b/source3/lib/filename_util.c
@@ -125,14 +125,42 @@ const char *smb_fname_str_dbg(const struct smb_filename *smb_fname)
 }
 
 /**
- * Return a debug string using the talloc_tos().  This can only be called from
- * DEBUG() macros due to the debut_ctx().
+ * Return a debug string of the path name of an fsp using the talloc_tos().
  */
 const char *fsp_str_dbg(const struct files_struct *fsp)
 {
 	return smb_fname_str_dbg(fsp->fsp_name);
 }
 
+/**
+ * Create a debug string for the fnum of an fsp.
+ *
+ * This is allocated to talloc_tos() or a string constant
+ * in certain corner cases. The returned string should
+ * hence not be free'd directly but only via the talloc stack.
+ */
+const char *fsp_fnum_dbg(const struct files_struct *fsp)
+{
+	char *str;
+
+	if (fsp == NULL) {
+		return "fnum [fsp is NULL]";
+	}
+
+	if (fsp->fnum == FNUM_FIELD_INVALID) {
+		return "fnum [invalid value]";
+	}
+
+	str = talloc_asprintf(talloc_tos(), "fnum %llu",
+			      (unsigned long long)fsp->fnum);
+	if (str == NULL) {
+		DEBUG(1, ("%s: talloc_asprintf failed\n", __FUNCTION__));
+		return "fnum [talloc failed!]";
+	}
+
+	return str;
+}
+
 NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
 			   const struct smb_filename *smb_fname_in,
 			   struct smb_filename **smb_fname_out)
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index b82914a..836bbb4 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -1315,9 +1315,9 @@ bool brl_locktest(struct byte_range_lock *br_lck,
 	if(lp_posix_locking(fsp->conn->params) && (lock_flav == WINDOWS_LOCK)) {
 		ret = is_posix_locked(fsp, &start, &size, &lock_type, WINDOWS_LOCK);
 
-		DEBUG(10,("brl_locktest: posix start=%.0f len=%.0f %s for fnum %d file %s\n",
+		DEBUG(10,("brl_locktest: posix start=%.0f len=%.0f %s for %s file %s\n",
 			(double)start, (double)size, ret ? "locked" : "unlocked",
-			fsp->fnum, fsp_str_dbg(fsp)));
+			fsp_fnum_dbg(fsp), fsp_str_dbg(fsp)));
 
 		/* We need to return the inverse of is_posix_locked. */
 		ret = !ret;
@@ -1381,9 +1381,9 @@ NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
 	if(lp_posix_locking(fsp->conn->params)) {
 		bool ret = is_posix_locked(fsp, pstart, psize, plock_type, POSIX_LOCK);
 
-		DEBUG(10,("brl_lockquery: posix start=%.0f len=%.0f %s for fnum %d file %s\n",
+		DEBUG(10,("brl_lockquery: posix start=%.0f len=%.0f %s for %s file %s\n",
 			(double)*pstart, (double)*psize, ret ? "locked" : "unlocked",
-			fsp->fnum, fsp_str_dbg(fsp)));
+			fsp_fnum_dbg(fsp), fsp_str_dbg(fsp)));
 
 		if (ret) {
 			/* Hmmm. No clue what to set smblctx to - use -1. */
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 5553702..b3bd8dd 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -267,10 +267,10 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
 	/* NOTE! 0 byte long ranges ARE allowed and should be stored  */
 
 	DEBUG(10,("do_lock: lock flavour %s lock type %s start=%.0f len=%.0f "
-		"blocking_lock=%s requested for fnum %d file %s\n",
+		"blocking_lock=%s requested for %s file %s\n",
 		lock_flav_name(lock_flav), lock_type_name(lock_type),
 		(double)offset, (double)count, blocking_lock ? "true" :
-		"false", fsp->fnum, fsp_str_dbg(fsp)));
+		"false", fsp_fnum_dbg(fsp), fsp_str_dbg(fsp)));
 
 	br_lck = brl_get_locks(talloc_tos(), fsp);
 	if (!br_lck) {
@@ -318,8 +318,8 @@ NTSTATUS do_unlock(struct messaging_context *msg_ctx,
 		return NT_STATUS_OK;
 	}
 
-	DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for fnum %d file %s\n",
-		  (double)offset, (double)count, fsp->fnum,
+	DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for %s file %s\n",
+		  (double)offset, (double)count, fsp_fnum_dbg(fsp),
 		  fsp_str_dbg(fsp)));
 
 	br_lck = brl_get_locks(talloc_tos(), fsp);
@@ -369,8 +369,8 @@ NTSTATUS do_lock_cancel(files_struct *fsp,
 		return NT_STATUS_DOS(ERRDOS, ERRcancelviolation);
 	}
 
-	DEBUG(10,("do_lock_cancel: cancel start=%.0f len=%.0f requested for fnum %d file %s\n",
-		  (double)offset, (double)count, fsp->fnum,
+	DEBUG(10,("do_lock_cancel: cancel start=%.0f len=%.0f requested for %s file %s\n",
+		  (double)offset, (double)count, fsp_fnum_dbg(fsp),
 		  fsp_str_dbg(fsp)));
 
 	br_lck = brl_get_locks(talloc_tos(), fsp);
@@ -1013,8 +1013,8 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
 	struct share_mode_lock *lck;
 
 	DEBUG(10,("set_delete_on_close: %s delete on close flag for "
-		  "fnum = %d, file %s\n",
-		  delete_on_close ? "Adding" : "Removing", fsp->fnum,
+		  "%s, file %s\n",
+		  delete_on_close ? "Adding" : "Removing", fsp_fnum_dbg(fsp),
 		  fsp_str_dbg(fsp)));
 
 	lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id);
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index a39e10a..b387cce 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -819,7 +819,8 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 		 * I think I'll make this be the inode+dev. JRA.
 		 */
 
-		DEBUG(10,("FSCTL_CREATE_OR_GET_OBJECT_ID: called on FID[0x%04X]\n",fsp->fnum));
+		DEBUG(10,("FSCTL_CREATE_OR_GET_OBJECT_ID: called on %s\n",
+			  fsp_fnum_dbg(fsp)));
 
 		*out_len = (max_out_len >= 64) ? 64 : max_out_len;
 		/* Hmmm, will this cause problems if less data asked for? */
@@ -839,14 +840,16 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 	case FSCTL_GET_REPARSE_POINT:
 	{
 		/* Fail it with STATUS_NOT_A_REPARSE_POINT */
-		DEBUG(10, ("FSCTL_GET_REPARSE_POINT: called on FID[0x%04X] Status: NOT_IMPLEMENTED\n", fsp->fnum));
+		DEBUG(10, ("FSCTL_GET_REPARSE_POINT: called on %s. "
+			   "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
 		return NT_STATUS_NOT_A_REPARSE_POINT;
 	}
 
 	case FSCTL_SET_REPARSE_POINT:
 	{
 		/* Fail it with STATUS_NOT_A_REPARSE_POINT */
-		DEBUG(10, ("FSCTL_SET_REPARSE_POINT: called on FID[0x%04X] Status: NOT_IMPLEMENTED\n", fsp->fnum));
+		DEBUG(10, ("FSCTL_SET_REPARSE_POINT: called on %s. "
+			   "Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
 		return NT_STATUS_NOT_A_REPARSE_POINT;
 	}
 
@@ -967,7 +970,8 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 		uid_t uid;
 		size_t sid_len;
 
-		DEBUG(10,("FSCTL_FIND_FILES_BY_SID: called on FID[0x%04X]\n", fsp->fnum));
+		DEBUG(10, ("FSCTL_FIND_FILES_BY_SID: called on %s\n",
+			   fsp_fnum_dbg(fsp)));
 
 		if (in_len < 8) {
 			/* NT_STATUS_BUFFER_TOO_SMALL maybe? */
@@ -1079,8 +1083,8 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 
 	case FSCTL_IS_VOLUME_DIRTY:
 	{
-		DEBUG(10,("FSCTL_IS_VOLUME_DIRTY: called on FID[0x%04X] "
-			  "(but not implemented)\n", fsp->fnum));
+		DEBUG(10,("FSCTL_IS_VOLUME_DIRTY: called on %s "
+			  "(but not implemented)\n", fsp_fnum_dbg(fsp)));
 		/*
 		 * http://msdn.microsoft.com/en-us/library/cc232128%28PROT.10%29.aspx
 		 * says we have to respond with NT_STATUS_INVALID_PARAMETER
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 131094d..7ba0bdc 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -723,8 +723,8 @@ static int handle_aio_write_complete(struct aio_extra *aio_ex, int errcode)
 			SSVAL(outbuf,smb_err,ERRdiskfull);
 		}
 
-		DEBUG(3,("handle_aio_write: fnum=%d num=%d wrote=%d\n",
-			 fsp->fnum, (int)numtowrite, (int)nwritten));
+		DEBUG(3,("handle_aio_write: %s, num=%d wrote=%d\n",
+			 fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten));
 		status = sync_file(fsp->conn,fsp, aio_ex->write_through);
 		if (!NT_STATUS_IS_OK(status)) {
 			errcode = errno;
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index d512b96..3a45a27 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -254,10 +254,10 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
 	}
 
 	DEBUG(3,("push_blocking_lock_request: lock request blocked with "
-		"expiry time (%u sec. %u usec) (+%d msec) for fnum = %d, name = %s\n",
+		"expiry time (%u sec. %u usec) (+%d msec) for %s, name = %s\n",
 		(unsigned int)blr->expire_time.tv_sec,
 		(unsigned int)blr->expire_time.tv_usec, lock_timeout,
-		blr->fsp->fnum, fsp_str_dbg(blr->fsp)));
+		fsp_fnum_dbg(blr->fsp), fsp_str_dbg(blr->fsp)));
 
 	return True;
 }
@@ -485,8 +485,8 @@ static bool process_lockingX(struct blocking_lock_record *blr)
 		 * Success - we got all the locks.
 		 */
 
-		DEBUG(3,("process_lockingX file = %s, fnum=%d type=%d "
-			 "num_locks=%d\n", fsp_str_dbg(fsp), fsp->fnum,
+		DEBUG(3,("process_lockingX file = %s, %s, type=%d "
+			 "num_locks=%d\n", fsp_str_dbg(fsp), fsp_fnum_dbg(fsp),
 			 (unsigned int)locktype, num_locks));
 
 		reply_lockingX_success(blr);
@@ -508,9 +508,10 @@ static bool process_lockingX(struct blocking_lock_record *blr)
 	 * Still can't get all the locks - keep waiting.
 	 */
 
-	DEBUG(10,("process_lockingX: only got %d locks of %d needed for file %s, fnum = %d. \
-Waiting....\n", 
-		 blr->lock_num, num_locks, fsp_str_dbg(fsp), fsp->fnum));
+	DEBUG(10, ("process_lockingX: only got %d locks of %d needed for "
+		   "file %s, %s. Waiting....\n",
+		   blr->lock_num, num_locks, fsp_str_dbg(fsp),
+		   fsp_fnum_dbg(fsp)));
 
 	return False;
 }
@@ -612,8 +613,8 @@ void smbd_cancel_pending_lock_requests_by_fid(files_struct *fsp,
 		}
 
 		DEBUG(10, ("remove_pending_lock_requests_by_fid - removing "
-			   "request type %d for file %s fnum = %d\n",
-			   blr->req->cmd, fsp_str_dbg(fsp), fsp->fnum));
+			   "request type %d for file %s, %s\n",
+			   blr->req->cmd, fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
 		blr_cancelled = blocking_lock_cancel_smb1(fsp,
 				     blr->smblctx,
@@ -664,9 +665,9 @@ void remove_pending_lock_requests_by_mid_smb1(
 
 		if (br_lck) {
 			DEBUG(10, ("remove_pending_lock_requests_by_mid_smb1 - "
-				   "removing request type %d for file %s fnum "
-				   "= %d\n", blr->req->cmd, fsp_str_dbg(fsp),
-				   fsp->fnum ));
+				   "removing request type %d for file %s, %s\n",
+				   blr->req->cmd, fsp_str_dbg(fsp),
+				   fsp_fnum_dbg(fsp)));
 
 			brl_lock_cancel(br_lck,
 					blr->smblctx,
@@ -800,8 +801,8 @@ void process_blocking_lock_queue(struct smbd_server_connection *sconn)
 
 			if (br_lck) {
 				DEBUG(5,("process_blocking_lock_queue: "
-					 "pending lock fnum = %d for file %s "
-					 "timed out.\n", blr->fsp->fnum,
+					 "pending lock for %s, file %s "
+					 "timed out.\n", fsp_fnum_dbg(blr->fsp),
 					 fsp_str_dbg(blr->fsp)));
 
 				brl_lock_cancel(br_lck,
diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c
index 01235ba..ffc8d78 100644
--- a/source3/smbd/fake_file.c
+++ b/source3/smbd/fake_file.c
@@ -156,8 +156,8 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
 		return status;
 	}
 
-	DEBUG(5,("open_fake_file_shared: fname = %s, FID = %d, access_mask = 0x%x\n",
-		 smb_fname_str_dbg(smb_fname), fsp->fnum,
+	DEBUG(5,("open_fake_file_shared: fname = %s, %s, access_mask = 0x%x\n",
+		 smb_fname_str_dbg(smb_fname), fsp_fnum_dbg(fsp),
 		 (unsigned int)access_mask));
 
 	fsp->conn = conn;
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index d410083..bec157b 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -54,6 +54,54 @@ static unsigned long get_gen_count(struct smbd_server_connection *sconn)
 	return sconn->file_gen_counter;
 }
 
+/**
+ * create new fsp to be used for file_new or a durable handle reconnect
+ */
+NTSTATUS fsp_new(struct connection_struct *conn, TALLOC_CTX *mem_ctx,
+		 files_struct **result)
+{
+	NTSTATUS status = NT_STATUS_NO_MEMORY;
+	files_struct *fsp = NULL;
+	struct smbd_server_connection *sconn = conn->sconn;
+
+	fsp = talloc_zero(mem_ctx, struct files_struct);
+	if (fsp == NULL) {
+		goto fail;
+	}
+
+	/*
+	 * This can't be a child of fsp because the file_handle can be ref'd
+	 * when doing a dos/fcb open, which will then share the file_handle
+	 * across multiple fsps.
+	 */
+	fsp->fh = talloc_zero(mem_ctx, struct fd_handle);
+	if (fsp->fh == NULL) {
+		goto fail;
+	}
+
+	fsp->fh->ref_count = 1;
+	fsp->fh->fd = -1;
+
+	fsp->fnum = FNUM_FIELD_INVALID;
+	fsp->conn = conn;
+
+	DLIST_ADD(sconn->files, fsp);
+	sconn->num_files += 1;
+
+	conn->num_files_open++;
+
+	*result = fsp;
+	return NT_STATUS_OK;
+
+fail:
+	if (fsp != NULL) {
+		TALLOC_FREE(fsp->fh);
+	}
+	TALLOC_FREE(fsp);
+
+	return status;
+}
+
 /****************************************************************************
  Find first available file slot.
 ****************************************************************************/
@@ -66,6 +114,13 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
 	files_struct *fsp;
 	NTSTATUS status;
 
+	status = fsp_new(conn, conn, &fsp);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	GetTimeOfDay(&fsp->open_time);
+
 	if (sconn->file_bmap != NULL) {
 
 		/*
@@ -92,36 +147,7 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
 			 */
 			return NT_STATUS_TOO_MANY_OPENED_FILES;
 		}
-	}
 
-	/*
-	 * Make a child of the connection_struct as an fsp can't exist
-	 * independent of a connection.
-	 */
-	fsp = talloc_zero(conn, struct files_struct);
-	if (!fsp) {
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	/*
-	 * This can't be a child of fsp because the file_handle can be ref'd
-	 * when doing a dos/fcb open, which will then share the file_handle
-	 * across multiple fsps.
-	 */
-	fsp->fh = talloc_zero(conn, struct fd_handle);
-	if (!fsp->fh) {
-		TALLOC_FREE(fsp);
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	fsp->fh->ref_count = 1;
-	fsp->fh->fd = -1;
-
-	fsp->fnum = -1;
-	fsp->conn = conn;
-	GetTimeOfDay(&fsp->open_time);
-
-	if (sconn->file_bmap != NULL) {
 		sconn->first_file = (i+1) % (sconn->real_max_open_files);
 
 		bitmap_set(sconn->file_bmap, i);
@@ -132,11 +158,6 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
 		fsp->fh->gen_id = get_gen_count(sconn);
 	}
 
-	DLIST_ADD(sconn->files, fsp);
-	sconn->num_files += 1;
-
-	conn->num_files_open++;
-
 	/*
 	 * Create an smb_filename with "" for the base_name.  There are very
 	 * few NULL checks, so make sure it's initialized with something. to
@@ -149,8 +170,8 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
 		return status;
 	}
 
-	DEBUG(5,("allocated file structure %d, fnum = %d (%u used)\n",
-		 i, fsp->fnum, (unsigned int)sconn->num_files));
+	DEBUG(5,("allocated file structure %d, %s (%u used)\n",
+		 i, fsp_fnum_dbg(fsp), (unsigned int)sconn->num_files));
 
 	if (req != NULL) {
 		req->chain_fsp = fsp;
@@ -478,7 +499,7 @@ void file_sync_all(connection_struct *conn)
  Free up a fsp.
 ****************************************************************************/
 
-void file_free(struct smb_request *req, files_struct *fsp)
+void fsp_free(files_struct *fsp)
 {
 	struct smbd_server_connection *sconn = fsp->conn->sconn;
 
@@ -494,6 +515,21 @@ void file_free(struct smb_request *req, files_struct *fsp)
 		fsp->fh->ref_count--;
 	}
 
+	fsp->conn->num_files_open--;
+
+	/* this is paranoia, just in case someone tries to reuse the
+	   information */
+	ZERO_STRUCTP(fsp);
+
+	/* fsp->fsp_name is a talloc child and is free'd automatically. */
+	TALLOC_FREE(fsp);
+}
+
+void file_free(struct smb_request *req, files_struct *fsp)
+{
+	struct smbd_server_connection *sconn = fsp->conn->sconn;
+	int fnum = fsp->fnum;
+
 	if (fsp->notify) {
 		struct notify_context *notify_ctx =
 			fsp->conn->sconn->notify_ctx;
@@ -507,10 +543,6 @@ void file_free(struct smb_request *req, files_struct *fsp)
 	if (sconn->file_bmap != NULL) {
 		bitmap_clear(sconn->file_bmap, fsp->fnum - FILE_HANDLE_OFFSET);
 	}
-	DEBUG(5,("freed files structure %d (%u used)\n",
-		 fsp->fnum, (unsigned int)sconn->num_files));
-
-	fsp->conn->num_files_open--;
 
 	if ((req != NULL) && (fsp == req->chain_fsp)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list