windows NTFS 和 $Object_ID 上的唯一文件标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3892592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unique file identifiers on NTFS and $Object_ID
提问by Elan
From articles I have found online there appears to be two forms of unique identifiers for files on NTFS:
从我在网上找到的文章来看,NTFS 上的文件似乎有两种形式的唯一标识符:
Using Windows API GetFileInformationByHandle(), we can get access to the struct BY_HANDLE_FILE_INFORMATION, which contains a volume serial number and a low/high file index. http://msdn.microsoft.com/en-us/library/aa363788(VS.85).aspx
$Object_ID - The article http://blogs.technet.com/b/askcore/archive/2010/08/25/ntfs-file-attributes.aspxstates:
使用 Windows API GetFileInformationByHandle(),我们可以访问结构 BY_HANDLE_FILE_INFORMATION,其中包含卷序列号和低/高文件索引。 http://msdn.microsoft.com/en-us/library/aa363788(VS.85).aspx
$Object_ID - 文章http://blogs.technet.com/b/askcore/archive/2010/08/25/ntfs-file-attributes.aspx指出:
$OBJECT_ID – This is an attribute that holds an ID. This ID is used by the Distributed Link Tracking Service. An example of how it is used would be found in shortcuts. Make a shortcut on your desktop that points to a file. Then move that file. The shortcut will still function because it is using a way to tack the source file other than just the path and file name.
Not all files will have an $OBJECT_ID attribute. In fact, it isn't until an actual ID is to be assigned that the attribute is added to the file.
$OBJECT_ID – 这是一个包含 ID 的属性。此 ID 由分布式链接跟踪服务使用。可以在快捷方式中找到如何使用它的示例。在桌面上创建一个指向文件的快捷方式。然后移动那个文件。快捷方式仍然有效,因为它使用了一种方式来添加源文件,而不仅仅是路径和文件名。
并非所有文件都具有 $OBJECT_ID 属性。事实上,直到分配了实际的 ID 后,才将属性添加到文件中。
I am trying to understand when the Object ID is set. Here are a few questions:
我试图了解何时设置对象 ID。这里有几个问题:
When does the Object ID get assigned? It would appear based on the above article that in one scenario this occurs when a shortcut to a file is created.
Does the Object ID get assigned automatically when a file references another file, e.g. a Word document, which embeds a Visio diagram?
Do Object IDs only get assigned when Distributed Link Tracking is enabled/running or do they exist regardless of Distributed Link Tracking?
If I wanted to track a unique identifier for a file, would there be any advantage for me to use the Object ID (64 bytes) over the combined volume serial number and file index (low/high), which are 12 bytes combined.
何时分配对象 ID?根据上面的文章,在一种情况下,当创建文件的快捷方式时会出现这种情况。
当文件引用另一个文件(例如嵌入 Visio 图表的 Word 文档)时,是否会自动分配对象 ID?
对象 ID 是否仅在分布式链接跟踪启用/运行时分配,或者它们是否存在而与分布式链接跟踪无关?
如果我想跟踪文件的唯一标识符,使用对象 ID(64 字节)比组合卷序列号和文件索引(低/高)(组合 12 个字节)有什么优势。
Thanks, Elan
谢谢,伊兰
采纳答案by jrtipton
It All Depends On What You're Trying To Do. :)
这一切都取决于你想要做什么。:)
The file index number, like the documentation says, is really only a good identifier for the file in NTFS (as opposed to FAT), but even then it can change if the file is deleted and recreated (think backup/restore), though you might actually consider that a bonus if you were looking to distinguish those.
文件索引号,就像文档说的那样,实际上只是 NTFS 中文件的一个很好的标识符(与 FAT 相对),但即使如此,如果文件被删除和重新创建(想想备份/恢复),它也会改变,尽管你如果您想区分它们,实际上可能会认为这是一种奖励。
It's probably best not to worry about the link tracking service with regard to object IDs, and instead think of them as something you can create/set/read, though again only in NTFS.
最好不要担心与对象 ID 相关的链接跟踪服务,而是将它们视为您可以创建/设置/读取的东西,尽管再次仅在 NTFS 中。
Object IDs have some overhead, whereas file IDs do not. For most applications, I would probably end up picking file reference numbers (even though they are potentially fragile).
对象 ID 有一些开销,而文件 ID 没有。对于大多数应用程序,我可能最终会选择文件参考号(即使它们可能很脆弱)。
回答by Michael McCollough
Figured I would put this here for others like me researching FRN
and OBJECTID
s. These IDs might be stable for directories (other than file restore) on a single file system, but both the FRN and the ObjectID will change as soon as you save and close a file with many different applications.
我想我会把它放在这里给像我这样的其他人研究FRN
和OBJECTID
s。对于单个文件系统上的目录(而不是文件还原),这些 ID 可能是稳定的,但是一旦您使用许多不同的应用程序保存和关闭文件,FRN 和 ObjectID 都会更改。
For example, if you open a Word file with FRN#: 1000 and you have assigned OBJECTID: 8675309, when you make a change, save, and close it. The FRN# will be a new number and there will be no ObjectID.
例如,如果您打开一个带有 FRN#: 1000 的 Word 文件并分配了 OBJECTID: 8675309,则在进行更改时,请保存并关闭它。FRN# 将是一个新编号,并且没有 ObjectID。
In the following I did a simple open, make a change to text in a paragraph, save and close of a word file. There are more than 52 events, in my program, I have filtered out all the ~WRL*tmp
files, etc that are involved. But even on the same file system with the same files, FRN is not a constant thing. I do not have ObjectID showing at the moment but trust me when you assign one, open this file and save it, it is essentially a new file.
在下面我做了一个简单的打开,对段落中的文本进行更改,保存并关闭一个 word 文件。有超过52个事件,在我的程序中,我已经过滤掉了所有~WRL*tmp
涉及的文件等。但是即使是在同一个文件系统上有相同的文件,FRN也不是一成不变的东西。我目前没有显示 ObjectID,但请相信我,当你分配一个时,打开这个文件并保存它,它本质上是一个新文件。
Sample USN Journal output with the first number is the file reference number, the second is the Parent File Reference# (the FRN for the directory which is steady)
示例 USN 日志输出,第一个数字是文件参考号,第二个是父文件参考号(稳定目录的 FRN)
viewchanges
562949953421470 | 2251799813685402 | FILE | 7/10/2014 8:12:13 PM | \MyDemo\WordFileDemo.docx
OBJECT ID CHANGE
----------------------------------------------------------------------------------------------------
562949953421470 | 2251799813685402 | FILE | 7/10/2014 8:12:13 PM | \MyDemo\WordFileDemo.docx
OBJECT ID CHANGE
CLOSE
----------------------------------------------------------------------------------------------------
562949953421470 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
RENAME OLD NAME
----------------------------------------------------------------------------------------------------
1125899906842780 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
RENAME NEW NAME
BASIC INFO CHANGE
OBJECT ID CHANGE
----------------------------------------------------------------------------------------------------
1125899906842780 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
RENAME NEW NAME
BASIC INFO CHANGE
OBJECT ID CHANGE
CLOSE
----------------------------------------------------------------------------------------------------
1125899906842780 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
----------------------------------------------------------------------------------------------------
1125899906842780 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
CLOSE
----------------------------------------------------------------------------------------------------
1125899906842780 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
OBJECT ID CHANGE
----------------------------------------------------------------------------------------------------
1125899906842780 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
OBJECT ID CHANGE
CLOSE
----------------------------------------------------------------------------------------------------
1125899906842780 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
RENAME OLD NAME
----------------------------------------------------------------------------------------------------
1125899906842781 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
RENAME NEW NAME
BASIC INFO CHANGE
OBJECT ID CHANGE
----------------------------------------------------------------------------------------------------
1125899906842781 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
RENAME NEW NAME
BASIC INFO CHANGE
OBJECT ID CHANGE
CLOSE
----------------------------------------------------------------------------------------------------
1125899906842781 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
----------------------------------------------------------------------------------------------------
1125899906842781 | 2251799813685402 | FILE | 7/10/2014 8:12:19 PM | \MyDemo\WordFileDemo.docx
SECURITY CHANGE
CLOSE
----------------------------------------------------------------------------------------------------