[PATCH] unshare system call -v5: unshare filesystem info
authorJANAK DESAI <janak@us.ibm.com>
Tue, 7 Feb 2006 20:58:59 +0000 (12:58 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 8 Feb 2006 00:12:34 +0000 (16:12 -0800)
If filesystem structure is being shared, allocate a new one and copy
information from the current, shared, structure.

Signed-off-by: Janak Desai <janak@us.ibm.com>
Cc: Al Viro <viro@ftp.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: Andi Kleen <ak@muc.de>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/fork.c

index 6eb9362775f92580ad0393b82e1348009dec6987..598e5c27242c16c0a780c2783d9d27c592bf2090 100644 (file)
@@ -1371,15 +1371,18 @@ static int unshare_thread(unsigned long unshare_flags)
 }
 
 /*
- * 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;
 
        if ((unshare_flags & CLONE_FS) &&
-           (fs && atomic_read(&fs->count) > 1))
-               return -EINVAL;
+           (fs && atomic_read(&fs->count) > 1)) {
+               *new_fsp = __copy_fs_struct(current->fs);
+               if (!*new_fsp)
+                       return -ENOMEM;
+       }
 
        return 0;
 }