在 FreeBSD 系统调用中用 c 列出物理磁盘

List physical disks in c on FreeBSD system call

你能给我指明正确的方向吗?现在我正在寻找系统调用 g_io_getattr.. 我不想调用子进程。 return 将是例如'da0'、'da1' 或 'ada0'...

您很可能想要使用 FreeBSD 的 libgeom - specifically geom_gettree(). The source to freebsd's partedit - shows it being used and the resulting structure being iterated through in the read_geom_mesh and related functions in order to get a list of the disks. What appears to be the source of the geom program 还演示了 geom_gettree 函数的一些用法并遍历其返回的结构。