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.
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.
I wasn't finding a suitable duplicate so here's an answer to your question.
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:
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:
Source: The Linux Documentation Project: Filesystem
The file name is stored in the respective directory ("directory file"). This entry points to an inode.
Filenames are stored in the directory data structures, which have the filename (a string) and the corresponding inode number.
directory is responsible for mapping filename --> inode.
and inode is responsible for mapping data area location --> sector on disk.
.
in themselves. – Stéphane Chazelas Mar 31 '14 at 20:58