sfdisk: failure to write partition layout to loopback devices
In util-linux 2.26 and onward a check is done to see if there are any open filehandles on the device that is being updated. Specifically, this check is being done in 'is_device_used': disk-utils/sfdisk.c:1055
For loopback devices the ioctl(fd, BLKRRPART) will always fail with return code -1. Checking errno will yield error '22'. This is "expected" and parted has considered making exceptions for this in the past [1]. I would propose that instead of having to iss ue a '--force' flag for basic loopback device operation, an exception should be included in the is_device_used function.
It could be as simple as:
+ // If we are dealing with a loopback device this will fail, but
shouldn't
+ if (!strncmp("/dev/loop", fdisk_get_devname(sf->cxt), 9)) {
+ return 0;
+ }
[1] http://comments.gmane.org/gmane.comp.gnu.parted.devel/2254
Karel Zak
maintainerQuoted 15 lines · Unknown
In util-linux 2.26 and onward a check is done to see if there are any open filehandles on the device that is being updated. Specifically, this check is being done in '
is_device_used':disk-utils/sfdisk.c:1055For loopback devices the
ioctl(fd, BLKRRPART)will always fail with return code -1. Checking errno will yield error '22'. This is "expected" and parted has considered making exceptions for this in the past [1]. I would propose that instead of having to iss ue a '--force' flag for basic loopback device operation, an exception should be included in theis_device_usedfunction.It could be as simple as:
+ // If we are dealing with a loopback device this will fail, but
shouldn't
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (!strncmp("/dev/loop", fdisk_get_devname(sf->cxt), 9)) { + return 0; + }
Fixed (I have use major(st.st_rdev) == LOOPDEV_MAJOR).
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com