Seagate / opensea-transport

Cross platform library containing common set of functions to issue standard commands to storage devices.
Other
21 stars 22 forks source link

report /dev/sgx devices sorted in numeric order #7

Closed ThunderEX closed 3 years ago

ThunderEX commented 3 years ago

I have a number of drives in my system, and when using lsscsi to list them the drives will show up in order of sg1, sg2,.. sg10, sg11, sg12,... But with openSeaChest_something -s, they could only be shown up in alphabetical order like sg1, sg10, sg11,.. sg19, sg2, sg20, sg21,.. sg3, sg4, sg5,... I could see that the problem is due to alphasort used in scandir: https://github.com/Seagate/opensea-transport/blob/5ce71525022ba195dd3b90c0cc8a5aee2a1b0f12/src/sg_helper.c#L1609 According to man page, using versionsort could sort it in numeric order. Could you please consider such an improvement?

vonericsen commented 3 years ago

Hi @ThunderEX,

This looks like a good improvement we can make. I want to make sure that this is also available in musl-libc since we would like to make releases using it in the future, but at first glance it looks supported. I'm going to do a little testing in a sample code, but once I get that figured out, I see no major issues using versionsort instead.

ThunderEX commented 3 years ago

Thx @vonericsen 🤗