Re: [PATCH v4 RFC liburing 3/3] Wrap all syscalls in a kernel style return value

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

 



> diff --git a/src/register.c b/src/register.c
> index cb09dea..fec144d 100644
> --- a/src/register.c
> +++ b/src/register.c
> @@ -6,7 +6,6 @@
>  #include <sys/mman.h>
>  #include <sys/resource.h>
>  #include <unistd.h>
> -#include <errno.h>
>  #include <string.h>
>  
>  #include "liburing/compat.h"
> @@ -104,13 +103,16 @@ int io_uring_register_files_update(struct io_uring *ring, unsigned off,
>  
>  static int increase_rlimit_nofile(unsigned nr)
>  {
> +	int ret;
>  	struct rlimit rlim;
>  
> -	if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
> -		return -errno;
> +	ret = uring_getrlimit(RLIMIT_NOFILE, &rlim);
> +	if (ret < 0)
> +		return ret;
> +
>  	if (rlim.rlim_cur < nr) {
>  		rlim.rlim_cur += nr;
> -		setrlimit(RLIMIT_NOFILE, &rlim);
> +		return uring_setrlimit(RLIMIT_NOFILE, &rlim);
>  	}

This isn't a functionally equivalent transformation, and it's
purposefully not returning failure to increase. It may still succeed if
we fail here, relying on failure later for the actual operation that
needs an increase in files.

> diff --git a/src/syscall.h b/src/syscall.h
> index f7f63aa..3e964ed 100644
> --- a/src/syscall.h
> +++ b/src/syscall.h
> @@ -4,11 +4,15 @@
>  
>  #include <errno.h>
>  #include <signal.h>
> +#include <stdint.h>
>  #include <unistd.h>
> +#include <stdbool.h>
>  #include <sys/mman.h>
>  #include <sys/syscall.h>
>  #include <sys/resource.h>
>  
> +#include <liburing.h>
> +
>  #ifdef __alpha__
>  /*
>   * alpha and mips are exception, other architectures have
> @@ -60,6 +64,21 @@ int __sys_io_uring_register(int fd, unsigned int opcode, const void *arg,
>  			    unsigned int nr_args);
>  
>  
> +static inline void *ERR_PTR(intptr_t n)
> +{
> +	return (void *) n;
> +}
> +
> +

Extra newline here.

Apart from those two, starting to look pretty reasonable.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux