Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ compiler:
- gcc
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libfuse-dev
- sudo apt-get install -qq libfuse3-dev
script: ./autogen.sh && ./configure && make && sudo make install
7 changes: 5 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC

# Enable large file support (required by FUSE3 on 32-bit platforms)
AC_SYS_LARGEFILE

# Checks for libraries.
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
PKG_CHECK_MODULES([FUSE], [fuse >= 2.3])
CFLAGS="$CFLAGS -Wall -Wextra $FUSE_CFLAGS -DFUSE_USE_VERSION=25"
PKG_CHECK_MODULES([FUSE], [fuse3])
CFLAGS="$CFLAGS -Wall -Wextra $FUSE_CFLAGS -DFUSE_USE_VERSION=31"
LIBS="$FUSE_LIBS"

# Check if we need to enable compatibility code for old FUSE versions
Expand Down
60 changes: 26 additions & 34 deletions src/afuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#endif

#include <fuse.h>
#include <fuse_opt.h>
#ifndef __USE_BSD
// for mkdtemp
#define __USE_BSD
Expand Down Expand Up @@ -631,8 +630,9 @@ proc_result_t process_path(const char *path_in, char *path_out, char *root_name,
return PROC_PATH_ROOT_DIR;
}

static int afuse_getattr(const char *path, struct stat *stbuf)
static int afuse_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi)
{
(void) fi;
char *root_name = alloca(strlen(path));
char *real_path = alloca(max_path_out_len(path));
int retval;
Expand Down Expand Up @@ -822,7 +822,7 @@ int populate_root_dir(char *pop_cmd, struct list_t **dir_entry_listptr,
}

if (strlen(dir_entry) != 0)
filler(buf, dir_entry, NULL, 0);
filler(buf, dir_entry, NULL, 0, 0);
}

free(dir_entry);
Expand All @@ -840,8 +840,10 @@ int populate_root_dir(char *pop_cmd, struct list_t **dir_entry_listptr,
}

static int afuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
off_t offset, struct fuse_file_info *fi,
enum fuse_readdir_flags flags)
{
(void) flags;
DIR *dp = get_dirp(fi);
struct dirent *de;
char *root_name = alloca(strlen(path));
Expand All @@ -857,8 +859,8 @@ static int afuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
break;

case PROC_PATH_ROOT_DIR:
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, ".", NULL, 0, 0);
filler(buf, "..", NULL, 0, 0);
insert_sorted_if_unique(&dir_entry_list, ".");
insert_sorted_if_unique(&dir_entry_list, "..");
for (mount = mount_list; mount; mount = next) {
Expand All @@ -870,7 +872,7 @@ static int afuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
if (insert_sorted_if_unique
(&dir_entry_list, mount->root_name))
retval = -1;
filler(buf, mount->root_name, NULL, 0);
filler(buf, mount->root_name, NULL, 0, 0);
}
}
populate_root_dir(user_options.populate_root_command,
Expand All @@ -892,7 +894,7 @@ static int afuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
st.st_mode = de->d_type << 12;
if (filler(buf, de->d_name, &st, telldir(dp)))
if (filler(buf, de->d_name, &st, telldir(dp), 0))
break;
}
retval = 0;
Expand Down Expand Up @@ -1107,8 +1109,10 @@ static int afuse_symlink(const char *from, const char *to)
return retval;
}

static int afuse_rename(const char *from, const char *to)
static int afuse_rename(const char *from, const char *to, unsigned int flags)
{
if (flags)
return -EINVAL;
char *root_name_from = alloca(strlen(from));
char *root_name_to = alloca(strlen(to));
char *real_from_path = alloca(max_path_out_len(from));
Expand Down Expand Up @@ -1214,8 +1218,9 @@ static int afuse_link(const char *from, const char *to)
return retval;
}

static int afuse_chmod(const char *path, mode_t mode)
static int afuse_chmod(const char *path, mode_t mode, struct fuse_file_info *fi)
{
(void) fi;
char *root_name = alloca(strlen(path));
char *real_path = alloca(max_path_out_len(path));
mount_list_t *mount;
Expand Down Expand Up @@ -1243,8 +1248,9 @@ static int afuse_chmod(const char *path, mode_t mode)
return retval;
}

static int afuse_chown(const char *path, uid_t uid, gid_t gid)
static int afuse_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi)
{
(void) fi;
char *root_name = alloca(strlen(path));
char *real_path = alloca(max_path_out_len(path));
mount_list_t *mount;
Expand Down Expand Up @@ -1272,8 +1278,9 @@ static int afuse_chown(const char *path, uid_t uid, gid_t gid)
return retval;
}

static int afuse_truncate(const char *path, off_t size)
static int afuse_truncate(const char *path, off_t size, struct fuse_file_info *fi)
{
(void) fi;
char *root_name = alloca(strlen(path));
char *real_path = alloca(max_path_out_len(path));
mount_list_t *mount;
Expand Down Expand Up @@ -1301,8 +1308,9 @@ static int afuse_truncate(const char *path, off_t size)
return retval;
}

static int afuse_utime(const char *path, struct utimbuf *buf)
static int afuse_utimens(const char *path, const struct timespec tv[2], struct fuse_file_info *fi)
{
(void) fi;
char *root_name = alloca(strlen(path));
char *real_path = alloca(max_path_out_len(path));
mount_list_t *mount;
Expand All @@ -1322,7 +1330,7 @@ static int afuse_utime(const char *path, struct utimbuf *buf)
break;
}
case PROC_PATH_PROXY_DIR:
retval = get_retval(utime(real_path, buf));
retval = get_retval(utimensat(AT_FDCWD, real_path, tv, AT_SYMLINK_NOFOLLOW));
break;

default:
Expand Down Expand Up @@ -1472,13 +1480,6 @@ static int afuse_access(const char *path, int mask)
return retval;
}

static int afuse_ftruncate(const char *path, off_t size,
struct fuse_file_info *fi)
{
(void)path;
return get_retval(ftruncate(fi->fh, size));
}

static int afuse_create(const char *path, mode_t mode,
struct fuse_file_info *fi)
{
Expand Down Expand Up @@ -1516,13 +1517,6 @@ static int afuse_create(const char *path, mode_t mode,
return retval;
}

static int afuse_fgetattr(const char *path, struct stat *stbuf,
struct fuse_file_info *fi)
{
(void)path;

return get_retval(fstat(fi->fh, stbuf));
}
#endif

#if FUSE_VERSION >= 25
Expand Down Expand Up @@ -1736,7 +1730,7 @@ static struct fuse_operations afuse_oper = {
.chmod = afuse_chmod,
.chown = afuse_chown,
.truncate = afuse_truncate,
.utime = afuse_utime,
.utimens = afuse_utimens,
.open = afuse_open,
.read = afuse_read,
.write = afuse_write,
Expand All @@ -1746,8 +1740,6 @@ static struct fuse_operations afuse_oper = {
#if FUSE_VERSION >= 25
.access = afuse_access,
.create = afuse_create,
.ftruncate = afuse_ftruncate,
.fgetattr = afuse_fgetattr,
#endif
.destroy = afuse_destroy,
#ifdef HAVE_SETXATTR
Expand Down Expand Up @@ -1838,7 +1830,7 @@ static int afuse_opt_proc(void *data, const char *arg, int key,
case KEY_HELP:
usage(outargs->argv[0]);
fuse_opt_add_arg(outargs, "-ho");
fuse_main(outargs->argc, outargs->argv, &afuse_oper);
fuse_main(outargs->argc, outargs->argv, &afuse_oper, NULL);
exit(1);

case KEY_FLUSHWRITES:
Expand Down Expand Up @@ -1905,7 +1897,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "(Un)Mount command templates missing.\n\n");
usage(argv[0]);
fuse_opt_add_arg(&args, "-ho");
fuse_main(args.argc, args.argv, &afuse_oper);
fuse_main(args.argc, args.argv, &afuse_oper, NULL);

return 1;
}
Expand All @@ -1932,5 +1924,5 @@ int main(int argc, char *argv[])
umask(0);

// !!FIXME!! death by signal doesn't unmount fs
return fuse_main(args.argc, args.argv, &afuse_oper);
return fuse_main(args.argc, args.argv, &afuse_oper, NULL);
}