[LTP] [PATCH v2] syscalls/{fanotify17, getxattr05}: Fix the ENOSPC error
Cyril Hrubis
chrubis@suse.cz
Tue Apr 29 11:47:09 CEST 2025
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
More information about the ltp
mailing list