summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-04-16 15:36:15 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-04-18 12:05:00 +1000
commitce9676839b50ad34cead8f7f02488272a2bb3c85 (patch)
tree0adee5acee5cdd3d04de1b2b7ce8c7eb4bca42b9 /source3
parentea5a9b21fb384524c8370c6d7a712b35e170fd06 (diff)
downloadsamba-ce9676839b50ad34cead8f7f02488272a2bb3c85.tar.gz
samba-ce9676839b50ad34cead8f7f02488272a2bb3c85.tar.bz2
samba-ce9676839b50ad34cead8f7f02488272a2bb3c85.zip
s3-lib: Add file_id_string()
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/file_id.c15
-rw-r--r--source3/lib/file_id.h11
2 files changed, 23 insertions, 3 deletions
diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c
index 026d2f8d27..1640708d6c 100644
--- a/source3/lib/file_id.c
+++ b/source3/lib/file_id.c
@@ -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)
{
@@ -45,6 +45,19 @@ 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)
+{
+ 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).
*/
diff --git a/source3/lib/file_id.h b/source3/lib/file_id.h
index 594f788e49..2ca839077f 100644
--- a/source3/lib/file_id.h
+++ b/source3/lib/file_id.h
@@ -19,12 +19,19 @@
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);