2

以下のコマンドを実行すると、指定された btrfs パーティション内のサブボリュームのリストを取得する便利な API が c に必要です。

btrfs サブボリューム リスト btrfs/subvol/path

4

1 に答える 1

1

便利な 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;
}
于 2014-07-04T10:53:35.637 に答える