[mc] SYMLINK_NOFOLLOW
mi
codejodler at gmx.ch
Fri Feb 6 01:42:14 UTC 2026
> It’s getting the information about the symlink proper and not the file that it's pointing to.
>
> https://linux.die.net/man/2/fstatat
it says,
"AT_SYMLINK_NOFOLLOW If pathname is a symbolic link, do not dereference it: instead return information about the link itself, like lstat(2). (By default, fstatat() dereferences symbolic links, like stat(2).) "
According to some old Samurai book, the ending is the most essential thing so let me start from the end :D - the crucial difference for me is that in below scenario III., mc does not seem to eval the mc.keymap or anything at all in that symlinked folder.
It works fine in I. and II.
Here are 3 strace examples.
I.
This seems to be a regular valid read operation:
newfstatat(AT_FDCWD, "/etc/mc/mc.keymap", {st_mode=S_IFREG|0644, st_size=9532, ...}, 0) = 0
openat(AT_FDCWD, "/etc/mc/mc.keymap", O_RDONLY|O_CLOEXEC) = 7
II.
This too seems to work flawless (but why is it 3 times in a row ?)
access("/home/micha/.config/mc/mc.keymap", R_OK) = 0
access("/home/micha/.config/mc/mc.keymap", R_OK) = 0
access("/home/micha/.config/mc/mc.keymap", R_OK) = 0
newfstatat(AT_FDCWD, "/home/micha/.config/mc/mc.keymap", {st_mode=S_IFREG|0644, st_size=10012, ...}, 0) = 0
openat(AT_FDCWD, "/home/micha/.config/mc/mc.keymap", O_RDONLY|O_CLOEXEC) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=10012, ...}) = 0
However, my ~/.config/mc is a symlink, the real folder it points to is ~/conf/mc.
(If you need an explanation, i use this folder to assemble the few apps that i have configured heavily / with much spent time, to be able to quickly find them and for a precise backp. I don't need to backup the zillion apps configs which i never configure. So, instead of giving my backup script the say only really important 12 pathes of .config i just give 'conf' and that's it.
So far everything with reading the keymap worked as expected.
III.
Now, the example i have given in my previous OP,
newfstatat(AT_FDCWD, "/tmp/test/subfolder", {st_mode=S_IFDIR|0700, st_size=40, ...}, AT_SYMLINK_NOFOLLOW) = 0
is when i had pointed mc to that 'subfolder' with exporting env MC_PROFILE_ROOT=/tmp/cache/mc/.config. This /tmp is a tmpfs, but the path does not include any symlink. I have been creating this path with login, so it already exists when mc launches. (Establishing kind of a kiosk mode)
In that scenario III., mc spits out the above message about SYMLINK_NOFOLLOW.
And i have to admit i do not understand what all this means, how is a 'dereferenced' path different from a 'symlink proper' and why does it say NOFOLLOW, doesn't that word semantically imply it won't read anyting with that kind of symlinked path ?
And why no such NOFOLLOW in scenario II. which actually includes a symlink ?
And remember the NOFOLLOW seems to result in mc not evaluating anything cionfig and that's why i would like to understand this fstat ... maybe the coders among us here can enlighten me.
More information about the mc
mailing list