mirror of
https://github.com/systemd/systemd
synced 2024-07-21 10:17:21 +00:00
stat-util: add _at() variant for files_same()
This commit is contained in:
parent
e47622a61c
commit
676ade310a
|
@ -183,16 +183,18 @@ int path_is_read_only_fs(const char *path) {
|
|||
return fd_is_read_only_fs(fd);
|
||||
}
|
||||
|
||||
int files_same(const char *filea, const char *fileb, int flags) {
|
||||
int files_same_at(int fda, const char *filea, int fdb, const char *fileb, int flags) {
|
||||
struct stat a, b;
|
||||
|
||||
assert(fda >= 0 || fda == AT_FDCWD);
|
||||
assert(filea);
|
||||
assert(fdb >= 0 || fdb == AT_FDCWD);
|
||||
assert(fileb);
|
||||
|
||||
if (fstatat(AT_FDCWD, filea, &a, flags) < 0)
|
||||
if (fstatat(fda, filea, &a, flags) < 0)
|
||||
return log_debug_errno(errno, "Cannot stat %s: %m", filea);
|
||||
|
||||
if (fstatat(AT_FDCWD, fileb, &b, flags) < 0)
|
||||
if (fstatat(fdb, fileb, &b, flags) < 0)
|
||||
return log_debug_errno(errno, "Cannot stat %s: %m", fileb);
|
||||
|
||||
return stat_inode_same(&a, &b);
|
||||
|
|
|
@ -37,7 +37,11 @@ static inline int null_or_empty_path(const char *fn) {
|
|||
|
||||
int path_is_read_only_fs(const char *path);
|
||||
|
||||
int files_same(const char *filea, const char *fileb, int flags);
|
||||
int files_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);
|
||||
}
|
||||
|
||||
/* The .f_type field of struct statfs is really weird defined on
|
||||
* different archs. Let's give its type a name. */
|
||||
|
|
Loading…
Reference in a new issue