43 #include <sys/mount.h>
44 #include <sys/param.h>
46 #elif defined(HAVE_FICLONERANGE)
51 #include <sys/ioctl.h>
59 struct attrlist attribute_list;
62 vol_capabilities_attr_t capabilities;
65 if (
statfs(
".", &fs) < 0) {
66 fprintf(stderr,
"%s: can't get mount point of current directory: %s\n",
argv[0], strerror(errno));
75 memset(&attribute_list, 0,
sizeof(attribute_list));
76 attribute_list.bitmapcount = ATTR_BIT_MAP_COUNT;
77 attribute_list.volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES;
78 memset(&volume_attributes, 0,
sizeof(volume_attributes));
80 if (getattrlist(fs.f_mntonname, &attribute_list, &volume_attributes,
sizeof(volume_attributes), 0) < 0) {
81 fprintf(stderr,
"%s: can't get volume capabilities of '%s': %s\n",
argv[0], fs.f_mntonname, strerror(errno));
85 if (volume_attributes.capabilities.capabilities[VOL_CAPABILITIES_INTERFACES] & VOL_CAP_INT_CLONE) {
88 #elif defined(HAVE_FICLONERANGE)
89 char namea[32] =
"a.fioclone.XXXXXX";
90 char nameb[32] =
"b.fioclone.XXXXXX";
92 struct file_clone_range
range;
94 if ((fda = mkstemp(namea)) < 0) {
95 fprintf(stderr,
"can't create temp file a: %s\n", strerror(errno));
98 if ((fdb = mkstemp(nameb)) < 0) {
99 fprintf(stderr,
"can't create temp file b: %s\n", strerror(errno));
104 if (
write(fda,
"test\n", 5) < 0) {
105 fprintf(stderr,
"can't write temp file a: %s\n", strerror(errno));
113 range.src_offset = 0;
114 range.src_length = 0;
115 range.dest_offset = 0;
int main(int argc, char *argv[])
static static fork const void static count close
static static sync static getppid static getegid const char static filename ioctl
return memset(p, 0, total)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who statfs
static static fork const void static count static fd const char const char static newpath char char argv