[PATCH 13/23] linux: Add fchroot

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Nov 5 18:44:15 GMT 2026



On 05/11/26 14:02, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> On 05/11/26 13:42, Florian Weimer wrote:
>>> * Andreas Schwab:
>>>
>>>> On Nov 05 2026, Florian Weimer wrote:
>>>>
>>>>> * Adhemerval Zanella:
>>>>>
>>>>>> diff --git a/sysdeps/unix/sysv/linux/bits/unistd_ext.h b/sysdeps/unix/sysv/linux/bits/unistd_ext.h
>>>>>> index a541b378d03..6597435ace7 100644
>>>>>> --- a/sysdeps/unix/sysv/linux/bits/unistd_ext.h
>>>>>> +++ b/sysdeps/unix/sysv/linux/bits/unistd_ext.h
>>>>>> @@ -47,4 +47,10 @@ extern __pid_t gettid (void) __THROW;
>>>>>>  # define CLOSE_RANGE_CLOEXEC (1U << 2)
>>>>>>  #endif
>>>>>>  
>>>>>> +/* Change the root directory of the calling process to the directory
>>>>>> +   referred to by the file descriptor FD.  FD can also be FD_FAILFS_ROOT,
>>>>>> +   in which case all subsequent absolute file name lookups fail.  FLAGS
>>>>>> +   must be zero.  */
>>>>>> +extern int fchroot (int __fd, unsigned int __flags) __THROW;
>>>>>> +
>>>>>>  #endif /* __USE_GNU  */
>>>>>
>>>>> CRIU defines _GNU_SOURCE, and it has:
>>>>>
>>>>> criu/files.c:#include <unistd.h>
>>>>>
>>>>> criu/files.c:static int fchroot(int fd)
>>>>
>>>> BSD also has fchroot without the flags.
>>>
>>> So does Hurd.
>>>
>>>> Should the one above be called fchroot2, or should the flags be
>>>> dropped for now?
>>>
>>> It won't fix the fchroot build failure.  It's surprisingly rare, though:
>>
>> What do you mean by it won't fix the build failure? We can provide both,
>> although it still be confusing that on Linux you have 2 functions.
> 
> With the single-argument version, it's still a static definition folling
> an extern declaration, which is a compiler error.
Right, but on this case the usual expected way is a configure check if
the system library already provides it.  Having this as a blocker will
make *any* new syscall wrappers really hard to justify.


More information about the Libc-alpha mailing list