Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99d1419d authored by JANAK DESAI's avatar JANAK DESAI Committed by Linus Torvalds
Browse files

[PATCH] unshare system call -v5: unshare filesystem info



If filesystem structure is being shared, allocate a new one and copy
information from the current, shared, structure.

Signed-off-by: default avatarJanak 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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cf2e340f
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -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)
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;


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


	return 0;
	return 0;
}
}