<div dir="ltr"><div dir="ltr">Hi,<br><br>Apology for the late reply. <br><br>I am not sure about the st_blocks size. If you can guide me how to check that I might work on that?<br><br>Are you planning to merge this patch with the st_blocks check or the current version is ready to be merged?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 10, 2022 at 9:04 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>The subject should be shorter and more to the point, something as:<br><br>"fstat02: Validate st_nlink as well"<br><br>> Implements: #517<br><br>The code looks good now, but it's not complete solution to #517, there<br>are still many fields of the structure that are not checked and a few<br>more patches would be required to complete it.<br><br>For instance the st_blocks should be more or less equal size/512<br><br>And we should check the atime/mtime/ctime as well, but maybe it would be<br>easier if we do that in a separate test.<br><br>> This patch creates a hard link for a file during setup and checks if number of hardlinks<br>> match with the expected number.<br><br>This is missing Signed-off-by: line see:<br><br><a href="https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin" rel="noreferrer" target="_blank">https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin</a><br><br>> ---<br>> testcases/kernel/syscalls/fstat/fstat02.c | 10 ++++++++++<br>> 1 file changed, 10 insertions(+)<br>><br>> diff --git a/testcases/kernel/syscalls/fstat/fstat02.c b/testcases/kernel/syscalls/fstat/fstat02.c<br>> index c0229de44..2f9632edf 100644<br>> --- a/testcases/kernel/syscalls/fstat/fstat02.c<br>> +++ b/testcases/kernel/syscalls/fstat/fstat02.c<br>> @@ -17,8 +17,10 @@<br>> #include "tst_safe_macros.h"<br>> <br>> #define TESTFILE "test_file"<br>> +#define LINK_TESTFILE "link_test_file"<br>> #define FILE_SIZE 1024<br>> #define FILE_MODE 0644<br>> +#define NLINK 2<br>> <br>> static struct stat stat_buf;<br>> static uid_t user_id;<br>> @@ -61,6 +63,12 @@ static void run(void)<br>> fail++;<br>> }<br>> <br>> + if (stat_buf.st_nlink != NLINK) {<br>> + tst_res(TFAIL, "stat_buf.st_nlink = %li expected %i",<br>> + (long)stat_buf.st_nlink, NLINK);<br>> + fail++;<br>> + }<br>> +<br>> if (fail)<br>> return;<br>> <br>> @@ -78,6 +86,8 @@ static void setup(void)<br>> <br>> if (tst_fill_file(TESTFILE, 'a', FILE_SIZE, 1))<br>> tst_brk(TBROK, "Could not fill Testfile!");<br>> +<br>> + SAFE_LINK(TESTFILE, LINK_TESTFILE);<br>> }<br>> <br>> static void cleanup(void)<br>> --<br>> 2.25.1<br>><br>><br>> --<br>> Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br><br>--<br>Cyril Hrubis<br><a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a></blockquote></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 10, 2022 at 9:04 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
The subject should be shorter and more to the point, something as:<br>
<br>
"fstat02: Validate st_nlink as well"<br>
<br>
> Implements: #517<br>
<br>
The code looks good now, but it's not complete solution to #517, there<br>
are still many fields of the structure that are not checked and a few<br>
more patches would be required to complete it.<br>
<br>
For instance the st_blocks should be more or less equal size/512<br>
<br>
And we should check the atime/mtime/ctime as well, but maybe it would be<br>
easier if we do that in a separate test.<br>
<br>
> This patch creates a hard link for a file during setup and checks if number of hardlinks<br>
> match with the expected number.<br>
<br>
This is missing Signed-off-by: line see:<br>
<br>
<a href="https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin" rel="noreferrer" target="_blank">https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin</a><br>
<br>
> ---<br>
> testcases/kernel/syscalls/fstat/fstat02.c | 10 ++++++++++<br>
> 1 file changed, 10 insertions(+)<br>
> <br>
> diff --git a/testcases/kernel/syscalls/fstat/fstat02.c b/testcases/kernel/syscalls/fstat/fstat02.c<br>
> index c0229de44..2f9632edf 100644<br>
> --- a/testcases/kernel/syscalls/fstat/fstat02.c<br>
> +++ b/testcases/kernel/syscalls/fstat/fstat02.c<br>
> @@ -17,8 +17,10 @@<br>
> #include "tst_safe_macros.h"<br>
> <br>
> #define TESTFILE "test_file"<br>
> +#define LINK_TESTFILE "link_test_file"<br>
> #define FILE_SIZE 1024<br>
> #define FILE_MODE 0644<br>
> +#define NLINK 2<br>
> <br>
> static struct stat stat_buf;<br>
> static uid_t user_id;<br>
> @@ -61,6 +63,12 @@ static void run(void)<br>
> fail++;<br>
> }<br>
> <br>
> + if (stat_buf.st_nlink != NLINK) {<br>
> + tst_res(TFAIL, "stat_buf.st_nlink = %li expected %i",<br>
> + (long)stat_buf.st_nlink, NLINK);<br>
> + fail++;<br>
> + }<br>
> +<br>
> if (fail)<br>
> return;<br>
> <br>
> @@ -78,6 +86,8 @@ static void setup(void)<br>
> <br>
> if (tst_fill_file(TESTFILE, 'a', FILE_SIZE, 1))<br>
> tst_brk(TBROK, "Could not fill Testfile!");<br>
> +<br>
> + SAFE_LINK(TESTFILE, LINK_TESTFILE);<br>
> }<br>
> <br>
> static void cleanup(void)<br>
> -- <br>
> 2.25.1<br>
> <br>
> <br>
> -- <br>
> Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
-- <br>
Cyril Hrubis<br>
<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a><br>
</blockquote></div>