我想在 Linux 中以编程方式挂载 USB 驱动器,以便我可以使用 fprintf 编写文本文档。我无法找到如何安装驱动器。我一直在网上搜索答案,我找到了很多关于如何通过命令行完成此操作的教程,但没有在 C 中找到答案。有人可以用这个为我指明正确的方向吗?
最佳答案
man 2 mount
例如
#include <sys/mount.h>
if (mount("/dev/mmcblk0p1", "/mnt/sd", "vfat", MS_NOATIME, NULL)) {
if (errno == EBUSY) {
printf("Mountpoint busy");
} else {
printf("Mount error: %s", strerror(errno));
}
} else {
printf("Mount successful");
}
关于c - 使用 C 在 linux 中挂载 USB 驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10458549/