X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=yaffs_vfs_multi.c;h=e763e0c9c5cd3089f0513f87279f276719a429d6;hb=c3588d722cf93ff57ed931ddf0fa889f38535337;hp=d70d406560ed527a24538aa1010ed95f65da518c;hpb=9c7a57844a5770db45d25e2539d73cd1004d501f;p=yaffs2.git diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index d70d406..e763e0c 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -1,8 +1,7 @@ /* * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * - * Copyright (C) 2002-2011 Aleph One Ltd. - * for Toby Churchill Ltd and Brightstar Engineering + * Copyright (C) 2002-2018 Aleph One Ltd. * * Created by Charles Manning * Acknowledgements: @@ -241,16 +240,19 @@ MODULE_PARM(yaffs_gc_control, "i"); #define YAFFS_USE_DIR_ITERATE #endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) +#define YAFFS_USE_XATTR +#endif + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) #define YAFFS_NEW_PROCFS #include #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) #define PAGE_CACHE_SIZE PAGE_SIZE #define PAGE_CACHE_SHIFT PAGE_SHIFT #define Y_GET_DENTRY(f) ((f)->f_path.dentry) -#define page_cache_release put_page #define YAFFS_NEW_XATTR 1 #define YAFFS_NEW_GET_LINK 1 #else @@ -259,10 +261,21 @@ MODULE_PARM(yaffs_gc_control, "i"); #define YAFFS_NEW_GET_LINK 0 #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) +#define page_cache_release put_page +#endif + #define update_dir_time(dir) do {\ (dir)->i_ctime = (dir)->i_mtime = CURRENT_TIME; \ } while (0) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) +static inline int setattr_prepare(struct dentry *dentry, struct iattr *attr) +{ + return inode_change_ok(dentry->d_inode, attr); +} +#endif + static void yaffs_fill_inode_from_obj(struct inode *inode, struct yaffs_obj *obj); @@ -790,7 +803,7 @@ static int yaffs_sync_object(struct file *file, struct dentry *dentry, #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)) static const struct file_operations yaffs_file_operations = { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) .read = new_sync_read, .write = new_sync_write, #endif @@ -895,7 +908,7 @@ static int yaffs_setattr(struct dentry *dentry, struct iattr *attr) #endif if (error == 0) - error = inode_change_ok(inode, attr); + error = setattr_prepare(dentry, attr); if (error == 0) { int result; if (!error) { @@ -929,6 +942,7 @@ static int yaffs_setattr(struct dentry *dentry, struct iattr *attr) return error; } +#ifdef YAFFS_USE_XATTR #if (YAFFS_NEW_XATTR > 0) static int yaffs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, const void *value, size_t size, int flags) @@ -962,7 +976,7 @@ static int yaffs_setxattr(struct dentry *dentry, const char *name, return error; } -#ifdef YAFFS_NEW_XATTR +#if (YAFFS_NEW_XATTR > 0) static ssize_t yaffs_getxattr(struct dentry * dentry, struct inode *inode, const char *name, void *buff, size_t size) { @@ -1019,6 +1033,7 @@ static int yaffs_removexattr(struct dentry *dentry, const char *name) return error; } +#endif static ssize_t yaffs_listxattr(struct dentry * dentry, char *buff, size_t size) { @@ -1046,10 +1061,12 @@ static ssize_t yaffs_listxattr(struct dentry * dentry, char *buff, size_t size) static const struct inode_operations yaffs_file_inode_operations = { .setattr = yaffs_setattr, +#ifdef YAFFS_USE_XATTR .setxattr = yaffs_setxattr, .getxattr = yaffs_getxattr, - .listxattr = yaffs_listxattr, .removexattr = yaffs_removexattr, +#endif + .listxattr = yaffs_listxattr, }; @@ -1173,10 +1190,12 @@ static const struct inode_operations yaffs_symlink_inode_operations = { .put_link = yaffs_put_link, #endif .setattr = yaffs_setattr, +#ifdef YAFFS_USE_XATTR .setxattr = yaffs_setxattr, .getxattr = yaffs_getxattr, - .listxattr = yaffs_listxattr, .removexattr = yaffs_removexattr, +#endif + .listxattr = yaffs_listxattr, }; #ifdef YAFFS_USE_OWN_IGET @@ -1558,8 +1577,13 @@ static int yaffs_symlink(struct inode *dir, struct dentry *dentry, * * NB: POSIX says you can rename an object over an old object of the same name */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) +static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, unsigned int unused) +#else static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) +#endif { struct yaffs_dev *dev; int ret_val = YAFFS_FAIL; @@ -1647,10 +1671,12 @@ static const struct inode_operations yaffs_dir_inode_operations = { .mknod = yaffs_mknod, .rename = yaffs_rename, .setattr = yaffs_setattr, + .listxattr = yaffs_listxattr, +#ifdef YAFFS_USE_XATTR .setxattr = yaffs_setxattr, .getxattr = yaffs_getxattr, - .listxattr = yaffs_listxattr, .removexattr = yaffs_removexattr, +#endif }; /*-----------------------------------------------------------------*/ @@ -1793,8 +1819,10 @@ static int yaffs_iterate(struct file *f, struct dir_context *dc) goto out; } - if (!dir_emit_dots(f, dc)) + if (!dir_emit_dots(f, dc)) { + yaffs_gross_unlock(dev); return 0; + } curoffs = 1;