mountpoint-util: introduce path_is_mount_point_full

This commit is contained in:
Mike Yuan
2024-02-06 15:09:28 +08:00
parent 561d879305
commit b409aacb0a
29 changed files with 97 additions and 94 deletions
+4 -4
View File
@@ -265,7 +265,7 @@ static int mount_legacy_cgroup_hierarchy(
to = strjoina(strempty(dest), "/sys/fs/cgroup/", hierarchy);
r = path_is_mount_point(to, dest, 0);
r = path_is_mount_point_full(to, dest, /* flags = */ 0);
if (r < 0 && r != -ENOENT)
return log_error_errno(r, "Failed to determine if %s is mounted already: %m", to);
if (r > 0)
@@ -317,7 +317,7 @@ static int mount_legacy_cgns_supported(
(void) mkdir_p(cgroup_root, 0755);
/* Mount a tmpfs to /sys/fs/cgroup if it's not mounted there yet. */
r = path_is_mount_point(cgroup_root, dest, AT_SYMLINK_FOLLOW);
r = path_is_mount_point_full(cgroup_root, dest, AT_SYMLINK_FOLLOW);
if (r < 0)
return log_error_errno(r, "Failed to determine if /sys/fs/cgroup is already mounted: %m");
if (r == 0) {
@@ -427,7 +427,7 @@ static int mount_legacy_cgns_unsupported(
(void) mkdir_p(cgroup_root, 0755);
/* Mount a tmpfs to /sys/fs/cgroup if it's not mounted there yet. */
r = path_is_mount_point(cgroup_root, dest, AT_SYMLINK_FOLLOW);
r = path_is_mount_point_full(cgroup_root, dest, AT_SYMLINK_FOLLOW);
if (r < 0)
return log_error_errno(r, "Failed to determine if /sys/fs/cgroup is already mounted: %m");
if (r == 0) {
@@ -529,7 +529,7 @@ static int mount_unified_cgroups(const char *dest) {
(void) mkdir_p(p, 0755);
r = path_is_mount_point(p, dest, AT_SYMLINK_FOLLOW);
r = path_is_mount_point_full(p, dest, AT_SYMLINK_FOLLOW);
if (r < 0)
return log_error_errno(r, "Failed to determine if %s is mounted already: %m", p);
if (r > 0) {
+1 -1
View File
@@ -642,7 +642,7 @@ int mount_all(const char *dest,
/* Skip this entry if it is not a remount. */
if (mount_table[k].what) {
r = path_is_mount_point(where, NULL, 0);
r = path_is_mount_point(where);
if (r < 0 && r != -ENOENT)
return log_error_errno(r, "Failed to detect whether %s is a mount point: %m", where);
if (r > 0)
+4 -4
View File
@@ -2560,7 +2560,7 @@ static int setup_journal(const char *directory) {
p = strjoina("/var/log/journal/", SD_ID128_TO_STRING(arg_uuid));
q = prefix_roota(directory, p);
if (path_is_mount_point(p, NULL, 0) > 0) {
if (path_is_mount_point(p) > 0) {
if (try)
return 0;
@@ -2568,7 +2568,7 @@ static int setup_journal(const char *directory) {
"%s: already a mount point, refusing to use for journal", p);
}
if (path_is_mount_point(q, NULL, 0) > 0) {
if (path_is_mount_point(q) > 0) {
if (try)
return 0;
@@ -3633,7 +3633,7 @@ static int setup_unix_export_dir_outside(char **ret) {
if (!p)
return log_oom();
r = path_is_mount_point(p, /* root= */ NULL, 0);
r = path_is_mount_point(p);
if (r > 0)
return log_error_errno(SYNTHETIC_ERRNO(EEXIST), "Mount point '%s' exists already, refusing.", p);
if (r < 0 && r != -ENOENT)
@@ -5680,7 +5680,7 @@ static int run(int argc, char *argv[]) {
/* If the specified path is a mount point we generate the new snapshot immediately
* inside it under a random name. However if the specified is not a mount point we
* create the new snapshot in the parent directory, just next to it. */
r = path_is_mount_point(arg_directory, NULL, 0);
r = path_is_mount_point(arg_directory);
if (r < 0) {
log_error_errno(r, "Failed to determine whether directory %s is mount point: %m", arg_directory);
goto finish;