From 96f00936b12461e37dcaab3928a162a8f2e5f886 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Wed, 29 Jan 2020 11:33:29 +0530 Subject: [PATCH] cephfs-shell: Add listxattr command Fixes: https://tracker.ceph.com/issues/42530 Signed-off-by: Varsha Rao --- src/tools/cephfs/cephfs-shell | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index 8e5dc381a0f..68e0df8f623 100755 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -1451,6 +1451,27 @@ class CephFSShell(Cmd): perror(e) self.exit_code = e.get_error_code() + listxattr_parser = argparse.ArgumentParser( + description='List extended attributes set for a file') + listxattr_parser.add_argument('path', type=str, action=path_to_bytes, + help='Name of the file') + + @with_argparser(listxattr_parser) + def do_listxattr(self, args): + """ + List extended attributes for a file + """ + try: + size, xattr_list = cephfs.listxattr(args.path) + if size > 0: + poutput('{}'.format(xattr_list.replace(b'\x00', b' ').decode('utf-8'))) + else: + poutput('No extended attribute is set') + except libcephfs.Error as e: + perror(e) + self.exit_code = e.get_error_code() + + ####################################################### # # Following are methods that get cephfs-shell started. -- 2.39.5