1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-24 10:30:38 +02:00

[kernel] fix mini_fo on 2.6.25

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@10943 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2008-04-26 08:11:06 +00:00
parent 4c6dc78fd9
commit cdafce8aee
2 changed files with 477 additions and 326 deletions

View File

@ -195,11 +195,11 @@ Index: linux-2.6.23/fs/mini_fo/aux.c
+ err = vfs_path_lookup(mnt->mnt_root, mnt, bpath+1, 0, &nd); + err = vfs_path_lookup(mnt->mnt_root, mnt, bpath+1, 0, &nd);
+ +
+ /* validate */ + /* validate */
+ if (err || !nd.path.dentry || !nd.path.dentry->d_inode) { + if (err || !nd.dentry || !nd.dentry->d_inode) {
+ printk(KERN_CRIT "mini_fo: bpath_walk: path_walk failed.\n"); + printk(KERN_CRIT "mini_fo: bpath_walk: path_walk failed.\n");
+ return NULL; + return NULL;
+ } + }
+ return nd.path.dentry; + return nd.dentry;
+} +}
+ +
+ +
@ -3774,7 +3774,7 @@ Index: linux-2.6.23/fs/mini_fo/main.c
+ /* + /*
+ * original: inode = iget(sb, hidden_inode->i_ino); + * original: inode = iget(sb, hidden_inode->i_ino);
+ */ + */
+ inode = iget_locked(sb, iunique(sb, 25)); + inode = iget(sb, iunique(sb, 25));
+ if (!inode) { + if (!inode) {
+ err = -EACCES; /* should be impossible??? */ + err = -EACCES; /* should be impossible??? */
+ goto out; + goto out;
@ -3876,9 +3876,9 @@ Index: linux-2.6.23/fs/mini_fo/main.c
+ hidden_root = ERR_PTR(err); + hidden_root = ERR_PTR(err);
+ goto out; + goto out;
+ } + }
+ hidden_root = nd.path.dentry; + hidden_root = nd.dentry;
+ stopd(sb)->base_dir_dentry = nd.path.dentry; + stopd(sb)->base_dir_dentry = nd.dentry;
+ stopd(sb)->hidden_mnt = nd.path.mnt; + stopd(sb)->hidden_mnt = nd.mnt;
+ +
+ } else if(!strncmp("sto=", options, 4)) { + } else if(!strncmp("sto=", options, 4)) {
+ /* parse the storage dir */ + /* parse the storage dir */
@ -3896,9 +3896,9 @@ Index: linux-2.6.23/fs/mini_fo/main.c
+ hidden_root2 = ERR_PTR(err); + hidden_root2 = ERR_PTR(err);
+ goto out; + goto out;
+ } + }
+ hidden_root2 = nd2.path.dentry; + hidden_root2 = nd2.dentry;
+ stopd(sb)->storage_dir_dentry = nd2.path.dentry; + stopd(sb)->storage_dir_dentry = nd2.dentry;
+ stopd(sb)->hidden_mnt2 = nd2.path.mnt; + stopd(sb)->hidden_mnt2 = nd2.mnt;
+ stohs2(sb) = hidden_root2->d_sb; + stohs2(sb) = hidden_root2->d_sb;
+ +
+ /* validate storage dir, this is done in + /* validate storage dir, this is done in
@ -7561,7 +7561,7 @@ Index: linux-2.6.23/fs/mini_fo/super.c
+#include "fist.h" +#include "fist.h"
+#include "mini_fo.h" +#include "mini_fo.h"
+ +
+#if 0 +
+STATIC void +STATIC void
+mini_fo_read_inode(inode_t *inode) +mini_fo_read_inode(inode_t *inode)
+{ +{
@ -7600,7 +7600,7 @@ Index: linux-2.6.23/fs/mini_fo/super.c
+ /* I don't think ->a_ops is ever allowed to be NULL */ + /* I don't think ->a_ops is ever allowed to be NULL */
+ inode->i_mapping->a_ops = &mini_fo_empty_aops; + inode->i_mapping->a_ops = &mini_fo_empty_aops;
+} +}
+#endif +
+ +
+#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) +#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
+/* +/*
@ -7798,7 +7798,7 @@ Index: linux-2.6.23/fs/mini_fo/super.c
+ +
+struct super_operations mini_fo_sops = +struct super_operations mini_fo_sops =
+{ +{
+// read_inode: mini_fo_read_inode, + read_inode: mini_fo_read_inode,
+#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) +#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
+ write_inode: mini_fo_write_inode, + write_inode: mini_fo_write_inode,
+#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */ +#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */

View File

@ -0,0 +1,151 @@
Index: linux-2.6.25/fs/mini_fo/main.c
===================================================================
--- linux-2.6.25.orig/fs/mini_fo/main.c
+++ linux-2.6.25/fs/mini_fo/main.c
@@ -79,6 +79,7 @@ mini_fo_tri_interpose(dentry_t *hidden_d
* of the new inode's fields
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
/*
* original: inode = iget(sb, hidden_inode->i_ino);
*/
@@ -87,6 +88,13 @@ mini_fo_tri_interpose(dentry_t *hidden_d
err = -EACCES; /* should be impossible??? */
goto out;
}
+#else
+ inode = mini_fo_iget(sb, iunique(sb, 25));
+ if (IS_ERR(inode)) {
+ err = PTR_ERR(inode);
+ goto out;
+ }
+#endif
/*
* interpose the inode if not already interposed
@@ -184,9 +192,9 @@ mini_fo_parse_options(super_block_t *sb,
hidden_root = ERR_PTR(err);
goto out;
}
- hidden_root = nd.dentry;
- stopd(sb)->base_dir_dentry = nd.dentry;
- stopd(sb)->hidden_mnt = nd.mnt;
+ hidden_root = nd_get_dentry(&nd);
+ stopd(sb)->base_dir_dentry = nd_get_dentry(&nd);
+ stopd(sb)->hidden_mnt = nd_get_mnt(&nd);
} else if(!strncmp("sto=", options, 4)) {
/* parse the storage dir */
@@ -204,9 +212,9 @@ mini_fo_parse_options(super_block_t *sb,
hidden_root2 = ERR_PTR(err);
goto out;
}
- hidden_root2 = nd2.dentry;
- stopd(sb)->storage_dir_dentry = nd2.dentry;
- stopd(sb)->hidden_mnt2 = nd2.mnt;
+ hidden_root2 = nd_get_dentry(&nd2);
+ stopd(sb)->storage_dir_dentry = nd_get_dentry(&nd2);
+ stopd(sb)->hidden_mnt2 = nd_get_mnt(&nd2);
stohs2(sb) = hidden_root2->d_sb;
/* validate storage dir, this is done in
Index: linux-2.6.25/fs/mini_fo/mini_fo.h
===================================================================
--- linux-2.6.25.orig/fs/mini_fo/mini_fo.h
+++ linux-2.6.25/fs/mini_fo/mini_fo.h
@@ -302,6 +302,10 @@ extern int mini_fo_tri_interpose(dentry_
extern int mini_fo_cp_cont(dentry_t *tgt_dentry, struct vfsmount *tgt_mnt,
dentry_t *src_dentry, struct vfsmount *src_mnt);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+extern struct inode *mini_fo_iget(struct super_block *sb, unsigned long ino);
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
extern int mini_fo_create(inode_t *dir, dentry_t *dentry, int mode, struct nameidata *nd);
@@ -501,6 +505,29 @@ static inline void double_unlock(struct
#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
#endif /* __KERNEL__ */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+static inline dentry_t *nd_get_dentry(struct nameidata *nd)
+{
+ return (nd->path.dentry);
+}
+
+static inline struct vfsmount *nd_get_mnt(struct nameidata *nd)
+{
+ return (nd->path.mnt);
+}
+#else
+static inline dentry_t *nd_get_dentry(struct nameidata *nd)
+{
+ return (nd->dentry);
+}
+
+static inline struct vfsmount *nd_get_mnt(struct nameidata *nd)
+{
+ return (nd->mnt);
+}
+#endif
+
/*
* Definitions for user and kernel code
*/
Index: linux-2.6.25/fs/mini_fo/super.c
===================================================================
--- linux-2.6.25.orig/fs/mini_fo/super.c
+++ linux-2.6.25/fs/mini_fo/super.c
@@ -262,10 +262,31 @@ mini_fo_umount_begin(super_block_t *sb)
}
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+struct inode *
+mini_fo_iget(struct super_block *sb, unsigned long ino)
+{
+ struct inode *inode;
+
+ inode = iget_locked(sb, ino);
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
+
+ if (!(inode->i_state & I_NEW))
+ return inode;
+
+ mini_fo_read_inode(inode);
+
+ unlock_new_inode(inode);
+ return inode;
+}
+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) */
struct super_operations mini_fo_sops =
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
read_inode: mini_fo_read_inode,
+#endif
#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
write_inode: mini_fo_write_inode,
#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */
Index: linux-2.6.25/fs/mini_fo/aux.c
===================================================================
--- linux-2.6.25.orig/fs/mini_fo/aux.c
+++ linux-2.6.25/fs/mini_fo/aux.c
@@ -164,11 +164,11 @@ dentry_t *bpath_walk(super_block_t *sb,
err = vfs_path_lookup(mnt->mnt_root, mnt, bpath+1, 0, &nd);
/* validate */
- if (err || !nd.dentry || !nd.dentry->d_inode) {
+ if (err || !nd_get_dentry(&nd) || !nd_get_dentry(&nd)->d_inode) {
printk(KERN_CRIT "mini_fo: bpath_walk: path_walk failed.\n");
return NULL;
}
- return nd.dentry;
+ return nd_get_dentry(&nd);
}