I have a strange question about file system in Unix. Why isn't it possible to give the same name to two files under same directory ?
Wouldn't it be possible to use IDs to differentiate between distinct files with a similar name?
|
I have a strange question about file system in Unix. Why isn't it possible to give the same name to two files under same directory ? Wouldn't it be possible to use IDs to differentiate between distinct files with a similar name? |
|||||||||||||
|
|
Think about it this way: A file's name is a unique human-readable identifier used to unequivocally refer to a file in your commands. Modern shells are able to understand relative paths, but think of names as the full path of the parent directory + the filename. The real question you should ask yourself is: is there any advantage to make the unique identifier of a file non-human-readable? |
|||||
|
|
Moving the disambiguation between files from the name of the file to the ID isn't helpful. What we call the name is now the ID, no problem! Except of course, the name of your file is no longer |
|||
|
|
|
No filesystem (as far as I know) allows one to have two files with the same name, and if any of them did, many applications would be broken or would pose security hazards. If you have 2 files with the same name, you generate ambiguity: even if they have the same file name but different IDs, how do you tell applications which file to refer to (this "open file by ID" could be done, but would require deep changes to many applications, libraries etc...)? |
|||||
|