# define LISTMOUNT_REVERSE BIT(0) /* List later mounts first */
#endif
+/* Don't use this "raw" version. See ul_statmount() below. */
#if defined(SYS_statmount)
-static inline int ul_statmount(uint64_t mnt_id,
+static inline int ul_statmount_syscall(uint64_t mnt_id,
uint64_t ns_id,
uint64_t mask,
struct ul_statmount *buf,
return syscall(SYS_statmount, &req, buf, bufsize, flags);
}
-#endif
-#if defined(SYS_listmount)
-static inline ssize_t ul_listmount(uint64_t mnt_id,
- uint64_t ns_id,
- uint64_t last_mnt_id,
- uint64_t list[], size_t num,
- unsigned int flags)
+static inline int has_statmount(void)
{
- struct ul_mnt_id_req req = {
- .size = MNT_ID_REQ_SIZE_VER1,
- .mnt_id = mnt_id,
- .param = last_mnt_id,
- .mnt_ns_id = ns_id
- };
+ errno = 0;
- return syscall(SYS_listmount, &req, list, num, flags);
+ if (ul_statmount_syscall(0, 0, 0, NULL, 0, 0) < 0 && errno == ENOSYS)
+ return 0;
+ return 1;
}
-#endif
/* This is a version of statmount() that reallocates @buf to be large enough to
* store data for the requested @id. This function never deallocates; it is the
* caller's responsibility.
*/
-static inline int sys_statmount(uint64_t id,
+static inline int ul_statmount(uint64_t id,
uint64_t ns_id,
uint64_t mask,
struct ul_statmount **buf,
}
errno = 0;
- rc = ul_statmount(id, ns_id, mask, *buf, *bufsiz, flags);
+ rc = ul_statmount_syscall(id, ns_id, mask, *buf, *bufsiz, flags);
if (!rc)
break;
if (errno != EOVERFLOW)
return rc;
}
+#endif /* SYS_statmount */
+
+
+#if defined(SYS_listmount)
+static inline ssize_t ul_listmount(uint64_t mnt_id,
+ uint64_t ns_id,
+ uint64_t last_mnt_id,
+ uint64_t list[], size_t num,
+ unsigned int flags)
+{
+ struct ul_mnt_id_req req = {
+ .size = MNT_ID_REQ_SIZE_VER1,
+ .mnt_id = mnt_id,
+ .param = last_mnt_id,
+ .mnt_ns_id = ns_id
+ };
+
+ return syscall(SYS_listmount, &req, list, num, flags);
+}
+#endif
#endif /* HAVE_STATMOUNT_API */
struct libmnt_statmnt *sm;
errno = 0;
- if (ul_statmount(0, 0, 0, NULL, 0, 0) < 0 && errno == ENOSYS) {
+ if (!has_statmount()) {
DBG(FS, ul_debug("statmount: unsuppported"));
return NULL;
}
if (fs->stmnt) {
DBG(FS, ul_debugobj(fs, " reuse libmnt_stmnt"));
memset(fs->stmnt->buf, 0, fs->stmnt->bufsiz);
- rc = sys_statmount(fs->uniq_id, 0, mask,
+
+ rc = ul_statmount(fs->uniq_id, 0, mask,
&fs->stmnt->buf, &fs->stmnt->bufsiz, 0);
buf = fs->stmnt->buf;
bufsiz = fs->stmnt->bufsiz;
} else {
DBG(FS, ul_debugobj(fs, " use private buffer"));
- rc = sys_statmount(fs->uniq_id, 0, mask, &buf, &bufsiz, 0);
+ rc = ul_statmount(fs->uniq_id, 0, mask, &buf, &bufsiz, 0);
}
DBG(FS, ul_debugobj(fs, " statmount [rc=%d bufsiz=%zu ns=%" PRIu64 " mask: %s%s%s%s%s%s%s]",
rc, bufsiz, ns,
mask & STATMOUNT_FS_TYPE ? "fs-type " : "",
mask & STATMOUNT_MNT_OPTS ? "mnt-opts " : "",
mask & STATMOUNT_SB_SOURCE ? "sb-source " : ""));
-
if (!rc)
rc = apply_statmount(fs, buf);
done:
-
if (fs->stmnt)
mnt_statmnt_disable_fetching(fs->stmnt, status);
else