From: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] syscalls/statx01: Add stx_mnt_id check
Date: Tue, 30 Nov 2021 03:40:43 +0000 [thread overview]
Message-ID: <61A59D4D.8020409@fujitsu.com> (raw)
In-Reply-To: <YaSYuLV+XPW/pQ5/@yuki>
Hi Cyril
> Hi!
>> +static int file_fd = -1;
>> +
>> +#ifdef HAVE_STRUCT_STATX_STX_MNT_ID
>> +static void test_mnt_id(struct statx *buf)
>> +{
>> + FILE *file;
>> + char line[PATH_MAX];
>> + int pid;
>> + unsigned int line_mjr, line_mnr, mnt_id;
>
> Shouldn't we check the STATX_MNT_ID bit here before we event attempt to
> continue? Otherwise if we compile the test with headers where stx_mnt_id
> is defined then run it on old kernel there will be garbage in the
> stx_mnt_id field.
Agree.
>
>> + file = SAFE_FOPEN("/proc/self/mountinfo", "r");
>> +
>> + while (fgets(line, sizeof(line), file)) {
>> + if (sscanf(line, "%d %*d %d:%d",&mnt_id,&line_mjr,&line_mnr) != 3)
>> + continue;
>> +
>> + if (line_mjr == buf->stx_dev_major&& line_mnr == buf->stx_dev_minor)
>> + break;
>> + }
>> +
>> + SAFE_FCLOSE(file);
>> +
>> + if (buf->stx_mnt_id == mnt_id)
>> + tst_res(TPASS,
>> + "statx.stx_mnt_id equals to mount_id(%d) in /proc/self/mountinfo",
>> + mnt_id);
>> + else
>> + tst_res(TFAIL,
>> + "statx.stx_mnt_id(%d) is different from mount_id(%d) in /proc/self/mountinfo",
>> + buf->stx_mnt_id, mnt_id);
>> +
>> + pid = getpid();
>> + snprintf(line, PATH_MAX, "/proc/%d/fdinfo/%d", pid, file_fd);
>> + TST_ASSERT_FILE_INT(line, "mnt_id:", buf->stx_mnt_id);
>> +}
>> +#endif
>> +
>> static void test_normal_file(void)
>> {
>> struct statx buff;
>> @@ -106,6 +146,11 @@ static void test_normal_file(void)
>> tst_res(TFAIL, "stx_nlink(%u) is different from expected(1)",
>> buff.stx_nlink);
>>
>> +#ifdef HAVE_STRUCT_STATX_STX_MNT_ID
>> + test_mnt_id(&buff);
>> +#else
>> + tst_res(TCONF, "stx_mnt_id was not supported until linux 5.8.");
>
> This is confusing at best, if we end up here we were missing the
> structure member during compilation regardless the kernel version.
>
> So this message really should be:
>
> "stx_mnt_id not defined in struct statx"
Will do it in v2.
Best Regards
Yang Xu
>
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2021-11-30 3:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 9:35 [LTP] [PATCH] syscalls/statx01: Add stx_mnt_id check Yang Xu
2021-11-29 9:09 ` Cyril Hrubis
2021-11-30 3:40 ` xuyang2018.jy [this message]
2021-11-30 7:11 ` [LTP] [PATCH v2 1/2] " Yang Xu
2021-11-30 7:11 ` [LTP] [PATCH v2 2/2] syscalls/statx: Add docparse formatting Yang Xu
2021-11-30 15:54 ` Cyril Hrubis
2021-12-01 1:51 ` xuyang2018.jy
2021-11-30 15:18 ` [LTP] [PATCH v2 1/2] syscalls/statx01: Add stx_mnt_id check Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=61A59D4D.8020409@fujitsu.com \
--to=xuyang2018.jy@fujitsu.com \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.