[LTP] [PATCH] tst_creat_unlinked(): Add missing mode argument

Petr Vorel pvorel@suse.cz
Fri Dec 13 23:02:58 CET 2024


Hi Martin,

> The open() syscall requires the mode parameter if O_CREAT flag is used.
> Add the missing mode parameter to the tst_creat_unlinked() helper function.

> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---

> During investigation of strange hugemmap11 failures I've noticed that
> the test tries to create a scratch file with uninitialized access mode.
> This was unrelated to the failures but should be fixed anyway.

Good catch, rebased and merged.

I see from man open(2):


	The mode argument specifies the file mode bits to be applied when a new file
	is created.  If neither O_CREAT nor O_TMPFILE is specified in flags, then
	mode is ignored (and can thus be specified as 0, or simply omitted).  The
	mode argument must be supplied if O_CREAT or O_TMPFILE is specified in
	flags; if it is not supplied, some arbitrary bytes from the stack will be
	applied as the file mode.

It looks like that all O_TMPFILE are covered. Too late now to check O_CREAT.

It would be handy if somebody spent time to add this check into our sparse
checks.

Kind regards,
Petr


More information about the ltp mailing list