2005-12-13 03:01:33

by Janak Desai

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


[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;
}



2005-12-13 13:47:10

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH -mm 6/9] unshare system call : allow unsharing of fs structure

On Mon, Dec 12, 2005 at 10:00:07PM -0500, JANAK DESAI wrote:
> + new_fs = __copy_fs_struct(current->fs);
*new_fsp = __copy_fs_struct(current->fs);

no need of local variables...