Reasonably filtered list of disks (block devices)

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk works asàneeded byàdefault, andàIàthought itàwillàbe that simple toàmerely look into its sources toàcopy theàlogic, but that was not theàcase asàit turnedàout.
According toàset_cxt() function, theàdevice is excluded ifàit has size ofàzero, oràis non-SCSI, which inàturn is checked byàsysfs_blkdev_scsi_get_hctl() â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk output byàdefault.
What else may one check toàreliably filteràout dummy devices like ram15? Those are pre-created inàbig numbers,àhaving sizeà>à0 andàroà=à0, making itàhard toàdistinguish them fromàregular disks. Inàsimple terms, theàresult should ideally be identical toàlsblk -d -n -o NAME â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
add a comment |Â
up vote
0
down vote
favorite
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk works asàneeded byàdefault, andàIàthought itàwillàbe that simple toàmerely look into its sources toàcopy theàlogic, but that was not theàcase asàit turnedàout.
According toàset_cxt() function, theàdevice is excluded ifàit has size ofàzero, oràis non-SCSI, which inàturn is checked byàsysfs_blkdev_scsi_get_hctl() â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk output byàdefault.
What else may one check toàreliably filteràout dummy devices like ram15? Those are pre-created inàbig numbers,àhaving sizeà>à0 andàroà=à0, making itàhard toàdistinguish them fromàregular disks. Inàsimple terms, theàresult should ideally be identical toàlsblk -d -n -o NAME â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk works asàneeded byàdefault, andàIàthought itàwillàbe that simple toàmerely look into its sources toàcopy theàlogic, but that was not theàcase asàit turnedàout.
According toàset_cxt() function, theàdevice is excluded ifàit has size ofàzero, oràis non-SCSI, which inàturn is checked byàsysfs_blkdev_scsi_get_hctl() â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk output byàdefault.
What else may one check toàreliably filteràout dummy devices like ram15? Those are pre-created inàbig numbers,àhaving sizeà>à0 andàroà=à0, making itàhard toàdistinguish them fromàregular disks. Inàsimple terms, theàresult should ideally be identical toàlsblk -d -n -o NAME â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk works asàneeded byàdefault, andàIàthought itàwillàbe that simple toàmerely look into its sources toàcopy theàlogic, but that was not theàcase asàit turnedàout.
According toàset_cxt() function, theàdevice is excluded ifàit has size ofàzero, oràis non-SCSI, which inàturn is checked byàsysfs_blkdev_scsi_get_hctl() â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk output byàdefault.
What else may one check toàreliably filteràout dummy devices like ram15? Those are pre-created inàbig numbers,àhaving sizeà>à0 andàroà=à0, making itàhard toàdistinguish them fromàregular disks. Inàsimple terms, theàresult should ideally be identical toàlsblk -d -n -o NAME â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
linux block-device lsblk
asked 15 mins ago
Anton Samsonov
1977
1977
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475151%2freasonably-filtered-list-of-disks-block-devices%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password