From 86ffdf24a233cd844c0784b26475bccdab66495a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 29 Aug 2016 10:23:44 -0700 Subject: [PATCH] Add symlink support Print out the raw symlink items. Signed-off-by: Zach Brown --- utils/src/format.h | 6 +++++- utils/src/print.c | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/utils/src/format.h b/utils/src/format.h index 82fa436b..d2e542d9 100644 --- a/utils/src/format.h +++ b/utils/src/format.h @@ -104,7 +104,8 @@ struct scoutfs_key { #define SCOUTFS_XATTR_VAL_HASH_KEY 4 #define SCOUTFS_DIRENT_KEY 5 #define SCOUTFS_LINK_BACKREF_KEY 6 -#define SCOUTFS_BMAP_KEY 7 +#define SCOUTFS_SYMLINK_KEY 7 +#define SCOUTFS_BMAP_KEY 8 #define SCOUTFS_MAX_ITEM_LEN 512 @@ -191,6 +192,9 @@ struct scoutfs_inode { #define SCOUTFS_ROOT_INO 1 +/* like the block size, a reasonable min PATH_MAX across platforms */ +#define SCOUTFS_SYMLINK_MAX_SIZE 4096 + /* * Dirents are stored in items with an offset of the hash of their name. * Colliding names are packed into the value. diff --git a/utils/src/print.c b/utils/src/print.c index ed9e15db..e1a888bc 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -114,6 +114,12 @@ static void print_link_backref(struct scoutfs_link_backref *lref, le64_to_cpu(lref->ino), le64_to_cpu(lref->offset)); } +/* for now show the raw component items not the whole path */ +static void print_symlink(char *str, unsigned int val_len) +{ + printf(" symlink: %.*s\n", val_len, str); +} + static void print_block_map(struct scoutfs_block_map *map) { int i; @@ -156,6 +162,9 @@ static void print_btree_val(struct scoutfs_btree_item *item, u8 level) print_link_backref((void *)item->val, le16_to_cpu(item->val_len)); break; + case SCOUTFS_SYMLINK_KEY: + print_symlink((void *)item->val, le16_to_cpu(item->val_len)); + break; case SCOUTFS_BMAP_KEY: print_block_map((void *)item->val); break;