I’m trying to get unique volume ID that will still remain valid even after system restart. I’ve got a potentially large number of log entries, each of which is associated with a particular volume. The information in a log entry needs to be persistent across reboot and requires a small size volume ID (preferably 16- or 32-bit) to minimize the log size.
The only way I could think of is to grab all persistent volume names (i.e. ??\Volume{41479d12-134f-11de-b425-005056c00008}) and assign them to 16- or 32-bit index numbers. I’m pretty sure it would work. But is there any easier way to map volumes to small-size volume IDs?
I’m trying to get unique volume ID that will still remain valid even after
system restart. I’ve got a potentially large number of log entries, each of
which is associated with a particular volume. The information in a log entry
needs to be persistent across reboot and requires a small size volume ID
(preferably 16- or 32-bit) to minimize the log size.
The only way I could think of is to grab all persistent volume names (i.e.
??\Volume{41479d12-134f-11de-b425-005056c00008}) and assign them to 16- or
32-bit index numbers. I’m pretty sure it would work. But is there any easier
way to map volumes to small-size volume IDs?
Thanks a lot.
Sean
NTFSD is sponsored by OSR
For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit: http://www.osr.com/seminars
>The information in a log entry needs to be persistent across reboot and >requires a small size volume ID (preferably 16- or 32-bit) to minimize the >log size.
I think you can use ZwQueryVolumeInformationFile/ FltQueryVolumeInformationFile with FileFsVolumeInformation class. You can use the VolumeSerialNumber field of the returned structure. That is a 32 bit value.
It has to support any hard drive including USB drive. The algorithm I’m thinking of is:
VolumeNameMappingTable management:
OnFilterInstanceSetUp()
InstanceSetUp stores both “my” volume id and the actual volume name (i.e. ??\Volume{41479d12-134f-11de-b425-005056c00008}) in filter instance context. InstanceSetUp() will either SetMyVolumeId() on VolumeNameMappingTable, if the volume is not already there in VolumeNameMappingTable , or GetMyVolumeId() if the volume is found in VolumeNameMappingTable.
OnLogEvent()
Log processing routine will call this function. It will simply grab my volume id from filter instance context. (filter instance context can be retrieved for every log event)
OnSystemShutdown()
Saves VolumeNameMappingTable to a file
OnSystemStartup()
Constructs in-memory VolumeNameMappingTable from the file
It’s a boring and time-consuming task. That’s why I was asking for an “easier” way assuming this algorithm would work for any disk drive including USB.