Manpage documentation for exit status 3 is not clear

Bug #1445456 reported by Алексей
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gdisk (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

Package: gdisk

Bin: sgdisk

gdisk:
  Installed: 0.8.1-1build1
  Candidate: 0.8.1-1build1
  Version table:
 *** 0.8.1-1build1 0
        500 http://mirror.yandex.ru/ubuntu/ precise/universe amd64 Packages
        100 /var/lib/dpkg/status

System:
Description: Ubuntu 12.04 LTS
Release: 12.04

As described here http://sourceforge.net/p/gptfdisk/code/ci/master/tree/sgdisk.8 (sgdisk) (Return values):
.TP
.B 3
Non\-GPT disk detected and no \fI\-g\fR option

But if we run:
sgdisk -b ~/test.dump /dev/sda ; echo $?

where sda has MBR, no GPT, we get ec = 0.
Here is example of fix:
https://github.com/kini/gptfdisk/compare/master...overquota:master
(need "saveData = 1;" in case 'b' for check condition and return 3 worked then)

Also there fix of make errors, when compiling on ubuntu precise (#include <unistd.h> in diskio-unix.cc) - I don't know, maybe it's not necessary in upstream, i just couldn't build bin file without it

Could this be fixed in gdisk?
We have this problem in precise, but in newer packages problem exists too.

description: updated
Revision history for this message
Robie Basak (racb) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better.

It isn't clear to me from the manpage that you linked that the behaviour is documented to do what you expect. Has this been reported upstream? It isn't a good idea to change behaviour on Ubuntu from all the other distributions that run sgdisk, so ideally this would be fixed upstream first so the intent is clear.

If upstream have committed a fix, then we can look into whether it is a bugfix that should be applied to existing stable Ubuntu releases, or if it is not suitable and should go into the Ubuntu development release only.

If upstream have not committed a fix, then I'm not sure it's a good idea for Ubuntu to diverge on this behaviour.

tags: added: needs-upstream-report
Changed in gdisk (Ubuntu):
status: New → Incomplete
Revision history for this message
Алексей (f-mail-r) wrote :

wroted email to rodsmith@ (maintainer of source code). Can't make pull request on sourceforge - some problems with registration (seems it broken)

Revision history for this message
Rod Smith (rodsmith) wrote :

I'm the upstream author of GPT fdisk.

The intent of the "3" return code is to signal when sgdisk failed to operate because the disk was a non-GPT disk -- for instance, a "-d" operation to delete a partition, which sgdisk will refuse to do on an MBR disk unless "-g" is also included, to make it clear that the user (or script) intends to convert from MBR to GPT.

The "-b" option will complete successfully on an MBR disk, although the backup data won't reflect the MBR data as it was, since it will be a GPT-converted version of the MBR data. This makes this particular case a bit ambiguous: sgdisk CAN do as it was asked, but the resulting data might not be useful. IMO, it's better to know the partition table type BEFORE using sgdisk than to rely on sgdisk to return an error code if you use it inappropriately. You can learn the partition table type with "gdisk -l /dev/sdx" or "parted /dev/sdx print" and grepping on appropriate output lines.

Another consideration is that there may be existing scripts that rely on sgdisk creating a "backup" GPT data file even of MBR disks. This would be a little weird, but I can't rule out the possibility that somebody would want to do this, and I'm reluctant to introduce a change to sgdisk that would break somebody's scripts.

For these reasons, I've introduced changes upstream to the man page to more clearly describe the fact that the "3" return value occurs only when sgdisk doesn't do what it's asked to do because of the fact that it was launched on a non-GPT disk, not whenever it was launched on a non-GPT disk even if it could do what it was asked to do.

Revision history for this message
Robie Basak (racb) wrote :

Hi Roderick,

Thank you for clarifying. I guess this bug is really just "manpage is unclear" then, is fixed upstream but open in Ubuntu until we have picked up a new upstream release. I'll rename accordingly.

summary: - sgdisk return 0 if nonGPT partition style (must return 3)
+ Manpage documentation for exit status 3 is not clear
Changed in gdisk (Ubuntu):
status: Incomplete → Triaged
importance: Undecided → Medium
Revision history for this message
Robie Basak (racb) wrote :

BTW, in case you're not aware you can mass-subscribe to bugmail to the gdisk package in Ubuntu generally from https://launchpad.net/ubuntu/+source/gdisk/+subscribe if you wish, though if you don't want to do that then that's not a problem.

Revision history for this message
Rod Smith (rodsmith) wrote :

I've released gdisk 1.0.1 this weekend, which addresses this documentation issue.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.