16.12.2021 11:47, Vladimir Sementsov-Ogievskiy wrote:
15.12.2021 15:56, Karel Zak wrote:
On Tue, Dec 14, 2021 at 05:24:44PM +0300, Vladimir Sementsov-Ogievskiy wrote:
What does it mean didn't help?
I tried it, but the bug remains as it was.. As I understand,
dropping O_NONBLOCK by fcntl just removes this flag, to change
further behavior of device to non-blocking. But it doesn't do any
additional actions in driver.
Hmm ...
The solution based on blkid_safe_open() means that we have to modify
many applications. For example, systemd/udevd uses
fd = open(devnode, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
r = blkid_probe_set_device(pr, fd, offset, 0);
Hmm, yes, that's not very good :(
The same is probably in many other places (mkfs-like programs, etc.).
What do you think?
Maybe be we can get filename from fd reading it from /proc, then do
open() and than dup() to old fd.. But that's even more dirty to do
in a library call.
Yes, re-open() sounds like a possible way.
The dup() is not necessary. The library already support private FD for
probing. See blkid_new_probe_from_filename() and BLKID_FL_PRIVATE_FD.
It's also often used when the library probe whole-disk device (when you
probe sda1 than it also reads data from partition table on sda). In
this case it opens a separate FD.
It's for floppies (0.001% of all cases). IMHO re-open is good enough and
better than force changes in all applications :-)> I'll try to prepare a patch and ask you for test/review. Thanks!
Great!
Hi! Are you working on this? If not I can try to make a v2.
--
Best regards,
Vladimir