git: f62db988942a - stable/13 - linux(4): Add F_GETPIPE_SZ fcntl operation which returns the capacity of the pipe referred by fd.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Jun 2022 19:24:07 UTC
The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f62db988942a337c6bbe04f52a1afb5a7be0fb8d commit f62db988942a337c6bbe04f52a1afb5a7be0fb8d Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2021-05-31 19:15:02 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2022-06-17 19:22:16 +0000 linux(4): Add F_GETPIPE_SZ fcntl operation which returns the capacity of the pipe referred by fd. Differential Revision: https://reviews.freebsd.org/D30517 MFC after: 2 weeks (cherry picked from commit a06c12464bb49750c6b113c971e2770408ce422a) --- sys/compat/linux/linux_file.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index ff5f5da7fc33..a5ab3506767e 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include <sys/mount.h> #include <sys/mutex.h> #include <sys/namei.h> +#include <sys/selinfo.h> +#include <sys/pipe.h> #include <sys/proc.h> #include <sys/stat.h> #include <sys/sx.h> @@ -1523,6 +1525,7 @@ fcntl_common(struct thread *td, struct linux_fcntl_args *args) { struct l_flock linux_flock; struct flock bsd_flock; + struct pipe *fpipe; struct file *fp; long arg; int error, result; @@ -1654,6 +1657,21 @@ fcntl_common(struct thread *td, struct linux_fcntl_args *args) case LINUX_F_ADD_SEALS: return (kern_fcntl(td, args->fd, F_ADD_SEALS, linux_to_bsd_bits(args->arg, seal_bitmap, 0))); + + case LINUX_F_GETPIPE_SZ: + error = fget(td, args->fd, + &cap_fcntl_rights, &fp); + if (error != 0) + return (error); + if (fp->f_type != DTYPE_PIPE) { + fdrop(fp, td); + return (EINVAL); + } + fpipe = fp->f_data; + td->td_retval[0] = fpipe->pipe_buffer.size; + fdrop(fp, td); + return (0); + default: linux_msg(td, "unsupported fcntl cmd %d", args->cmd); return (EINVAL);