Skip to contentSkip to conversation

quotactl ESRCH fixes

PATCH In review Petr Vorel 3 participants 15 messages Feb 23, 2022 – Mar 4, 2022

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover quotactl ESRCH fixes

Hi,

simple cleanup to use already provided errno ESRCH handling.

Fortunately all tests which require do_mount() use quotactl_syscall_var.h, thus I didn't have to introduce yet another header.

Kind regards,
Petr

Petr Vorel (3):
quotactl: Move do_mount() to header
quotactl08: Use do_mount()
quotactl09: Use do_mount()

 .../kernel/syscalls/quotactl/quotactl04.c     | 25 ++-----------------
 .../kernel/syscalls/quotactl/quotactl08.c     |  2 +-
 .../kernel/syscalls/quotactl/quotactl09.c     | 16 +++++++++---
 .../syscalls/quotactl/quotactl_syscall_var.h  | 25 +++++++++++++++++--
 4 files changed, 39 insertions(+), 29 deletions(-)
Signature · 5 lines
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH 1/3 quotactl: Move do_mount() to header

This allows do_mount() to be reusable in quotactl08.c and quotactl09.c.

Add inline keyword to it and to the other two functions (to follow LTP convention).

---
 .../kernel/syscalls/quotactl/quotactl04.c     | 25 ++-----------------
 .../syscalls/quotactl/quotactl_syscall_var.h  | 25 +++++++++++++++++--
 2 files changed, 25 insertions(+), 25 deletions(-)
testcases/kernel/syscalls/quotactl/quotactl04.c +2 -23
index 55da282705..f45ee43960 100644
@@ -25,7 +25,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include <sys/mount.h>
 #include "tst_test.h"
 #include "quotactl_syscall_var.h"
 
@@ -95,28 +94,6 @@ static struct tcase {
 
 };
 
-static void do_mount(const char *source, const char *target,
-	const char *filesystemtype, unsigned long mountflags,
-	const void *data)
-{
-	TEST(mount(source, target, filesystemtype, mountflags, data));
-
-	if (TST_RET == -1 && TST_ERR == ESRCH)
-		tst_brk(TCONF, "Kernel or device does not support FS quotas");
-
-	if (TST_RET == -1) {
-		tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
-			source, target, filesystemtype, mountflags, data);
-	}
-
-	if (TST_RET) {
-		tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
-			source, target, filesystemtype, mountflags, data);
-	}
-
-	mount_flag = 1;
-}
-
 static void setup(void)
 {
 	const char *const fs_opts[] = {"-I 256", "-O quota,project", NULL};
@@ -124,6 +101,8 @@ static void setup(void)
 	quotactl_info();
 	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
 	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	mount_flag = 1;
+
 	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
 }
 
testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h +23 -2
index 3d1a2c8f5a..ba25fd9936 100644
@@ -7,6 +7,7 @@
 #ifndef LTP_QUOTACTL_SYSCALL_VAR_H
 #define LTP_QUOTACTL_SYSCALL_VAR_H
 
+#include <sys/mount.h>
 #include "lapi/quotactl.h"
 
 #define QUOTACTL_SYSCALL_VARIANTS 2
@@ -14,14 +15,14 @@
 
 static int fd = -1;
 
-static int do_quotactl(int fd, int cmd, const char *special, int id, caddr_t addr)
+static inline int do_quotactl(int fd, int cmd, const char *special, int id, caddr_t addr)
 {
 	if (tst_variant == 0)
 		return quotactl(cmd, special, id, addr);
 	return quotactl_fd(fd, cmd, id, addr);
 }
 
-static void quotactl_info(void)
+static inline void quotactl_info(void)
 {
 	if (tst_variant == 0)
 		tst_res(TINFO, "Test quotactl()");
@@ -29,4 +30,24 @@ static void quotactl_info(void)
 		tst_res(TINFO, "Test quotactl_fd()");
 }
 
+static inline void do_mount(const char *source, const char *target,
+	const char *filesystemtype, unsigned long mountflags,
+	const void *data)
+{
+	TEST(mount(source, target, filesystemtype, mountflags, data));
+
+	if (TST_RET == -1 && TST_ERR == ESRCH)
+		tst_brk(TCONF, "Kernel or device does not support FS quotas");
+
+	if (TST_RET == -1) {
+		tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
+			source, target, filesystemtype, mountflags, data);
+	}
+
+	if (TST_RET) {
+		tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed",
+			source, target, filesystemtype, mountflags, data);
+	}
+}
+
 #endif /* LTP_QUOTACTL_SYSCALL_VAR_H */
Signature · 5 lines
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#2 lore raw

PATCH 2/3 quotactl08: Use do_mount()

In reply to Petr Vorel

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
 testcases/kernel/syscalls/quotactl/quotactl08.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl08.c +1 -1
index 3793867f23..9f54bebcc0 100644
@@ -157,7 +157,7 @@ static void setup(void)
 	quotactl_info();
 
 	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
 	mount_flag = 1;
 
 	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
Signature · 5 lines
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

Best Regards
Yang Xu

Quoted 21 lines

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
  testcases/kernel/syscalls/quotactl/quotactl08.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl08.c +1 -1
index 3793867f23..9f54bebcc0 100644
@@ -157,7 +157,7 @@ static void setup(void)
  	quotactl_info();
 
  	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
  	mount_flag = 1;
 
  	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#4 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Quoted 5 lines

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

I have no idea.
And yes, the config contains CONFIG_QFMT_V2=m

Kind regards,
Petr

Quoted 23 lines

Best Regards
Yang Xu

Quoted 20 lines

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
  testcases/kernel/syscalls/quotactl/quotactl08.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl08.c +1 -1
index 3793867f23..9f54bebcc0 100644
@@ -157,7 +157,7 @@ static void setup(void)
  	quotactl_info();
 
  	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
  	mount_flag = 1;
 
  	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

In reply to [email protected]

Hi Xu,

Quoted 5 lines

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

There is probably bug on the SUT, thus it might be correct it fails.

But how about martin's fix 4aab31e4c7 ("syscalls/quotactl: Skip tests if FS quota is not supported") - quotactl04.c also checks for CONFIG_QFMT_V2 and uses do_mount(). I'll check whether it was another bug on the system.

Kind regards,
Petr

Quoted 23 lines

Best Regards
Yang Xu

Quoted 20 lines

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
  testcases/kernel/syscalls/quotactl/quotactl08.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl08.c +1 -1
index 3793867f23..9f54bebcc0 100644
@@ -157,7 +157,7 @@ static void setup(void)
  	quotactl_info();
 
  	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
  	mount_flag = 1;
 
  	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Hi Petr

Quoted 5 lines

Hi Xu,

Quoted 3 lines

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

Quoted 8 lines
Quoted 2 lines

I doubt why fs quota is not supported on this case since we have check kernel config?

There is probably bug on the SUT, thus it might be correct it fails.

But how about martin's fix 4aab31e4c7 ("syscalls/quotactl: Skip tests if FS quota is not supported") - quotactl04.c also checks for CONFIG_QFMT_V2 and uses do_mount(). I'll check whether it was another bug on the system.

Maybe we miss check the following kernel config?
CONFIG_QUOTA=y
CONFIG_QUOTA_TREE=y
CONFIG_QUOTACTL=y

Best Regards
Yang Xu

Quoted 27 lines

Kind regards,
Petr

Quoted 23 lines

Best Regards
Yang Xu

Quoted 20 lines

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
   testcases/kernel/syscalls/quotactl/quotactl08.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl08.c +1 -1
index 3793867f23..9f54bebcc0 100644
@@ -157,7 +157,7 @@ static void setup(void)
   	quotactl_info();
 
   	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
   	mount_flag = 1;
 
   	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Quoted 9 lines

Hi Petr

Quoted 7 lines

Hi Xu,

Quoted 5 lines

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

Quoted 6 lines
Quoted 5 lines

There is probably bug on the SUT, thus it might be correct it fails.

But how about martin's fix 4aab31e4c7 ("syscalls/quotactl: Skip tests if FS quota is not supported") - quotactl04.c also checks for CONFIG_QFMT_V2 and uses do_mount(). I'll check whether it was another bug on the system.

Maybe we miss check the following kernel config?

In my case it's probably a problem with mkfs.

Quoted 1 line

CONFIG_QUOTA=y

Selected by [m]:
- OCFS2_FS [=m] && BLOCK [=y] && INET [=y] && SYSFS [=y] && CONFIGFS_FS [=m]
=> very unlikely not to be selected (but we might want to check also corner case configurations; but I guess also CONFIG_QUOTA=m would be ok)

Quoted 1 line

CONFIG_QUOTA_TREE=y

Selected by [m]:
- OCFS2_FS [=m] && BLOCK [=y] && INET [=y] && SYSFS [=y] && CONFIGFS_FS [=m]
Selected by [n]:
- QFMT_V2 [=n] && QUOTA [=y]
ditto

Quoted 1 line

CONFIG_QUOTACTL=y

Selected by [y]:
- QUOTA [=y]
Selected by [m]:
- XFS_QUOTA [=y] && BLOCK [=y] && XFS_FS [=m]
- GFS2_FS [=m] && BLOCK [=y]
even more likely to be selected.

Kind regards,
Petr

Quoted 29 lines

Best Regards
Yang Xu

Quoted 26 lines

Kind regards,
Petr

Quoted 23 lines

Best Regards
Yang Xu

Quoted 20 lines

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
   testcases/kernel/syscalls/quotactl/quotactl08.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl08.c +1 -1
index 3793867f23..9f54bebcc0 100644
@@ -157,7 +157,7 @@ static void setup(void)
   	quotactl_info();
 
   	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
   	mount_flag = 1;
 
   	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Hi Petr

Quoted 9 lines
Quoted 8 lines

Hi Petr

Quoted 7 lines

Hi Xu,

Quoted 5 lines

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

There is probably bug on the SUT, thus it might be correct it fails.

But how about martin's fix 4aab31e4c7 ("syscalls/quotactl: Skip tests if FS quota is not supported") - quotactl04.c also checks for CONFIG_QFMT_V2 and uses do_mount(). I'll check whether it was another bug on the system.

Maybe we miss check the following kernel config?

In my case it's probably a problem with mkfs.

Another possible way about loop driver. So do you use default loop image to create ext4 filesystem or export LTP_DEV?

Best Regards
Yang Xu

Quoted 54 lines
Quoted 2 lines

CONFIG_QUOTA=y

Selected by [m]:
- OCFS2_FS [=m]&& BLOCK [=y]&& INET [=y]&& SYSFS [=y]&& CONFIGFS_FS [=m]
=> very unlikely not to be selected (but we might want to check also corner case configurations; but I guess also CONFIG_QUOTA=m would be ok)

Quoted 1 line

CONFIG_QUOTA_TREE=y

Selected by [m]:
- OCFS2_FS [=m]&& BLOCK [=y]&& INET [=y]&& SYSFS [=y]&& CONFIGFS_FS [=m]
Selected by [n]:
- QFMT_V2 [=n]&& QUOTA [=y]
ditto

Quoted 1 line

CONFIG_QUOTACTL=y

Selected by [y]:
- QUOTA [=y]
Selected by [m]:
- XFS_QUOTA [=y]&& BLOCK [=y]&& XFS_FS [=m]
- GFS2_FS [=m]&& BLOCK [=y]
even more likely to be selected.

Kind regards,
Petr

Quoted 29 lines

Best Regards
Yang Xu

Quoted 26 lines

Kind regards,
Petr

Quoted 23 lines

Best Regards
Yang Xu

Quoted 20 lines

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
    testcases/kernel/syscalls/quotactl/quotactl08.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl08.c +1 -1
index 3793867f23..9f54bebcc0 100644
@@ -157,7 +157,7 @@ static void setup(void)
    	quotactl_info();
 
    	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
    	mount_flag = 1;
 
    	fd = SAFE_OPEN(MNTPOINT, O_RDONLY);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Hi Xu,

...

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

There is probably bug on the SUT, thus it might be correct it fails.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

But how about martin's fix 4aab31e4c7 ("syscalls/quotactl: Skip tests if FS quota is not supported") - quotactl04.c also checks for CONFIG_QFMT_V2 and uses do_mount(). I'll check whether it was another bug on the system.

Maybe we miss check the following kernel config?

In my case it's probably a problem with mkfs.

Another possible way about loop driver. So do you use default loop image to create ext4 filesystem or export LTP_DEV?

FYI: in our case it was JeOS broken due missing quota_v2 kernel driver (JeOS tries to be minimal, so it's always a fiddling between space and functionality). I'm still not sure if we want to add check for .needs_drivers quota_v2.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Quoted 4 lines · Petr Vorel

FYI: in our case it was JeOS broken due missing quota_v2 kernel driver (JeOS tries to be minimal, so it's always a fiddling between space and functionality). I'm still not sure if we want to add check for .needs_drivers quota_v2.

.needs_drivers would probably be the cleaner solution.

Signature · 10 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#11 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Hi Martin,

Quoted 7 lines · Petr Vorel
Quoted 4 lines

FYI: in our case it was JeOS broken due missing quota_v2 kernel driver (JeOS tries to be minimal, so it's always a fiddling between space and functionality). I'm still not sure if we want to add check for .needs_drivers quota_v2.

.needs_drivers would probably be the cleaner solution.

Sure - I'm closing this as wrong approach. I just wasn't sure if we want to check for .needs_drivers. Because there could be numerous of other tests which require test for missing driver. And it's relevant just fo JeOS like installations, which strive for minimal size. BTW in our case it endup with module added to kernel-default-base package (thus to be always installed).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

In reply to [email protected]
Quoted 5 lines · On 24. 02. 22 2:47, [email protected] wrote:

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

In this case, kernel config says that quota is enabled as a module (=M). But the module is packaged in a separate RPM and the test is running on a minimalistic system where that RPM is not available. Therefore just checking the kernel config is not sufficient. We need to query actual module presence.

(Sorry for duplicate mail, I forgot to CC the mailing list.)

Signature · 10 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#13 lore raw

Re: [LTP] [PATCH 2/3] quotactl08: Use do_mount()

Hi Martin

Quoted 7 lines · On 24. 02. 22 2:47, [email protected] wrote:
Quoted 5 lines

Hi Petr

Quoted 2 lines

to change
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

I doubt why fs quota is not supported on this case since we have check kernel config?

Quoted 7 lines

In this case, kernel config says that quota is enabled as a module (=M). But the module is packaged in a separate RPM and the test is running on a minimalistic system where that RPM is not available. Therefore just checking the kernel config is not sufficient. We need to query actual module presence.

(Sorry for duplicate mail, I forgot to CC the mailing list.)

Oh, I replied the personal mail.

Thanks for your explaination. I don't know this complex situation before.

I think the quota module is belong to kernel-default package but not belong to kernel-default-base package. So jeos use kernel-default-base will pass kernel config check but indeed it miss this module.

This problem also occurs on centos if we use module from kernel-module-extra.

So a better solution is that if the module is belong to kernel-default-base ,then we can use kconfig check, but if the module is not belong to kernel-default-base, then use need_driver maybe more correct.

Best Regards
Yang Xu

Quoted 1 line
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#14 lore raw

PATCH 3/3 quotactl09: Use do_mount()

In reply to Petr Vorel

to change:
quotactl08.c:160: TBROK: mount(/dev/loop0, mntpoint, ext4, 0, (nil)) failed: ESRCH (3)

to TCONF if FS quota is not supported (the same fix as 4aab31e4c7).

---
 testcases/kernel/syscalls/quotactl/quotactl09.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/quotactl/quotactl09.c +13 -3
index 8b959909ca..57030f7d2e 100644
@@ -32,7 +32,7 @@
 #define OPTION_INVALID 999
 
 static int32_t fmt_id = QFMT_VFS_V1;
-static int test_id;
+static int test_id, mount_flag;
 static int getnextquota_nsup, socket_fd = -1;
 
 static struct if_nextdqblk res_ndq;
@@ -144,6 +144,12 @@ static void setup(void)
 {
 	unsigned int i;
 
+	if (!tst_variant)
+		SAFE_MKDIR(MNTPOINT, 0777);
+
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+	mount_flag = 1;
+
 	quotactl_info();
 
 	socket_fd = SAFE_SOCKET(PF_INET, SOCK_STREAM, 0);
@@ -163,8 +169,12 @@ static void cleanup(void)
 {
 	if (fd > -1)
 		SAFE_CLOSE(fd);
+
 	if (socket_fd > -1)
 		SAFE_CLOSE(socket_fd);
+
+	if (mount_flag && tst_umount(MNTPOINT))
+		tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
 }
 
 static struct tst_test test = {
@@ -178,8 +188,8 @@ static struct tst_test test = {
 	.test = verify_quotactl,
 	.dev_fs_opts = (const char *const[]){"-O quota", NULL},
 	.dev_fs_type = "ext4",
-	.mntpoint = MNTPOINT,
-	.mount_device = 1,
+	//.mntpoint = MNTPOINT,
+	.format_device = 1,
 	.needs_root = 1,
 	.test_variants = QUOTACTL_SYSCALL_VARIANTS,
 	.needs_cmds = (const char *[]) {
Signature · 5 lines
2.35.1


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