Get BLKID of an unmounted volume in go

佐手、 提交于 2020-07-09 03:40:07

问题


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

  1. Shell out to the blkid utility
  2. Write a cgo interface to libblkid
  3. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!