fuse2fs: many fixes and improvements
PATCH 3/5 fuse2fs: many fixes and improvements
Hi all,
This series fixes many many bugs in fuse2fs.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
Comments and questions are, as always, welcome.
e2fsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/e2fsprogs.git/log/?h=fuse2fs-fixes
---
Commits in this patchset:
* fuse2fs: refuse unsupported features
* fuse2fs: return -EOPNOTSUPP when we don't recognize a fallocate mode
* fuse2fs: implement zero range
* fuse2fs: remove posix acl translation
* fuse2fs: log names of xattrs being set/get/removed
* fuse2fs: add an easy option for emulating kernel access behaviors
* fuse2fs: report nanoseconds resolution through getattr
* fuse2fs: clamp timestamps that are being written to disk
* fuse2fs: add supportable mount options from the kernel
* fuse2fs: support getting and setting via struct fsxattr
* fuse2fs: support changing newer iflags
* fuse2fs: update new child timestamps during mkdir/symlink
* fuse2fs: report real inode numbers
* fuse2fs: disable renameat2
* fuse2fs: fix FITRIM validation
* fuse2fs: report inode number and file type via readdir
--- lib/ext2fs/ext2_fs.h | 4 misc/fuse2fs.1.in | 9 + misc/fuse2fs.c | 629 ++++++++++++++++++++++++++------------------------ 3 files changed, 341 insertions(+), 301 deletions(-)
PATCH 1/16 fuse2fs: refuse unsupported features
From: Darrick J. Wong <[email protected]>
Don't mount a filesystem with superblock features that we don't actually know how to support.
--- misc/fuse2fs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
misc/fuse2fs.c +20 -0
@@ -3902,6 +3902,26 @@ int main(int argc, char *argv[]) ret =3 ; +if (ext2fs_has_feature_quota (global_fs->super)) { +err_printf (&fctx,"%s" ,_ ("quotas not supported." )); + goto out; + } +if (ext2fs_has_feature_verity (global_fs->super)) { +err_printf (&fctx,"%s" ,_ ("verity not supported." )); + goto out; + } +if (ext2fs_has_feature_encrypt (global_fs->super)) { +err_printf (&fctx,"%s" ,_ ("encryption not supported." )); + goto out; + } +if (ext2fs_has_feature_casefold (global_fs->super)) { +err_printf (&fctx,"%s" ,_ ("casefolding not supported." )); + goto out; + } + +if (ext2fs_has_feature_shared_blocks (global_fs->super)) + fctx.ro =1 ; +if (ext2fs_has_feature_journal_needs_recovery (global_fs->super)) {if (fctx.norecovery) { log_printf(&fctx, "%s\n",
PATCH 2/16 fuse2fs: return -EOPNOTSUPP when we don't recognize a fallocate mode
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
If we don't recognize a set bit in the mode parameter to fallocate, return EOPNOTSUPP to communicate that we don't support that mode instead of EINVAL. This avoids unnecessary failures in generic/521 such as:
generic/521 - output mismatch (see /var/tmp/fstests/generic/521.out.bad)
--- tests/generic/521.out 2025-01-30 10:00:16.898276477 -0800
+++ /var/tmp/fstests/generic/521.out.bad 2025-04-03 14:46:20.019822396 -0700
@@ -1,2 +1,9 @@
QA output created by 521
+zero range: 0x407ca to 0x52885
+do_zero_range: fallocate: Invalid argument--- misc/fuse2fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
misc/fuse2fs.c +1 -1
@@ -3630,7 +3630,7 @@ static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode,/* Catch unknown flags */ if (mode & ~(FL_PUNCH_HOLE_FLAG |FL_KEEP_SIZE_FLAG )) -return -EINVAL ; +return -EOPNOTSUPP ;pthread_mutex_lock (&ff->bfl);if (!fs_writeable (fs)) {
PATCH 3/16 fuse2fs: implement zero range
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Implement FALLOC_FL_ZERO_RANGE.
--- misc/fuse2fs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
misc/fuse2fs.c +19 -1
@@ -123,6 +123,12 @@ static ext2_filsys global_fs; /* Try not to use this directly */# define FL_PUNCH_HOLE_FLAG (0)#endif +#ifdef FALLOC_FL_ZERO_RANGE +# define FL_ZERO_RANGE_FLAG FALLOC_FL_ZERO_RANGE +#else +# define FL_ZERO_RANGE_FLAG (0) +#endif +errcode_t ext2fs_run_ext3_journal (ext2_filsys *fs);#ifdef CONFIG_JBD_DEBUG /* Enabled by configure --enable-jbd-debug */
@@ -3619,6 +3625,16 @@ static int punch_helper(struct fuse_file_info *fp, int mode, off_t offset,return 0 ; } +static int zero_helper (struct fuse_file_info *fp,int mode,off_t offset, +off_t len) +{ +int ret =punch_helper (fp, mode |FL_KEEP_SIZE_FLAG , offset, len); + +if (!ret) + ret =fallocate_helper (fp, mode, offset, len); +return ret; +} + static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode, off_t offset, off_t len, struct fuse_file_info *fp)
@@ -3637,7 +3653,9 @@ static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode, ret = -EROFS ; goto out; } -if (mode &FL_PUNCH_HOLE_FLAG ) +if (mode &FL_ZERO_RANGE_FLAG ) + ret =zero_helper (fp, mode, offset, len); +else if (mode &FL_PUNCH_HOLE_FLAG ) ret =punch_helper (fp, mode, offset, len);else ret =fallocate_helper (fp, mode, offset, len);
PATCH 4/16 fuse2fs: remove posix acl translation
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Remove the POSIX ACL format translation since libext2fs takes care of that now.
--- misc/fuse2fs.c | 267 +------------------------------------------------------- 1 file changed, 4 insertions(+), 263 deletions(-)
misc/fuse2fs.c +4 -263
@@ -17,12 +17,6 @@# include <linux/fs.h> # include <linux/falloc.h> # include <linux/xattr.h> -# ifdef HAVE_SYS_ACL_H -# define TRANSLATE_LINUX_ACLS -# endif -#endif -#ifdef TRANSLATE_LINUX_ACLS -# include <sys/acl.h> #endif #include <sys/ioctl.h> #include <unistd.h>
@@ -135,206 +129,6 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs);int journal_enable_debug =-1 ;#endif -/* ACL translation stuff */ -#ifdef TRANSLATE_LINUX_ACLS -/* -* Copied from acl_ea.h in libacl source; ACLs have to be sent to and from fuse -* in this format... at least on Linux. -*/ -#define ACL_EA_ACCESS "system.posix_acl_access" -#define ACL_EA_DEFAULT "system.posix_acl_default" - -#define ACL_EA_VERSION 0x0002 - -typedef struct { -u_int16_t e_tag; -u_int16_t e_perm; -u_int32_t e_id; -}acl_ea_entry ; - -typedef struct { -u_int32_t a_version; -#if __GNUC_PREREQ (4 ,8 ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpedantic" -#endif -acl_ea_entry a_entries[0 ]; -#if __GNUC_PREREQ (4 ,8 ) -#pragma GCC diagnostic pop -#endif -}acl_ea_header ; - -static inline size_t acl_ea_size (int count) -{ -return sizeof (acl_ea_header) + count *sizeof (acl_ea_entry); -} - -static inline int acl_ea_count (size_t size) -{ -if (size <sizeof (acl_ea_header)) -return -1 ; - size -=sizeof (acl_ea_header); -if (size %sizeof (acl_ea_entry)) -return -1 ; -return size /sizeof (acl_ea_entry); -} - -/* -* ext4 ACL structures, copied from fs/ext4/acl.h. -*/ -#define EXT4_ACL_VERSION 0x0001 - -typedef struct { -__u16 e_tag; -__u16 e_perm; -__u32 e_id; -}ext4_acl_entry ; - -typedef struct { -__u16 e_tag; -__u16 e_perm; -}ext4_acl_entry_short ; - -typedef struct { -__u32 a_version; -}ext4_acl_header ; - -static inline size_t ext4_acl_size (int count) -{ -if (count <=4 ) { -return sizeof (ext4_acl_header) + - count *sizeof (ext4_acl_entry_short); - }else { -return sizeof (ext4_acl_header) + -4 *sizeof (ext4_acl_entry_short) + - (count -4 ) *sizeof (ext4_acl_entry); - } -} - -static inline int ext4_acl_count (size_t size) -{ -ssize_t s; - - size -=sizeof (ext4_acl_header); - s = size -4 *sizeof (ext4_acl_entry_short); -if (s <0 ) { -if (size %sizeof (ext4_acl_entry_short)) -return -1 ; -return size /sizeof (ext4_acl_entry_short); - } -if (s %sizeof (ext4_acl_entry)) -return -1 ; -return s /sizeof (ext4_acl_entry) +4 ; -} - -static errcode_t fuse_to_ext4_acl (acl_ea_header *facl,size_t facl_sz, -ext4_acl_header **eacl,size_t *eacl_sz) -{ -int i, facl_count; -ext4_acl_header *h; -size_t h_sz; -ext4_acl_entry *e; -acl_ea_entry *a; -unsigned char *hptr; -errcode_t err; - - facl_count =acl_ea_count (facl_sz); - h_sz =ext4_acl_size (facl_count); -if (facl_count <0 || facl->a_version !=ACL_EA_VERSION ) -return EXT2_ET_INVALID_ARGUMENT ; - - err =ext2fs_get_mem (h_sz, &h); -if (err) -return err; - - h->a_version =ext2fs_cpu_to_le32 (EXT4_ACL_VERSION ); - hptr = (unsigned char *) (h +1 ); -for (i =0 , a = facl->a_entries; i < facl_count; i++, a++) { - e = (ext4_acl_entry *) hptr; - e->e_tag =ext2fs_cpu_to_le16 (a->e_tag); - e->e_perm =ext2fs_cpu_to_le16 (a->e_perm); - -switch (a->e_tag) { -case ACL_USER : -case ACL_GROUP : - e->e_id =ext2fs_cpu_to_le32 (a->e_id); - hptr +=sizeof (ext4_acl_entry); -break ; -case ACL_USER_OBJ : -case ACL_GROUP_OBJ : -case ACL_MASK : -case ACL_OTHER : - hptr +=sizeof (ext4_acl_entry_short); -break ; -default : - err =EXT2_ET_INVALID_ARGUMENT ; - goto out; - } - } - - *eacl = h; - *eacl_sz = h_sz; -return err; -out: -ext2fs_free_mem (&h); -return err; -} - -static errcode_t ext4_to_fuse_acl (acl_ea_header **facl,size_t *facl_sz, -ext4_acl_header *eacl,size_t eacl_sz) -{ -int i, eacl_count; -acl_ea_header *f; -ext4_acl_entry *e; -acl_ea_entry *a; -size_t f_sz; -unsigned char *hptr; -errcode_t err; - - eacl_count =ext4_acl_count (eacl_sz); - f_sz =acl_ea_size (eacl_count); -if (eacl_count <0 || - eacl->a_version !=ext2fs_cpu_to_le32 (EXT4_ACL_VERSION )) -return EXT2_ET_INVALID_ARGUMENT ; - - err =ext2fs_get_mem (f_sz, &f); -if (err) -return err; - - f->a_version =ACL_EA_VERSION ; - hptr = (unsigned char *) (eacl +1 ); -for (i =0 , a = f->a_entries; i < eacl_count; i++, a++) { - e = (ext4_acl_entry *) hptr; - a->e_tag =ext2fs_le16_to_cpu (e->e_tag); - a->e_perm =ext2fs_le16_to_cpu (e->e_perm); - -switch (a->e_tag) { -case ACL_USER : -case ACL_GROUP : - a->e_id =ext2fs_le32_to_cpu (e->e_id); - hptr +=sizeof (ext4_acl_entry); -break ; -case ACL_USER_OBJ : -case ACL_GROUP_OBJ : -case ACL_MASK : -case ACL_OTHER : - hptr +=sizeof (ext4_acl_entry_short); -break ; -default : - err =EXT2_ET_INVALID_ARGUMENT ; - goto out; - } - } - - *facl = f; - *facl_sz = f_sz; -return err; -out: -ext2fs_free_mem (&f); -return err; -} -#endif /* TRANSLATE_LINUX_ACLS */ -/* * ext2_file_t contains a struct inode, so we can't leave files open. * Use this as a proxy instead.
@@ -2451,30 +2245,6 @@ static int op_statfs(const char *path EXT2FS_ATTR((unused)),return 0 ; } -typedef errcode_t (*xattr_xlate_get )(void **cooked_buf,size_t *cooked_sz, -const void *raw_buf,size_t raw_sz); -typedef errcode_t (*xattr_xlate_set )(const void *cooked_buf,size_t cooked_sz, -const void **raw_buf,size_t *raw_sz); -struct xattr_translate { -const char *prefix; -xattr_xlate_get get; -xattr_xlate_set set; -}; - -#define XATTR_TRANSLATOR (p, g, s) \ - {.prefix = (p), \ - .get = (xattr_xlate_get)(g), \ - .set = (xattr_xlate_set)(s)} - -static struct xattr_translate xattr_translators[] = { -#ifdef TRANSLATE_LINUX_ACLS -XATTR_TRANSLATOR (ACL_EA_ACCESS , ext4_to_fuse_acl, fuse_to_ext4_acl), -XATTR_TRANSLATOR (ACL_EA_DEFAULT , ext4_to_fuse_acl, fuse_to_ext4_acl), -#endif - XATTR_TRANSLATOR(NULL, NULL, NULL), -}; -#undef XATTR_TRANSLATOR -static int op_getxattr (const char *path,const char *key,char *value,size_t len) {
@@ -2482,9 +2252,8 @@ static int op_getxattr(const char *path, const char *key, char *value,struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;ext2_filsys fs;struct ext2_xattr_handle *h; -struct xattr_translate *xt; -void *ptr, *cptr; -size_t plen, clen; +void *ptr; +size_t plen;ext2_ino_t ino;errcode_t err;int ret =0 ;
@@ -2526,17 +2295,6 @@ static int op_getxattr(const char *path, const char *key, char *value, goto out2; } -for (xt = xattr_translators; xt->prefix !=NULL ; xt++) { -if (strncmp (key, xt->prefix,strlen (xt->prefix)) ==0 ) { - err = xt->get (&cptr, &clen, ptr, plen); -if (err) - goto out3; -ext2fs_free_mem (&ptr); - ptr = cptr; - plen = clen; - } - } -if (!len) { ret = plen; }else if (len < plen) {
@@ -2546,7 +2304,6 @@ static int op_getxattr(const char *path, const char *key, char *value, ret = plen; } -out3:ext2fs_free_mem (&ptr); out2: err =ext2fs_xattrs_close (&h);
@@ -2664,9 +2421,6 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)),struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;ext2_filsys fs;struct ext2_xattr_handle *h; -struct xattr_translate *xt; -const void *cvalue; -size_t clen;ext2_ino_t ino;errcode_t err;int ret =0 ;
@@ -2705,26 +2459,13 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)), goto out2; } - cvalue = value; - clen = len; -for (xt = xattr_translators; xt->prefix !=NULL ; xt++) { -if (strncmp (key, xt->prefix,strlen (xt->prefix)) ==0 ) { - err = xt->set (value, len, &cvalue, &clen); -if (err) - goto out3; - } - } - - err =ext2fs_xattr_set (h, key, cvalue, clen); + err =ext2fs_xattr_set (h, key, value, len);if (err) { ret =translate_error (fs, ino, err); - goto out3; + goto out2; } ret =update_ctime (fs, ino,NULL ); -out3: -if (cvalue != value) -ext2fs_free_mem (&cvalue); out2: err =ext2fs_xattrs_close (&h);if (!ret && err)
PATCH 5/16 fuse2fs: log names of xattrs being set/get/removed
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Actually record the names of the xattrs being modified to make it easier to debug fstests failures.
--- misc/fuse2fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
misc/fuse2fs.c +3 -3
@@ -2271,7 +2271,7 @@ static int op_getxattr(const char *path, const char *key, char *value, ret =translate_error (fs,0 , err); goto out; } -dbg_printf (ff,"%s: ino=%d\n" , __func__, ino); +dbg_printf (ff,"%s: ino=%d name=%s\n" , __func__, ino, key); ret =check_inum_access (fs, ino,R_OK );if (ret)
@@ -2438,7 +2438,7 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)), ret =translate_error (fs,0 , err); goto out; } -dbg_printf (ff,"%s: ino=%d\n" , __func__, ino); +dbg_printf (ff,"%s: ino=%d name=%s\n" , __func__, ino, key); ret =check_inum_access (fs, ino,W_OK );if (ret == -EACCES ) {
@@ -2504,7 +2504,7 @@ static int op_removexattr(const char *path, const char *key) ret =translate_error (fs,0 , err); goto out; } -dbg_printf (ff,"%s: ino=%d\n" , __func__, ino); +dbg_printf (ff,"%s: ino=%d name=%s\n" , __func__, ino, key); ret =check_inum_access (fs, ino,W_OK );if (ret)
PATCH 6/16 fuse2fs: add an easy option for emulating kernel access behaviors
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
By default, fuse doesn't allow processes with a uid/gid that don't match those of the server process to access the fuse mount, it doesn't allow suid files or devices, and it relies on the fuse server to perform permissions checking. This is a secure default for very untrusted filesystems, but it's possible that we might actually want to allow general access to an ext4 filesystem as part of containerizing the ext4 metadata parsing. In other words, we want the kernel access control behavior.
Add an "kernel" mount option that moves most of the access permissions interpretation back into the kernel, and logs mount/unmount/error messages to dmesg. Right now this is mostly useful for fstests, so we leave it off by default.
--- misc/fuse2fs.1.in | 9 +++++++++ misc/fuse2fs.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
misc/fuse2fs.1.in +9 -0
@@ -53,6 +53,15 @@ .SS "fuse2fs options:" .TP \fB-o\fR fuse2fs_debug enable fuse2fs debugging +.TP +.BR -o kernel +Behave more like the kernel ext4 driver in the following ways: +Allows processes owned by other users to access the filesystem. +Uses the kernel's permissions checking logic instead of fuse2fs's. +Enables setuid and device files. +Note that these options can still be overridden (e.g. +.I nosuid +) later. .SS "FUSE options:" .TP \fB-d -o\fR debug
misc/fuse2fs.c +30 -0
@@ -52,6 +52,7 @@#endif #include "../version.h" +#include "uuid/uuid.h" #ifdef ENABLE_NLS #include <libintl.h>
@@ -156,6 +157,7 @@ struct fuse2fs {int fakeroot;int alloc_all_blocks;int norecovery; +int kernel;unsigned long offset;unsigned int next_generation; };
@@ -556,6 +558,13 @@ static void op_destroy(void *p EXT2FS_ATTR((unused)))if (err)translate_error (fs,0 , err); } + +if (ff->kernel) { +char uuid[UUID_STR_SIZE ]; + +uuid_unparse (fs->super->s_uuid, uuid); +log_printf (ff,"%s %s.\n" ,_ ("unmounting filesystem" ), uuid); + } } static void *op_init(struct fuse_conn_info *conn
@@ -589,6 +598,13 @@ static void *op_init(struct fuse_conn_info *conn }if (ff->debug) cfg->debug =1 ; + +if (ff->kernel) { +char uuid[UUID_STR_SIZE ]; + +uuid_unparse (fs->super->s_uuid, uuid); +log_printf (ff,"%s %s.\n" ,_ ("mounted filesystem" ), uuid); + }return ff; }
@@ -3506,6 +3522,7 @@ static struct fuse_opt fuse2fs_opts[] = {FUSE2FS_OPT ("no_default_opts" , no_default_opts,1 ),FUSE2FS_OPT ("norecovery" , norecovery,1 ),FUSE2FS_OPT ("offset=%lu" , offset,0 ), +FUSE2FS_OPT ("kernel" , kernel,1 ),FUSE_OPT_KEY ("acl" ,FUSE2FS_IGNORED ), FUSE_OPT_KEY("user_xattr", FUSE2FS_IGNORED),
@@ -3551,6 +3568,8 @@ static int fuse2fs_opt_proc(void *data, const char *arg," -o offset=<bytes> similar to mount -o offset=<bytes>, mount the partition starting at <bytes>\n" " -o norecovery don't replay the journal\n" " -o fuse2fs_debug enable fuse2fs debugging\n" +" -o kernel run this as if it were the kernel, which sets:\n" +" allow_others,default_permissions,suid,dev\n" "\n" , outargs->argv[0]);if (key ==FUSE2FS_HELPFULL ) {
@@ -3636,6 +3655,13 @@ int main(int argc, char *argv[]) } stderr = fp; stdout = fp; + }else if (fctx.kernel) { +/* in kernel mode, try to log errors to the kernel log */ +FILE *fp =fopen ("/dev/ttyprintk" ,"a" ); +if (fp) { + stderr = fp; + stdout = fp; + } }/* Will we allow users to allocate every last block? */
@@ -3762,6 +3788,10 @@ int main(int argc, char *argv[])#endif } +if (fctx.kernel) +fuse_opt_insert_arg (&args,1 , +"-oallow_other,default_permissions,suid,dev" ); +if (fctx.debug) {int i;
PATCH 7/16 fuse2fs: report nanoseconds resolution through getattr
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Report the nanonseconds component of timestamps via getattr, and tell fuse that we actually support nanosecond granularity.
--- misc/fuse2fs.c | 6 ++++++ 1 file changed, 6 insertions(+)
misc/fuse2fs.c +6 -0
@@ -586,6 +586,9 @@ static void *op_init(struct fuse_conn_info *conndbg_printf (ff,"%s: dev=%s\n" , __func__, fs->device_name);#ifdef FUSE_CAP_IOCTL_DIR conn->want |=FUSE_CAP_IOCTL_DIR ; +#endif +#if FUSE_VERSION >=FUSE_MAKE_VERSION (3 ,0 ) + conn->time_gran =1 ;#endif if (fs->flags &EXT2_FLAG_RW ) { fs->super->s_mnt_count++;
@@ -635,10 +638,13 @@ static int stat_inode(ext2_filsys fs, ext2_ino_t ino, struct stat *statbuf) (struct ext2_inode *)&inode);EXT4_INODE_GET_XTIME (i_atime, &tv, &inode); statbuf->st_atime = tv.tv_sec; + statbuf->st_atim.tv_nsec = tv.tv_nsec;EXT4_INODE_GET_XTIME (i_mtime, &tv, &inode); statbuf->st_mtime = tv.tv_sec; + statbuf->st_mtim.tv_nsec = tv.tv_nsec;EXT4_INODE_GET_XTIME (i_ctime, &tv, &inode); statbuf->st_ctime = tv.tv_sec; + statbuf->st_ctim.tv_nsec = tv.tv_nsec;if (LINUX_S_ISCHR (inode.i_mode) ||LINUX_S_ISBLK (inode.i_mode)) {if (inode.i_block[0 ])
PATCH 8/16 fuse2fs: clamp timestamps that are being written to disk
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Clamp the timestamps that we write to disk to the minimum and maximum values permitted given the ondisk format. This fixes y2038 support, as tested by generic/402.
--- lib/ext2fs/ext2_fs.h | 4 ++++ misc/fuse2fs.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-)
lib/ext2fs/ext2_fs.h +4 -0
@@ -801,6 +801,10 @@ struct ext2_super_block {#define EXT2_GOOD_OLD_INODE_SIZE 128 +#define EXT4_EXTRA_TIMESTAMP_MAX (((int64_t)1 << 34) - 1 + INT32_MIN) +#define EXT4_NON_EXTRA_TIMESTAMP_MAX INT32_MAX +#define EXT4_TIMESTAMP_MIN INT32_MIN +/* * Journal inode backup types */
misc/fuse2fs.c +32 -7
@@ -227,21 +227,43 @@ static inline void ext4_decode_extra_time(struct timespec *time, __u32 extra) time->tv_nsec = ((extra) &EXT4_NSEC_MASK ) >>EXT4_EPOCH_BITS ; } +#define EXT4_CLAMP_TIMESTAMP (xtime, timespec, raw_inode) \ +do { \ + if ((timespec)->tv_sec < EXT4_TIMESTAMP_MIN) \ + (timespec)->tv_sec = EXT4_TIMESTAMP_MIN; \ + if ((timespec)->tv_sec < EXT4_TIMESTAMP_MIN) \ + (timespec)->tv_sec = EXT4_TIMESTAMP_MIN; \ + \ + if (EXT4_FITS_IN_INODE(raw_inode, xtime ## _extra)) { \ + if ((timespec)->tv_sec > EXT4_EXTRA_TIMESTAMP_MAX) \ + (timespec)->tv_sec = EXT4_EXTRA_TIMESTAMP_MAX; \ + } else { \ + if ((timespec)->tv_sec > EXT4_NON_EXTRA_TIMESTAMP_MAX) \ + (timespec)->tv_sec = EXT4_NON_EXTRA_TIMESTAMP_MAX; \ + } \ +} while (0) +#define EXT4_INODE_SET_XTIME (xtime, timespec, raw_inode) \ do { \ - (raw_inode)->xtime = (timespec)->tv_sec; \ + typeof(*(timespec)) _ts = *(timespec); \ + \ + EXT4_CLAMP_TIMESTAMP(xtime, &_ts, raw_inode); \ + (raw_inode)->xtime = _ts.tv_sec; \ if (EXT4_FITS_IN_INODE(raw_inode, xtime ## _extra)) \ (raw_inode)->xtime ## _extra = \ - ext4_encode_extra_time(timespec); \ + ext4_encode_extra_time(&_ts); \ } while (0)#define EXT4_EINODE_SET_XTIME (xtime, timespec, raw_inode) \ do { \ + typeof(*(timespec)) _ts = *(timespec); \ + \ + EXT4_CLAMP_TIMESTAMP(xtime, &_ts, raw_inode); \ if (EXT4_FITS_IN_INODE(raw_inode, xtime)) \ - (raw_inode)->xtime = (timespec)->tv_sec; \ + (raw_inode)->xtime = _ts.tv_sec; \ if (EXT4_FITS_IN_INODE(raw_inode, xtime ## _extra)) \ (raw_inode)->xtime ## _extra = \ - ext4_encode_extra_time(timespec); \ + ext4_encode_extra_time(&_ts); \ } while (0)#define EXT4_INODE_GET_XTIME (xtime, timespec, raw_inode) \
@@ -2884,7 +2906,10 @@ static int op_utimens(const char *path, const struct timespec ctv[2] ret =translate_error (fs,0 , err); goto out; } -dbg_printf (ff,"%s: ino=%d\n" , __func__, ino); +dbg_printf (ff,"%s: ino=%d atime=%lld.%ld mtime=%lld.%ld\n" , __func__, + ino, + (long long int )ctv[0 ].tv_sec, ctv[0 ].tv_nsec, + (long long int )ctv[1 ].tv_sec, ctv[1 ].tv_nsec); ret =check_inum_access (fs, ino,W_OK );if (ret)
@@ -2908,9 +2933,9 @@ static int op_utimens(const char *path, const struct timespec ctv[2]#endif /* UTIME_NOW */ #ifdef UTIME_OMIT if (tv[0 ].tv_nsec !=UTIME_OMIT ) -EXT4_INODE_SET_XTIME (i_atime, tv, &inode); +EXT4_INODE_SET_XTIME (i_atime, &tv[0 ], &inode);if (tv[1 ].tv_nsec !=UTIME_OMIT ) -EXT4_INODE_SET_XTIME (i_mtime, tv +1 , &inode); +EXT4_INODE_SET_XTIME (i_mtime, &tv[1 ], &inode);#endif /* UTIME_OMIT */ ret =update_ctime (fs, ino, &inode);if (ret)
PATCH 9/16 fuse2fs: add supportable mount options from the kernel
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Add all the kernel mount options that we can actually support.
--- misc/fuse2fs.c | 3 +++ 1 file changed, 3 insertions(+)
misc/fuse2fs.c +3 -0
@@ -3548,15 +3548,18 @@ static struct fuse_opt fuse2fs_opts[] = {FUSE2FS_OPT ("rw" , ro,0 ),FUSE2FS_OPT ("errors=panic" , panic_on_error,1 ),FUSE2FS_OPT ("minixdf" , minixdf,1 ), +FUSE2FS_OPT ("bsddf" , minixdf,0 ),FUSE2FS_OPT ("fakeroot" , fakeroot,1 ),FUSE2FS_OPT ("fuse2fs_debug" , debug,1 ),FUSE2FS_OPT ("no_default_opts" , no_default_opts,1 ),FUSE2FS_OPT ("norecovery" , norecovery,1 ), +FUSE2FS_OPT ("noload" , norecovery,1 ),FUSE2FS_OPT ("offset=%lu" , offset,0 ),FUSE2FS_OPT ("kernel" , kernel,1 ),FUSE_OPT_KEY ("acl" ,FUSE2FS_IGNORED ),FUSE_OPT_KEY ("user_xattr" ,FUSE2FS_IGNORED ), +FUSE_OPT_KEY ("noblock_validity" ,FUSE2FS_IGNORED ),FUSE_OPT_KEY ("-V" ,FUSE2FS_VERSION ), FUSE_OPT_KEY("--version", FUSE2FS_VERSION),
PATCH 10/16 fuse2fs: support getting and setting via struct fsxattr
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Support querying xfs file attributes in fuse2fs so that the vfs getattr/setattr functions continue to work.
--- misc/fuse2fs.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 153 insertions(+), 25 deletions(-)
misc/fuse2fs.c +153 -25
@@ -2953,31 +2953,41 @@ static int op_utimens(const char *path, const struct timespec ctv[2]return ret; } -#ifdef SUPPORT_I_FLAGS -static int ioctl_getflags (struct fuse2fs *ff,struct fuse2fs_file_handle *fh, -void *data) -{ -ext2_filsys fs = ff->fs; -errcode_t err; -struct ext2_inode_large inode; - -FUSE2FS_CHECK_MAGIC (fs, fh,FUSE2FS_FILE_MAGIC ); -dbg_printf (ff,"%s: ino=%d\n" , __func__, fh->ino); -memset (&inode,0 ,sizeof (inode)); - err =ext2fs_read_inode_full (fs, fh->ino, (struct ext2_inode *)&inode, -sizeof (inode)); -if (err) -return translate_error (fs, fh->ino, err); - - *(__u32 *)data = inode.i_flags &EXT2_FL_USER_VISIBLE ; -return 0 ; -} -#define FUSE2FS_MODIFIABLE_IFLAGS \ (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL | EXT2_NODUMP_FL | \ EXT2_NOATIME_FL | EXT3_JOURNAL_DATA_FL | EXT2_DIRSYNC_FL | \ EXT2_TOPDIR_FL) +static inline int set_iflags (struct ext2_inode_large *inode,__u32 iflags) +{ +if ((inode->i_flags ^ iflags) & ~FUSE2FS_MODIFIABLE_IFLAGS ) +return -EINVAL ; + + inode->i_flags = (inode->i_flags & ~FUSE2FS_MODIFIABLE_IFLAGS ) | + (iflags &FUSE2FS_MODIFIABLE_IFLAGS ); +return 0 ; +} + +#ifdef SUPPORT_I_FLAGS +static int ioctl_getflags (struct fuse2fs *ff,struct fuse2fs_file_handle *fh, +void *data) +{ +ext2_filsys fs = ff->fs; +errcode_t err; +struct ext2_inode_large inode; + +FUSE2FS_CHECK_MAGIC (fs, fh,FUSE2FS_FILE_MAGIC ); +dbg_printf (ff,"%s: ino=%d\n" , __func__, fh->ino); +memset (&inode,0 ,sizeof (inode)); + err =ext2fs_read_inode_full (fs, fh->ino, (struct ext2_inode *)&inode, +sizeof (inode)); +if (err) +return translate_error (fs, fh->ino, err); + + *(__u32 *)data = inode.i_flags &EXT2_FL_USER_VISIBLE ; +return 0 ; +} +static int ioctl_setflags (struct fuse2fs *ff,struct fuse2fs_file_handle *fh,void *data) {
@@ -2999,11 +3009,9 @@ static int ioctl_setflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,if (!ff->fakeroot && ctxt->uid !=0 &&inode_uid (inode) != ctxt->uid)return -EPERM ; -if ((inode.i_flags ^ flags) & ~FUSE2FS_MODIFIABLE_IFLAGS ) -return -EINVAL ; - - inode.i_flags = (inode.i_flags & ~FUSE2FS_MODIFIABLE_IFLAGS ) | - (flags &FUSE2FS_MODIFIABLE_IFLAGS ); + ret =set_iflags (&inode, flags); +if (ret) +return ret; ret =update_ctime (fs, fh->ino, &inode);if (ret)
@@ -3072,6 +3080,118 @@ static int ioctl_setversion(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, }#endif /* SUPPORT_I_FLAGS */ +#ifdef FS_IOC_FSGETXATTR +static __u32 iflags_to_fsxflags (__u32 iflags) +{ +__u32 xflags =0 ; + +if (iflags &FS_SYNC_FL ) + xflags |=FS_XFLAG_SYNC ; +if (iflags &FS_IMMUTABLE_FL ) + xflags |=FS_XFLAG_IMMUTABLE ; +if (iflags &FS_APPEND_FL ) + xflags |=FS_XFLAG_APPEND ; +if (iflags &FS_NODUMP_FL ) + xflags |=FS_XFLAG_NODUMP ; +if (iflags &FS_NOATIME_FL ) + xflags |=FS_XFLAG_NOATIME ; +if (iflags &FS_DAX_FL ) + xflags |=FS_XFLAG_DAX ; +if (iflags &FS_PROJINHERIT_FL ) + xflags |=FS_XFLAG_PROJINHERIT ; +return xflags; +} + +static int ioctl_fsgetxattr (struct fuse2fs *ff,struct fuse2fs_file_handle *fh, +void *data) +{ +ext2_filsys fs = ff->fs; +errcode_t err; +struct ext2_inode_large inode; +struct fsxattr *fsx = data; +unsigned int inode_size; + +FUSE2FS_CHECK_MAGIC (fs, fh,FUSE2FS_FILE_MAGIC ); +dbg_printf (ff,"%s: ino=%d\n" , __func__, fh->ino); +memset (&inode,0 ,sizeof (inode)); + err =ext2fs_read_inode_full (fs, fh->ino, (struct ext2_inode *)&inode, +sizeof (inode)); +if (err) +return translate_error (fs, fh->ino, err); + +memset (fsx,0 ,sizeof (*fsx)); + inode_size =EXT2_GOOD_OLD_INODE_SIZE + inode.i_extra_isize; +if (ext2fs_inode_includes (inode_size, i_projid)) + fsx->fsx_projid =inode_projid (inode); + fsx->fsx_xflags =iflags_to_fsxflags (inode.i_flags); +return 0 ; +} + +static __u32 fsxflags_to_iflags (__u32 xflags) +{ +__u32 iflags =0 ; + +if (xflags &FS_XFLAG_IMMUTABLE ) + iflags |=FS_IMMUTABLE_FL ; +if (xflags &FS_XFLAG_APPEND ) + iflags |=FS_APPEND_FL ; +if (xflags &FS_XFLAG_SYNC ) + iflags |=FS_SYNC_FL ; +if (xflags &FS_XFLAG_NOATIME ) + iflags |=FS_NOATIME_FL ; +if (xflags &FS_XFLAG_NODUMP ) + iflags |=FS_NODUMP_FL ; +if (xflags &FS_XFLAG_DAX ) + iflags |=FS_DAX_FL ; +if (xflags &FS_XFLAG_PROJINHERIT ) + iflags |=FS_PROJINHERIT_FL ; +return iflags; +} + +static int ioctl_fssetxattr (struct fuse2fs *ff,struct fuse2fs_file_handle *fh, +void *data) +{ +ext2_filsys fs = ff->fs; +errcode_t err; +struct ext2_inode_large inode; +int ret; +struct fuse_context *ctxt =fuse_get_context (); +struct fsxattr *fsx = data; +__u32 flags =fsxflags_to_iflags (fsx->fsx_xflags); +unsigned int inode_size; + +FUSE2FS_CHECK_MAGIC (fs, fh,FUSE2FS_FILE_MAGIC ); +dbg_printf (ff,"%s: ino=%d\n" , __func__, fh->ino); +memset (&inode,0 ,sizeof (inode)); + err =ext2fs_read_inode_full (fs, fh->ino, (struct ext2_inode *)&inode, +sizeof (inode)); +if (err) +return translate_error (fs, fh->ino, err); + +if (!ff->fakeroot && ctxt->uid !=0 &&inode_uid (inode) != ctxt->uid) +return -EPERM ; + + ret =set_iflags (&inode, flags); +if (ret) +return ret; + + inode_size =EXT2_GOOD_OLD_INODE_SIZE + inode.i_extra_isize; +if (ext2fs_inode_includes (inode_size, i_projid)) + inode.i_projid = fsx->fsx_projid; + + ret =update_ctime (fs, fh->ino, &inode); +if (ret) +return ret; + + err =ext2fs_write_inode_full (fs, fh->ino, (struct ext2_inode *)&inode, +sizeof (inode)); +if (err) +return translate_error (fs, fh->ino, err); + +return 0 ; +} +#endif /* FS_IOC_FSGETXATTR */ +#ifdef FITRIM static int ioctl_fitrim (struct fuse2fs *ff,struct fuse2fs_file_handle *fh,void *data)
@@ -3160,6 +3280,14 @@ static int op_ioctl(const char *path EXT2FS_ATTR((unused)), ret =ioctl_setversion (ff, fh, data);break ;#endif +#ifdef FS_IOC_FSGETXATTR +case FS_IOC_FSGETXATTR : + ret =ioctl_fsgetxattr (ff, fh, data); +break ; +case FS_IOC_FSSETXATTR : + ret =ioctl_fssetxattr (ff, fh, data); +break ; +#endif #ifdef FITRIM case FITRIM : ret =ioctl_fitrim (ff, fh, data);
PATCH 11/16 fuse2fs: support changing newer iflags
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Redefine FUSE2FS_MODIFIABLE_IFLAGS so that userspace can modify any flags that the kernel can, except for the ones that fuse2fs lacks the ability to change.
--- misc/fuse2fs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
misc/fuse2fs.c +2 -3
@@ -2954,9 +2954,8 @@ static int op_utimens(const char *path, const struct timespec ctv[2] }#define FUSE2FS_MODIFIABLE_IFLAGS \ - (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL | EXT2_NODUMP_FL | \ - EXT2_NOATIME_FL | EXT3_JOURNAL_DATA_FL | EXT2_DIRSYNC_FL | \ - EXT2_TOPDIR_FL) + (EXT2_FL_USER_MODIFIABLE & ~(EXT4_EXTENTS_FL | EXT4_CASEFOLD_FL | \ + EXT3_JOURNAL_DATA_FL))static inline int set_iflags (struct ext2_inode_large *inode,__u32 iflags) {
PATCH 12/16 fuse2fs: update new child timestamps during mkdir/symlink
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
These two file creation functions fail to update the timestamps of the new child file, unlike the others (mknod/creat). Fix that.
--- misc/fuse2fs.c | 2 ++ 1 file changed, 2 insertions(+)
misc/fuse2fs.c +2 -0
@@ -1016,6 +1016,7 @@ static int op_mkdir(const char *path, mode_t mode) inode.i_mode =LINUX_S_IFDIR | (mode & ~S_ISUID ) | parent_sgid; inode.i_generation = ff->next_generation++; +init_times (&inode); err =ext2fs_write_inode_full (fs, child, (struct ext2_inode *)&inode,sizeof (inode));
@@ -1390,6 +1391,7 @@ static int op_symlink(const char *src, const char *dest) inode.i_gid = ctxt->gid;ext2fs_set_i_gid_high (inode, ctxt->gid >>16 ); inode.i_generation = ff->next_generation++; +init_times (&inode); err =ext2fs_write_inode_full (fs, child, (struct ext2_inode *)&inode,sizeof (inode));
PATCH 13/16 fuse2fs: report real inode numbers
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Report real inode numbers in stat instead of letting fuse invent them for us.
--- misc/fuse2fs.c | 1 + 1 file changed, 1 insertion(+)
misc/fuse2fs.c +1 -0
@@ -611,6 +611,7 @@ static void *op_init(struct fuse_conn_info *conn#endif #if FUSE_VERSION >=FUSE_MAKE_VERSION (3 ,0 ) conn->time_gran =1 ; + cfg->use_ino =1 ;#endif if (fs->flags &EXT2_FLAG_RW ) { fs->super->s_mnt_count++;
PATCH 14/16 fuse2fs: disable renameat2
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Apparently fuse munged rename and renameat2 together into the same upcall, so we actually have to filter out nonzero flags because otherwise we do a regular rename for a RENAME_EXCHANGE/WHITEOUT, which is not what the user asked for.
--- misc/fuse2fs.c | 6 ++++++ 1 file changed, 6 insertions(+)
misc/fuse2fs.c +6 -0
@@ -1447,6 +1447,12 @@ static int op_rename(const char *from, const char *tostruct update_dotdot ud;int ret =0 ; +#if FUSE_VERSION >=FUSE_MAKE_VERSION (3 ,0 ) +/* renameat2 is not supported */ +if (flags) +return -ENOSYS ; +#endif +FUSE2FS_CHECK_CONTEXT (ff); fs = ff->fs;dbg_printf (ff,"%s: renaming %s to %s\n" , __func__, from, to);
PATCH 15/16 fuse2fs: fix FITRIM validation
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Fix the validation here to match the kernel, and report the number of blocks trimmed.
--- misc/fuse2fs.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
misc/fuse2fs.c +26 -8
@@ -3206,17 +3206,27 @@ static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, {ext2_filsys fs = ff->fs;struct fstrim_range *fr = data; -blk64_t start, end, max_blocks, b, cleared; +blk64_t start, end, max_blocks, b, cleared, minlen; +blk64_t max_blks =ext2fs_blocks_count (fs->super);errcode_t err =0 ; +if (!fs_writeable (fs)) +return -EROFS ; + start = fr->start / fs->blocksize; end = (fr->start + fr->len -1 ) / fs->blocksize; -dbg_printf (ff,"%s: start=%llu end=%llu\n" , __func__, start, end); + minlen = fr->minlen / fs->blocksize; + +if (EXT2FS_NUM_B2C (fs, minlen) >EXT2_CLUSTERS_PER_GROUP (fs->super) || + start >= max_blks || + fr->len < fs->blocksize) +return -EINVAL ; + +dbg_printf (ff,"%s: start=%llu end=%llu minlen=%llu\n" , __func__, + start, end, minlen);if (start < fs->super->s_first_data_block) start = fs->super->s_first_data_block; -if (start >=ext2fs_blocks_count (fs->super)) - start =ext2fs_blocks_count (fs->super) -1 ;if (end < fs->super->s_first_data_block) end = fs->super->s_first_data_block;
@@ -3230,17 +3240,23 @@ static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,while (start <= end) { err =ext2fs_find_first_zero_block_bitmap2 (fs->block_map, start, end, &start); -if (err ==ENOENT ) -return 0 ; -else if (err) +switch (err) { +case 0 : +break ; +case ENOENT : +/* no free blocks found, so we're done */ + err =0 ; + goto out; +default :return translate_error (fs, fh->ino, err); + } b = start + max_blocks < end ? start + max_blocks : end; err =ext2fs_find_first_set_block_bitmap2 (fs->block_map, start, b, &b);if (err && err !=ENOENT )return translate_error (fs, fh->ino, err); -if (b - start >= fr->minlen) { +if (b - start >= minlen) { err =io_channel_discard (fs->io, start, b - start);if (err)return translate_error (fs, fh->ino, err);
@@ -3250,6 +3266,8 @@ static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, start = b + 1; } +out: + fr->len = cleared;return err; }#endif /* FITRIM */
PATCH 16/16 fuse2fs: report inode number and file type via readdir
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Report the inode number and file type in readdir to speed up directory iteration a bit.
--- misc/fuse2fs.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-)
misc/fuse2fs.c +38 -8
@@ -2594,9 +2594,36 @@ static int op_removexattr(const char *path, const char *key)struct readdir_iter {void *buf; +ext2_filsys fs;fuse_fill_dir_t func; }; +static inline mode_t dirent_fmode (ext2_filsys fs, +const struct ext2_dir_entry *dirent) +{ +if (!ext2fs_has_feature_filetype (fs->super)) +return 0 ; + +switch (ext2fs_dirent_file_type (dirent)) { +case EXT2_FT_REG_FILE : +return S_IFREG ; +case EXT2_FT_DIR : +return S_IFDIR ; +case EXT2_FT_CHRDEV : +return S_IFCHR ; +case EXT2_FT_BLKDEV : +return S_IFBLK ; +case EXT2_FT_FIFO : +return S_IFIFO ; +case EXT2_FT_SOCK : +return S_IFSOCK ; +case EXT2_FT_SYMLINK : +return S_IFLNK ; + } + +return 0 ; +} + static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)), int entry EXT2FS_ATTR((unused)), struct ext2_dir_entry *dirent,
@@ -2606,11 +2633,15 @@ static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)), {struct readdir_iter *i = data;char namebuf[EXT2_NAME_LEN +1 ]; +struct stat stat = { + .st_ino = dirent->inode, + .st_mode =dirent_fmode (i->fs, dirent), + };int ret;memcpy (namebuf, dirent->name, dirent->name_len &0xFF ); namebuf[dirent->name_len &0xFF ] =0 ; - ret = i->func(i->buf, namebuf, NULL, 0 + ret = i->func(i->buf, namebuf, &stat, 0 #if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0) , 0 #endif
@@ -2634,26 +2665,25 @@ static int op_readdir(const char *path EXT2FS_ATTR((unused)),struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)(uintptr_t )fp->fh; -ext2_filsys fs;errcode_t err;struct readdir_iter i;int ret =0 ;FUSE2FS_CHECK_CONTEXT (ff); - fs = ff->fs; -FUSE2FS_CHECK_MAGIC (fs, fh,FUSE2FS_FILE_MAGIC ); + i.fs = ff->fs; +FUSE2FS_CHECK_MAGIC (i.fs, fh,FUSE2FS_FILE_MAGIC );dbg_printf (ff,"%s: ino=%d\n" , __func__, fh->ino);pthread_mutex_lock (&ff->bfl); i.buf = buf; i.func = fill_func; - err =ext2fs_dir_iterate2 (fs, fh->ino,0 ,NULL , op_readdir_iter, &i); + err =ext2fs_dir_iterate2 (i.fs, fh->ino,0 ,NULL , op_readdir_iter, &i);if (err) { - ret =translate_error (fs, fh->ino, err); + ret =translate_error (i.fs, fh->ino, err); goto out; } -if (fs_writeable (fs)) { - ret =update_atime (fs, fh->ino); +if (fs_writeable (i.fs)) { + ret =update_atime (i.fs, fh->ino);if (ret) goto out; }
Theodore Ts'o
AppliedQuoted 8 lines · Darrick J. Wong
This series fixes many many bugs in fuse2fs.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
Comments and questions are, as always, welcome.
[...]
Applied, thanks!
[01/16] fuse2fs: refuse unsupported features
commit: ccbc6f24fed095b28f9faa7b575159e49787fae0
[02/16] fuse2fs: return -EOPNOTSUPP when we don't recognize a fallocate mode
commit: 7775293c08d2255e90b1e003ee532d826af52d95
[03/16] fuse2fs: implement zero range
commit: 44e024fd9cea41097c9f16bfbc73bc6aaac21f00
[04/16] fuse2fs: remove posix acl translation
commit: 0111bdb70a9c460052387111414a2e2dc8c06822
[05/16] fuse2fs: log names of xattrs being set/get/removed
commit: 1686713e8afc3f40f4a92e86949a909492fda3cd
[06/16] fuse2fs: add an easy option for emulating kernel access behaviors
commit: 667ea124cf16c45f3a35b3ba024a3add962788c7
[07/16] fuse2fs: report nanoseconds resolution through getattr
commit: f2b51fa65536f7172de4252b56c7b16d222d8178
[08/16] fuse2fs: clamp timestamps that are being written to disk
commit: e13395876d63cebf008101b934ee9e5cdaae0150
[09/16] fuse2fs: add supportable mount options from the kernel
commit: 8ba9236f207a9a2fe5cecadbb5bcb45b62ee2cc5
[10/16] fuse2fs: support getting and setting via struct fsxattr
commit: 9b5012c1569d4e6a0df1aa506bee1564435b7fd3
[11/16] fuse2fs: support changing newer iflags
commit: 0b47ce4878eb9fd2e33991ac6bb6d5a172b6a2f2
[12/16] fuse2fs: update new child timestamps during mkdir/symlink
commit: f73fbf8e2cee1f2d49f4e7573eadb9f1cf141879
[13/16] fuse2fs: report real inode numbers
commit: e135cae7d121f051e047c1e78a9aaacc6733603c
[14/16] fuse2fs: disable renameat2
commit: b431abbc8fe0fd1de4e414aae3520c4c19411048
[15/16] fuse2fs: fix FITRIM validation
commit: 7235b58533b9cd72b783daa4d6d554a9d8ee088c
[16/16] fuse2fs: report inode number and file type via readdir
commit: 7b5d75ef8843ff0fd60397160ab002e70b858fd4Best regards,
Signature · 1 line
Theodore Ts'o <[email protected]>