tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: procfs files vs symlink



On Thu, 13 Jan 2022, Robert Elz wrote:

This problem isn't in procfs, but in ls, and is hard to fix.
The general issus is that any directory can change while ls
is processing it, leading to either incorrect (or even nonsense)
output, or apparent errors.

procfs is only notable here by being more dynamic than most
filesystems, and its self/fd subr particularly in that it changes
as the process opens and closes files


That's it exactly.

 | Anyway, here's one more patch:
 |
 | ---START PATCH---
 | --- sys/miscfs/procfs/procfs_vnops.c.orig	2022-01-12 20:57:25.944841288 +0000
 | +++ sys/miscfs/procfs/procfs_vnops.c	2022-01-12 23:07:44.736070587 +0000


that cannot be more than papering over one special case.


The patch is for processes to know that stat() will have to be
called for that particular dirent. DT_REG would not be right there.
(I've done this myself: call stat() if dirent.d_type is DT_UNKNOWN;
otherwise, take dirent.d_type as valid and save a syscall.)

A note in dirent.3 that procfs (and some others?) will always return
DT_UNKNOWN would be a good idea, I think.

Thanks,
-RVP


Home | Main Index | Thread Index | Old Index