Linux Test Project
 help / color / mirror / Atom feed
From: Wei Gao via ltp <ltp@lists.linux.it>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] mount_setattr02.c: Check mount_setattr attr.propagation
Date: Sun, 23 Feb 2025 20:44:44 -0500	[thread overview]
Message-ID: <Z7vPDGJbgSNmIhd0@wegao> (raw)
In-Reply-To: <20250221125458.GA2784225@pevik>

On Fri, Feb 21, 2025 at 01:54:58PM +0100, Petr Vorel wrote:
> Hi Wei,
> 
> nit: You did not change commit message subject (we talked about it).
Oh, if you check time of message, i sent v2 patch before we talked about this :)
> 
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/mount_setattr/mount_setattr02.c
> > @@ -0,0 +1,103 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Copyright (C) 2025 SUSE LLC Wei Gao <wegao@suse.com>
> > + */
> > +
> > +/*\
> > + * [Description]
> NOTE: this '[Description]' should no longer be added.
> 
> See:
> https://github.com/linux-test-project/ltp/commit/a3e27df34d6cb49477c9bd6f9bbaa1ce4de155f9
> (it updated also examples in doc)
> 
> and follow ups
> https://github.com/linux-test-project/ltp/commit/63eceaa2a83bca41997edcd649eb62272622a100
> https://github.com/linux-test-project/ltp/commit/824f66ca72fc7505a31c30792334905b646c9d37
Got it, thanks your information.
> > + *
> > + * Basic mount_setattr() test.
> nit: here is better a blank line.
> > + * Test basic propagation mount attributes are set correctly.
> > + */
> > +
> > +#define _GNU_SOURCE
> > +
> > +#include <sys/statvfs.h>
> > +#include "tst_test.h"
> > +#include "lapi/fsmount.h"
> > +#include "tst_safe_stdio.h"
> > +
> > +#define DIRA "/DIRA_PROPAGATION_CHECK"
> 
> Also, I found a way to test into TMPDIR. There is no need to touch a real root.
> It works even on separate /tmp.
> 
> If you agree, I merge with following diff.
> https://github.com/pevik/ltp/blob/wei/mount_setattr02.v2.fixes/testcases/kernel/syscalls/mount_setattr/mount_setattr02.c
I agree. Great!
> 
> With changes below.
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
> Kind regards,
> Petr
> 
> +++ testcases/kernel/syscalls/mount_setattr/mount_setattr02.c
> @@ -4,9 +4,8 @@
>   */
>  
>  /*\
> - * [Description]
> - *
>   * Basic mount_setattr() test.
> + *
>   * Test basic propagation mount attributes are set correctly.
>   */
>  
> @@ -17,9 +16,9 @@
>  #include "lapi/fsmount.h"
>  #include "tst_safe_stdio.h"
>  
> -#define DIRA "/DIRA_PROPAGATION_CHECK"
> +static char *tmpdir;
>  
> -static int dir_created, mounted;
> +static int mounted;
>  
>  static bool is_shared_mount(const char *path)
>  {
> @@ -52,19 +51,15 @@ static bool is_shared_mount(const char *path)
>  static void cleanup(void)
>  {
>  	if (mounted)
> -		SAFE_UMOUNT(DIRA);
> -
> -	if (dir_created)
> -		SAFE_RMDIR(DIRA);
> +		SAFE_UMOUNT(tmpdir);
>  }
>  
>  static void setup(void)
>  {
> -	SAFE_MKDIR(DIRA, 0777);
> +	tmpdir = tst_tmpdir_path();
>  	SAFE_UNSHARE(CLONE_NEWNS);
> -	dir_created = 1;
>  	SAFE_MOUNT(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
> -	SAFE_MOUNT("testing", DIRA, "tmpfs", MS_NOATIME | MS_NODEV, "");
> +	SAFE_MOUNT("testing", tmpdir, "tmpfs", MS_NOATIME | MS_NODEV, "");
>  	mounted = 1;
>  }
>  
> @@ -75,24 +70,24 @@ static void run(void)
>  		.attr_clr       = MOUNT_ATTR__ATIME,
>  	};
>  
> -	TST_EXP_PASS_SILENT(mount_setattr(-1, DIRA, 0, &attr, sizeof(attr)));
> -	TST_EXP_EQ_LI(is_shared_mount(DIRA), 0);
> +	TST_EXP_PASS_SILENT(mount_setattr(-1, tmpdir, 0, &attr, sizeof(attr)));
> +	TST_EXP_EQ_LI(is_shared_mount(tmpdir), 0);
>  
>  	attr.propagation = -1;
> -	TST_EXP_FAIL_SILENT(mount_setattr(-1, DIRA, 0, &attr, sizeof(attr)), EINVAL);
> -	TST_EXP_EQ_LI(is_shared_mount(DIRA), 0);
> +	TST_EXP_FAIL_SILENT(mount_setattr(-1, tmpdir, 0, &attr, sizeof(attr)), EINVAL);
> +	TST_EXP_EQ_LI(is_shared_mount(tmpdir), 0);
>  
>  	attr.propagation = MS_SHARED;
> -	TST_EXP_PASS_SILENT(mount_setattr(-1, DIRA, 0, &attr, sizeof(attr)));
> -	TST_EXP_EQ_LI(is_shared_mount(DIRA), 1);
> +	TST_EXP_PASS_SILENT(mount_setattr(-1, tmpdir, 0, &attr, sizeof(attr)));
> +	TST_EXP_EQ_LI(is_shared_mount(tmpdir), 1);
>  
>  	attr.propagation = MS_PRIVATE;
> -	TST_EXP_PASS_SILENT(mount_setattr(-1, DIRA, 0, &attr, sizeof(attr)));
> -	TST_EXP_EQ_LI(is_shared_mount(DIRA), 0);
> +	TST_EXP_PASS_SILENT(mount_setattr(-1, tmpdir, 0, &attr, sizeof(attr)));
> +	TST_EXP_EQ_LI(is_shared_mount(tmpdir), 0);
>  
>  	attr.propagation = MS_SLAVE;
> -	TST_EXP_PASS_SILENT(mount_setattr(-1, DIRA, 0, &attr, sizeof(attr)));
> -	TST_EXP_EQ_LI(is_shared_mount(DIRA), 0);
> +	TST_EXP_PASS_SILENT(mount_setattr(-1, tmpdir, 0, &attr, sizeof(attr)));
> +	TST_EXP_EQ_LI(is_shared_mount(tmpdir), 0);
>  }
>  
>  static struct tst_test test = {
> @@ -100,4 +95,5 @@ static struct tst_test test = {
>  	.setup = setup,
>  	.cleanup = cleanup,
>  	.needs_root = 1,
> +	.needs_tmpdir = 1,
>  };

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2025-02-24  1:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17  2:04 [LTP] [PATCH v1] mount_setattr02.c: Check mount_setattr attr.propagation Wei Gao via ltp
2025-02-18 15:18 ` Petr Vorel
2025-02-19  8:47   ` Wei Gao via ltp
2025-02-19  9:05     ` Petr Vorel
2025-02-19  9:51       ` Wei Gao via ltp
2025-02-19 11:24         ` Petr Vorel
2025-02-19  8:29 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-02-21 12:54   ` Petr Vorel
2025-02-24  1:44     ` Wei Gao via ltp [this message]
2025-03-19 11:41   ` [LTP] [PATCH v3] mount_setattr02.c: Check mount_setattr attr propagation Wei Gao via ltp
2025-07-11  9:21     ` Cyril Hrubis
2025-07-24 13:40     ` [LTP] [PATCH v4] " Wei Gao via ltp
2025-07-28 15:37       ` 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=Z7vPDGJbgSNmIhd0@wegao \
    --to=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    --cc=wegao@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox