简体   繁体   中英

Get UUID of a device on which a given file is stored, on *NIX systems using C

Given: The path of a file on a UNIX file system

How can I get the UUID of the device it is stored on, possibly with a library call from C, in a way that is the most portable amongst UNIX like system (including OS X)?

You can call int stat(const char *path, struct stat *buf) and the buf->st_dev will give to you the device's ID. stat() is POSIX.1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM