fstat02: Verify st_ino field
PATCH 1/1 fstat02: Verify st_ino field
fstat01 does not currently verify the st_ino field.
Add a check to verify that fstat() reports the expected inode number, improving coverage of the metadata returned by fstat().
--- testcases/kernel/syscalls/fstat/fstat02.c | 4 ++++ 1 file changed, 4 insertions(+)
testcases/kernel/syscalls/fstat/fstat02.c +4 -0
@@ -19,6 +19,7 @@#define NLINK 2static struct stat stat_buf; +static struct stat link_stat_buf;static uid_t user_id;static gid_t group_id;static int fildes;
@@ -31,6 +32,7 @@ static void run(void)TST_EXP_EQ_LI (stat_buf.st_size,FILE_SIZE );TST_EXP_EQ_LU (stat_buf.st_mode &0777 ,FILE_MODE );TST_EXP_EQ_LU (stat_buf.st_nlink,NLINK ); +TST_EXP_EQ_LU (stat_buf.st_ino, link_stat_buf.st_ino); }static void setup (void )
@@ -46,6 +48,8 @@ static void setup(void)tst_brk (TBROK ,"Could not fill test file" );SAFE_LINK (TESTFILE ,LINK_TESTFILE ); + +SAFE_STAT (LINK_TESTFILE , &link_stat_buf); }static void cleanup (void )
--
2.43.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Jinseok,
Quoted 3 lines · Jinseok Kim
fstat02: Verify
st_inofieldfstat01 does not currently verify the
st_inofield.
The patch modifies fstat02.c, not fstat01.c -- and fstat01 does not exist in this directory. Should this say "fstat02"?
Verdict: Needs revision
Pre-existing issues:
static int fildes;
File descriptors should be initialized to -1, not 0 (stdin). The cleanup guard should use fildes != -1 instead of fildes > 0 to match.
---
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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Jinseok,
besides the error discovered by the agent, this patch is missing the testing point. We are calling stat() on a hard link, which is actually following the path and getting the file status information.
That means we are testing IF stat() provides the same inode number of fstat() on the same file while following a hard link.
Why not just calling stat() on the file then? Also, they end up calling the same vfs_getattr(), while only the path lookup actually changes.
As you can see from the other tests for fstat()/stat()/lstat() syscalls, the idea is to compare them _only_ when there's a layer in between them, otherwise the information coming from the syscall should be compared only with specific setup that we force on files before obtaining any data.
I will reject this patch for this reason, since a similar pattern has been achieved by lstat03.c already.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp