stat-util: rename files_same() → inode_same()

Let's be more accurate about what this function does: it checks whether
the underlying reported inode is the same. Internally, this already uses
a better named stat_inode_same() call, hence let's similarly name the
wrapping function following the same logic.

Similar for files_same_at() and path_equal_or_same_files().

No code changes, just some renaming.
This commit is contained in:
Lennart Poettering
2023-05-19 17:42:41 +02:00
parent 5268188de1
commit 563e684689
16 changed files with 44 additions and 44 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int
/* Can't setns to your own userns, since then you could escalate from non-root to root in
* your own namespace, so check if namespaces are equal before attempting to enter. */
r = files_same(FORMAT_PROC_FD_PATH(userns_fd), "/proc/self/ns/user", 0);
r = inode_same(FORMAT_PROC_FD_PATH(userns_fd), "/proc/self/ns/user", 0);
if (r < 0)
return r;
if (r)
+2 -2
View File
@@ -485,8 +485,8 @@ int path_compare(const char *a, const char *b) {
}
}
bool path_equal_or_files_same(const char *a, const char *b, int flags) {
return path_equal(a, b) || files_same(a, b, flags) > 0;
bool path_equal_or_inode_same(const char *a, const char *b, int flags) {
return path_equal(a, b) || inode_same(a, b, flags) > 0;
}
int path_compare_filename(const char *a, const char *b) {
+1 -1
View File
@@ -77,7 +77,7 @@ static inline bool path_equal_filename(const char *a, const char *b) {
return path_compare_filename(a, b) == 0;
}
bool path_equal_or_files_same(const char *a, const char *b, int flags);
bool path_equal_or_inode_same(const char *a, const char *b, int flags);
char* path_extend_internal(char **x, ...);
#define path_extend(x, ...) path_extend_internal(x, __VA_ARGS__, POINTER_MAX)
+1 -1
View File
@@ -946,7 +946,7 @@ int pid_from_same_root_fs(pid_t pid) {
root = procfs_file_alloca(pid, "root");
return files_same(root, "/proc/1/root", 0);
return inode_same(root, "/proc/1/root", 0);
}
bool is_main_thread(void) {
+1 -1
View File
@@ -223,7 +223,7 @@ bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) {
return false;
if (a->sockaddr.un.sun_path[0]) {
if (!path_equal_or_files_same(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, 0))
if (!path_equal_or_inode_same(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, 0))
return false;
} else {
if (a->size != b->size)
+1 -1
View File
@@ -183,7 +183,7 @@ int path_is_read_only_fs(const char *path) {
return fd_is_read_only_fs(fd);
}
int files_same_at(int fda, const char *filea, int fdb, const char *fileb, int flags) {
int inode_same_at(int fda, const char *filea, int fdb, const char *fileb, int flags) {
struct stat a, b;
assert(fda >= 0 || fda == AT_FDCWD);
+3 -3
View File
@@ -37,10 +37,10 @@ static inline int null_or_empty_path(const char *fn) {
int path_is_read_only_fs(const char *path);
int files_same_at(int fda, const char *filea, int fdb, const char *fileb, int flags);
int inode_same_at(int fda, const char *filea, int fdb, const char *fileb, int flags);
static inline int files_same(const char *filea, const char *fileb, int flags) {
return files_same_at(AT_FDCWD, filea, AT_FDCWD, fileb, flags);
static inline int inode_same(const char *filea, const char *fileb, int flags) {
return inode_same_at(AT_FDCWD, filea, AT_FDCWD, fileb, flags);
}
/* The .f_type field of struct statfs is really weird defined on
+1 -1
View File
@@ -891,7 +891,7 @@ int running_in_chroot(void) {
if (getpid_cached() == 1)
return false; /* We're PID 1, we can't be in a chroot. */
r = files_same("/proc/1/root", "/", 0);
r = inode_same("/proc/1/root", "/", 0);
if (r == -ENOENT) {
r = proc_mounted();
if (r == 0) {