Author: Didier Kryn Date: To: dng Subject: [DNG] File hierarchy [was: Re (2): Migrating advice]
Le 17/10/2025 à 02:14, Peter via Dng a écrit : > The example was
> mentioned only to illustrate that a hierarchy can exist in names
> without directories.
Interesting to learn that there are and has been OSes with
filesystems without directories.
I see two things which make directories essential in Unix: they
serve as moutpoints, and as intermediate points in the file permission
management.
Regarding performance, I had a look at some Internet resources and
here is a summary of the possible configurations sorted by /decreasing
access time/, therefore /increasing performance/, with the same number
of files:
1) calling open() with the need to traverse subdirectories
2) calling open() with all the files in the same directoriy
3) having the files in subdirectories but pre-openning the
lowest-level subdirectories and opening the files by openat() -- in this
case, there is only one directory to search but it is smaller than in
the previous case.
Anyway, openat() is the recommended way to open files which are not
in the working directory of the process, for good reasons. Note that
this is a POSIX function, not part of the C standard, which means that
you must then call fdopen() if you need an stdio FILE pointer.
Note also that, thanks to hard links, you may have alternative
access paths to the same files.
There is yet another concept: the file_handle, which is an opaque
structure referring a file. IMHO the performance of open_by_handle_at()
deserves to be studied. An interesting feature is that the file_handles
and mount_id (they work together), can be obtained by one process and
re-used by another process, which, IIUC, means that you can store them
in a file for later use.