s3: Avoid some transaction_commit on gencache.tdb
[kai/samba.git] / source3 / lib / filename_util.c
index d24660c981959dccff0b2d48ae7c75edd0e0be93..9a6ab2b34a97da09e335167000aa393a6405c090 100644 (file)
@@ -47,7 +47,7 @@ NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx,
 
 /**
  * There are actually legitimate callers of this such as functions that
- * enumerate streams using the SMB_VFS_STREAMINFO interface and then want to
+ * enumerate streams using the vfs_streaminfo interface and then want to
  * operate on each stream.
  */
 NTSTATUS create_synthetic_smb_fname(TALLOC_CTX *ctx, const char *base_name,
@@ -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)
@@ -202,5 +230,5 @@ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname)
                return false;
        }
 
-       return StrCaseCmp(smb_fname->stream_name, "::$DATA") == 0;
+       return strcasecmp_m(smb_fname->stream_name, "::$DATA") == 0;
 }