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

li wang <[email protected]> Wed, 25 Oct 2023 11:07:49 +0800
Newsgroups gmane.comp.gnu.parted.bugs
Message-ID <CA+4qKjq-O8KB_oOtgOo7vW+_5=NYWAbfQ8nZFtxtBtYdaSdojA@mail.gmail.com>
--0000000000003d799d060881c3c5
Content-Type: text/plain; charset="UTF-8"

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

--0000000000003d799d060881c3c5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><b>test case:</b><div><p style=3D"margin:0px;padding:0px;c=
olor:rgb(23,43,77);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe=
 UI&quot;,Roboto,Oxygen,Ubuntu,&quot;Fira Sans&quot;,&quot;Droid Sans&quot;=
,&quot;Helvetica Neue&quot;,sans-serif;font-size:14px"># systemctl restart =
systemd-udevd<br># systemctl status systemd-udevd</p><p style=3D"margin:0px=
;padding:0px;color:rgb(23,43,77);font-family:-apple-system,BlinkMacSystemFo=
nt,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu,&quot;Fira Sans&quot;,&quot;Dr=
oid Sans&quot;,&quot;Helvetica Neue&quot;,sans-serif;font-size:14px"># dd i=
f=3D/dev/zero of=3D./blk-file bs=3D1M count=3D200</p><p style=3D"margin:0px=
;padding:0px;color:rgb(23,43,77);font-family:-apple-system,BlinkMacSystemFo=
nt,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu,&quot;Fira Sans&quot;,&quot;Dr=
oid Sans&quot;,&quot;Helvetica Neue&quot;,sans-serif;font-size:14px"># lose=
tup -f</p><p style=3D"margin:0px;padding:0px;color:rgb(23,43,77);font-famil=
y:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubunt=
u,&quot;Fira Sans&quot;,&quot;Droid Sans&quot;,&quot;Helvetica Neue&quot;,s=
ans-serif;font-size:14px"># losetup /dev/loop0 ./blk-file</p><p style=3D"ma=
rgin:0px;padding:0px;color:rgb(23,43,77);font-family:-apple-system,BlinkMac=
SystemFont,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu,&quot;Fira Sans&quot;,=
&quot;Droid Sans&quot;,&quot;Helvetica Neue&quot;,sans-serif;font-size:14px=
"># losetup -f</p><p style=3D"margin:0px;padding:0px;color:rgb(23,43,77);fo=
nt-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Oxyg=
en,Ubuntu,&quot;Fira Sans&quot;,&quot;Droid Sans&quot;,&quot;Helvetica Neue=
&quot;,sans-serif;font-size:14px"># parted -s /dev/loop0 mklabel MSDOS</p><=
p style=3D"margin:10px 0px 0px;padding:0px;color:rgb(23,43,77);font-family:=
-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu,=
&quot;Fira Sans&quot;,&quot;Droid Sans&quot;,&quot;Helvetica Neue&quot;,san=
s-serif;font-size:14px">Error: Partition(s) 1, ..., 64 on /dev/loop0 have b=
een written, but we have been unable to inform the kernel of the change, pr=
obably because it/they are in use. As a result, the old partition(s) will r=
emain in use. You should reboot now before making further changes.<br># ech=
o $?<br>1</p><p style=3D"margin:10px 0px 0px;padding:0px;color:rgb(23,43,77=
);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,=
Oxygen,Ubuntu,&quot;Fira Sans&quot;,&quot;Droid Sans&quot;,&quot;Helvetica =
Neue&quot;,sans-serif;font-size:14px"><b>root case:</b></p><p style=3D"marg=
in:10px 0px 0px;padding:0px;color:rgb(23,43,77);font-family:-apple-system,B=
linkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu,&quot;Fira Sans=
&quot;,&quot;Droid Sans&quot;,&quot;Helvetica Neue&quot;,sans-serif;font-si=
ze:14px">linux kernel update:<br>Upstream commit 1a721de8489fa559ff4471f73c=
58bb74ac5580d3<br>+ =C2=A0 =C2=A0 =C2=A0 if (disk-&gt;flags &amp; GENHD_FL_=
NO_PART)<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -EINV=
AL;<br></p><p style=3D"margin:10px 0px 0px;padding:0px;color:rgb(23,43,77);=
font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Ox=
ygen,Ubuntu,&quot;Fira Sans&quot;,&quot;Droid Sans&quot;,&quot;Helvetica Ne=
ue&quot;,sans-serif;font-size:14px">parted: libparted/arch/linux.c<br>3075 =
static int _disk_sync_part_table (PedDisk* disk)<br>3077 {<br>...<br>3165 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!ok[i - 1] &amp=
;&amp; errnums[i - 1] =3D=3D ENXIO)<br>3166 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ok[i - 1] =3D 1; /* it=
 already doesn&#39;t exist */<br>3167 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br></p>=
<p style=3D"margin:10px 0px 0px;padding:0px;color:rgb(23,43,77);font-family=
:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu=
,&quot;Fira Sans&quot;,&quot;Droid Sans&quot;,&quot;Helvetica Neue&quot;,sa=
ns-serif;font-size:14px"><b>thought:</b></p><p style=3D"margin:10px 0px 0px=
;padding:0px;color:rgb(23,43,77);font-family:-apple-system,BlinkMacSystemFo=
nt,&quot;Segoe UI&quot;,Roboto,Oxygen,Ubuntu,&quot;Fira Sans&quot;,&quot;Dr=
oid Sans&quot;,&quot;Helvetica Neue&quot;,sans-serif;font-size:14px">parted=
 codes need refresh according to kernel=C2=A0of return value.</p></div></di=
v>

--0000000000003d799d060881c3c5--