From 63fb40b63efdc4f6ee0376a532a0b39b27ef49ed Mon Sep 17 00:00:00 2001 From: dparmar18 Date: Fri, 6 May 2022 11:00:10 +0530 Subject: [PATCH] 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 --- src/tools/cephfs/cephfs-shell | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index ce12ffeab71..47d5cbf4665 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): """ -- 2.39.5