diff options
author | Justin Keogh <[email protected]> | 2020-02-12 19:36:05 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-12 11:36:05 -0800 |
commit | 12f7b90c93ecad822d79067386574f39c6462fbf (patch) | |
tree | 401e391da03a4ffee19d3bc95fe8ba9290b0f443 | |
parent | 948f0c44196d2fa254399ec0d716c2ba0bb9ffad (diff) |
zdb: Always print symlink target
When zdb is printing paths, also print the symlink target if it exists.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Matt Ahrens <[email protected]>
Signed-off-by: Justin Keogh <[email protected]>
Closes #9925
-rw-r--r-- | cmd/zdb/zdb.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index d6d8b91a9..caaf1e608 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -2419,6 +2419,23 @@ dump_znode_sa_xattr(sa_handle_t *hdl) free(sa_xattr_packed); } +static void +dump_znode_symlink(sa_handle_t *hdl) +{ + int sa_symlink_size = 0; + char linktarget[MAXPATHLEN]; + linktarget[0] = '\0'; + int error; + + error = sa_size(hdl, sa_attr_table[ZPL_SYMLINK], &sa_symlink_size); + if (error || sa_symlink_size == 0) { + return; + } + if (sa_lookup(hdl, sa_attr_table[ZPL_SYMLINK], + &linktarget, sa_symlink_size) == 0) + (void) printf("\ttarget %s\n", linktarget); +} + /*ARGSUSED*/ static void dump_znode(objset_t *os, uint64_t object, void *data, size_t size) @@ -2483,6 +2500,9 @@ dump_znode(objset_t *os, uint64_t object, void *data, size_t size) } (void) printf("\tpath %s\n", path); } + + if (S_ISLNK(mode)) + dump_znode_symlink(hdl); dump_uidgid(os, uid, gid); (void) printf("\tatime %s", ctime(&z_atime)); (void) printf("\tmtime %s", ctime(&z_mtime)); |