Skip to content

Commit

Permalink
Provide definitions for struct file_clone_range and FICLONERANGE
Browse files Browse the repository at this point in the history
These are not available in the header files shipped with Ubuntu 16.04, so
let's do the missing.h dance.
  • Loading branch information
zonque committed May 19, 2017
1 parent 02d6072 commit 72391e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ AC_CHECK_DECLS([
#include <linux/random.h>
]])

AC_CHECK_TYPES([struct file_clone_range],
[], [], [[
#include <linux/fs.h>
]])

AC_CHECK_SIZEOF(uid_t)
AC_CHECK_SIZEOF(gid_t)
AC_CHECK_SIZEOF(pid_t)
Expand Down
14 changes: 14 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <unistd.h>

#include <linux/magic.h>
#include <linux/types.h>

#define new(t, n) ((t*) malloc((n) * sizeof(t)))
#define new0(t, n) ((t*) calloc((n), sizeof(t)))
Expand Down Expand Up @@ -550,6 +551,19 @@ static inline const char *yes_no(bool b) {
#define CGROUP2_SUPER_MAGIC 0x63677270
#endif

#ifndef FICLONERANGE
#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range)
#endif

#ifndef HAVE_STRUCT_FILE_CLONE_RANGE
struct file_clone_range {
__s64 src_fd;
__u64 src_offset;
__u64 src_length;
__u64 dest_offset;
};
#endif

#define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
#define INT_TO_PTR(u) ((void *) ((intptr_t) (u)))
#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
Expand Down

0 comments on commit 72391e7

Please sign in to comment.