Description of problem: chattr and lsattr always return 0 even if they haven't done anything because of errors. Version-Release number of selected component (if applicable): e2fsprogs-1.39-23.el5 How reproducible: 100% Steps to Reproduce: [root@a1 ~]# lsattr /non/existent/file; echo $? lsattr: No such file or directory while trying to stat /non/existent/file 0 [root@a1 ~]# chattr +a /non/existent/file; echo $? chattr: No such file or directory while trying to stat /non/existent/file 0 Actual results: error code = 0. This makes using in scripts very difficult wrt error checking Expected results: EC=0 means that operation was completed successfully. Any failure must result in error code > 0. Additional info:
I have a patch upstream for this: commit e68594d2376afd10e03b440b4bc288508ad13aa2 Author: Theodore Ts'o <tytso> Date: Mon Oct 22 08:51:39 2007 -0400 chattr: provide an exit code in case of failure and add -f flag Fix chattr so that if there are errors, it will report it via a non-zero exit code. It will now explicitly give errors when attempting to set files that are not files or directories (which are currently not supported under Linux). The -f flag will suppress error messages from being printed, although the exit status will still be non-zero. Addresses-Red-Hat-Bugzilla: #180596 Signed-off-by: "Theodore Ts'o" <tytso> Signed-off-by: Eric Sandeen <sandeen> which should resolve the issue.
This request was evaluated by Red Hat Product Management for inclusion in the current release of Red Hat Enterprise Linux. Because the affected component is not scheduled to be updated in the current release, Red Hat is unfortunately unable to address this request at this time. Red Hat invites you to ask your support representative to propose this request, if appropriate and relevant, in the next release of Red Hat Enterprise Linux.
Eric, did this get pulled into RHEL5 for ext4 or ext3? Thanks!
It is in RHEL6 via upstream. I plan to push it for RHEL5.7. The fix will be in e2fsprogs' chattr, and will work fine for any filesystem. -Eric
Built & tagged in e2fsprogs-1.39-28.el5
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-1080.html