Ben
Ben

Reputation: 489

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

Upvotes: 8

Views: 2971

Answers (1)

Lee Duhem
Lee Duhem

Reputation: 15121

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.

Upvotes: 12

Related Questions