Where are filenames stored on a filesystem?

Where are filenames stored on a filesystem?

It’s not in inode or with the actual file content since we have hard link that two filenames can point to the same inode.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I wasn’t finding a suitable duplicate so here’s an answer to your question.

File names & directories

excerpt

File names and directory implications:

  • inodes do not contain file names, only other file metadata.
  • Unix directories are lists of association structures, each of which contains one filename and one inode number.
  • The file system driver must search a directory looking for a particular filename and then convert the filename to the correct corresponding inode number.

Source: Wikipedia page on Inode

So the name of the file is stored within the directories’ information structure. For example:

                         ss of fs

Directory’s structure

excerpt

In the EXT2 file system, directories are special files that are used to create and hold access paths to the files in the file system. Figure 9.3 shows the layout of a directory entry in memory.

A directory file is a list of directory entries, each one containing the following information:

  • inode – The inode for this directory entry. This is an index into the array of inodes held in the Inode Table of the Block Group. In figure 9.3, the directory entry for the file called file has a reference to inode number i1,
  • name length – The length of this directory entry in bytes,
  • name – The name of this directory entry.

The first two entries for every directory are always the standard . and .. entries meaning “this directory” and “the parent directory” respectively.

Here’s the Figure 9.3 references above:

                 ss #2

Source: The Linux Documentation Project: Filesystem

References

Method 2

The file name is stored in the respective directory (“directory file”). This entry points to an inode.

Method 3

Filename is stored in the “directory” data structure which has “(string)filename” and the corresponding “(int) inode”.
directory is responsible for mapping
filename –> inode.
and in ode is responsible for mapping
inode –> sector on disk.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x