[PATCH 16/16] linux: Move xmknoda{at} to compat symbols

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Jul 24 12:49:03 GMT 2020



On 24/07/2020 09:43, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 24/07/2020 07:30, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>> diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c
>>>> new file mode 100644
>>>> index 0000000000..d160fe520b
>>>> --- /dev/null
>>>> +++ b/sysdeps/unix/sysv/linux/mknodat.c
>>>> @@ -0,0 +1,41 @@
>>>
>>>> +int
>>>> +__mknodat_common (int fd, const char *path, mode_t mode, dev_t *dev)
>>>> +{
>>>> +  /* We must convert the value to dev_t type used by the kernel.  */
>>>> +  unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
>>>> +  if (k_dev != *dev)
>>>> +    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
>>>> +
>>>> +  return INLINE_SYSCALL_CALL (mknodat, fd, path, mode,
>>>> +			      (unsigned int) k_dev);
>>>> +}
>>>
>>> This looks suspicious yo me.  Why use a dev_t * argument?  Why check
>>> against the unsigned long long int value, when the kernel receives an
>>> unsigned int value in the system call?
>>
>> Because glibc exports dev_t is 64-bit on all architectures (__DEV_T_TYPE),
>> while kernel current only accepts 32-bits.
> 
> But then the type of k_dev should be unsigned int, I think.

Indeed, the code at least does it on the INLINE_SYSCALL_CALL. I copied the 
code as is from current linux xmknodat, but I agree with you that it is
not the most clear one.

> 
>> But I used the dev_t * argument to make it more straightforward to
>> implement xmknod{at}.  I can change to use a dev_t as well
> 
> Yes please.

Ack.
 


More information about the Libc-alpha mailing list