Ynv
Ynv

Reputation: 1964

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)?

Upvotes: 1

Views: 411

Answers (1)

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.

Upvotes: 1

Related Questions