Mount USB drive in linux with C

前端 未结 1 1179
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-11 06:26

I am looking to programatically mount a USB drive in Linux, so that I can write a text document using fprintf. I am having trouble finding out how to mount the drive. I have bee

相关标签:
1条回答
  • 2021-02-11 06:54
    man 2 mount
    

    e.g.

    #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");
    }
    
    0 讨论(0)
提交回复
热议问题