lib: Move full_path_tos to util_str.c
authorVolker Lendecke <vl@samba.org>
Sun, 29 Dec 2013 12:56:44 +0000 (13:56 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 23 Apr 2014 20:33:08 +0000 (22:33 +0200)
This can be useful elsewhere

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/proto.h
source3/lib/util_str.c
source3/smbd/files.c
source3/smbd/proto.h

index 3197b76af7de2091216f976e41de9497ab36a2ce..c8548829770e92924cbe1bade5be03f816f1cb53 100644 (file)
@@ -724,6 +724,9 @@ bool validate_net_name( const char *name,
                int max_len);
 char *escape_shell_string(const char *src);
 char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
+ssize_t full_path_tos(const char *dir, const char *name,
+                     char *tmpbuf, size_t tmpbuf_len,
+                     char **pdst, char **to_free);
 
 /* The following definitions come from lib/version.c  */
 
index 967beda1c5d96bfbd8ec3544aaa8458b0e07ca8d..908f23aaa9df3405c159f8d956c3e587280b6d64 100644 (file)
@@ -1294,3 +1294,42 @@ char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string,
        TALLOC_FREE(s);
        return list;
 }
+
+/*
+ * This routine improves performance for operations temporarily acting on a
+ * full path. It is equivalent to the much more expensive
+ *
+ * talloc_asprintf(talloc_tos(), "%s/%s", dir, name)
+ *
+ * This actually does make a difference in metadata-heavy workloads (i.e. the
+ * "standard" client.txt nbench run.
+ */
+
+ssize_t full_path_tos(const char *dir, const char *name,
+                     char *tmpbuf, size_t tmpbuf_len,
+                     char **pdst, char **to_free)
+{
+       size_t dirlen, namelen, len;
+       char *dst;
+
+       dirlen = strlen(dir);
+       namelen = strlen(name);
+       len = dirlen + namelen + 1;
+
+       if (len < tmpbuf_len) {
+               dst = tmpbuf;
+               *to_free = NULL;
+       } else {
+               dst = talloc_array(talloc_tos(), char, len+1);
+               if (dst == NULL) {
+                       return -1;
+               }
+               *to_free = dst;
+       }
+
+       memcpy(dst, dir, dirlen);
+       dst[dirlen] = '/';
+       memcpy(dst+dirlen+1, name, namelen+1);
+       *pdst = dst;
+       return len;
+}
index 5cf037edc260926d1e5542a5d8e640f5cd323d31..84968067082fc79d525e83d1120a9cfe3b15e95d 100644 (file)
@@ -688,45 +688,6 @@ NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
        return fsp_set_smb_fname(to, from->fsp_name);
 }
 
-/*
- * This routine improves performance for operations temporarily acting on a
- * full path. It is equivalent to the much more expensive
- *
- * talloc_asprintf(talloc_tos(), "%s/%s", dir, name)
- *
- * This actually does make a difference in metadata-heavy workloads (i.e. the
- * "standard" client.txt nbench run.
- */
-
-ssize_t full_path_tos(const char *dir, const char *name,
-                     char *tmpbuf, size_t tmpbuf_len,
-                     char **pdst, char **to_free)
-{
-       size_t dirlen, namelen, len;
-       char *dst;
-
-       dirlen = strlen(dir);
-       namelen = strlen(name);
-       len = dirlen + namelen + 1;
-
-       if (len < tmpbuf_len) {
-               dst = tmpbuf;
-               *to_free = NULL;
-       } else {
-               dst = talloc_array(talloc_tos(), char, len+1);
-               if (dst == NULL) {
-                       return -1;
-               }
-               *to_free = dst;
-       }
-
-       memcpy(dst, dir, dirlen);
-       dst[dirlen] = '/';
-       memcpy(dst+dirlen+1, name, namelen+1);
-       *pdst = dst;
-       return len;
-}
-
 /**
  * Return a jenkins hash of a pathname on a connection.
  */
index 62c9728a4e8ef27e4c8f00c26abf9d40dde0b2d6..d9b86b6f539dd9707282428356ab8b59e81575b7 100644 (file)
@@ -397,9 +397,6 @@ NTSTATUS file_name_hash(connection_struct *conn,
                        const char *name, uint32_t *p_name_hash);
 NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
                           const struct smb_filename *smb_fname_in);
-ssize_t full_path_tos(const char *dir, const char *name,
-                     char *tmpbuf, size_t tmpbuf_len,
-                     char **pdst, char **to_free);
 
 /* The following definitions come from smbd/ipc.c  */