Getting lsblk kname in the cases where the model name isn't available

Authored by cjlcarvalho on Nov 1 2018, 2:47 AM.



lsblk command does not return model name as output in some specific cases, specially when you have a micro SD in your computer (perhaps it should happen with a normal SD card as well, but I haven't tested it).

So I included a verification in SfdiskBackend::scanDevice to check for kname in lsblk and use it as the name in these cases.

Diff Detail

R16 KPMCore
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
cjlcarvalho requested review of this revision.Nov 1 2018, 2:47 AM
cjlcarvalho created this revision.
stikonas accepted this revision.Nov 1 2018, 12:48 PM

It fixes the problem for me. So in principle it can go in. I would probably put on command line parameter per line, easier to read.

Although, now I was reading your comment, I thought that we can run just one command

lsblk --nodeps --noheadings --output model,kname --json deviceNode

and do JSON parsing. I'm not sure if it's worth it. In vast majority of cases device comes with a name, so json would slow it down a tiny bit.
But in the cases where device has no name, we would save one external command call which is a big win. What do you think? Is it worth it or not?

This revision is now accepted and ready to land.Nov 1 2018, 12:48 PM
stikonas added a comment.EditedNov 1 2018, 12:52 PM

Actually now I'm thinking, maybe we should always read KNAME for devices and partitions and store it. We need it in quite a few places in the code and I think right now we just follow symlinks.

There are a few places where we call

QFileInfo kernelPath(deviceNode);

In any case this patch can go in and we can improve on top of this.

This revision was automatically updated to reflect the committed changes.