util: make path_is_mount_point() recognize bind mounts, too
This commit is contained in:
parent
ddffe89246
commit
cde9cb343a
6
TODO
6
TODO
|
@ -49,12 +49,12 @@ Bugfixes:
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
* introduce $container_boot_id
|
* introduce /run/kmsg in containers?
|
||||||
|
|
||||||
|
* introduce $container_boot_id?
|
||||||
|
|
||||||
* wall messages for shutdown should move to logind
|
* wall messages for shutdown should move to logind
|
||||||
|
|
||||||
* remove wants from journald.service
|
|
||||||
|
|
||||||
* allow writing multiple conditions in unit files on one line
|
* allow writing multiple conditions in unit files on one line
|
||||||
|
|
||||||
* journal: json output needs to be able to deal with multiple assignments of the same field
|
* journal: json output needs to be able to deal with multiple assignments of the same field
|
||||||
|
|
|
@ -330,15 +330,22 @@ bool path_equal(const char *a, const char *b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int path_is_mount_point(const char *t, bool allow_symlink) {
|
int path_is_mount_point(const char *t, bool allow_symlink) {
|
||||||
struct stat a, b;
|
|
||||||
char *parent;
|
char *parent;
|
||||||
int r;
|
int r;
|
||||||
|
struct file_handle *h;
|
||||||
|
int mount_id, mount_id_parent;
|
||||||
|
|
||||||
if (allow_symlink)
|
/* We are not actually interested in the file handles, but
|
||||||
r = stat(t, &a);
|
* name_to_handle_at() also passes us the mount ID, hence use
|
||||||
else
|
* it but throw the handle away */
|
||||||
r = lstat(t, &a);
|
|
||||||
|
|
||||||
|
if (path_equal(t, "/"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
h = alloca(MAX_HANDLE_SZ);
|
||||||
|
h->handle_bytes = MAX_HANDLE_SZ;
|
||||||
|
|
||||||
|
r = name_to_handle_at(AT_FDCWD, t, h, &mount_id, allow_symlink ? AT_SYMLINK_FOLLOW : 0);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -350,13 +357,15 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = lstat(parent, &b);
|
h->handle_bytes = MAX_HANDLE_SZ;
|
||||||
|
r = name_to_handle_at(AT_FDCWD, parent, h, &mount_id_parent, 0);
|
||||||
free(parent);
|
free(parent);
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
return a.st_dev != b.st_dev;
|
|
||||||
|
return mount_id != mount_id_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
int path_is_read_only_fs(const char *path) {
|
int path_is_read_only_fs(const char *path) {
|
||||||
|
|
Loading…
Reference in New Issue