linux - unmount USB drive in C++ -
i developing qt application linux (ubuntu) in use usb drive backup content. application should unmount target drive after copying stuff. have udev
rule file mount usb @ specific location env{mount_options}="relatime,users,umask=0,uid=user,gid=user"
user represents user name.
i tried using without luck.
const char* usb = "/mnt/mountpoint/usbdrive"; if (!umount(usb)) { qdebug() << "device unmounted"; } else { qdebug() << "can't unmount" << strerror(errno); //this prints operation not permitted }
could please me here? using umount
right?
thanks in advance.
appropriate privilege (linux: cap_sys_admin capability) required unmount file systems.
per umount
code fine. need privilege umount devices.
the cap_sys_admin capability allows process perform various administrative tasks, namely: calling mount(), umount(). there 2 worth articles capabilities here:
- cap_sys_admin: new root
- overview of linux capabilities (list of capabilities)
Comments
Post a Comment