All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls: avoid creating whiteout device in tests
@ 2015-12-10 11:38 Eryu Guan
  2015-12-11 13:00 ` Jan Stancek
  2015-12-11 13:24 ` [LTP] [PATCH v2] " Eryu Guan
  0 siblings, 2 replies; 5+ messages in thread
From: Eryu Guan @ 2015-12-10 11:38 UTC (permalink / raw)
  To: ltp

A char device with major 0 and minor 0 is known as whiteout device, and
overlayfs refuses to create such device. mknod01 and mount02 fail on
overlayfs because of this restriction.

Fix it by creating null device instead.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 testcases/kernel/syscalls/mknod/mknod01.c | 17 +++++++++++++----
 testcases/kernel/syscalls/mount/mount02.c |  8 ++++++--
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/mknod/mknod01.c b/testcases/kernel/syscalls/mknod/mknod01.c
index 863d02d..a35adf9 100644
--- a/testcases/kernel/syscalls/mknod/mknod01.c
+++ b/testcases/kernel/syscalls/mknod/mknod01.c
@@ -66,6 +66,7 @@ int TST_TOTAL = ARRAY_SIZE(tcases);
 int main(int ac, char **av)
 {
 	int lc, i;
+	dev_t dev;
 
 	tst_parse_opts(ac, av, NULL, NULL);
 
@@ -75,17 +76,25 @@ int main(int ac, char **av)
 		tst_count = 0;
 
 		for (i = 0; i < TST_TOTAL; i++) {
+			/*
+			 * overlayfs doesn't support mknod char device with
+			 * major 0 and minor 0, which is known as whiteout_dev
+			 */
+			if (S_ISCHR(tcases[i]))
+				dev = makedev(1, 3);
+			else
+				dev = 0;
 			TEST(mknod(PATH, tcases[i], 0));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL,
-					 "mknod(%s, %#o, 0) failed, errno=%d : %s",
-					 PATH, tcases[i], TEST_ERRNO,
+					 "mknod(%s, %#o, %lu) failed, errno=%d : %s",
+					 PATH, tcases[i], dev, TEST_ERRNO,
 					 strerror(TEST_ERRNO));
 			} else {
 				tst_resm(TPASS,
-					 "mknod(%s, %#o, 0) returned %ld",
-					 PATH, tcases[i], TEST_RETURN);
+					 "mknod(%s, %#o, %lu) returned %ld",
+					 PATH, tcases[i], dev, TEST_RETURN);
 			}
 
 			SAFE_UNLINK(cleanup, PATH);
diff --git a/testcases/kernel/syscalls/mount/mount02.c b/testcases/kernel/syscalls/mount/mount02.c
index 85c050d..916c35e 100644
--- a/testcases/kernel/syscalls/mount/mount02.c
+++ b/testcases/kernel/syscalls/mount/mount02.c
@@ -170,6 +170,8 @@ static void do_umount(void)
 
 static void setup(void)
 {
+	dev_t dev;
+
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
 	tst_require_root();
@@ -190,9 +192,11 @@ static void setup(void)
 
 	memset(path, 'a', PATH_MAX + 1);
 
-	if (mknod(char_dev, S_IFCHR | FILE_MODE, 0)) {
+	dev = makedev(1, 3);
+	if (mknod(char_dev, S_IFCHR | FILE_MODE, dev)) {
 		tst_brkm(TBROK | TERRNO, cleanup,
-		         "failed to mknod(char_dev, S_IFCHR | FILE_MODE, 0)");
+			 "failed to mknod(char_dev, S_IFCHR | FILE_MODE, %lu)",
+			 dev);
 	}
 
 	TEST_PAUSE;
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] syscalls: avoid creating whiteout device in tests
  2015-12-10 11:38 [LTP] [PATCH] syscalls: avoid creating whiteout device in tests Eryu Guan
@ 2015-12-11 13:00 ` Jan Stancek
  2015-12-11 13:19   ` Eryu Guan
  2015-12-11 13:24 ` [LTP] [PATCH v2] " Eryu Guan
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2015-12-11 13:00 UTC (permalink / raw)
  To: ltp





----- Original Message -----
> From: "Eryu Guan" <eguan@redhat.com>
> To: ltp@lists.linux.it
> Sent: Thursday, 10 December, 2015 12:38:22 PM
> Subject: [LTP] [PATCH] syscalls: avoid creating whiteout device in tests
> 
> A char device with major 0 and minor 0 is known as whiteout device, and
> overlayfs refuses to create such device. mknod01 and mount02 fail on
> overlayfs because of this restriction.
> 
> Fix it by creating null device instead.
> 
> Signed-off-by: Eryu Guan <eguan@redhat.com>

Hi,

> ---
>  testcases/kernel/syscalls/mknod/mknod01.c | 17 +++++++++++++----
>  testcases/kernel/syscalls/mount/mount02.c |  8 ++++++--
>  2 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/mknod/mknod01.c
> b/testcases/kernel/syscalls/mknod/mknod01.c
> index 863d02d..a35adf9 100644
> --- a/testcases/kernel/syscalls/mknod/mknod01.c
> +++ b/testcases/kernel/syscalls/mknod/mknod01.c
> @@ -66,6 +66,7 @@ int TST_TOTAL = ARRAY_SIZE(tcases);
>  int main(int ac, char **av)
>  {
>  	int lc, i;
> +	dev_t dev;
>  
>  	tst_parse_opts(ac, av, NULL, NULL);
>  
> @@ -75,17 +76,25 @@ int main(int ac, char **av)
>  		tst_count = 0;
>  
>  		for (i = 0; i < TST_TOTAL; i++) {
> +			/*
> +			 * overlayfs doesn't support mknod char device with
> +			 * major 0 and minor 0, which is known as whiteout_dev
> +			 */
> +			if (S_ISCHR(tcases[i]))
> +				dev = makedev(1, 3);
> +			else
> +				dev = 0;
>  			TEST(mknod(PATH, tcases[i], 0));

Did you mean to use "dev" variable here? ----------^^^

The rest looks OK to me.

Regards,
Jan

>  
>  			if (TEST_RETURN == -1) {
>  				tst_resm(TFAIL,
> -					 "mknod(%s, %#o, 0) failed, errno=%d : %s",
> -					 PATH, tcases[i], TEST_ERRNO,
> +					 "mknod(%s, %#o, %lu) failed, errno=%d : %s",
> +					 PATH, tcases[i], dev, TEST_ERRNO,
>  					 strerror(TEST_ERRNO));
>  			} else {
>  				tst_resm(TPASS,
> -					 "mknod(%s, %#o, 0) returned %ld",
> -					 PATH, tcases[i], TEST_RETURN);
> +					 "mknod(%s, %#o, %lu) returned %ld",
> +					 PATH, tcases[i], dev, TEST_RETURN);
>  			}
>  
>  			SAFE_UNLINK(cleanup, PATH);
> diff --git a/testcases/kernel/syscalls/mount/mount02.c
> b/testcases/kernel/syscalls/mount/mount02.c
> index 85c050d..916c35e 100644
> --- a/testcases/kernel/syscalls/mount/mount02.c
> +++ b/testcases/kernel/syscalls/mount/mount02.c
> @@ -170,6 +170,8 @@ static void do_umount(void)
>  
>  static void setup(void)
>  {
> +	dev_t dev;
> +
>  	tst_sig(FORK, DEF_HANDLER, cleanup);
>  
>  	tst_require_root();
> @@ -190,9 +192,11 @@ static void setup(void)
>  
>  	memset(path, 'a', PATH_MAX + 1);
>  
> -	if (mknod(char_dev, S_IFCHR | FILE_MODE, 0)) {
> +	dev = makedev(1, 3);
> +	if (mknod(char_dev, S_IFCHR | FILE_MODE, dev)) {
>  		tst_brkm(TBROK | TERRNO, cleanup,
> -		         "failed to mknod(char_dev, S_IFCHR | FILE_MODE, 0)");
> +			 "failed to mknod(char_dev, S_IFCHR | FILE_MODE, %lu)",
> +			 dev);
>  	}
>  
>  	TEST_PAUSE;
> --
> 2.5.0
> 
> 
> --
> Mailing list info: http://lists.linux.it/listinfo/ltp
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] syscalls: avoid creating whiteout device in tests
  2015-12-11 13:00 ` Jan Stancek
@ 2015-12-11 13:19   ` Eryu Guan
  0 siblings, 0 replies; 5+ messages in thread
From: Eryu Guan @ 2015-12-11 13:19 UTC (permalink / raw)
  To: ltp

On Fri, Dec 11, 2015 at 08:00:55AM -0500, Jan Stancek wrote:
> 
> 
> 
> 
> ----- Original Message -----
> > From: "Eryu Guan" <eguan@redhat.com>
> > To: ltp@lists.linux.it
> > Sent: Thursday, 10 December, 2015 12:38:22 PM
> > Subject: [LTP] [PATCH] syscalls: avoid creating whiteout device in tests
> > 
> > A char device with major 0 and minor 0 is known as whiteout device, and
> > overlayfs refuses to create such device. mknod01 and mount02 fail on
> > overlayfs because of this restriction.
> > 
> > Fix it by creating null device instead.
> > 
> > Signed-off-by: Eryu Guan <eguan@redhat.com>
> 
> Hi,
> 
> > ---
> >  testcases/kernel/syscalls/mknod/mknod01.c | 17 +++++++++++++----
> >  testcases/kernel/syscalls/mount/mount02.c |  8 ++++++--
> >  2 files changed, 19 insertions(+), 6 deletions(-)
> > 
> > diff --git a/testcases/kernel/syscalls/mknod/mknod01.c
> > b/testcases/kernel/syscalls/mknod/mknod01.c
> > index 863d02d..a35adf9 100644
> > --- a/testcases/kernel/syscalls/mknod/mknod01.c
> > +++ b/testcases/kernel/syscalls/mknod/mknod01.c
> > @@ -66,6 +66,7 @@ int TST_TOTAL = ARRAY_SIZE(tcases);
> >  int main(int ac, char **av)
> >  {
> >  	int lc, i;
> > +	dev_t dev;
> >  
> >  	tst_parse_opts(ac, av, NULL, NULL);
> >  
> > @@ -75,17 +76,25 @@ int main(int ac, char **av)
> >  		tst_count = 0;
> >  
> >  		for (i = 0; i < TST_TOTAL; i++) {
> > +			/*
> > +			 * overlayfs doesn't support mknod char device with
> > +			 * major 0 and minor 0, which is known as whiteout_dev
> > +			 */
> > +			if (S_ISCHR(tcases[i]))
> > +				dev = makedev(1, 3);
> > +			else
> > +				dev = 0;
> >  			TEST(mknod(PATH, tcases[i], 0));
> 
> Did you mean to use "dev" variable here? ----------^^^

Thanks for the review! Yes, it should be "dev", will send v2 shortly. (I
should generate patch on my test machine, where I test the code, not on
my laptop..)

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v2] syscalls: avoid creating whiteout device in tests
  2015-12-10 11:38 [LTP] [PATCH] syscalls: avoid creating whiteout device in tests Eryu Guan
  2015-12-11 13:00 ` Jan Stancek
@ 2015-12-11 13:24 ` Eryu Guan
  2015-12-11 13:33   ` Jan Stancek
  1 sibling, 1 reply; 5+ messages in thread
From: Eryu Guan @ 2015-12-11 13:24 UTC (permalink / raw)
  To: ltp

A char device with major 0 and minor 0 is known as whiteout device, and
overlayfs refuses to create such device. mknod01 and mount02 fail on
overlayfs because of this restriction.

Fix it by creating null device instead.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---

v2:
- update the arg in mknod syscall to really use variable "dev", which is the
  whole point of this patch

 testcases/kernel/syscalls/mknod/mknod01.c | 19 ++++++++++++++-----
 testcases/kernel/syscalls/mount/mount02.c |  8 ++++++--
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/mknod/mknod01.c b/testcases/kernel/syscalls/mknod/mknod01.c
index 863d02d..c4da3a2 100644
--- a/testcases/kernel/syscalls/mknod/mknod01.c
+++ b/testcases/kernel/syscalls/mknod/mknod01.c
@@ -66,6 +66,7 @@ int TST_TOTAL = ARRAY_SIZE(tcases);
 int main(int ac, char **av)
 {
 	int lc, i;
+	dev_t dev;
 
 	tst_parse_opts(ac, av, NULL, NULL);
 
@@ -75,17 +76,25 @@ int main(int ac, char **av)
 		tst_count = 0;
 
 		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(mknod(PATH, tcases[i], 0));
+			/*
+			 * overlayfs doesn't support mknod char device with
+			 * major 0 and minor 0, which is known as whiteout_dev
+			 */
+			if (S_ISCHR(tcases[i]))
+				dev = makedev(1, 3);
+			else
+				dev = 0;
+			TEST(mknod(PATH, tcases[i], dev));
 
 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL,
-					 "mknod(%s, %#o, 0) failed, errno=%d : %s",
-					 PATH, tcases[i], TEST_ERRNO,
+					 "mknod(%s, %#o, %lu) failed, errno=%d : %s",
+					 PATH, tcases[i], dev, TEST_ERRNO,
 					 strerror(TEST_ERRNO));
 			} else {
 				tst_resm(TPASS,
-					 "mknod(%s, %#o, 0) returned %ld",
-					 PATH, tcases[i], TEST_RETURN);
+					 "mknod(%s, %#o, %lu) returned %ld",
+					 PATH, tcases[i], dev, TEST_RETURN);
 			}
 
 			SAFE_UNLINK(cleanup, PATH);
diff --git a/testcases/kernel/syscalls/mount/mount02.c b/testcases/kernel/syscalls/mount/mount02.c
index 85c050d..916c35e 100644
--- a/testcases/kernel/syscalls/mount/mount02.c
+++ b/testcases/kernel/syscalls/mount/mount02.c
@@ -170,6 +170,8 @@ static void do_umount(void)
 
 static void setup(void)
 {
+	dev_t dev;
+
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
 	tst_require_root();
@@ -190,9 +192,11 @@ static void setup(void)
 
 	memset(path, 'a', PATH_MAX + 1);
 
-	if (mknod(char_dev, S_IFCHR | FILE_MODE, 0)) {
+	dev = makedev(1, 3);
+	if (mknod(char_dev, S_IFCHR | FILE_MODE, dev)) {
 		tst_brkm(TBROK | TERRNO, cleanup,
-		         "failed to mknod(char_dev, S_IFCHR | FILE_MODE, 0)");
+			 "failed to mknod(char_dev, S_IFCHR | FILE_MODE, %lu)",
+			 dev);
 	}
 
 	TEST_PAUSE;
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v2] syscalls: avoid creating whiteout device in tests
  2015-12-11 13:24 ` [LTP] [PATCH v2] " Eryu Guan
@ 2015-12-11 13:33   ` Jan Stancek
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Stancek @ 2015-12-11 13:33 UTC (permalink / raw)
  To: ltp





----- Original Message -----
> From: "Eryu Guan" <eguan@redhat.com>
> To: ltp@lists.linux.it
> Sent: Friday, 11 December, 2015 2:24:23 PM
> Subject: [LTP] [PATCH v2] syscalls: avoid creating whiteout device in tests
> 
> A char device with major 0 and minor 0 is known as whiteout device, and
> overlayfs refuses to create such device. mknod01 and mount02 fail on
> overlayfs because of this restriction.
> 
> Fix it by creating null device instead.
> 
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---
> 
> v2:
> - update the arg in mknod syscall to really use variable "dev", which is the
>   whole point of this patch

Pushed with reference to Documentation about whiteout device.

Regards,
Jan

> 
>  testcases/kernel/syscalls/mknod/mknod01.c | 19 ++++++++++++++-----
>  testcases/kernel/syscalls/mount/mount02.c |  8 ++++++--
>  2 files changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/mknod/mknod01.c
> b/testcases/kernel/syscalls/mknod/mknod01.c
> index 863d02d..c4da3a2 100644
> --- a/testcases/kernel/syscalls/mknod/mknod01.c
> +++ b/testcases/kernel/syscalls/mknod/mknod01.c
> @@ -66,6 +66,7 @@ int TST_TOTAL = ARRAY_SIZE(tcases);
>  int main(int ac, char **av)
>  {
>  	int lc, i;
> +	dev_t dev;
>  
>  	tst_parse_opts(ac, av, NULL, NULL);
>  
> @@ -75,17 +76,25 @@ int main(int ac, char **av)
>  		tst_count = 0;
>  
>  		for (i = 0; i < TST_TOTAL; i++) {
> -			TEST(mknod(PATH, tcases[i], 0));
> +			/*
> +			 * overlayfs doesn't support mknod char device with
> +			 * major 0 and minor 0, which is known as whiteout_dev
> +			 */
> +			if (S_ISCHR(tcases[i]))
> +				dev = makedev(1, 3);
> +			else
> +				dev = 0;
> +			TEST(mknod(PATH, tcases[i], dev));
>  
>  			if (TEST_RETURN == -1) {
>  				tst_resm(TFAIL,
> -					 "mknod(%s, %#o, 0) failed, errno=%d : %s",
> -					 PATH, tcases[i], TEST_ERRNO,
> +					 "mknod(%s, %#o, %lu) failed, errno=%d : %s",
> +					 PATH, tcases[i], dev, TEST_ERRNO,
>  					 strerror(TEST_ERRNO));
>  			} else {
>  				tst_resm(TPASS,
> -					 "mknod(%s, %#o, 0) returned %ld",
> -					 PATH, tcases[i], TEST_RETURN);
> +					 "mknod(%s, %#o, %lu) returned %ld",
> +					 PATH, tcases[i], dev, TEST_RETURN);
>  			}
>  
>  			SAFE_UNLINK(cleanup, PATH);
> diff --git a/testcases/kernel/syscalls/mount/mount02.c
> b/testcases/kernel/syscalls/mount/mount02.c
> index 85c050d..916c35e 100644
> --- a/testcases/kernel/syscalls/mount/mount02.c
> +++ b/testcases/kernel/syscalls/mount/mount02.c
> @@ -170,6 +170,8 @@ static void do_umount(void)
>  
>  static void setup(void)
>  {
> +	dev_t dev;
> +
>  	tst_sig(FORK, DEF_HANDLER, cleanup);
>  
>  	tst_require_root();
> @@ -190,9 +192,11 @@ static void setup(void)
>  
>  	memset(path, 'a', PATH_MAX + 1);
>  
> -	if (mknod(char_dev, S_IFCHR | FILE_MODE, 0)) {
> +	dev = makedev(1, 3);
> +	if (mknod(char_dev, S_IFCHR | FILE_MODE, dev)) {
>  		tst_brkm(TBROK | TERRNO, cleanup,
> -		         "failed to mknod(char_dev, S_IFCHR | FILE_MODE, 0)");
> +			 "failed to mknod(char_dev, S_IFCHR | FILE_MODE, %lu)",
> +			 dev);
>  	}
>  
>  	TEST_PAUSE;
> --
> 2.5.0
> 
> 
> --
> Mailing list info: http://lists.linux.it/listinfo/ltp
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-11 13:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-10 11:38 [LTP] [PATCH] syscalls: avoid creating whiteout device in tests Eryu Guan
2015-12-11 13:00 ` Jan Stancek
2015-12-11 13:19   ` Eryu Guan
2015-12-11 13:24 ` [LTP] [PATCH v2] " Eryu Guan
2015-12-11 13:33   ` Jan Stancek

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.