summaryrefslogtreecommitdiff
path: root/target/linux/generic/patches-2.6.31/210-mini_fo_2.6.25_fixes.patch
blob: b64630d50045480d022ba26c901cea68f6da66b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
--- a/fs/mini_fo/main.c
+++ b/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
--- a/fs/mini_fo/mini_fo.h
+++ b/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
  */
--- a/fs/mini_fo/super.c
+++ b/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) */
--- a/fs/mini_fo/aux.c
+++ b/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);
 }