dro7152 2013-03-18 21:52
浏览 29
已采纳

是否有用于在Linux上创建回送设备的golang库?

I have a file. Let's call it "x". I'd like to associate "x" with a loopback device in linux. From bash, I'd type:

losetup -f x

That will create something like /dev/loop0 that I can mount wherever I'd like. When it's not mounted, I can destroy the loopback file with something like:

losetup -d /dev/loop0

I'd like to be able to do the same in golang without calling losetup from the go program. Is there a library somewhere to that implements this as I looked through the losetup source, and it looks somewhat tricky, especially the create part.

  • 写回答

1条回答 默认 最新

  • doutouman6245 2013-03-18 23:03
    关注

    I don't think there is an losetup library :-(

    If you really don't want to call losetup from your code (which is the most sensible thing to do IMHO) then I'd copy the losetup.c source code into my go project, rename the main() function and then use cgo to call the renamed main function or the relevant internals directly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作