Skip to contentSkip to conversation

unshare system call: allow unsharing of filesystem

PATCH In review JANAK DESAI 1 participant 1 message Dec 13, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 6/9 unshare system call: allow unsharing of filesystem

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

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

Changes since the first submission of this patch on 12/12/05:
- Removed an unnecessary local variable (12/13/05)

---

 fork.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
kernel/fork.c +6 -3
diff -Naurp 2.6.15-rc5-mm2+patch/kernel/fork.c 2.6.15-rc5-mm2+patch6/kernel/fork.c
@@ -1378,15 +1378,18 @@ 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;
 
 	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;
 }