[LTP] open: remove O_DIRECTORY case (move to fstat test)
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Sun Jun 21 12:08:01 CEST 2026
Hi Jinseok,
On Sun, 21 Jun 2026 18:03:59 +0900, Jinseok Kim wrote:
> open: remove O_DIRECTORY case (move to fstat test)
--- [PATCH 2/2] ---
> +/*\
> + * Verify that :manpage:`fstat(2)` correctly identifies various
> + * file types.
> + */
The test uses .needs_root = 1 for mknod() to create device nodes, but
the doc comment does not mention why root is required.
> + switch (tc->exp_type) {
> + case S_IFREG:
> + TST_EXP_EXPR(S_ISREG(buf.st_mode));
> + break;
> + case S_IFDIR:
> + TST_EXP_EXPR(S_ISDIR(buf.st_mode));
> + break;
> + case S_IFIFO:
> + TST_EXP_EXPR(S_ISFIFO(buf.st_mode));
> + break;
> + case S_IFCHR:
> + TST_EXP_EXPR(S_ISCHR(buf.st_mode));
> + break;
> + case S_IFBLK:
> + TST_EXP_EXPR(S_ISBLK(buf.st_mode));
> + break;
> + }
Each S_IS*() macro is equivalent to (st_mode & S_IFMT) == S_IF*, and
tc->exp_type already holds the expected S_IF* value. Could the whole
switch be replaced with a single check?
TST_EXP_EXPR((buf.st_mode & S_IFMT) == tc->exp_type,
"fstat on %s", tc->path);
This would also give more informative output on failure by
identifying the file being tested.
Verdict - Needs revision
Pre-existing issues in open01.c (not introduced by this series):
- static int fd; should be static int fd = -1;
- cleanup() uses if (fd > 0) which should be if (fd != -1)
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list