From: dparmar18 Date: Fri, 6 May 2022 05:30:10 +0000 (+0530) Subject: cephfs-shell: fix rm cmd's error output X-Git-Tag: v18.0.0~824^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=63fb40b63efdc4f6ee0376a532a0b39b27ef49ed;p=ceph.git cephfs-shell: fix rm cmd's error output 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 --- diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index ce12ffeab718..47d5cbf46655 100755 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -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): """