[PATCH -mm 6/9] unshare system call : allow unsharing of fs

From: JANAK DESAI
Date: Tue Dec 13 2005 - 08:45:11 EST



[PATCH -mm 6/9] unshare system call: allow unsharing of fs

fork.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)


diff -Naurp 2.6.15-rc5-mm2+patch/kernel/fork.c 2.6.15-rc5-mm2+patch6/kernel/fork.c
--- 2.6.15-rc5-mm2+patch/kernel/fork.c 2005-12-12 19:31:48.000000000 +0000
+++ 2.6.15-rc5-mm2+patch6/kernel/fork.c 2005-12-12 21:12:36.000000000 +0000
@@ -1378,15 +1378,19 @@ static int unshare_thread(unsigned long
}

/*
- * Unsharing of fs info for tasks created with CLONE_FS is not supported yet
+ * Unshare the filesystem structure if it is being shared
*/
static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
{
- struct fs_struct *fs = current->fs;
+ struct fs_struct *fs = current->fs, *new_fs;

if ((unshare_flags & CLONE_FS) &&
- (fs && atomic_read(&fs->count) > 1))
- return -EINVAL;
+ (fs && atomic_read(&fs->count) > 1)) {
+ new_fs = __copy_fs_struct(current->fs);
+ if (!new_fs)
+ return -ENOMEM;
+ *new_fsp = new_fs;
+ }

return 0;
}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/