c - 使用 C 在 linux 中挂载 USB 驱动器

标签 c linux usb

我想在 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/

相关文章:

.net - [DllImport] 正在加载哪个 DLL?

android - OTG在Android设备中的路径

c - gcc 警告赋值使指针来自整数而不进行强制转换

c++ - 链接器错误(MEX 找不到 OpenCV 库)

c - 小于(<)float与c中if语句的比较

ruby-on-rails - git post-receive hook 没有运行 bundle install

Linux TCP 堆栈 - 对等重置或连接断开的通知

c - 并行 block 中允许哪些功能和操作?

c++ - 将 GNU/Linux C++ 包导入 Windows 上的 Visual Studio

gousb - 不是 OUT 端点