问题
I am trying to find out if there is a way to get details of blkid of an unmounted volume, through some native golang library. I am particularly interested in fstype of the volume
回答1:
I don't think there is a native library - I couldn't find one.
I think you've got 3 choices
- Shell out to the
blkid
utility - Write a cgo interface to libblkid
- Trawl through the
libblkid
source and re-implement it in go
1 is very easy. 2 is harder. 3 might be easy depending on exactly which feature of blkid
you want. strace blkid args
and seem how many system calls it does to get the result you want to get an idea.
I'd probably go with 1. as blkid
is one of the core linux tools which you are guaranteed to have I think.
来源:https://stackoverflow.com/questions/29324739/get-blkid-of-an-unmounted-volume-in-go