stat-util: introduce fd_inode_same
authorMike Yuan <me@yhndnzj.com>
Mon, 11 Mar 2024 08:28:30 +0000 (16:28 +0800)
committerMike Yuan <me@yhndnzj.com>
Mon, 11 Mar 2024 14:53:08 +0000 (22:53 +0800)
src/basic/stat-util.h
src/shared/ptyfwd.c

index 47445d852a0f83a39427677c4c84a0330accddad..c5dfd2db16a3f425eb3c44e621c8badc90b4a0cb 100644 (file)
@@ -47,10 +47,12 @@ static inline int null_or_empty_path(const char *fn) {
 int path_is_read_only_fs(const char *path);
 
 int inode_same_at(int fda, const char *filea, int fdb, const char *fileb, int 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);
 }
+static inline int fd_inode_same(int fda, int fdb) {
+        return inode_same_at(fda, NULL, fdb, NULL, AT_EMPTY_PATH);
+}
 
 /* The .f_type field of struct statfs is really weird defined on
  * different archs. Let's give its type a name. */
index 17c1549132ead45b7dea0f23f89230a6f28ac34e..d572a02ca486e52e2f3e0e4874b7f78f75f59b4b 100644 (file)
@@ -884,7 +884,7 @@ int pty_forward_new(
 
                 assert(f->input_fd >= 0);
 
-                same = inode_same_at(f->input_fd, NULL, f->output_fd, NULL, AT_EMPTY_PATH);
+                same = fd_inode_same(f->input_fd, f->output_fd);
                 if (same < 0)
                         return same;