]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-shell: fix rm cmd's error output 46185/head
authordparmar18 <dparmar@redhat.com>
Fri, 6 May 2022 05:30:10 +0000 (11:00 +0530)
committerdparmar18 <dparmar@redhat.com>
Fri, 13 May 2022 12:42:08 +0000 (18:12 +0530)
Description: rm command when is used to delete a directory
             or in any way that it fails, it just throws an int
             on the shell which is the error code. This is now
             fixed and it shows correct error message.

Fixes: https://tracker.ceph.com/issues/55567
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
src/tools/cephfs/cephfs-shell

index ce12ffeab71810cfd0c2a795603840317282c8aa..47d5cbf466559f6dbbbf12bf42a24a41aa9dda71 100755 (executable)
@@ -79,7 +79,8 @@ exit_codes = {'Misc': 1,
               errno.ECONNABORTED: 19,
               errno.ECONNREFUSED: 20,
               errno.ECONNRESET: 21,
-              errno.EINTR: 22}
+              errno.EINTR: 22,
+              errno.EISDIR: 23}
 
 
 #########################################################################
@@ -949,7 +950,18 @@ class CephFSShell(Cmd):
                     cephfs.unlink(path)
                 except libcephfs.Error as e:
                     # NOTE: perhaps we need a better msg here
-                    set_exit_code_msg(msg=e)
+                    if e.get_error_code() == 2:
+                        set_exit_code_msg(e.get_error_code(),
+                                          "rm: failed to remove "
+                                          f"{path.decode('utf-8')}: "
+                                          "No such file or directory")
+                    elif e.get_error_code() == 21:
+                        set_exit_code_msg(e.get_error_code(),
+                                          "rm: failed to remove "
+                                          f"{path.decode('utf-8')}: "
+                                          "Is a directory")
+                    else:
+                        set_exit_code_msg(msg=e)
 
     def complete_mv(self, text, line, begidx, endidx):
         """