mountpoint-util: rename fd_is_mount_point() to is_mount_point_at()
fd_* functions in our codebase usually mean fd-specific operations, while this one actually takes openat()-style params. Rename it accordingly hence.
This commit is contained in:
@@ -452,14 +452,14 @@ TEST(fd_make_mount_point) {
|
||||
fd = open(s, O_PATH|O_CLOEXEC);
|
||||
assert_se(fd >= 0);
|
||||
|
||||
assert_se(fd_is_mount_point(fd, NULL, AT_SYMLINK_FOLLOW) == 0);
|
||||
assert_se(is_mount_point_at(fd, NULL, AT_SYMLINK_FOLLOW) == 0);
|
||||
|
||||
assert_se(fd_make_mount_point(fd) > 0);
|
||||
|
||||
/* Reopen the inode so that we end up on the new mount */
|
||||
fd2 = open(s, O_PATH|O_CLOEXEC);
|
||||
|
||||
assert_se(fd_is_mount_point(fd2, NULL, AT_SYMLINK_FOLLOW) > 0);
|
||||
assert_se(is_mount_point_at(fd2, NULL, AT_SYMLINK_FOLLOW) > 0);
|
||||
|
||||
assert_se(fd_make_mount_point(fd2) == 0);
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ TEST(path_is_mount_point) {
|
||||
assert_se(rm_rf(tmp_dir, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
|
||||
}
|
||||
|
||||
TEST(fd_is_mount_point) {
|
||||
TEST(is_mount_point_at) {
|
||||
_cleanup_(rm_rf_physical_and_freep) char *tmpdir = NULL;
|
||||
_cleanup_free_ char *pwd = NULL;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
@@ -281,42 +281,42 @@ TEST(fd_is_mount_point) {
|
||||
assert_se(fd >= 0);
|
||||
|
||||
/* Not allowed, since "/" is a path, not a plain filename */
|
||||
assert_se(fd_is_mount_point(fd, "/", 0) == -EINVAL);
|
||||
assert_se(fd_is_mount_point(fd, "..", 0) == -EINVAL);
|
||||
assert_se(fd_is_mount_point(fd, "../", 0) == -EINVAL);
|
||||
assert_se(fd_is_mount_point(fd, "/proc", 0) == -EINVAL);
|
||||
assert_se(fd_is_mount_point(fd, "/proc/", 0) == -EINVAL);
|
||||
assert_se(fd_is_mount_point(fd, "proc/sys", 0) == -EINVAL);
|
||||
assert_se(fd_is_mount_point(fd, "proc/sys/", 0) == -EINVAL);
|
||||
assert_se(is_mount_point_at(fd, "/", 0) == -EINVAL);
|
||||
assert_se(is_mount_point_at(fd, "..", 0) == -EINVAL);
|
||||
assert_se(is_mount_point_at(fd, "../", 0) == -EINVAL);
|
||||
assert_se(is_mount_point_at(fd, "/proc", 0) == -EINVAL);
|
||||
assert_se(is_mount_point_at(fd, "/proc/", 0) == -EINVAL);
|
||||
assert_se(is_mount_point_at(fd, "proc/sys", 0) == -EINVAL);
|
||||
assert_se(is_mount_point_at(fd, "proc/sys/", 0) == -EINVAL);
|
||||
|
||||
/* This one definitely is a mount point */
|
||||
assert_se(fd_is_mount_point(fd, "proc", 0) > 0);
|
||||
assert_se(fd_is_mount_point(fd, "proc/", 0) > 0);
|
||||
assert_se(is_mount_point_at(fd, "proc", 0) > 0);
|
||||
assert_se(is_mount_point_at(fd, "proc/", 0) > 0);
|
||||
|
||||
safe_close(fd);
|
||||
fd = open("/tmp", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
|
||||
assert_se(fd >= 0);
|
||||
|
||||
assert_se(mkdtemp_malloc("/tmp/not-mounted-XXXXXX", &tmpdir) >= 0);
|
||||
assert_se(fd_is_mount_point(fd, basename(tmpdir), 0) == 0);
|
||||
assert_se(fd_is_mount_point(fd, strjoina(basename(tmpdir), "/"), 0) == 0);
|
||||
assert_se(is_mount_point_at(fd, basename(tmpdir), 0) == 0);
|
||||
assert_se(is_mount_point_at(fd, strjoina(basename(tmpdir), "/"), 0) == 0);
|
||||
|
||||
safe_close(fd);
|
||||
fd = open("/proc", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
|
||||
assert_se(fd >= 0);
|
||||
|
||||
ASSERT_OK_POSITIVE(fd_is_mount_point(fd, NULL, 0));
|
||||
ASSERT_OK_POSITIVE(fd_is_mount_point(fd, "", 0));
|
||||
ASSERT_OK_POSITIVE(fd_is_mount_point(fd, ".", 0));
|
||||
ASSERT_OK_POSITIVE(fd_is_mount_point(fd, "./", 0));
|
||||
ASSERT_OK_ZERO(fd_is_mount_point(fd, "version", 0));
|
||||
ASSERT_OK_POSITIVE(is_mount_point_at(fd, NULL, 0));
|
||||
ASSERT_OK_POSITIVE(is_mount_point_at(fd, "", 0));
|
||||
ASSERT_OK_POSITIVE(is_mount_point_at(fd, ".", 0));
|
||||
ASSERT_OK_POSITIVE(is_mount_point_at(fd, "./", 0));
|
||||
ASSERT_OK_ZERO(is_mount_point_at(fd, "version", 0));
|
||||
|
||||
ASSERT_OK(safe_getcwd(&pwd));
|
||||
ASSERT_OK_ERRNO(fchdir(fd));
|
||||
|
||||
ASSERT_OK_POSITIVE(fd_is_mount_point(AT_FDCWD, NULL, 0));
|
||||
ASSERT_OK_POSITIVE(fd_is_mount_point(AT_FDCWD, "", 0));
|
||||
ASSERT_OK_POSITIVE(fd_is_mount_point(AT_FDCWD, "./", 0));
|
||||
ASSERT_OK_POSITIVE(is_mount_point_at(AT_FDCWD, NULL, 0));
|
||||
ASSERT_OK_POSITIVE(is_mount_point_at(AT_FDCWD, "", 0));
|
||||
ASSERT_OK_POSITIVE(is_mount_point_at(AT_FDCWD, "./", 0));
|
||||
|
||||
ASSERT_OK_ERRNO(chdir(pwd));
|
||||
|
||||
@@ -324,7 +324,7 @@ TEST(fd_is_mount_point) {
|
||||
fd = open("/proc/version", O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
assert_se(fd >= 0);
|
||||
|
||||
r = fd_is_mount_point(fd, NULL, 0);
|
||||
r = is_mount_point_at(fd, NULL, 0);
|
||||
assert_se(IN_SET(r, 0, -ENOTDIR)); /* on old kernels we can't determine if regular files are mount points if we have no directory fd */
|
||||
|
||||
if (!mount_new_api_supported())
|
||||
@@ -354,7 +354,7 @@ TEST(fd_is_mount_point) {
|
||||
ASSERT_OK(readlinkat_malloc(fd, "regular", &t));
|
||||
ASSERT_STREQ(t, "/usr");
|
||||
|
||||
ASSERT_OK(fd_is_mount_point(fd, "regular", 0));
|
||||
ASSERT_OK(is_mount_point_at(fd, "regular", 0));
|
||||
}
|
||||
|
||||
TEST(ms_nosymfollow_supported) {
|
||||
|
||||
Reference in New Issue
Block a user