简体   繁体   English

在使用C的* NIX系统上,获取存储给定文件的设备的UUID

[英]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 给定:UNIX文件系统上文件的路径

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)? 如何以一种在UNIX之类的系统(包括OS X)中最可移植的方式,获取存储在设备上的UUID(可能通过C进行库调用)?

You can call int stat(const char *path, struct stat *buf) and the buf->st_dev will give to you the device's ID. 您可以调用int stat(const char * path,struct stat * buf) ,而buf-> st_dev将为您提供设备的ID。 stat() is POSIX.1. stat()是POSIX.1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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