fsutil硬链接不起作用?(fsutil hardlink doesn't work?)

编程入门 行业动态 更新时间:2024-10-22 15:21:35
fsutil硬链接不起作用?(fsutil hardlink doesn't work?)

我正在寻找一种在Windows下创建硬链接的方式,并且我找到了此页面: http : //technet.microsoft.com/en-us/library/cc788097.aspx

为了尝试它,我在C:驱动器的根目录下创建了一个具有100行以下内容的文件(1.txt):

C:\ 1.txt(2.598字节):

test test test test test

然后我打开命令提示符并键入:

fsutil hardlink create C:\2.txt C:\1.txt

成功,创建了2.txt,但当我去看它的大小时,它确实有2.598字节,并且还注意到一些奇怪的行为(就我对硬链接的理解而言):

如果我删除2.txt(硬链接文件),则不删除1.txt,反之亦然。 如果在删除1.txt(原始文件)后打开2.txt,则内容仍然相同。

fsutil硬链接创建命令如何与复制命令不同? 我怎样才能在Windows下创建一个真正的硬链接?

我使用的是Windows XP SP 3,而我的文件系统是NTFS。

I was looking for a way to create hard links under Windows and I found this page: http://technet.microsoft.com/en-us/library/cc788097.aspx

To try it out, I created a file (1.txt) on the root of my C: drive with 100 lines of the following content:

C:\1.txt (2.598 bytes):

test test test test test

Then I open the command prompt and typed:

fsutil hardlink create C:\2.txt C:\1.txt

Success, 2.txt was created but when I go to see it's size it has exactly 2.598 bytes and also noticed some strange behaviours (as far as my understanding of hard links goes):

If I delete 2.txt (the hard linked file) 1.txt is not deleted, and vice-versa. If I open 2.txt after I delete 1.txt (the original file) the content is still the same.

How does the fsutil hardlink create command differs from the copy command? And how can I create a true hard link under Windows?

I'm using Windows XP SP 3, and my file system is NTFS.

最满意答案

这正是应该发生的行为。 你确定你明白链接是如何工作的吗? 硬链接实际上只是文件系统中涉及完全相同文件的多个条目。 如果创建一个到文件的硬链接并修改文件的其中一个实例,则其他文件将显示您的更改,因为它们都指向磁盘上的相同数据块。

当你删除一个硬链接时,你实际上只是删除了引用该文件的文件系统条目之一。 在删除所有硬链接(包括原始链接)之前,文件不会被删除。 删除1.txt后,2.txt仍然存在,并引用原来存在的相同文件,现在只有一个涉及该文件的文件系统条目(即2.txt)。 2.txt 该文件。

That's exactly the behavior that supposed to happen. Are you sure you understand how hard links work? Hard links are really just multiple entries in the file system that refer to the exact same file. If you create a hard link to a file and modify one of the instances of the file, the other file will show up with your changes because they both refer to the same blocks of data on disk.

When you delete one of the hard links, you're really just deleting one of the file system entries referring to that file. The file doesn't get deleted until you delete all of its hard links (including the original one). After you delete 1.txt, 2.txt still exists and refers to the same file that was originally there, only now there is only a single file system entry referring to that file (namely, 2.txt). 2.txt is that file.

更多推荐

本文发布于:2023-08-05 05:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1427591.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   链接   fsutil   hardlink   work

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!