All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 1/2] OVL_MNT: add helpers to setup overlayfs mountpoint
Date: Mon, 27 May 2019 14:09:45 +0200	[thread overview]
Message-ID: <20190527120945.GA25513@dell5510> (raw)
In-Reply-To: <20190525115112.15399-1-xzhou@redhat.com>

Hi Murphy, Amir, Cyril,

just a suggestion to apply diff below:

1) mount_overlay(): you don't actually use lineno and safe in error messages
tst_fs_setup.c: In function ‘mount_overlay’:
tst_fs_setup.c:26:31: warning: unused parameter ‘file’ [-Wunused-parameter]
 int mount_overlay(const char *file, const int lineno, int safe)
                   ~~~~~~~~~~~~^~~~
tst_fs_setup.c:26:47: warning: unused parameter ‘lineno’ [-Wunused-parameter]
 int mount_overlay(const char *file, const int lineno, int safe)

2) mount_overlay(): return ret from mount (usually -1) instead of 1 (in case
anybody is interested).

3) mount_overlay(): earlier return 0 after checking ENODEV saves us one shift
right (but might look as error, as tst_res() is usually followed by return).

4) create_overlay_dirs(): checks for OVL_LOWER and thus can be called in
mount_overlay() without any check. This saves us calling it before
{SAFE,TST}_MOUNT_OVERLAY() in execveat03.c and readahead02.c

5) removed unused headers (<stdint.h>, <stdio.h>, <stdlib.h>, <sys/vfs.h>),
is any of them needed and the need masked by it's include in tst_test.h?

5) other cleanup

TODO:
I'm still not sure about ovl_mounted. There is static int mntpoint_mounted in
lib/tst_test.c, which does umount.  tst_test->mntpoint, I guess we should use
it. WDYT?

Kind regards,
Petr
---
* diff to first commit:
diff --git lib/tst_fs_setup.c lib/tst_fs_setup.c
index de09c7135..60dedc283 100644
--- lib/tst_fs_setup.c
+++ lib/tst_fs_setup.c
@@ -1,46 +1,46 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * DESCRIPTION
- *	A place for setup filesystem helpers.
- */
 
-#include <stdint.h>
+#include <dirent.h>
 #include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/vfs.h>
 #include <sys/mount.h>
 
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_fs.h"
 
+#define TST_FS_SETUP_OVERLAYFS_MSG "overlayfs is not configured in this kernel"
+#define TST_FS_SETUP_OVERLAYFS_CONFIG "lowerdir="OVL_LOWER",upperdir="OVL_UPPER",workdir="OVL_WORK
+
 void create_overlay_dirs(void)
 {
-	SAFE_MKDIR(OVL_LOWER, 0755);
-	SAFE_MKDIR(OVL_UPPER, 0755);
-	SAFE_MKDIR(OVL_WORK, 0755);
-	SAFE_MKDIR(OVL_MNT, 0755);
+	DIR* dir = opendir(OVL_BASE_MNTPOINT);
+	if (!dir) {
+		SAFE_MKDIR(OVL_LOWER, 0755);
+		SAFE_MKDIR(OVL_UPPER, 0755);
+		SAFE_MKDIR(OVL_WORK, 0755);
+		SAFE_MKDIR(OVL_MNT, 0755);
+	}
 }
 
 int mount_overlay(const char *file, const int lineno, int safe)
 {
-	int ret = 0;
-	char *cfgmsg = "overlayfs is not configured in this kernel.";
-
-	ret = mount("overlay", OVL_MNT, "overlay", 0, "lowerdir="OVL_LOWER
-		    ",upperdir="OVL_UPPER",workdir="OVL_WORK);
-	if (ret < 0) {
-		if (errno == ENODEV) {
-			if (safe) {
-				tst_brk(TCONF, cfgmsg);
-			} else {
-				tst_res(TINFO, cfgmsg);
-				return 1;
-			}
+	int ret;
+
+	create_overlay_dirs();
+
+	ret = mount("overlay", OVL_MNT, "overlay", 0, TST_FS_SETUP_OVERLAYFS_CONFIG);
+
+	if (!ret)
+		return 0;
+
+	if (errno == ENODEV) {
+		if (safe) {
+			tst_brk(TCONF, "%s:%d: " TST_FS_SETUP_OVERLAYFS_MSG, file, lineno);
 		} else {
-			tst_brk(TBROK | TERRNO, "overlayfs mount failed");
+			tst_res(TINFO, "%s:%d: " TST_FS_SETUP_OVERLAYFS_MSG, file, lineno);
 		}
+	} else {
+		tst_brk(TBROK | TERRNO, "overlayfs mount failed");
 	}
-	return 0;
+	return ret;
 }

* diff to second commit:
diff --git testcases/kernel/syscalls/execveat/execveat03.c testcases/kernel/syscalls/execveat/execveat03.c
index 446ff4f1d..eb088bc4c 100644
--- testcases/kernel/syscalls/execveat/execveat03.c
+++ testcases/kernel/syscalls/execveat/execveat03.c
@@ -88,8 +88,6 @@ static void verify_execveat(void)
 static void setup(void)
 {
 	check_execveat();
-
-	create_overlay_dirs();
 	SAFE_MOUNT_OVERLAY();
 	ovl_mounted = 1;
 }
diff --git testcases/kernel/syscalls/inotify/inotify08.c testcases/kernel/syscalls/inotify/inotify08.c
index 929ed08f1..9433315e2 100644
--- testcases/kernel/syscalls/inotify/inotify08.c
+++ testcases/kernel/syscalls/inotify/inotify08.c
@@ -165,7 +165,7 @@ static void setup(void)
 	if (fd_notify < 0) {
 		if (errno == ENOSYS) {
 			tst_brk(TCONF,
-				"inotify is not configured in this kernel.");
+				"inotify is not configured in this kernel");
 		} else {
 			tst_brk(TBROK | TERRNO,
 				"inotify_init () failed");
diff --git testcases/kernel/syscalls/readahead/readahead02.c testcases/kernel/syscalls/readahead/readahead02.c
index db95c2b01..f6e07173d 100644
--- testcases/kernel/syscalls/readahead/readahead02.c
+++ testcases/kernel/syscalls/readahead/readahead02.c
@@ -388,7 +388,6 @@ static void setup(void)
 	setup_readahead_length();
 	tst_res(TINFO, "readahead length: %d", readahead_length);
 
-	create_overlay_dirs();
 	ovl_mounted = TST_MOUNT_OVERLAY();
 }

  parent reply	other threads:[~2019-05-27 12:09 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
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                 ` Petr Vorel [this message]
2019-05-27 13:17                   ` [LTP] [PATCH v4 1/2] OVL_MNT: add helpers to setup overlayfs mountpoint 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=20190527120945.GA25513@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 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.