]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephfs-shell: Add listxattr command
authorVarsha Rao <varao@redhat.com>
Wed, 29 Jan 2020 06:03:29 +0000 (11:33 +0530)
committerVarsha Rao <varao@redhat.com>
Wed, 29 Jan 2020 19:46:27 +0000 (01:16 +0530)
Fixes: https://tracker.ceph.com/issues/42530
Signed-off-by: Varsha Rao <varao@redhat.com>
src/tools/cephfs/cephfs-shell

index 8e5dc381a0f7f3ebcd4178dce3069cd81bfb59bb..68e0df8f623fa0ccf539b0cdd1b9832cbcee12e0 100755 (executable)
@@ -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.