New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lsblk: Would it be bad to not ignore /dev/sr* if their size is 0 ? #1118
Comments
Hi, i now stumbled over lsblk option -a. Still i deem my chances bad for getting a change into the kernel which So at least the test in line 909 should get the same And in the sum i would still wish for empty /dev/sr0 to be listed without -a Have a nice day :) Thomas |
I think about an extension to the --include option. Now --include filter is used as "what is specified and nothing else". It would be nice to add semantic "default devices and devices specified by --include +list", it means:
(11 is a major number). It means +MAJ will override all other tests (like size==0). So, you can add shell alias lsblk="lsblk --include +11" to see what you need. |
Hi, meanwhile i got used to adding -a when asking for the currently known size Do you agree that blank media and empty tray should be represented by the If there is any reason for the current habit to let blank media appear Have a nice day :) Thomas |
Hi, i forgot to ask: Is there a special reason why SIZE 0 is shown by lsblk as empty text ?
(It's not so easy to get the size of empty tray otherwise, because already Have a nice day :) Thomas |
I think the current "empty" device test is pretty basic (=poor). It would be better to analyze the device and create some rules what we need to display. For example -- the original idea has been to filter out the loop devices, but it would be better to check if the device is associated with any file than make the decision on the device size. Ad empty SIZE -- we usually use an empty string when util is not able to determine the value, but this is not the case. You're probably right, this should be fixed. |
Addresses: #1118 Signed-off-by: Karel Zak <kzak@redhat.com>
* do not ignore all empty devices, we need more smart solution * ignore only loop devices without backing file, for example: # touch img # losetup -f img losetup: img: Warning: file is smaller than 512 bytes; the loop device may be useless or invisible for system tools. - old version display nothing - new version: # lsblk /dev/loop0 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 0B 0 loop Addresses: #1118 Signed-off-by: Karel Zak <kzak@redhat.com>
Implemented. Test it for your use-case. Thanks for your report! |
Hi, thanks for the changes. I currently have my first kernel patch set pending (about automatic tray Have a nice day :) Thomas |
Hi, i forgot that i already had a working util-linux git clone from a month Reason is a logical flaw in ignore_empty(). It lets pass devices with I could make it work by this change:
Results:
Have a nice day :) Thomas |
Hi, i forgot to report that a loop device with backing still shows up Have a nice day :) Thomas |
Sorry: A copy+paste mishap (s//home/thomas/x/empty_file/) and the wrong type of ''' marks. |
This patch improves the previous commit to accept also another empty devices. Addresses: #1118 Signed-off-by: Karel Zak <kzak@redhat.com>
Ah, good point. I have only extended the current behavior to show empty loopdev, it's useless for your use-case. Sorry ;-) Fixed (I hope). |
Hi, the new change works for me. Thanks again. loop devices show up with 0 or more bytes, but not if not backed. sr devices on my hacked kernel 4.19.118 show up with size 0 if the tray Now i only have to convince linux-scsi of my ideas ... Have a nice day :) Thomas |
Addresses: #1118 Signed-off-by: Karel Zak <kzak@redhat.com>
Hi,
i am fiddling with the kernel to improve its perception of optical drives
and media. One of my experiments is to set the size of /dev/sr0 to 0 if
a unwritten and unformatted disc is inserted.
But now sr0 with size 0 does not show up in lsblk.
The program gets to see the device but ignores it:
Reason is obviously this code snippet from
https://github.com/karelzak/util-linux/blob/master/misc-utils/lsblk.c
line 1205
By a mere glitch in drivers/scsi/sr.c:get_sectorsize() blank media currently
get attributed a size of 2048 bytes. SCSI command READ CAPACITY cannot
reply -1 and get_sectorsize() naively makes cd->capacity = 1 out of its
reply 0.
Actually one should not ask READ CAPACITY if READ DISC INFORMATION replies
Disc Type 0 (= Empty, aka Blank).
I wonder whether it would be possible to get an exemption for /dev/sr*,
which allows them to be listed despite size 0.
Is there a strong reason why size 0 would cause trouble ?
(An empty drive gets reported with size 1024M, which i would try to
change to 0, too, if no reasons against that pop up.
)
Own experiments with lsblk:
I cloned
git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
and added a clause to the Ignore-devices test which prevents dev->filename
"/dev/sr[0-9]" from getting ignored.
The run did not explode, at least:
But "SIZE" is empty instead of 0.
So i added my not-/dev/sr[0-9] clause to this test in line 909:
Now the output is:
Would this be bad in any way ?
Have a nice day :)
Thomas
The text was updated successfully, but these errors were encountered: