Subject: fail to run 'parted -s /dev/loop0 mklabel MSDOS'

From: li wang <[email-masked]>
Date: Wed, 25 Oct 2023 11:07:49 +0800

*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.