7

I noticed that renaming a file doesn't change its hash. I also noticed that creating an empty file gives a file of zero bytes, yet it has a filename.

Since the filename seems to travel with the file across devices I was wondering what exactly is the filename? How come it can be changed without altering the hash, and why doesn't it seem to take up any space?

I guess if I understood how they are stored, it would answer those questions.

1 Answer 1

12

In NTFS, all file data — file name, creation date, access permissions (by the use of access control lists), and contents — are stored as metadata in the Master File Table. In Windows world, you might also have heard about the File Allocation Table. Other file systems have other names and structures.

All file systems work this way. A certain amount of space is reserved, usually at the very beginning of the disk, right after the boot sector. That space contains a data structure which contains the information to retrieve the files.

The Master File Table is not a file. It is just organized data. As a matter of fact, files are just data that have a beginning and a size, stored in an MFT, FAT, or similar. When you change the file name, you do not change the file, just some bytes in the Master File Table.

Since the name and attributes are different from the data, you can download a file stored on a Linux server to a Windows machine. The data is transferred, not the metadata. You have to name and select a location for the file yourself (although the server and browser can hint you the original file name).

4
  • 4
    Your explanation made me wonder how the MFT changes in size over time. How NTFS reserves space for its Master File Table (MFT) has some information about that. I thought this was interesting: NTFS reserves 12.5 percent of the volume for exclusive use of the MFT until and unless the remainder of the volume is completely used up... If the unreserved space becomes full, space for user files and directories starts to be allocated from the MFT zone... If the MFT zone becomes full, space for new MFT entries is allocated from the remainder of the disk... Nov 28, 2012 at 3:57
  • But what if file transfer via torrent p2p or ftp?? How does it work then?? (Without dialogs) Jan 28, 2013 at 4:14
  • 1
    It is protocol dependent. Many protocols have a way to send the original file metadata, such as name and creation date. HTTP uses 'content-disposition' for this. Some protocols let the user select the final name, others don't, leaving you to change it after the file is transfered. If you have a question about a specific protocol, I suggest you make it a new question. +Keep in mind that there might not even be a file on the server, like a PDF of an invoice that is generated on the fly when you ask for it.
    – ixe013
    Jan 28, 2013 at 15:29
  • The master file table is a (self referencing) file as far as NTFS is concerned, even the bootsector is a file. Unlike with FAT32, exFAT etc. where meta structures are outside the data area. Jun 7, 2023 at 13:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .