s3-lib: Add file_id_string()
authorAndrew Bartlett <abartlet@samba.org>
Mon, 16 Apr 2012 05:36:15 +0000 (15:36 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 18 Apr 2012 02:05:00 +0000 (12:05 +1000)
source3/lib/file_id.c
source3/lib/file_id.h

index 026d2f8d27d1fa01ccda3585aa57cebe9d8ec7c5..1640708d6c50902baceee16e58cbc6f90da34b16 100644 (file)
@@ -32,7 +32,7 @@ bool file_id_equal(const struct file_id *id1, const struct file_id *id2)
 }
 
 /*
-  a static string for a file_id structure
+  a static-like (on talloc_tos()) string for a file_id structure
  */
 const char *file_id_string_tos(const struct file_id *id)
 {
@@ -44,6 +44,19 @@ const char *file_id_string_tos(const struct file_id *id)
        return result;
 }
 
+/*
+  an allocated string for a file_id structure
+ */
+const char *file_id_string(TALLOC_CTX *mem_ctx, const struct file_id *id)
+{
+       char *result = talloc_asprintf(mem_ctx, "%llx:%llx:%llx",
+                                      (unsigned long long)id->devid,
+                                      (unsigned long long)id->inode,
+                                      (unsigned long long)id->extid);
+       SMB_ASSERT(result != NULL);
+       return result;
+}
+
 /*
   push a 16 byte version of a file id into a buffer.  This ignores the extid
   and is needed when dev/inodes are stored in persistent storage (tdbs).
index 594f788e491da191aa3ed6fe9eeb608ce26a648c..2ca839077fdebbb7a454463127d7c00bb99ddd1d 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-/* The following definitions come from lib/file_id.c  */
-
 #include "librpc/gen_ndr/file_id.h"
 
+/* The following definitions come from lib/file_id.c  */
+
 bool file_id_equal(const struct file_id *id1, const struct file_id *id2);
+/*
+  a static-like (on talloc_tos()) string for a file_id structure
+ */
 const char *file_id_string_tos(const struct file_id *id);
+/*
+  an allocated string for a file_id structure
+ */
+const char *file_id_string(TALLOC_CTX *mem_ctx, const struct file_id *id);
 void push_file_id_16(char *buf, const struct file_id *id);
 void push_file_id_24(char *buf, const struct file_id *id);
 void pull_file_id_24(char *buf, struct file_id *id);