Re: [yocto-patches] [pseudo] [PATCH v2 0/2] close_range: implement it rather than return ENOSYS

Mark Hatle <[email protected]> Thu, 16 Jul 2026 18:16:14 -0500
Newsgroups org.yoctoproject.lists.yocto-patches
Message-ID <[email protected]>

On 7/16/26 11:55 AM, Richard Purdie via lists.yoctoproject.org wrote:
> On Thu, 2026-07-16 at 08:46 -0700, Babanpreet Singh wrote:
>> Thanks!
>>
>>>    That said, I couldn't see what pseudo_prefix_dir_fd actually helps with
>>> and I couldn't see why we need that...
>>
>> I flagged it since it is held open and a close_range() sweep will wipe it out. I hadn't checked if anything still reads it untill now. It seems like it is just kept open and alive and the socket connection + fchdir() has been moved to pseudo_localstate_dir_fd.
>>
>> So, for the follow-up I'd purpose:
>>
>> 1/2: remove  pseudo_prefix_dir_fd
>> 2/2: add pseudo_pwd_lck_fd and pseudo_util_evlog_fd to the descriptors OP_CLOSEFROM and OP_CLOSE_RANGE step around
>>
>> If you'd rather keep the fd, I'll drop the removal and add it to the protected set in 2/2 instead.
> 
> I'd suggest making the series the other way around, protect it for now,
> send a removal patch on top and we can look at the removal patch and
> test and check it isn't really used anywhere. It is possible I'm
> missing some usage of it and I'm curious what Mark thinks.

I agree.  Maybe it's no longer needed, but we're not sure.

The code was introduced VERY early in pseudo development, 2010 era.

The variable, pseudo_prefix_dir_fd was introduced in 
551bf567c171c9f6f475f02de80e35df9563dce7, but this is based on an earlier commit.

^33d9386 (Peter Seebach 2010-03-16 19:26:24 -0500  713)         pseudo_path = 
pseudo_prefix_path(NULL);
^33d9386 (Peter Seebach 2010-03-16 19:26:24 -0500  714)         if 
(pseudo_dir_fd == -1) {
^33d9386 (Peter Seebach 2010-03-16 19:26:24 -0500  715)                 if 
(pseudo_path) {
^33d9386 (Peter Seebach 2010-03-16 19:26:24 -0500  716) 
pseudo_dir_fd = open(pseudo_path, O_RDONLY);
^33d9386 (Peter Seebach 2010-03-16 19:26:24 -0500  717) 
pseudo_dir_fd = pseudo_fd(pseudo_dir_fd, COPY_FD);
^33d9386 (Peter Seebach 2010-03-16 19:26:24 -0500  718) 
free(pseudo_path);

Unfortunately this was the _FIRST_ commit.  So based on that, there really is no 
history why this was added to begin with.

 From looking at that first commit, it was using this fd to spawn the server and 
change the cwd.  By holding an open fd on the path we were sure that the 
directory wouldn't be removed until all the FDs cleared.  (Some filesystems you 
can't delete open directories, other just postpone the removal until the fds 
clear..)

--Mark

> The protection patch makes sense and should be easy to merge compared
> to that.
> 
> Cheers,
> 
> Richard
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#4497): https://lists.yoctoproject.org/g/yocto-patches/message/4497
> Mute This Topic: https://lists.yoctoproject.org/mt/120294678/3616948
> Group Owner: [email protected]
> Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13201099/3616948/947757854/xyzzy [[email protected]]
> -=-=-=-=-=-=-=-=-=-=-=-
> 
>