NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Matching file to a physical medium



On 10/14/10 15:49, Sad Clouds wrote:
Hi, does anyone know if there is a way to match a file to a particular
physical medium, such as a disk.

With the help of stat(2) I can get st_dev for this file, but st_dev is
unique for each file system, even if those file systems reside on the
same physical disk. What I need is something that can uniquely identify
a physical disk.

Any ideas?

Afraid I don't know of any good way to do this.
The information is encoded in the st_dev value, but it is not standardized.
The major number will tell you what type of device it is, but the minor number will tell you both which specific disk, and which partition of that disk. So it is split into two parts, and you'd like to look at just one part of that. However, the split between unit and partition in the minor number depends on the actual type of disk we talk about. Some have minor as (unit * 8) + partition, while others have (unit * 16)+partition, and some have an even more odd scheme. See /dev/MAKEDEV for some details. Or else the various device drivers.

        Johnny



Home | Main Index | Thread Index | Old Index