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

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Jul 24 12:34:06 GMT 2020



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 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

> 
> What's the intended difference between __mknodat_common and __mknodat
None, in fact I think it would be better to implement xmknod{at} in terms
of mknod{at}.


More information about the Libc-alpha mailing list