Imported Upstream version 4.0.0+dfsg1
[abartlet/samba-debian.git] / source3 / lib / file_id.c
index 67c1dd0b1b00b3b0c22948b3e697591789a7c407..1640708d6c50902baceee16e58cbc6f90da34b16 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "includes.h"
+#include "lib/file_id.h"
 
 /*
   return True if two file_id structures are equal
@@ -31,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)
 {
@@ -43,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).