View | Details | Raw Unified | Return to bug 15837
Collapse All | Expand All

(-)kernel-source-subfs-0.9.orig/subfs.c (-13 / +96 lines)
Lines 7-12 Link Here
7
 *  or above.
7
 *  or above.
8
 */
8
 */
9
9
10
#include <linux/version.h>
10
#include <linux/init.h>
11
#include <linux/init.h>
11
#include <linux/module.h>
12
#include <linux/module.h>
12
#include <linux/kernel.h>
13
#include <linux/kernel.h>
Lines 17-23 Link Here
17
#include <asm/uaccess.h>
18
#include <asm/uaccess.h>
18
#include <linux/list.h>
19
#include <linux/list.h>
19
#include <linux/mount.h>
20
#include <linux/mount.h>
21
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
22
#include <linux/nsproxy.h>
23
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
24
#include <linux/mnt_namespace.h>
25
#else
20
#include <linux/namespace.h>
26
#include <linux/namespace.h>
27
#endif
21
#include <linux/namei.h>
28
#include <linux/namei.h>
22
#include <linux/dcache.h>
29
#include <linux/dcache.h>
23
#include <linux/sysfs.h>
30
#include <linux/sysfs.h>
Lines 25-30 Link Here
25
#include <asm/signal.h>
32
#include <asm/signal.h>
26
#include <linux/signal.h>
33
#include <linux/signal.h>
27
#include <linux/sched.h>
34
#include <linux/sched.h>
35
#include <linux/rcupdate.h>
28
36
29
#include "subfs.h"
37
#include "subfs.h"
30
38
Lines 47-53 Link Here
47
	/* Get the head of the global mount list from the init process. */
56
	/* Get the head of the global mount list from the init process. */
48
	/* Is there a better way? */
57
	/* Is there a better way? */
49
	init_fs = init_task.fs;
58
	init_fs = init_task.fs;
59
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
60
	head = &init_fs->root.mnt->mnt_list;
61
#else
50
	head = &init_fs->rootmnt->mnt_list;
62
	head = &init_fs->rootmnt->mnt_list;
63
#endif
51
64
52
	/* Go through the list and look for a superblock pointer match. */
65
	/* Go through the list and look for a superblock pointer match. */
53
	list_for_each_safe(entry, lh, head) {
66
	list_for_each_safe(entry, lh, head) {
Lines 72-81 Link Here
72
	struct vfsmount *old_pwdmnt;
85
	struct vfsmount *old_pwdmnt;
73
86
74
	write_lock(&fs->lock);
87
	write_lock(&fs->lock);
88
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
89
	old_pwd = fs->pwd.dentry;
90
	old_pwdmnt = fs->pwd.mnt;
91
	fs->pwd.mnt = mntget(mnt);
92
	fs->pwd.dentry = dget(dentry);
93
#else
75
	old_pwd = fs->pwd;
94
	old_pwd = fs->pwd;
76
	old_pwdmnt = fs->pwdmnt;
95
	old_pwdmnt = fs->pwdmnt;
77
	fs->pwdmnt = mntget(mnt);
96
	fs->pwdmnt = mntget(mnt);
78
	fs->pwd = dget(dentry);
97
	fs->pwd = dget(dentry);
98
#endif
79
	write_unlock(&fs->lock);
99
	write_unlock(&fs->lock);
80
100
81
	if (old_pwd) {
101
	if (old_pwd) {
Lines 94-104 Link Here
94
	struct task_struct *task = current;
114
	struct task_struct *task = current;
95
	int signal = SIGCONT;
115
	int signal = SIGCONT;
96
116
97
	read_lock(&tasklist_lock);
117
	rcu_read_lock();
98
	spin_lock_irq(&task->sighand->siglock);
118
	spin_lock_irq(&task->sighand->siglock);
99
	sigaddset(&task->pending.signal, signal);
119
	sigaddset(&task->pending.signal, signal);
100
	spin_unlock_irq(&task->sighand->siglock);
120
	spin_unlock_irq(&task->sighand->siglock);
101
	read_unlock(&tasklist_lock);
121
	rcu_read_unlock();
102
	set_tsk_thread_flag(task, TIF_SIGPENDING);
122
	set_tsk_thread_flag(task, TIF_SIGPENDING);
103
	return;
123
	return;
104
}
124
}
Lines 137-150 Link Here
137
	char *envp[2] = { "HOME=/", NULL };
157
	char *envp[2] = { "HOME=/", NULL };
138
	char *path_buf;
158
	char *path_buf;
139
	int result, len = 0;
159
	int result, len = 0;
160
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
161
	struct path p;
162
#endif
140
163
141
	argv[1] = sfs_mnt->device;
164
	argv[1] = sfs_mnt->device;
142
	path_buf = (char *) __get_free_page(GFP_KERNEL);
165
	path_buf = (char *) __get_free_page(GFP_KERNEL);
143
	if (!path_buf)
166
	if (!path_buf)
144
		return -ENOMEM;
167
		return -ENOMEM;
145
	argv[2] =
168
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
146
	    d_path(sfs_mnt->mount->mnt_mountpoint,
169
	p.mnt = sfs_mnt->mount;
147
		   sfs_mnt->mount->mnt_parent, path_buf, PAGE_SIZE);
170
	p.dentry = p.mnt->mnt_root;
171
	argv[2] = d_path(&p, path_buf, PAGE_SIZE);
172
#else
173
	argv[2] = d_path(sfs_mnt->mount->mnt_mountpoint, sfs_mnt->mount->mnt_parent, path_buf, PAGE_SIZE);
174
#endif
148
	argv[3] = sfs_mnt->req_fs;
175
	argv[3] = sfs_mnt->req_fs;
149
	if (!(argv[4] = kmalloc(17, GFP_KERNEL))) {
176
	if (!(argv[4] = kmalloc(17, GFP_KERNEL))) {
150
		free_page((unsigned long) path_buf);
177
		free_page((unsigned long) path_buf);
Lines 221-238 Link Here
221
	struct vfsmount *child;
248
	struct vfsmount *child;
222
249
223
	/* This is ugly, but prevents a lockup during mount. */
250
	/* This is ugly, but prevents a lockup during mount. */
251
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
252
	mutex_unlock(&dir->i_mutex);
253
#else
224
	up(&dir->i_sem);
254
	up(&dir->i_sem);
255
#endif
225
	if (down_interruptible(&sfs_mnt->sem)) {
256
	if (down_interruptible(&sfs_mnt->sem)) {
226
		down(&dir->i_sem);/*put the dir sem back down if interrupted*/
257
		/*put the dir sem back down if interrupted*/
258
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
259
		mutex_lock(&dir->i_mutex);
260
#else
261
		down(&dir->i_sem);
262
#endif
227
		return ERR_PTR(-ERESTARTSYS);
263
		return ERR_PTR(-ERESTARTSYS);
228
	}
264
	}
229
	child = get_child_mount(sfs_mnt);
265
	child = get_child_mount(sfs_mnt);
230
	up(&sfs_mnt->sem);
266
	up(&sfs_mnt->sem);
267
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
268
	mutex_lock(&dir->i_mutex);
269
#else
231
	down(&dir->i_sem);
270
	down(&dir->i_sem);
271
#endif
232
	if (IS_ERR(child))
272
	if (IS_ERR(child))
233
		return (void *) child;
273
		return (void *) child;
234
	subfs_send_signal();
274
	subfs_send_signal();
275
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
276
	if (sfs_mnt->mount == current->fs->pwd.mnt)
277
#else
235
	if (sfs_mnt->mount == current->fs->pwdmnt)
278
	if (sfs_mnt->mount == current->fs->pwdmnt)
279
#endif
236
		subfs_set_fs_pwd(current->fs, child, child->mnt_root);
280
		subfs_set_fs_pwd(current->fs, child, child->mnt_root);
237
	return ERR_PTR(-ERESTARTSYS);
281
	return ERR_PTR(-ERESTARTSYS);
238
}
282
}
Lines 254-260 Link Here
254
	if (IS_ERR(child))
298
	if (IS_ERR(child))
255
		return PTR_ERR(child);
299
		return PTR_ERR(child);
256
	subfs_send_signal();
300
	subfs_send_signal();
301
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
302
	if (sfs_mnt->mount == current->fs->pwd.mnt)
303
#else
257
	if (sfs_mnt->mount == current->fs->pwdmnt)
304
	if (sfs_mnt->mount == current->fs->pwdmnt)
305
#endif
258
		subfs_set_fs_pwd(current->fs, child, child->mnt_root);
306
		subfs_set_fs_pwd(current->fs, child, child->mnt_root);
259
	return -ERESTARTSYS;
307
	return -ERESTARTSYS;
260
}
308
}
Lines 262-270 Link Here
262
310
263
/*  Implements the statfs method so df and such will work on the mountpoint.
311
/*  Implements the statfs method so df and such will work on the mountpoint.
264
 */
312
 */
313
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)
314
static int subfs_statfs(struct dentry *dentry, struct kstatfs *buf)
315
{
316
	struct subfs_mount *sfs_mnt = dentry->d_sb->s_fs_info;
317
#else
265
static int subfs_statfs(struct super_block *sb, struct kstatfs *buf)
318
static int subfs_statfs(struct super_block *sb, struct kstatfs *buf)
266
{
319
{
267
	struct subfs_mount *sfs_mnt = sb->s_fs_info;
320
	struct subfs_mount *sfs_mnt = sb->s_fs_info;
321
#endif
268
	struct vfsmount *child;
322
	struct vfsmount *child;
269
	if (down_interruptible(&sfs_mnt->sem))
323
	if (down_interruptible(&sfs_mnt->sem))
270
		return -ERESTARTSYS;
324
		return -ERESTARTSYS;
Lines 286-292 Link Here
286
	if (ret) {
340
	if (ret) {
287
		ret->i_mode = mode;
341
		ret->i_mode = mode;
288
		ret->i_uid = ret->i_gid = 0;
342
		ret->i_uid = ret->i_gid = 0;
343
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
289
		ret->i_blksize = PAGE_CACHE_SIZE;
344
		ret->i_blksize = PAGE_CACHE_SIZE;
345
#endif
290
		ret->i_blocks = 0;
346
		ret->i_blocks = 0;
291
		ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
347
		ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
292
		ret->i_fop = &subfs_file_ops;
348
		ret->i_fop = &subfs_file_ops;
Lines 382-414 Link Here
382
 * subfs_mount structure is pointed to by the s_fs_info field of the
438
 * subfs_mount structure is pointed to by the s_fs_info field of the
383
 * superblock structure.
439
 * superblock structure.
384
 */
440
 */
441
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)
442
static int subfs_get_super(struct file_system_type *fst,
443
				int flags, const char *devname, void *data,
444
				struct vfsmount *mnt)
445
#else
385
static struct super_block *subfs_get_super(struct file_system_type *fst,
446
static struct super_block *subfs_get_super(struct file_system_type *fst,
386
				int flags, const char *devname, void *data)
447
				int flags, const char *devname, void *data)
448
#endif
387
{
449
{
388
	char *device;
450
	char *device;
389
	struct subfs_mount *newmount;
451
	struct subfs_mount *newmount;
390
	int ret;
452
	int ret;
391
453
392
	if (!(newmount = kmalloc(sizeof(struct subfs_mount), GFP_KERNEL)))
454
	if (!(newmount = kmalloc(sizeof(struct subfs_mount), GFP_KERNEL))) {
393
		return ERR_PTR(-ENOMEM);
455
		ret = -ENOMEM;
456
		goto err;
457
	}
394
	newmount->req_fs = NULL;
458
	newmount->req_fs = NULL;
395
	newmount->sb = NULL;
459
	newmount->sb = NULL;
396
	newmount->mount = NULL;
460
	newmount->mount = NULL;
397
	newmount->procuid = 0;
461
	newmount->procuid = 0;
398
	sema_init(&newmount->sem, 1);
462
	sema_init(&newmount->sem, 1);
399
	if (!(device = kmalloc((strlen(devname) + 1), GFP_KERNEL)))
463
	if (!(device = kmalloc((strlen(devname) + 1), GFP_KERNEL))) {
400
		return ERR_PTR(-ENOMEM);
464
		ret = -ENOMEM;
465
		goto err;
466
	}
401
	strcpy(device, devname);
467
	strcpy(device, devname);
402
	newmount->device = device;
468
	newmount->device = device;
403
        if (!(newmount->helper_prog =
469
        if (!(newmount->helper_prog =
404
        		kmalloc(sizeof(SUBMOUNTD_PATH), GFP_KERNEL)))
470
        		kmalloc(sizeof(SUBMOUNTD_PATH), GFP_KERNEL))) {
405
        	return ERR_PTR(-ENOMEM);
471
			ret = -ENOMEM;
472
			goto err;
473
		}
406
	strcpy(newmount->helper_prog, SUBMOUNTD_PATH);
474
	strcpy(newmount->helper_prog, SUBMOUNTD_PATH);
407
	if ((ret = proc_opts(newmount, data)))
475
	if ((ret = proc_opts(newmount, data)))
408
		return ERR_PTR(ret);
476
		goto err;
477
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)
478
	ret = get_sb_nodev(fst, flags, data, subfs_fill_super, mnt);
479
	if (ret)
480
		goto err;
481
	newmount->sb = mnt->mnt_sb;
482
	newmount->sb->s_fs_info = newmount;
483
	return ret;
484
#else
409
	newmount->sb = get_sb_nodev(fst, flags, data, subfs_fill_super);
485
	newmount->sb = get_sb_nodev(fst, flags, data, subfs_fill_super);
410
	newmount->sb->s_fs_info = newmount;
486
	newmount->sb->s_fs_info = newmount;
411
	return newmount->sb;
487
	return newmount->sb;
488
#endif
489
490
err:
491
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)
492
	return ret;
493
#else
494
	return ERR_PTR(ret);
495
#endif
412
}
496
}
413
497
414
498
(-)kernel-source-subfs-0.9.orig/subfs.h (-1 / +10 lines)
Lines 7-12 Link Here
7
 *  or above.
7
 *  or above.
8
 */
8
 */
9
9
10
#include <linux/version.h>
10
11
11
#define SUBFS_MAGIC 0x2c791058
12
#define SUBFS_MAGIC 0x2c791058
12
13
Lines 33-40 Link Here
33
34
34
35
35
static void subfs_kill_super(struct super_block *sb);
36
static void subfs_kill_super(struct super_block *sb);
37
38
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)
39
static int subfs_get_super(struct file_system_type *fst,
40
		int flags, const char *devname, void *data, struct vfsmount *mnt);
41
static int subfs_statfs(struct dentry *dentry, struct kstatfs *buf);
42
#else
36
static struct super_block *subfs_get_super(struct file_system_type *fst,
43
static struct super_block *subfs_get_super(struct file_system_type *fst,
37
		int flags, const char *devname, void *data);
44
		int flags, const char *devname, void *data);
45
static int subfs_statfs(struct super_block *sb, struct kstatfs *buf);
46
#endif
47
38
static struct vfsmount *get_subfs_vfsmount(struct super_block *sb);
48
static struct vfsmount *get_subfs_vfsmount(struct super_block *sb);
39
static int subfs_fill_super(struct super_block *sb, void *data,
49
static int subfs_fill_super(struct super_block *sb, void *data,
40
			    int silent);
50
			    int silent);
Lines 47-53 Link Here
47
static void subfs_send_signal(void);
57
static void subfs_send_signal(void);
48
static void subfs_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
58
static void subfs_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
49
			     struct dentry *dentry);
59
			     struct dentry *dentry);
50
static int subfs_statfs(struct super_block *sb, struct kstatfs *buf);
51
60
52
61
53
static struct file_system_type subfs_type = {
62
static struct file_system_type subfs_type = {

Return to bug 15837