英文:
Get BLKID of an unmounted volume in go
问题
我正在尝试找出是否有一种方法可以通过一些原生的Golang库获取未挂载卷的blkid详细信息。我特别关注卷的fstype。
英文:
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
得分: 4
我不认为有一个原生的库——我找不到一个。
我认为你有三个选择:
第一种方法非常简单。第二种方法较为困难。第三种方法可能很容易,具体取决于你想要使用blkid
的哪个功能。使用strace blkid args
命令并观察它执行多少系统调用来获取你想要的结果,以此来了解。
我可能会选择第一种方法,因为我认为blkid
是Linux的核心工具之一,你应该能够保证它的存在。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论