gpt4 book ai didi

c - c 中是否有用于创建、删除或列出 btrfs 子卷的任何 BTRFS 库接口(interface)?

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:23 24 4
gpt4 key购买 nike

我想要一个方便的 c 语言 API 来获取给定 btrfs 分区中的子卷列表,如我们运行以下命令时所列。

btrfs 子卷列表 btrfs/子卷/路径

最佳答案

如果找不到方便的 API,popen 就是您想要的:

#include <stdio.h>

FILE *popen(const char *command, const char *mode);
int pclose(FILE *stream);

int main(void)
{
FILE *cmd = popen("btrfs subvolume list btrfs/subvol/path", "r");
char result[128];

while (fgets(result, sizeof(result), cmd) != NULL)
printf("%s", result);
pclose(cmd);
return 0;
}

关于c - c 中是否有用于创建、删除或列出 btrfs 子卷的任何 BTRFS 库接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24572574/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com