diff options
author | Rob Landley <rob@landley.net> | 2022-06-29 21:54:42 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2022-06-29 21:54:42 -0500 |
commit | f51b02947baeb149d12a60befc9988634485af13 (patch) | |
tree | 6779ff65c3bbadbd6999cb808926fba0af828c57 /toys/posix/cp.c | |
parent | c7342f8b72f8bc2391c660000d4080eb745c6205 (diff) | |
download | toybox-f51b02947baeb149d12a60befc9988634485af13.tar.gz |
Add same_file() and same_def_ino() convenience functions, plus minor cleanups.
Diffstat (limited to 'toys/posix/cp.c')
-rw-r--r-- | toys/posix/cp.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 7b9889a2..a7359821 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -148,10 +148,8 @@ static int cp_node(struct dirtree *try) // Detect recursive copies via repeated top node (cp -R .. .) or // identical source/target (fun with hardlinks). - if ((TT.top.st_dev == try->st.st_dev && TT.top.st_ino == try->st.st_ino - && (catch = TT.destname)) - || (!fstatat(cfd, catch, &cst, 0) && cst.st_dev == try->st.st_dev - && cst.st_ino == try->st.st_ino)) + if ((same_file(&TT.top, &try->st) && (catch = TT.destname)) + || (!fstatat(cfd, catch, &cst, 0) && same_file(&cst, &try->st))) { error_msg("'%s' is '%s'", catch, err = dirtree_path(try, 0)); free(err); |