[LTP] [PATCH] syscalls/fork02: new test for fork()

zhaogongyi zhaogongyi@huawei.com
Wed Nov 16 03:51:53 CET 2022


Hi!

> 
> Hello,
> 
> Zhao Gongyi via ltp <ltp@lists.linux.it> writes:
> 
> > Verify that current workdir correctly inherited by child.
> 
> I'm not convinced by Cyrils comments that this should be included. I doubt
> LTP would work if the CWD wasn't inherited by children. At least in the
> common case. The test needs to do something more IMO.
> 
> Perhaps there has been a kernel bug involving fork and CWD? Perhaps
> relating to new file systems and mount options. I doubt we will see issues
> on a common setup. This isn't adding any test coverage in that case.
> 
> Also the path to the CWD and the CWD are two different things. The
> kernel generates the path on each invocation of getcwd IIRC.
> 
> Marking this as changes requested in patchwork. Although really, I think
> effort should be directed at clone3 which is lacking a lot of coverage.
> 
> --
> Thank you,
> Richard.

the pwd is one member of fs_struct:

struct fs_struct {
	int users;
	spinlock_t lock;
	seqcount_spinlock_t seq;
	int umask;
	int in_exec;
	struct path root, pwd;
} __randomize_layout;

And fs_struct is one member of struct task_struct:

	/* Filesystem information: */
	struct fs_struct		*fs;

In my opinion, the pwd will inherit from parent naturally if there is no a explicit change in fork.

Regards,
Gongyi



More information about the ltp mailing list