FreeBSD Bugzilla – Attachment 236825 Details for
Bug 266611
copy_file_range does not copy all the way to RLIMIT_FSIZE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test program
copy_file_range_rlimit_fsize.c (text/plain), 1.03 KB, created by
Alan Somers
on 2022-09-25 23:15:52 UTC
(
hide
)
Description:
Test program
Filename:
MIME Type:
Creator:
Alan Somers
Created:
2022-09-25 23:15:52 UTC
Size:
1.03 KB
patch
obsolete
>#include <sys/types.h> > >#include <sys/resource.h> >#include <sys/time.h> > >#include <assert.h> >#include <err.h> >#include <fcntl.h> >#include <stdlib.h> >#include <unistd.h> > >size_t FSIZE = 65536; > >int main(int argc, char **argv) { > struct rlimit rl; > int infd, outfd; > char *buf; > size_t nbytes = FSIZE; > ssize_t r; > off_t ioff = 0, ooff = 0; > > buf = calloc(FSIZE, 1); > > infd = open("copy_file_range_rlimit_fsize_infile", O_RDWR | O_CREAT, > 0644); > if (infd < 0) > err(1, "open"); > > while (nbytes > 0) { > int r; > if ((r = write(infd, buf, nbytes)) < 0) > err(1, "write"); > nbytes -= r; > } > > if (getrlimit(RLIMIT_FSIZE, &rl) != 0) > err(1, "getrlimit"); > > rl.rlim_cur = FSIZE / 2; > if (setrlimit(RLIMIT_FSIZE, &rl) != 0) > err(1, "setrlimit"); > > outfd = open("copy_file_range_rlimit_fsize_outfile", O_WRONLY | O_CREAT, > 0644); > if (outfd < 0) > err(1, "open"); > > r = copy_file_range(infd, &ioff, outfd, &ooff, FSIZE, 0); > if (r < 0) > err(1, "copy_file_range"); > if (r > rl.rlim_cur) > errx(1, "copy_file_range exceeded RLIMIT_FSIZE"); > > return (0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 266611
: 236825