bug#66740: fail to run 'parted -s /dev/loop0 mklabel MSDOS'

2023-10-25 Thread Brian C. Lane
On Wed, Oct 25, 2023 at 11:07:49AM +0800, li wang wrote:
> *test case:*
> 
> # systemctl restart systemd-udevd
> # systemctl status systemd-udevd
> 
> # dd if=/dev/zero of=./blk-file bs=1M count=200
> 
> # losetup -f
> 
> # losetup /dev/loop0 ./blk-file
> 
> # losetup -f
> 
> # parted -s /dev/loop0 mklabel MSDOS
> 
> Error: Partition(s) 1, ..., 64 on /dev/loop0 have been written, but we have
> been unable to inform the kernel of the change, probably because it/they
> are in use. As a result, the old partition(s) will remain in use. You
> should reboot now before making further changes.
> # echo $?
> 1
> 
> *root case:*
> 
> linux kernel update:
> Upstream commit 1a721de8489fa559ff4471f73c58bb74ac5580d3
> +   if (disk->flags & GENHD_FL_NO_PART)
> +   return -EINVAL;
> 
> parted: libparted/arch/linux.c
> 3075 static int _disk_sync_part_table (PedDisk* disk)
> 3077 {
> ...
> 3165 if (!ok[i - 1] && errnums[i - 1] == ENXIO)
> 3166 ok[i - 1] = 1; /* it already doesn't exist */
> 3167 }
> 
> *thought:*
> 
> parted codes need refresh according to kernel of return value.

Thanks, I'll have to dig into this when I have time. As a workaround you
don't need to attach the file to a loop device, parted can run on the
file directly.

Brian

-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart






bug#66740: fail to run 'parted -s /dev/loop0 mklabel MSDOS'

2023-10-25 Thread li wang
*test case:*

# systemctl restart systemd-udevd
# systemctl status systemd-udevd

# dd if=/dev/zero of=./blk-file bs=1M count=200

# losetup -f

# losetup /dev/loop0 ./blk-file

# losetup -f

# parted -s /dev/loop0 mklabel MSDOS

Error: Partition(s) 1, ..., 64 on /dev/loop0 have been written, but we have
been unable to inform the kernel of the change, probably because it/they
are in use. As a result, the old partition(s) will remain in use. You
should reboot now before making further changes.
# echo $?
1

*root case:*

linux kernel update:
Upstream commit 1a721de8489fa559ff4471f73c58bb74ac5580d3
+   if (disk->flags & GENHD_FL_NO_PART)
+   return -EINVAL;

parted: libparted/arch/linux.c
3075 static int _disk_sync_part_table (PedDisk* disk)
3077 {
...
3165 if (!ok[i - 1] && errnums[i - 1] == ENXIO)
3166 ok[i - 1] = 1; /* it already doesn't exist */
3167 }

*thought:*

parted codes need refresh according to kernel of return value.