Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133101174
D27016.id79050.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D27016.id79050.diff
View Options
Index: sys/compat/linux/linux_fork.c
===================================================================
--- sys/compat/linux/linux_fork.c
+++ sys/compat/linux/linux_fork.c
@@ -131,12 +131,13 @@
linux_clone_proc(struct thread *td, struct linux_clone_args *args)
{
struct fork_req fr;
- int error, ff = RFPROC | RFSTOPPED;
+ int error, ff = RFPROC | RFSTOPPED, f2;
struct proc *p2;
struct thread *td2;
int exit_signal;
struct linux_emuldata *em;
+ f2 = 0;
exit_signal = args->flags & 0x000000ff;
if (LINUX_SIG_VALID(exit_signal)) {
exit_signal = linux_to_bsd_signal(exit_signal);
@@ -147,14 +148,14 @@
ff |= RFMEM;
if (args->flags & LINUX_CLONE_SIGHAND)
ff |= RFSIGSHARE;
- /*
- * XXX: In Linux, sharing of fs info (chroot/cwd/umask)
- * and open files is independent. In FreeBSD, its in one
- * structure but in reality it does not cause any problems
- * because both of these flags are usually set together.
- */
- if (!(args->flags & (LINUX_CLONE_FILES | LINUX_CLONE_FS)))
+ if (args->flags & LINUX_CLONE_FILES) {
+ if (!(args->flags & LINUX_CLONE_FS))
+ f2 |= FR2_SHARE_PATHS;
+ } else {
ff |= RFFDG;
+ if (args->flags & LINUX_CLONE_FS)
+ f2 |= FR2_SHARE_PATHS;
+ }
if (args->flags & LINUX_CLONE_PARENT_SETTID)
if (args->parent_tidptr == NULL)
@@ -165,6 +166,7 @@
bzero(&fr, sizeof(fr));
fr.fr_flags = ff;
+ fr.fr_flags2 = f2;
fr.fr_procp = &p2;
error = fork1(td, &fr);
if (error)
Index: sys/kern/kern_fork.c
===================================================================
--- sys/kern/kern_fork.c
+++ sys/kern/kern_fork.c
@@ -414,11 +414,17 @@
fd = fdinit(p1->p_fd, false, NULL);
fdtol = NULL;
} else if (fr->fr_flags & RFFDG) {
- pd = pdcopy(p1->p_pd);
+ if (fr->fr_flags2 & FR2_SHARE_PATHS)
+ pd = pdshare(p1->p_pd);
+ else
+ pd = pdcopy(p1->p_pd);
fd = fdcopy(p1->p_fd);
fdtol = NULL;
} else {
- pd = pdshare(p1->p_pd);
+ if (fr->fr_flags2 & FR2_SHARE_PATHS)
+ pd = pdcopy(p1->p_pd);
+ else
+ pd = pdshare(p1->p_pd);
fd = fdshare(p1->p_fd);
if (p1->p_fdtol == NULL)
p1->p_fdtol = filedesc_to_leader_alloc(NULL, NULL,
Index: sys/sys/proc.h
===================================================================
--- sys/sys/proc.h
+++ sys/sys/proc.h
@@ -1016,7 +1016,8 @@
int fr_pd_flags;
struct filecaps *fr_pd_fcaps;
int fr_flags2;
-#define FR2_DROPSIG_CAUGHT 0x00001 /* Drop caught non-DFL signals */
+#define FR2_DROPSIG_CAUGHT 0x00000001 /* Drop caught non-DFL signals */
+#define FR2_SHARE_PATHS 0x00000002 /* Invert sense of RFFDG for paths */
};
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 23, 11:54 PM (2 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24108413
Default Alt Text
D27016.id79050.diff (2 KB)
Attached To
Mode
D27016: linux(4) clone(2): Correctly handle CLONE_FS and CLONE_FILES
Attached
Detach File
Event Timeline
Log In to Comment