From: Volker Lendecke Date: Mon, 2 Sep 2019 17:04:25 +0000 (+0200) Subject: lib: Add file_id_str_buf() X-Git-Tag: talloc-2.3.1~929 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=049b8833ae885412db3ce2d41c9e26134b4e7e7e;p=thirdparty%2Fsamba.git lib: Add file_id_str_buf() file_id_string() without talloc Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index 21f22ffbf3b..b2cf313b81f 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -39,6 +39,17 @@ const char *file_id_string_tos(const struct file_id *id) return file_id_string(talloc_tos(), id); } +char *file_id_str_buf(struct file_id fid, struct file_id_buf *dst) +{ + snprintf(dst->buf, + sizeof(dst->buf), + "%"PRIu64":%"PRIu64":%"PRIu64, + fid.devid, + fid.inode, + fid.extid); + return dst->buf; +} + /* an allocated string for a file_id structure */ diff --git a/source3/lib/file_id.h b/source3/lib/file_id.h index ddcaea6c94d..c001199a35b 100644 --- a/source3/lib/file_id.h +++ b/source3/lib/file_id.h @@ -27,6 +27,13 @@ /* The following definitions come from lib/file_id.c */ bool file_id_equal(const struct file_id *id1, const struct file_id *id2); + +/* + * strlen("18446744073709551615")=20 times 3 plus 2 colons plus trailing 0 + */ +struct file_id_buf { char buf[63]; }; +char *file_id_str_buf(struct file_id fid, struct file_id_buf *dst); + /* a static-like (on talloc_tos()) string for a file_id structure */