I am working on a small program written in C to mount and unmount a USB thumb drive on a Linux Ubuntu (Please see code below for mounting and unmounting). The problem I am facing is that each time I mount, I cannot unmount and I keep getting "Device or resource busy" error....
Both operations work fine if I mount/unmount my USB from the command prompt using the following command:
To mount my USB thumb drive using C code I write the following:
mount -t vfat /dev/sda1 /media/usb0
umount -f /media/usb0
mountAttempts = 0;
status = 0;
status = mount("/dev/sda1", "/media/usb0", "vfat", MS_MGC_VAL | MS_NOSUID, "");
if(status != SUCCESS)
}while(status != SUCCESS && mountAttempts < 3);
printf("USB mount - status = %s\n", strerror(errno));
Can anyone tell me if I have the flags set correctly and whether or not I am using "vfat" correctly? I searched online but I couldn't find exact filesystem string descriptions.
status = umount("/media/usb0");
printf("USB unmount - status = %s\n", strerror(errno));
I also read the man page for mounting but not sure which flags I need to set to be able to read, write, delete, copy, and create files/directories.
Any input is greatly appreciated.