Skip to content

Commit

Permalink
zdb: Always print symlink target
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jakeogh authored Feb 12, 2020
1 parent 948f0c4 commit 12f7b90
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 12f7b90

Please sign in to comment.