diff options
| -rw-r--r-- | include/mount-api-utils.h | 11 | ||||
| -rw-r--r-- | libmount/src/tab_listmount.c | 19 | ||||
| -rw-r--r-- | tests/helpers/test_sysinfo.c | 9 |
3 files changed, 22 insertions, 17 deletions
diff --git a/include/mount-api-utils.h b/include/mount-api-utils.h index ea9aeb816b..8dbe534672 100644 --- a/include/mount-api-utils.h +++ b/include/mount-api-utils.h @@ -437,6 +437,17 @@ static inline ssize_t ul_listmount(uint64_t mnt_id, return syscall(SYS_listmount, &req, list, num, flags); } + +static inline int has_listmount(void) +{ + uint64_t dummy; + + errno = 0; + + if (ul_listmount(LSMT_ROOT, 0, 0, &dummy, 1, LISTMOUNT_REVERSE) != 1) + return 0; + return 1; +} #endif #endif /* HAVE_STATMOUNT_API */ diff --git a/libmount/src/tab_listmount.c b/libmount/src/tab_listmount.c index c9725a23c5..e4a1c2a529 100644 --- a/libmount/src/tab_listmount.c +++ b/libmount/src/tab_listmount.c @@ -91,18 +91,13 @@ static int table_init_listmount(struct libmnt_table *tb, size_t stepsiz) ls = tb->lsmnt; /* check if supported by current kernel */ - if (!ls) { - uint64_t dummy; - - errno = 0; - if (ul_listmount(LSMT_ROOT, 0, 0, &dummy, 1, LISTMOUNT_REVERSE) != 1) { - if (errno == ENOSYS) - DBG(TAB, ul_debugobj(tb, "listmount: unsuppported")); - if (errno == EINVAL) - DBG(TAB, ul_debugobj(tb, "listmount: reverse unsuppported")); - errno = ENOSYS; - return -ENOSYS; - } + if (!ls && !has_listmount()) { + if (errno == ENOSYS) + DBG(TAB, ul_debugobj(tb, "listmount: unsuppported")); + if (errno == EINVAL) + DBG(TAB, ul_debugobj(tb, "listmount: reverse unsuppported")); + errno = ENOSYS; + return -ENOSYS; } /* reset if allocated for a different size */ diff --git a/tests/helpers/test_sysinfo.c b/tests/helpers/test_sysinfo.c index 00bf12727d..b4a601e3bc 100644 --- a/tests/helpers/test_sysinfo.c +++ b/tests/helpers/test_sysinfo.c @@ -157,14 +157,13 @@ static int hlp_statmount_ok(void) static int hlp_listmount_ok(void) { + printf("%d\n", #ifdef HAVE_STATMOUNT_API - uint64_t dummy; - errno = 0; - ul_listmount(LSMT_ROOT, 0, 0, &dummy, 1, LISTMOUNT_REVERSE); + has_listmount() #else - errno = ENOSYS; + 0 #endif - printf("%d\n", !(errno == ENOSYS || errno == EINVAL)); + ); return 0; } |
