]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: recover from ENOSYS for the new API
authorKarel Zak <kzak@redhat.com>
Mon, 24 Apr 2023 15:29:05 +0000 (17:29 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 24 Apr 2023 15:29:05 +0000 (17:29 +0200)
Addresses: https://github.com/util-linux/util-linux/pull/2188
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/hook_mount.c
libmount/src/mountP.h

index 7fcf3f3f8439c9f0a4590861eb1f9441709be2e3..2dbe5217cc2aac2abb3ce65bc913e7ed94135ef2 100644 (file)
@@ -571,6 +571,8 @@ fake:
  *
  * Note that this function interprets classic MS_* flags by new Linux mount FD
  * based API.
+ *
+ * Returns: 0 on success, <0 on error, >0 on recover-able error
  */
 static int hook_prepare(struct libmnt_context *cxt,
                        const struct libmnt_hookset *hs,
@@ -614,8 +616,15 @@ static int hook_prepare(struct libmnt_context *cxt,
                rc = mnt_optlist_get_attrs(ol, &set, &clr, 0);
 
        /* open_tree() or fsopen() */
-       if (!rc)
+       if (!rc) {
                rc = init_sysapi(cxt, hs, flags);
+               if (rc && cxt->syscall_status == -ENOSYS) {
+                       /* we need to recover from this error, so hook_mount_legacy.c
+                        * can try to continue */
+                       reset_syscall_status(cxt);
+                       return 1;
+               }
+       }
 
        /* check mutually exclusive operations */
        if (!rc && (flags & MS_BIND) && (flags & MS_MOVE))
index d7ae6b7d2d50c26649ef6f5aaef03a2c78f6f740..a2ab4a81453aa81ebea3893df09fd1e62af403ff 100644 (file)
@@ -490,6 +490,12 @@ struct libmnt_context
                } \
        })
 
+#define reset_syscall_status(_cxt)     __extension__ ({ \
+               DBG(CXT, ul_debug("reset sycall status")); \
+               (_cxt)->syscall_status = 0; \
+               (_cxt)->syscall_name = NULL; \
+       })
+
 /* optmap.c */
 extern const struct libmnt_optmap *mnt_optmap_get_entry(
                             struct libmnt_optmap const **maps,