Miklos Szeredi | f830a7f | 2001-11-16 17:46:45 +0000 | [diff] [blame] | 1 | /* |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 2 | FUSE: Filesystem in Userspace |
| 3 | Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> |
Sebastian Pipping | c605b5f | 2011-06-25 19:14:29 +0200 | [diff] [blame] | 4 | Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org> |
Miklos Szeredi | f830a7f | 2001-11-16 17:46:45 +0000 | [diff] [blame] | 5 | |
Dr. David Alan Gilbert | 252e978 | 2020-03-13 16:46:44 +0000 | [diff] [blame] | 6 | This program can be distributed under the terms of the GNU GPLv2. |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 7 | See the file COPYING. |
Miklos Szeredi | f830a7f | 2001-11-16 17:46:45 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Joachim Schiele | ea7227d | 2013-06-20 19:18:18 +0200 | [diff] [blame] | 10 | /** @file |
Joachim Schiele | ea7227d | 2013-06-20 19:18:18 +0200 | [diff] [blame] | 11 | * |
Nikolaus Rath | 463189c | 2016-10-09 19:22:57 -0700 | [diff] [blame] | 12 | * This file system mirrors the existing file system hierarchy of the |
| 13 | * system, starting at the root file system. This is implemented by |
| 14 | * just "passing through" all requests to the corresponding user-space |
Jay Hankins | d6d3e50 | 2016-12-04 12:13:25 -0500 | [diff] [blame] | 15 | * libc functions. Its performance is terrible. |
Joachim Schiele | ea7227d | 2013-06-20 19:18:18 +0200 | [diff] [blame] | 16 | * |
Nikolaus Rath | 7983414 | 2016-10-28 20:44:39 -0700 | [diff] [blame] | 17 | * Compile with |
Joachim Schiele | ea7227d | 2013-06-20 19:18:18 +0200 | [diff] [blame] | 18 | * |
Nikolaus Rath | 7983414 | 2016-10-28 20:44:39 -0700 | [diff] [blame] | 19 | * gcc -Wall passthrough.c `pkg-config fuse3 --cflags --libs` -o passthrough |
Joachim Schiele | ea7227d | 2013-06-20 19:18:18 +0200 | [diff] [blame] | 20 | * |
Nikolaus Rath | 7983414 | 2016-10-28 20:44:39 -0700 | [diff] [blame] | 21 | * ## Source code ## |
Nikolaus Rath | 463189c | 2016-10-09 19:22:57 -0700 | [diff] [blame] | 22 | * \include passthrough.c |
Joachim Schiele | ea7227d | 2013-06-20 19:18:18 +0200 | [diff] [blame] | 23 | */ |
| 24 | |
| 25 | |
Nikolaus Rath | e870a04 | 2017-07-07 15:25:41 +0200 | [diff] [blame] | 26 | #define FUSE_USE_VERSION 31 |
Miklos Szeredi | 4003dfa | 2006-10-01 13:46:02 +0000 | [diff] [blame] | 27 | |
Miklos Szeredi | ea8fdc0 | 2007-05-17 12:41:46 +0000 | [diff] [blame] | 28 | #ifdef HAVE_CONFIG_H |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 29 | #include <config.h> |
Miklos Szeredi | ea8fdc0 | 2007-05-17 12:41:46 +0000 | [diff] [blame] | 30 | #endif |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 31 | |
Niels de Vos | 2548c4b | 2018-06-26 21:40:21 +0200 | [diff] [blame] | 32 | #define _GNU_SOURCE |
| 33 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 34 | #ifdef linux |
Sebastian Pipping | c605b5f | 2011-06-25 19:14:29 +0200 | [diff] [blame] | 35 | /* For pread()/pwrite()/utimensat() */ |
| 36 | #define _XOPEN_SOURCE 700 |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 37 | #endif |
| 38 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 39 | #include <fuse.h> |
| 40 | #include <stdio.h> |
Miklos Szeredi | 074b4b9 | 2002-01-11 08:25:52 +0000 | [diff] [blame] | 41 | #include <string.h> |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 42 | #include <unistd.h> |
Miklos Szeredi | cc8c975 | 2001-11-21 10:03:39 +0000 | [diff] [blame] | 43 | #include <fcntl.h> |
Sebastian Pipping | c605b5f | 2011-06-25 19:14:29 +0200 | [diff] [blame] | 44 | #include <sys/stat.h> |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 45 | #include <dirent.h> |
| 46 | #include <errno.h> |
Alan Somers | 1f842c9 | 2019-05-15 14:35:57 -0600 | [diff] [blame] | 47 | #ifdef __FreeBSD__ |
| 48 | #include <sys/socket.h> |
| 49 | #include <sys/un.h> |
| 50 | #endif |
Miklos Szeredi | fa44077 | 2006-09-02 09:51:08 +0000 | [diff] [blame] | 51 | #include <sys/time.h> |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 52 | #ifdef HAVE_SETXATTR |
| 53 | #include <sys/xattr.h> |
| 54 | #endif |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 55 | |
Alan Somers | 1f842c9 | 2019-05-15 14:35:57 -0600 | [diff] [blame] | 56 | #include "passthrough_helpers.h" |
| 57 | |
Jean-Pierre André | bdd2d41 | 2021-03-18 10:52:30 +0100 | [diff] [blame] | 58 | static int fill_dir_plus = 0; |
| 59 | |
Nikolaus Rath | 8ee553d | 2016-10-18 21:23:22 -0700 | [diff] [blame] | 60 | static void *xmp_init(struct fuse_conn_info *conn, |
| 61 | struct fuse_config *cfg) |
| 62 | { |
| 63 | (void) conn; |
| 64 | cfg->use_ino = 1; |
Nikolaus Rath | f7c5d10 | 2017-04-06 11:47:06 -0700 | [diff] [blame] | 65 | |
| 66 | /* Pick up changes from lower filesystem right away. This is |
| 67 | also necessary for better hardlink support. When the kernel |
| 68 | calls the unlink() handler, it does not know the inode of |
| 69 | the to-be-removed entry and can therefore not invalidate |
| 70 | the cache of the associated inode - resulting in an |
| 71 | incorrect st_nlink value being reported for any remaining |
| 72 | hardlinks to this inode. */ |
| 73 | cfg->entry_timeout = 0; |
| 74 | cfg->attr_timeout = 0; |
| 75 | cfg->negative_timeout = 0; |
| 76 | |
Nikolaus Rath | 8ee553d | 2016-10-18 21:23:22 -0700 | [diff] [blame] | 77 | return NULL; |
| 78 | } |
| 79 | |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 80 | static int xmp_getattr(const char *path, struct stat *stbuf, |
| 81 | struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 82 | { |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 83 | (void) fi; |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 84 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 85 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 86 | res = lstat(path, stbuf); |
Nikolaus Rath | e6dd8ce | 2017-05-31 12:35:16 -0700 | [diff] [blame] | 87 | if (res == -1) |
| 88 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 89 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 90 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Miklos Szeredi | b0b13d1 | 2005-10-26 12:53:25 +0000 | [diff] [blame] | 93 | static int xmp_access(const char *path, int mask) |
| 94 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 95 | int res; |
Miklos Szeredi | b0b13d1 | 2005-10-26 12:53:25 +0000 | [diff] [blame] | 96 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 97 | res = access(path, mask); |
| 98 | if (res == -1) |
| 99 | return -errno; |
Miklos Szeredi | b0b13d1 | 2005-10-26 12:53:25 +0000 | [diff] [blame] | 100 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 101 | return 0; |
Miklos Szeredi | b0b13d1 | 2005-10-26 12:53:25 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 104 | static int xmp_readlink(const char *path, char *buf, size_t size) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 105 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 106 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 107 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 108 | res = readlink(path, buf, size - 1); |
| 109 | if (res == -1) |
| 110 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 111 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 112 | buf[res] = '\0'; |
| 113 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 117 | static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler, |
Eric Wong | 6bf2e6f | 2014-03-05 14:45:44 +0100 | [diff] [blame] | 118 | off_t offset, struct fuse_file_info *fi, |
| 119 | enum fuse_readdir_flags flags) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 120 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 121 | DIR *dp; |
| 122 | struct dirent *de; |
Miklos Szeredi | ab97456 | 2005-04-07 15:40:21 +0000 | [diff] [blame] | 123 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 124 | (void) offset; |
| 125 | (void) fi; |
Eric Wong | 6bf2e6f | 2014-03-05 14:45:44 +0100 | [diff] [blame] | 126 | (void) flags; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 127 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 128 | dp = opendir(path); |
| 129 | if (dp == NULL) |
| 130 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 131 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 132 | while ((de = readdir(dp)) != NULL) { |
| 133 | struct stat st; |
| 134 | memset(&st, 0, sizeof(st)); |
| 135 | st.st_ino = de->d_ino; |
| 136 | st.st_mode = de->d_type << 12; |
Jean-Pierre André | bdd2d41 | 2021-03-18 10:52:30 +0100 | [diff] [blame] | 137 | if (filler(buf, de->d_name, &st, 0, fill_dir_plus)) |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 138 | break; |
| 139 | } |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 140 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 141 | closedir(dp); |
| 142 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 145 | static int xmp_mknod(const char *path, mode_t mode, dev_t rdev) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 146 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 147 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 148 | |
Alan Somers | 1f842c9 | 2019-05-15 14:35:57 -0600 | [diff] [blame] | 149 | res = mknod_wrapper(AT_FDCWD, path, NULL, mode, rdev); |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 150 | if (res == -1) |
| 151 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 152 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 153 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 156 | static int xmp_mkdir(const char *path, mode_t mode) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 157 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 158 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 159 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 160 | res = mkdir(path, mode); |
| 161 | if (res == -1) |
| 162 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 163 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 164 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 167 | static int xmp_unlink(const char *path) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 168 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 169 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 170 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 171 | res = unlink(path); |
| 172 | if (res == -1) |
| 173 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 174 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 175 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 178 | static int xmp_rmdir(const char *path) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 179 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 180 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 181 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 182 | res = rmdir(path); |
| 183 | if (res == -1) |
| 184 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 185 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 186 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 189 | static int xmp_symlink(const char *from, const char *to) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 190 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 191 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 192 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 193 | res = symlink(from, to); |
| 194 | if (res == -1) |
| 195 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 196 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 197 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 198 | } |
| 199 | |
Miklos Szeredi | b49cf75 | 2014-07-15 18:02:19 +0200 | [diff] [blame] | 200 | static int xmp_rename(const char *from, const char *to, unsigned int flags) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 201 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 202 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 203 | |
Miklos Szeredi | b49cf75 | 2014-07-15 18:02:19 +0200 | [diff] [blame] | 204 | if (flags) |
| 205 | return -EINVAL; |
| 206 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 207 | res = rename(from, to); |
| 208 | if (res == -1) |
| 209 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 210 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 211 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 212 | } |
| 213 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 214 | static int xmp_link(const char *from, const char *to) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 215 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 216 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 217 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 218 | res = link(from, to); |
| 219 | if (res == -1) |
| 220 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 221 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 222 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 223 | } |
| 224 | |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 225 | static int xmp_chmod(const char *path, mode_t mode, |
| 226 | struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 227 | { |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 228 | (void) fi; |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 229 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 230 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 231 | res = chmod(path, mode); |
| 232 | if (res == -1) |
| 233 | return -errno; |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 234 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 235 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 238 | static int xmp_chown(const char *path, uid_t uid, gid_t gid, |
| 239 | struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 240 | { |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 241 | (void) fi; |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 242 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 243 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 244 | res = lchown(path, uid, gid); |
| 245 | if (res == -1) |
| 246 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 247 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 248 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 249 | } |
| 250 | |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 251 | static int xmp_truncate(const char *path, off_t size, |
| 252 | struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 253 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 254 | int res; |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 255 | |
Nikolaus Rath | 76218eb | 2017-04-07 16:27:59 -0700 | [diff] [blame] | 256 | if (fi != NULL) |
| 257 | res = ftruncate(fi->fh, size); |
| 258 | else |
| 259 | res = truncate(path, size); |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 260 | if (res == -1) |
| 261 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 262 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 263 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 264 | } |
| 265 | |
Emmanuel Dreyfus | 40a47ed | 2011-12-08 10:55:27 +0000 | [diff] [blame] | 266 | #ifdef HAVE_UTIMENSAT |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 267 | static int xmp_utimens(const char *path, const struct timespec ts[2], |
| 268 | struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 269 | { |
Nikolaus Rath | 73b6ff4 | 2016-10-15 18:46:27 -0700 | [diff] [blame] | 270 | (void) fi; |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 271 | int res; |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 272 | |
Emmanuel Dreyfus | 40a47ed | 2011-12-08 10:55:27 +0000 | [diff] [blame] | 273 | /* don't use utime/utimes since they follow symlinks */ |
Sebastian Pipping | c605b5f | 2011-06-25 19:14:29 +0200 | [diff] [blame] | 274 | res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW); |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 275 | if (res == -1) |
| 276 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 277 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 278 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 279 | } |
Emmanuel Dreyfus | 40a47ed | 2011-12-08 10:55:27 +0000 | [diff] [blame] | 280 | #endif |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 281 | |
Nikolaus Rath | 20b24a1 | 2017-04-07 16:36:52 -0700 | [diff] [blame] | 282 | static int xmp_create(const char *path, mode_t mode, |
| 283 | struct fuse_file_info *fi) |
| 284 | { |
| 285 | int res; |
| 286 | |
| 287 | res = open(path, fi->flags, mode); |
| 288 | if (res == -1) |
| 289 | return -errno; |
| 290 | |
| 291 | fi->fh = res; |
| 292 | return 0; |
| 293 | } |
| 294 | |
Miklos Szeredi | fb28c5e | 2004-11-26 12:15:06 +0000 | [diff] [blame] | 295 | static int xmp_open(const char *path, struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 296 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 297 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 298 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 299 | res = open(path, fi->flags); |
| 300 | if (res == -1) |
| 301 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 302 | |
Nikolaus Rath | db1c6ad | 2017-04-07 16:27:33 -0700 | [diff] [blame] | 303 | fi->fh = res; |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 304 | return 0; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 305 | } |
| 306 | |
Miklos Szeredi | fb28c5e | 2004-11-26 12:15:06 +0000 | [diff] [blame] | 307 | static int xmp_read(const char *path, char *buf, size_t size, off_t offset, |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 308 | struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 309 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 310 | int fd; |
| 311 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 312 | |
Nikolaus Rath | 0986255 | 2017-04-07 16:31:07 -0700 | [diff] [blame] | 313 | if(fi == NULL) |
| 314 | fd = open(path, O_RDONLY); |
| 315 | else |
| 316 | fd = fi->fh; |
| 317 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 318 | if (fd == -1) |
| 319 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 320 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 321 | res = pread(fd, buf, size, offset); |
| 322 | if (res == -1) |
| 323 | res = -errno; |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 324 | |
Nikolaus Rath | 0986255 | 2017-04-07 16:31:07 -0700 | [diff] [blame] | 325 | if(fi == NULL) |
| 326 | close(fd); |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 327 | return res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 328 | } |
| 329 | |
Miklos Szeredi | 0a7077f | 2001-11-11 18:20:17 +0000 | [diff] [blame] | 330 | static int xmp_write(const char *path, const char *buf, size_t size, |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 331 | off_t offset, struct fuse_file_info *fi) |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 332 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 333 | int fd; |
| 334 | int res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 335 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 336 | (void) fi; |
Nikolaus Rath | 0986255 | 2017-04-07 16:31:07 -0700 | [diff] [blame] | 337 | if(fi == NULL) |
| 338 | fd = open(path, O_WRONLY); |
| 339 | else |
| 340 | fd = fi->fh; |
| 341 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 342 | if (fd == -1) |
| 343 | return -errno; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 344 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 345 | res = pwrite(fd, buf, size, offset); |
| 346 | if (res == -1) |
| 347 | res = -errno; |
Miklos Szeredi | e518374 | 2005-02-02 11:14:04 +0000 | [diff] [blame] | 348 | |
Nikolaus Rath | 0986255 | 2017-04-07 16:31:07 -0700 | [diff] [blame] | 349 | if(fi == NULL) |
| 350 | close(fd); |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 351 | return res; |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 352 | } |
| 353 | |
Miklos Szeredi | 52cb09d | 2005-11-07 11:59:00 +0000 | [diff] [blame] | 354 | static int xmp_statfs(const char *path, struct statvfs *stbuf) |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame] | 355 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 356 | int res; |
Miklos Szeredi | 18e75e4 | 2004-02-19 14:23:27 +0000 | [diff] [blame] | 357 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 358 | res = statvfs(path, stbuf); |
| 359 | if (res == -1) |
| 360 | return -errno; |
Miklos Szeredi | 18e75e4 | 2004-02-19 14:23:27 +0000 | [diff] [blame] | 361 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 362 | return 0; |
Mark Glines | d84b39a | 2002-01-07 16:32:02 +0000 | [diff] [blame] | 363 | } |
| 364 | |
Miklos Szeredi | fb28c5e | 2004-11-26 12:15:06 +0000 | [diff] [blame] | 365 | static int xmp_release(const char *path, struct fuse_file_info *fi) |
David McNab | 7a19caf | 2003-12-13 02:05:46 +0000 | [diff] [blame] | 366 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 367 | (void) path; |
Nikolaus Rath | db1c6ad | 2017-04-07 16:27:33 -0700 | [diff] [blame] | 368 | close(fi->fh); |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 369 | return 0; |
David McNab | 7a19caf | 2003-12-13 02:05:46 +0000 | [diff] [blame] | 370 | } |
| 371 | |
Miklos Szeredi | fb28c5e | 2004-11-26 12:15:06 +0000 | [diff] [blame] | 372 | static int xmp_fsync(const char *path, int isdatasync, |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 373 | struct fuse_file_info *fi) |
David McNab | 7a19caf | 2003-12-13 02:05:46 +0000 | [diff] [blame] | 374 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 375 | /* Just a stub. This method is optional and can safely be left |
| 376 | unimplemented */ |
Miklos Szeredi | 2f3d940 | 2003-12-15 12:11:33 +0000 | [diff] [blame] | 377 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 378 | (void) path; |
| 379 | (void) isdatasync; |
| 380 | (void) fi; |
| 381 | return 0; |
David McNab | 7a19caf | 2003-12-13 02:05:46 +0000 | [diff] [blame] | 382 | } |
| 383 | |
Anatol Pomozov | 96ac0e5 | 2012-04-22 18:49:35 -0700 | [diff] [blame] | 384 | #ifdef HAVE_POSIX_FALLOCATE |
| 385 | static int xmp_fallocate(const char *path, int mode, |
| 386 | off_t offset, off_t length, struct fuse_file_info *fi) |
| 387 | { |
| 388 | int fd; |
| 389 | int res; |
| 390 | |
| 391 | (void) fi; |
| 392 | |
| 393 | if (mode) |
| 394 | return -EOPNOTSUPP; |
| 395 | |
Nikolaus Rath | 0986255 | 2017-04-07 16:31:07 -0700 | [diff] [blame] | 396 | if(fi == NULL) |
| 397 | fd = open(path, O_WRONLY); |
| 398 | else |
| 399 | fd = fi->fh; |
| 400 | |
Anatol Pomozov | 96ac0e5 | 2012-04-22 18:49:35 -0700 | [diff] [blame] | 401 | if (fd == -1) |
| 402 | return -errno; |
| 403 | |
| 404 | res = -posix_fallocate(fd, offset, length); |
| 405 | |
Nikolaus Rath | 0986255 | 2017-04-07 16:31:07 -0700 | [diff] [blame] | 406 | if(fi == NULL) |
| 407 | close(fd); |
Anatol Pomozov | 96ac0e5 | 2012-04-22 18:49:35 -0700 | [diff] [blame] | 408 | return res; |
| 409 | } |
| 410 | #endif |
| 411 | |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 412 | #ifdef HAVE_SETXATTR |
| 413 | /* xattr operations are optional and can safely be left unimplemented */ |
| 414 | static int xmp_setxattr(const char *path, const char *name, const char *value, |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 415 | size_t size, int flags) |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 416 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 417 | int res = lsetxattr(path, name, value, size, flags); |
| 418 | if (res == -1) |
| 419 | return -errno; |
| 420 | return 0; |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | static int xmp_getxattr(const char *path, const char *name, char *value, |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 424 | size_t size) |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 425 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 426 | int res = lgetxattr(path, name, value, size); |
| 427 | if (res == -1) |
| 428 | return -errno; |
| 429 | return res; |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | static int xmp_listxattr(const char *path, char *list, size_t size) |
| 433 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 434 | int res = llistxattr(path, list, size); |
| 435 | if (res == -1) |
| 436 | return -errno; |
| 437 | return res; |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | static int xmp_removexattr(const char *path, const char *name) |
| 441 | { |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 442 | int res = lremovexattr(path, name); |
| 443 | if (res == -1) |
| 444 | return -errno; |
| 445 | return 0; |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 446 | } |
| 447 | #endif /* HAVE_SETXATTR */ |
| 448 | |
Niels de Vos | 2548c4b | 2018-06-26 21:40:21 +0200 | [diff] [blame] | 449 | #ifdef HAVE_COPY_FILE_RANGE |
| 450 | static ssize_t xmp_copy_file_range(const char *path_in, |
| 451 | struct fuse_file_info *fi_in, |
| 452 | off_t offset_in, const char *path_out, |
| 453 | struct fuse_file_info *fi_out, |
| 454 | off_t offset_out, size_t len, int flags) |
| 455 | { |
| 456 | int fd_in, fd_out; |
| 457 | ssize_t res; |
| 458 | |
| 459 | if(fi_in == NULL) |
| 460 | fd_in = open(path_in, O_RDONLY); |
| 461 | else |
| 462 | fd_in = fi_in->fh; |
| 463 | |
| 464 | if (fd_in == -1) |
| 465 | return -errno; |
| 466 | |
| 467 | if(fi_out == NULL) |
| 468 | fd_out = open(path_out, O_WRONLY); |
| 469 | else |
| 470 | fd_out = fi_out->fh; |
| 471 | |
| 472 | if (fd_out == -1) { |
| 473 | close(fd_in); |
| 474 | return -errno; |
| 475 | } |
| 476 | |
| 477 | res = copy_file_range(fd_in, &offset_in, fd_out, &offset_out, len, |
| 478 | flags); |
| 479 | if (res == -1) |
| 480 | res = -errno; |
| 481 | |
Alan Somers | ccba27f | 2021-01-01 12:34:58 -0700 | [diff] [blame] | 482 | if (fi_out == NULL) |
| 483 | close(fd_out); |
| 484 | if (fi_in == NULL) |
| 485 | close(fd_in); |
Niels de Vos | 2548c4b | 2018-06-26 21:40:21 +0200 | [diff] [blame] | 486 | |
| 487 | return res; |
| 488 | } |
| 489 | #endif |
| 490 | |
Yuri Per | d735af9 | 2019-11-03 11:44:31 +0200 | [diff] [blame] | 491 | static off_t xmp_lseek(const char *path, off_t off, int whence, struct fuse_file_info *fi) |
| 492 | { |
| 493 | int fd; |
| 494 | off_t res; |
| 495 | |
| 496 | if (fi == NULL) |
| 497 | fd = open(path, O_RDONLY); |
| 498 | else |
| 499 | fd = fi->fh; |
| 500 | |
| 501 | if (fd == -1) |
| 502 | return -errno; |
| 503 | |
| 504 | res = lseek(fd, off, whence); |
| 505 | if (res == -1) |
| 506 | res = -errno; |
| 507 | |
| 508 | if (fi == NULL) |
| 509 | close(fd); |
| 510 | return res; |
| 511 | } |
| 512 | |
zsugabubus | 81ab7d8 | 2020-01-30 16:17:25 +0000 | [diff] [blame] | 513 | static const struct fuse_operations xmp_oper = { |
Nikolaus Rath | 8ee553d | 2016-10-18 21:23:22 -0700 | [diff] [blame] | 514 | .init = xmp_init, |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 515 | .getattr = xmp_getattr, |
| 516 | .access = xmp_access, |
| 517 | .readlink = xmp_readlink, |
| 518 | .readdir = xmp_readdir, |
| 519 | .mknod = xmp_mknod, |
| 520 | .mkdir = xmp_mkdir, |
| 521 | .symlink = xmp_symlink, |
| 522 | .unlink = xmp_unlink, |
| 523 | .rmdir = xmp_rmdir, |
| 524 | .rename = xmp_rename, |
| 525 | .link = xmp_link, |
| 526 | .chmod = xmp_chmod, |
| 527 | .chown = xmp_chown, |
| 528 | .truncate = xmp_truncate, |
Emmanuel Dreyfus | 40a47ed | 2011-12-08 10:55:27 +0000 | [diff] [blame] | 529 | #ifdef HAVE_UTIMENSAT |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 530 | .utimens = xmp_utimens, |
Emmanuel Dreyfus | 40a47ed | 2011-12-08 10:55:27 +0000 | [diff] [blame] | 531 | #endif |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 532 | .open = xmp_open, |
Nikolaus Rath | 20b24a1 | 2017-04-07 16:36:52 -0700 | [diff] [blame] | 533 | .create = xmp_create, |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 534 | .read = xmp_read, |
| 535 | .write = xmp_write, |
| 536 | .statfs = xmp_statfs, |
| 537 | .release = xmp_release, |
| 538 | .fsync = xmp_fsync, |
Anatol Pomozov | 96ac0e5 | 2012-04-22 18:49:35 -0700 | [diff] [blame] | 539 | #ifdef HAVE_POSIX_FALLOCATE |
| 540 | .fallocate = xmp_fallocate, |
| 541 | #endif |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 542 | #ifdef HAVE_SETXATTR |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 543 | .setxattr = xmp_setxattr, |
| 544 | .getxattr = xmp_getxattr, |
| 545 | .listxattr = xmp_listxattr, |
| 546 | .removexattr = xmp_removexattr, |
Miklos Szeredi | 03cebae | 2004-03-31 10:19:18 +0000 | [diff] [blame] | 547 | #endif |
Niels de Vos | 2548c4b | 2018-06-26 21:40:21 +0200 | [diff] [blame] | 548 | #ifdef HAVE_COPY_FILE_RANGE |
| 549 | .copy_file_range = xmp_copy_file_range, |
| 550 | #endif |
Yuri Per | d735af9 | 2019-11-03 11:44:31 +0200 | [diff] [blame] | 551 | .lseek = xmp_lseek, |
Miklos Szeredi | 680a69a | 2001-11-16 13:31:14 +0000 | [diff] [blame] | 552 | }; |
| 553 | |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 554 | int main(int argc, char *argv[]) |
| 555 | { |
Jean-Pierre André | bdd2d41 | 2021-03-18 10:52:30 +0100 | [diff] [blame] | 556 | enum { MAX_ARGS = 10 }; |
| 557 | int i,new_argc; |
| 558 | char *new_argv[MAX_ARGS]; |
| 559 | |
Miklos Szeredi | cdb8b79 | 2007-12-12 14:25:40 +0000 | [diff] [blame] | 560 | umask(0); |
Jean-Pierre André | bdd2d41 | 2021-03-18 10:52:30 +0100 | [diff] [blame] | 561 | /* Process the "--plus" option apart */ |
| 562 | for (i=0, new_argc=0; (i<argc) && (new_argc<MAX_ARGS); i++) { |
| 563 | if (!strcmp(argv[i], "--plus")) { |
| 564 | fill_dir_plus = FUSE_FILL_DIR_PLUS; |
| 565 | } else { |
| 566 | new_argv[new_argc++] = argv[i]; |
| 567 | } |
| 568 | } |
| 569 | return fuse_main(new_argc, new_argv, &xmp_oper, NULL); |
Miklos Szeredi | 2df1c04 | 2001-11-06 15:07:17 +0000 | [diff] [blame] | 570 | } |