Know the number of files / directories before doing a FSCTL_ENUM_USN_DATA

ぐ巨炮叔叔 提交于 2019-12-08 08:47:02

问题


Before doing a USN journal / NTFS MFT files-enumeration with

while (DeviceIoControl(hDrive, FSCTL_ENUM_USN_DATA, &med, sizeof(med), pData, sizeof(pData), &cb, NULL))
{
    // do stuff here
    med.StartFileReferenceNumber = *((DWORDLONG*) pData);    // pData contains FRN for next FSCTL_ENUM_USN_DATA
}

I'd like to know the number of files/directories (to "reserve" a std::vector: v.reserve(...) and also other reasons).

I thought about using FSCTL_QUERY_USN_JOURNAL before, that gives a USN_JOURNAL_DATA_V0 containing informations about the volume.

Unfortnuately FirstUsn, NextUsn, MaxUsn don't give this information. Even if I have 100k files on the volume, NextUsn can be 10 millions for example, so it doesn't give the right order of magnitude.

How to get the number of files / directories before doing a FSCTL_ENUM_USN_DATA?

来源:https://stackoverflow.com/questions/45223765/know-the-number-of-files-directories-before-doing-a-fsctl-enum-usn-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!