All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Xiao Yang <ice_yangxiao@163.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] syscalls/{fanotify17, getxattr05}: Fix the ENOSPC error
Date: Tue, 29 Apr 2025 11:47:09 +0200	[thread overview]
Message-ID: <aBCgHaiSIGxYDFPS@yuki.lan> (raw)
In-Reply-To: <20240925084921.16352-1-ice_yangxiao@163.com>

Hi!
> If the value of max_user_namespaces is set to 10 but more than
> 10 user namspaces are currently used on system.  In this case,
> these tests fail with ENOSPC. for example:

What about we add a functionality to increment syfs files to the
save_restore API? I guess that this is going to be a pattern that we
have in several tests already.

Should look like (beware untested):

diff --git a/include/tst_sys_conf.h b/include/tst_sys_conf.h
index a221a9a0d..b84f05a50 100644
--- a/include/tst_sys_conf.h
+++ b/include/tst_sys_conf.h
@@ -12,6 +12,7 @@
 #define TST_SR_TBROK_RO 0x4
 #define TST_SR_SKIP_RO 0x8
 #define TST_SR_IGNORE_ERR 0x10
+#define TST_SR_INC 0x20

 #define TST_SR_TCONF (TST_SR_TCONF_MISSING | TST_SR_TCONF_RO)
 #define TST_SR_TBROK (TST_SR_TBROK_MISSING | TST_SR_TBROK_RO)
diff --git a/lib/tst_sys_conf.c b/lib/tst_sys_conf.c
index 80cd83569..5d1de241a 100644
--- a/lib/tst_sys_conf.c
+++ b/lib/tst_sys_conf.c
@@ -55,6 +55,8 @@ void tst_sys_conf_save_str(const char *path, const char *value)
 int tst_sys_conf_save(const struct tst_path_val *conf)
 {
        char line[PATH_MAX];
+       char inc_val[32];
+       const char *new_val = conf->val;
        int ttype, iret;
        FILE *fp;
        void *ret;
@@ -105,7 +107,35 @@ int tst_sys_conf_save(const struct tst_path_val *conf)

        tst_sys_conf_save_str(conf->path, line);

-       if (!conf->val)
+
+       if (conf->flags & TST_SR_INC) {
+               long orig, inc;
+
+               if (!conf->val) {
+                       tst_brk(TBROK, "Increment value not defined!");
+               }
+
+               if (tst_parse_long(line, &orig, LONG_MIN, LONG_MAX)) {
+                       tst_brk(TBROK | TERRNO,
+                               "Failed to convert '%s' to long",
+                               conf->path);
+               }
+
+               if (tst_parse_long(line, &inc, LONG_MIN, LONG_MAX)) {
+                       tst_brk(TBROK | TERRNO,
+                               "Failed to convert increment (%s) for '%s' to long",
+                               conf->val, conf->path);
+               }
+
+               //TODO: Overflow?
+               orig += inc;
+
+               snprintf(inc_val, sizeof(inc_val), "%li", orig);
+
+               new_val = inc_val;
+       }
+
+       if (!new_val)
                return 0;

        fp = fopen(conf->path, "w");
@@ -116,7 +146,7 @@ int tst_sys_conf_save(const struct tst_path_val *conf)
                return 0;
        }

-       iret = fputs(conf->val, fp);
+       iret = fputs(new_val, fp);

        if (iret < 0) {
                print_error(__LINE__, conf->flags & TST_SR_IGNORE_ERR,


After this patch the val in tst_path_val is going to be interpreted as
an increment with TST_SR_INC flag.

-- 
Cyril Hrubis
chrubis@suse.cz

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

      parent reply	other threads:[~2025-04-29  9:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25  8:49 [LTP] [PATCH v2] syscalls/{fanotify17, getxattr05}: Fix the ENOSPC error Xiao Yang
2024-09-26 11:18 ` Cyril Hrubis
2024-11-04 16:38   ` Petr Vorel
2024-11-04 16:45 ` Petr Vorel
2025-01-27 17:14 ` Petr Vorel
2025-04-29  9:47 ` Cyril Hrubis [this message]

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=aBCgHaiSIGxYDFPS@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ice_yangxiao@163.com \
    --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.