Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why can't we store file names directly in inodes

I don't really understand why in UNIX systems they don't store file names directly in the inodes but use a mapping system .. is this only because the size of the inode is defined and can't be changed so in case of long file names we couldn't store them? Or maybe that's in case we change the file name we don't have to do it one more time in the inode ?

Please tell me if I'm wrong or if there are other explanations . Thanks in advance

like image 412
Ben Avatar asked Jan 13 '14 00:01

Ben


People also ask

Are file names stored in inodes?

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.

What is not stored in an inode?

What is an inode? Linux® must allocate an index node (inode) for every file and directory in the filesystem. Inodes do not store actual data. Instead, they store the metadata where you can find the storage blocks of each file's data.

What information is stored in inode?

By definition, an inode is an index node. It serves as a unique identifier for a specific piece of metadata on a given filesystem. Each piece of metadata describes what we think of as a file. That's right, inodes operate on each filesystem, independent of the others.

Does inode change rename?

You can't use inode to check if a file has been changed. It may or may not change when a file is renamed, or moved. It will typically stay the same unless moved onto another disk ...


1 Answers

Why do not include file name directly in inode, here is the reasons that come to my mind:

  1. a file may have multiple names, a.k.a. hard link
  2. to support long file name, say at least 255 bytes (on most POSIX system), the inode will be much large, and because usually file names are not so long, so many of these space are wasted.
  3. if in the future we want/need to support longer file name, we need to change the structure of inode, and this could cause backward compatibile problem.
like image 70
Lee Duhem Avatar answered Nov 14 '22 23:11

Lee Duhem