From: Varsha Rao Date: Wed, 29 Jan 2020 06:03:29 +0000 (+0530) Subject: cephfs-shell: Add listxattr command X-Git-Tag: v15.1.1~575^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=96f00936b12461e37dcaab3928a162a8f2e5f886;p=ceph.git cephfs-shell: Add listxattr command Fixes: https://tracker.ceph.com/issues/42530 Signed-off-by: Varsha Rao --- 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.