26#ifndef FUSE_EXAMPLE_PASSTHROUGH_HELPERS_H_
27#define FUSE_EXAMPLE_PASSTHROUGH_HELPERS_H_
36#include <sys/socket.h>
40static inline int do_fallocate(
int fd,
int mode, off_t offset, off_t length)
43 if (fallocate(fd, mode, offset, length) == -1)
48#ifdef HAVE_POSIX_FALLOCATE
50 return -posix_fallocate(fd, offset, length);
56 struct spacectl_range sr;
60 if (fspacectl(fd, SPACECTL_DEALLOC, &sr, 0, NULL) == -1)
74static inline int mknod_wrapper(
int dirfd,
const char *path,
const char *link,
80 res = openat(dirfd, path, O_CREAT | O_EXCL | O_WRONLY, mode);
83 }
else if (S_ISDIR(mode)) {
84 res = mkdirat(dirfd, path, mode);
85 }
else if (S_ISLNK(mode) && link != NULL) {
86 res = symlinkat(link, dirfd, path);
87 }
else if (S_ISFIFO(mode)) {
88 res = mkfifoat(dirfd, path, mode);
90 }
else if (S_ISSOCK(mode)) {
91 struct sockaddr_un su;
94 if (strlen(path) >=
sizeof(su.sun_path)) {
98 fd = socket(AF_UNIX, SOCK_STREAM, 0);
105 su.sun_family = AF_UNIX;
106 strncpy(su.sun_path, path,
sizeof(su.sun_path));
107 res = bindat(dirfd, fd, (
struct sockaddr*)&su,
116 res = mknodat(dirfd, path, mode, rdev);