Skip to content

Instantly share code, notes, and snippets.

@infinity0
Created November 12, 2020 21:42
Show Gist options
  • Save infinity0/93bcaa9951434a757843d6f595fd2c71 to your computer and use it in GitHub Desktop.
Save infinity0/93bcaa9951434a757843d6f595fd2c71 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <linux/types.h>
size_t max = (size_t)LONG_MAX +1; // (size_t)LONG_MAX+1
loff_t off = 0;
#define ISUNSIGNED(a) (a >= 0 && ~a >= 0)
int main() {
FILE *fa = fopen("a.txt", "rb");
FILE *fb = fopen("b.txt", "wb");
printf("sizes: size_t %p, ssize_t %p, loff_t %p, loff_t unsigned %d\n", sizeof((size_t)0), sizeof((ssize_t)0), sizeof((loff_t)0), ISUNSIGNED(off));
printf("calling copy_file_range with len %p\n", max);
if (copy_file_range(fileno(fa), NULL, fileno(fb), NULL, max, 0) < 0) {
perror(NULL);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment