public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Alejandro Colomar <alx.manpages@gmail.com>
Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org
Subject: Re: [PATCH v2] copy_file_range.2: Document glibc wrapper instead of kernel syscall
Date: Fri, 1 Jan 2021 22:23:43 +0100	[thread overview]
Message-ID: <d323ff01-4fe6-09dd-5531-aef8e66cf8d4@gmail.com> (raw)
In-Reply-To: <20201231132407.160590-1-alx.manpages@gmail.com>

Hello Alex,

On 12/31/20 2:24 PM, Alejandro Colomar wrote:
> Glibc uses 'off64_t' instead of 'loff_t'.
> 
> ......
> 
> Glibc prototype:
> 
> $ syscall='copy_file_range';
> $ ret='ssize_t';
> $ find glibc/ -type f -name '*.h' \
>   |xargs pcregrep -Mn "(?s)^[\w\s]*${ret}\s*${syscall}\s*\(.*?;";
> glibc/posix/unistd.h:1121:
> ssize_t copy_file_range (int __infd, __off64_t *__pinoff,
> 			 int __outfd, __off64_t *__poutoff,
> 			 size_t __length, unsigned int __flags);
> 
> ......
> 
> Testing example:
> 
> $ man ./man2/copy_file_range.2 \
>   |sed -n '/^EXAMPLES/,/^SEE ALSO/p' \
>   |head -n -1 \
>   |tail -n +2 \
>   >copy_file_range.c
> $ gcc -Wall -Wextra -Werror -pedantic
> copy_file_range.c -o copy_file_range
> $ ./copy_file_range 
> Usage: ./copy_file_range <source> <destination>
> $ tee a >/dev/null
> asdf
> $ tee b >/dev/null
> qwerty
> zxcvbn
> $ ./copy_file_range a b
> $ cat a
> asdf
> $ cat b
> asdf
> 
> 
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

Thanks! Patch applied.

Cheers,

Michael

> ---
>  man2/copy_file_range.2 | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/man2/copy_file_range.2 b/man2/copy_file_range.2
> index 1692aa44a..611a39b80 100644
> --- a/man2/copy_file_range.2
> +++ b/man2/copy_file_range.2
> @@ -30,8 +30,8 @@ copy_file_range \- Copy a range of data from one file to another
>  .B #define _GNU_SOURCE
>  .B #include <unistd.h>
>  .PP
> -.BI "ssize_t copy_file_range(int " fd_in ", loff_t *" off_in ,
> -.BI "                        int " fd_out ", loff_t *" off_out ,
> +.BI "ssize_t copy_file_range(int " fd_in ", off64_t *" off_in ,
> +.BI "                        int " fd_out ", off64_t *" off_out ,
>  .BI "                        size_t " len ", unsigned int " flags );
>  .fi
>  .SH DESCRIPTION
> @@ -233,26 +233,14 @@ or server-side-copy (in the case of NFS).
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <sys/stat.h>
> -#include <sys/syscall.h>
>  #include <unistd.h>
>  
> -/* On versions of glibc before 2.27, we must invoke copy_file_range()
> -   using syscall(2) */
> -
> -static loff_t
> -copy_file_range(int fd_in, loff_t *off_in, int fd_out,
> -                loff_t *off_out, size_t len, unsigned int flags)
> -{
> -    return syscall(__NR_copy_file_range, fd_in, off_in, fd_out,
> -                   off_out, len, flags);
> -}
> -
>  int
>  main(int argc, char **argv)
>  {
>      int fd_in, fd_out;
>      struct stat stat;
> -    loff_t len, ret;
> +    off64_t len, ret;
>  
>      if (argc != 3) {
>          fprintf(stderr, "Usage: %s <source> <destination>\en", argv[0]);
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

      reply	other threads:[~2021-01-01 21:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-30 21:41 [PATCH] copy_file_range.2: SYNOPSIS: Fix prototype parameter types Alejandro Colomar
2020-12-30 22:43 ` Michael Kerrisk (man-pages)
2020-12-30 23:20   ` Alejandro Colomar (man-pages)
2020-12-31  8:58     ` Michael Kerrisk (man-pages)
2020-12-31 12:46       ` Alejandro Colomar (man-pages)
2021-01-02  8:44         ` Michael Kerrisk (man-pages)
2020-12-31 13:01       ` [PATCH] Various pages: Consistently use 'unsigned int' Alejandro Colomar
2021-01-02  7:33         ` Michael Kerrisk (man-pages)
2020-12-31 13:24       ` [PATCH v2] copy_file_range.2: Document glibc wrapper instead of kernel syscall Alejandro Colomar
2021-01-01 21:23         ` Michael Kerrisk (man-pages) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d323ff01-4fe6-09dd-5531-aef8e66cf8d4@gmail.com \
    --to=mtk.manpages@gmail.com \
    --cc=alx.manpages@gmail.com \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox