Bug 110705 - gmirror(8) control utility does not exit with correct exit status
Summary: gmirror(8) control utility does not exit with correct exit status
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-geom (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-23 11:10 UTC by Tom Judge
Modified: 2010-11-08 21:59 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Judge 2007-03-23 11:10:03 UTC
When requesting the gmirror status of a non existant device the gmirror
utility exits with a 0 exit status which according to the man page
indicates that the command completed successfuly.

From man 8 gmirror:

EXIT STATUS
     Exit status is 0 on success, and 1 if the command fails.

I would have thought the command has failed if the device of whom the
status is being requested does not exist.

Fix: 

It would seem that the gctl_req structure has members that allow for
storing of error states perhapse these could be used in the cases where
error conditions are found (std_list, std_status etc...).  Or
exit(EXIT_FAILURE) could be called.

From sbin/geom/core/geom.c  I seems that neither "Class not found" or
"No such geom" cause exit(EXIT_FAILURE), where case "Cannot get GEOM tree"
does.
How-To-Repeat: Assuming gm0 is not an active gmirror device, and is not listed in the
output of "gmirror status"

gmirror status gm0; echo $?
No such geom: gm0.
0
Comment 1 Remko Lodder freebsd_committer freebsd_triage 2007-03-23 20:50:08 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-geom

Assign to GEOM team.
Comment 2 Pawel Jakub Dawidek freebsd_committer freebsd_triage 2007-03-23 21:04:26 UTC
State Changed
From-To: open->patched

Fix committed to HEAD, MFC in 2 weeks. Thanks!
Comment 3 dfilter service freebsd_committer freebsd_triage 2007-03-23 21:05:40 UTC
pjd         2007-03-23 21:05:36 UTC

  FreeBSD src repository

  Modified files:
    sbin/geom/core       geom.c 
  Log:
  Exit status should be 1 on error.
  
  PR:             bin/110705
  Reported by:    Tom Judge
  MFC after:      2 weeks
  
  Revision  Changes    Path
  1.28      +5 -8      src/sbin/geom/core/geom.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 4 Volker 2008-02-10 14:28:28 UTC
MFC to RELENG_6 missing! If done, this PR can be closed.
Comment 5 Rong-En Fan freebsd_committer freebsd_triage 2008-02-10 14:58:08 UTC
State Changed
From-To: patched->closed

Patch committed in RELENG_[67] and HEAD. Thanks!.
Comment 6 Rong-En Fan freebsd_committer freebsd_triage 2008-02-10 14:58:22 UTC
State Changed
From-To: closed->patched

Oops, this requires a MFC to 6
Comment 7 Gavin Atkinson freebsd_committer freebsd_triage 2010-11-08 21:56:49 UTC
State Changed
From-To: patched->closed

This has been fixed in 7+, and with 6-STABLE going EOL next month, the 
submitter is happy for this to be closed.