cholcombe973 / block-utils

Rust utilities for working with block devices
MIT License
22 stars 17 forks source link

need to handle different utils paths (eg, mkfs.btrfs, etc) #14

Open sprhawk opened 4 years ago

sprhawk commented 4 years ago

Thanks for your lib!

On my Debian 10.2, mkfs.btrfs is under /usr/bin, not hard coded /sbin/mkfs.btrfs

Better to handle different path on different platforms.

cholcombe973 commented 4 years ago

Great catch! Any thoughts on how I can discover the platform specific paths at build time?

sprhawk commented 4 years ago

Great catch! Any thoughts on how I can discover the platform specific paths at build time?

I guess as a start, simply we can check all possible position in /bin, /sbin, /usr/bin, /usr/sbin. and even provide an argument to provide binary path by caller.

cholcombe973 commented 4 years ago

Would you like to try a PR for this? If not I can try to get to it when I have some time.

sprhawk commented 4 years ago

Would you like to try a PR for this? If not I can try to get to it when I have some time.

I'm quite busy recently, I would try when I got available. I currently forked a repo to hardcod my path into it for hot fix.

However, I am also thinking whether I should even write a smaller crate for mkfs and block utils based on udev. I think current block-utils implements features by using both command line and udev based, not quite clean for my taste.

cholcombe973 commented 4 years ago

Sounds good! I agree this crate isn’t the cleanest code. It was meant largely to solve a problem. If I had to do it over again I’d avoid cli commands as much as possible. They’re slow and brittle

sprhawk commented 4 years ago

Sounds good! I agree this crate isn’t the cleanest code. It was meant largely to solve a problem. If I had to do it over again I’d avoid cli commands as much as possible. They’re slow and brittle

Sure, totally understand. After I finished the initial stage of my project, maybe we can discuss more about this. Part of my project will rely on these utils stable and usable.