在go中获取已卸载卷的BLKID [英] Get BLKID of an unmounted volume in go

查看:69
本文介绍了在go中获取已卸载卷的BLKID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出是否可以通过某些本地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

推荐答案

我认为没有本机库-我找不到本机库.

I don't think there is a native library - I couldn't find one.

我认为您有3个选择

  1. 掏出 blkid 实用程序
  2. cgo 接口写入
  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非常简单.2更难.根据您想要的 blkid 的确切功能,3可能会很容易. strace blkid args ,似乎有多少系统调用可以用来获得您想要的想法的结果.

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.

我可能会选择1.,因为 blkid 是您肯定拥有的核心linux工具之一.

I'd probably go with 1. as blkid is one of the core linux tools which you are guaranteed to have I think.

这篇关于在go中获取已卸载卷的BLKID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆