From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/2] OVL_MNT: add setup_overlay helper
Date: Wed, 15 May 2019 15:42:45 +0200 [thread overview]
Message-ID: <20190515134245.GC5429@dell5510> (raw)
In-Reply-To: <20190515133102.GA5429@dell5510>
Hi Murphy,
> ...
> > +int setup_overlay(int mountovl)
> > +{
> > + int ret;
> > +
> > + /* Setup an overlay mount with lower dir and file */
> > + SAFE_MKDIR(OVL_LOWER, 0755);
> > + SAFE_MKDIR(OVL_UPPER, 0755);
> > + SAFE_MKDIR(OVL_WORK, 0755);
> > + SAFE_MKDIR(OVL_MNT, 0755);
> > +
> > + /* Only create dirs, do not mount */
> > + if (mountovl == 0)
> > + return 0;
> Instead of having int parameter, there could be create_overlay_dirs()
> and mount_overlay(), which would call create_overlay_dirs().
> (no need to lookup meaning of parameter).
> > +
> > + ret = mount("overlay", OVL_MNT, "overlay", 0, "lowerdir="OVL_LOWER
> > + ",upperdir="OVL_UPPER",workdir="OVL_WORK);
> > + if (ret < 0) {
> > + if (errno == ENODEV) {
> > + tst_res(TINFO,
> > + "overlayfs is not configured in this kernel.");
> > + return 1;
> First I thought we'd implement it as a test flag (member of struct tst_test).
> When we have it as separate function I wonder whether we could TCONF on ENODEV
> instead of TINFO and return. Maybe there could be here for int strict parameter,
> where 1 would be force safe (i.e. TCONF), otherwise only TINFO.
> This could also to have SAFE_MOUNT_OVERLAY() macro which would use mount_overlay().
> Similar approach as SAFE_SEND() and safe_send().
From next patch:
> +++ b/testcases/kernel/syscalls/inotify/inotify07.c
> -#define OVL_MNT "ovl"
> #define DIR_NAME "test_dir"
> #define DIR_PATH OVL_MNT"/"DIR_NAME
> #define FILE_NAME "test_file"
> #define FILE_PATH OVL_MNT"/"DIR_NAME"/"FILE_NAME
> static int ovl_mounted;
> +static const char mntpoint[] = OVL_BASE_MNTPOINT;
> static struct event_t event_set[EVENT_MAX];
> @@ -164,14 +164,11 @@ static void setup(void)
> int ret;
> /* Setup an overlay mount with lower dir and file */
> - SAFE_MKDIR("lower", 0755);
> - SAFE_MKDIR("lower/"DIR_NAME, 0755);
> - SAFE_TOUCH("lower/"DIR_NAME"/"FILE_NAME, 0644, NULL);
> - SAFE_MKDIR("upper", 0755);
> - SAFE_MKDIR("work", 0755);
> - SAFE_MKDIR(OVL_MNT, 0755);
> - ret = mount("overlay", OVL_MNT, "overlay", 0,
> - "lowerdir=lower,upperdir=upper,workdir=work");
> + setup_overlay(0);
> + SAFE_MKDIR(OVL_LOWER"/"DIR_NAME, 0755);
> + SAFE_TOUCH(OVL_LOWER"/"DIR_NAME"/"FILE_NAME, 0644, NULL);
> + ret = mount("overlay", OVL_MNT, "overlay", 0, "lowerdir="OVL_LOWER
> + ",upperdir="OVL_UPPER",workdir="OVL_WORK);
> if (ret < 0) {
> if (errno == ENODEV) {
> tst_brk(TCONF,
In here in inotify07.c and in inotify08.c you create dirs (0 parameter) for because you it's
needed to create more dirs. Than the rest (mount, TCONF on ENODEV, TBROK
otherwise) is still copy pasted. I wonder how to move everything into
setup_overlay() helper. Maybe struct with files or directories and permissions
to for touch/mkdir? With this, int mountovl dir create_overlay_dirs() might not
be needed.
Kind regards,
Petr
next prev parent reply other threads:[~2019-05-15 13:42 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 4:39 [LTP] [PATCH] OVL_MNT: put overlayfs lower, upper, work, mnt dir in separated mountpoint Murphy Zhou
2019-04-30 8:18 ` Li Wang
2019-05-03 21:00 ` Petr Vorel
2019-05-15 9:21 ` [LTP] [PATCH v2 1/2] OVL_MNT: add setup_overlay helper Murphy Zhou
2019-05-15 9:21 ` [LTP] [PATCH v2 2/2] OVL_MNT: put overlayfs lower, upper, work, mnt dir in a separated mountpoint Murphy Zhou
2019-05-15 13:39 ` Petr Vorel
2019-05-16 9:14 ` Murphy Zhou
2019-05-15 13:31 ` [LTP] [PATCH v2 1/2] OVL_MNT: add setup_overlay helper Petr Vorel
2019-05-15 13:42 ` Petr Vorel [this message]
2019-05-15 14:30 ` Amir Goldstein
2019-05-15 18:20 ` Petr Vorel
2019-05-16 9:15 ` Murphy Zhou
2019-05-24 4:48 ` Murphy Zhou
2019-05-24 7:30 ` Petr Vorel
2019-05-24 9:04 ` [LTP] [PATCH v3 1/2] OVL_MNT: add helpers to setup overlayfs mountpoint Murphy Zhou
2019-05-24 9:04 ` [LTP] [PATCH v3 2/2] OVL_MNT: setup overlayfs dirs and mount in a separated mountpoint Murphy Zhou
2019-05-24 4:32 ` [LTP] [PATCH v2 1/2] OVL_MNT: add setup_overlay helper Murphy Zhou
2019-05-24 8:54 ` Petr Vorel
2019-05-24 11:24 ` Amir Goldstein
2019-05-24 12:23 ` Petr Vorel
2019-05-24 13:44 ` Murphy Zhou
2019-05-25 11:51 ` [LTP] [PATCH v4 1/2] OVL_MNT: add helpers to setup overlayfs mountpoint Murphy Zhou
2019-05-25 11:51 ` [LTP] [PATCH v4 2/2] OVL_MNT: setup overlayfs dirs and mount in a separated mountpoint Murphy Zhou
2019-05-27 12:09 ` [LTP] [PATCH v4 1/2] OVL_MNT: add helpers to setup overlayfs mountpoint Petr Vorel
2019-05-27 13:17 ` Amir Goldstein
2019-05-27 15:27 ` Petr Vorel
2019-05-27 13:38 ` Murphy Zhou
2019-05-27 15:36 ` Petr Vorel
2019-05-29 7:49 ` Murphy Zhou
2019-05-29 10:18 ` [LTP] [PATCH v5 " Murphy Zhou
2019-05-29 10:18 ` [LTP] [PATCH v5 2/2] OVL_MNT: setup overlayfs dirs and mount in a separated mountpoint Murphy Zhou
2019-05-29 10:55 ` Amir Goldstein
2019-05-29 10:59 ` [LTP] [PATCH v5 1/2] OVL_MNT: add helpers to setup overlayfs mountpoint Amir Goldstein
2019-05-30 2:41 ` Murphy Zhou
2019-05-30 2:53 ` [LTP] [PATCH v6 " Murphy Zhou
2019-05-30 2:53 ` [LTP] [PATCH v6 2/2] OVL_MNT: setup overlayfs dirs and mount in a separated mountpoint Murphy Zhou
2019-06-03 7:12 ` Petr Vorel
2019-06-03 5:06 ` [LTP] [PATCH v6 1/2] OVL_MNT: add helpers to setup overlayfs mountpoint Petr Vorel
2019-05-24 13:36 ` [LTP] [PATCH v2 1/2] OVL_MNT: add setup_overlay helper Murphy Zhou
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=20190515134245.GC5429@dell5510 \
--to=pvorel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox