Use C to get its mount point (cat/proc/mounts) after inserting the USB drive automatically after Linux

Source: Internet
Author: User

It is now possible to get the node name (via function Udev_device_get_devnode ()) of the USB stick when it is inserted through Libudev, which is/DEV/SDB1

What I do now is to read the/proc/mounts file, find the line that has/DEV/SDB1, parse out the mount point/media/11111

The contents of the/proc/mounts file are as follows:

 
Sysfs/sys Sysfs rw,nosuid,nodev,noexec,relatime 0 0
PROC/PROC proc Rw,nosuid,nodev,noexec,relatime 0 0
Udev/dev Devtmpfs rw,relatime,size=2002180k,nr_inodes=208893,mode=755 0 0
Devpts/dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
/dev/sdb1/media/11111 vfat ...
...

But I don't think it's good to know if there is a system API that provides such a feature

Use C to get its mount point (cat/proc/mounts) after inserting the USB drive automatically after Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.