Return true if the source file with basename SRCBASE and status SRC_ST is likely to be the simple backup file for DST_DIRFD+DST_RELNAME. */
| 1584 | /* Return true if the source file with basename SRCBASE and status SRC_ST |
| 1585 | is likely to be the simple backup file for DST_DIRFD+DST_RELNAME. */ |
| 1586 | static bool |
| 1587 | source_is_dst_backup (char const *srcbase, struct stat const *src_st, |
| 1588 | int dst_dirfd, char const *dst_relname) |
| 1589 | { |
| 1590 | size_t srcbaselen = strlen (srcbase); |
| 1591 | char const *dstbase = last_component (dst_relname); |
| 1592 | size_t dstbaselen = strlen (dstbase); |
| 1593 | size_t suffixlen = strlen (simple_backup_suffix); |
| 1594 | if (! (srcbaselen == dstbaselen + suffixlen |
| 1595 | && memeq (srcbase, dstbase, dstbaselen) |
| 1596 | && streq (srcbase + dstbaselen, simple_backup_suffix))) |
| 1597 | return false; |
| 1598 | char *dst_back = subst_suffix (dst_relname, |
| 1599 | dst_relname + strlen (dst_relname), |
| 1600 | simple_backup_suffix); |
| 1601 | struct stat dst_back_sb; |
| 1602 | int dst_back_status = fstatat (dst_dirfd, dst_back, &dst_back_sb, 0); |
| 1603 | free (dst_back); |
| 1604 | return dst_back_status == 0 && psame_inode (src_st, &dst_back_sb); |
| 1605 | } |
| 1606 | |
| 1607 | /* Copy the file SRC_NAME to the file DST_NAME aka DST_DIRFD+DST_RELNAME. |
| 1608 | If NONEXISTENT_DST is positive, DST_NAME does not exist even as a |
no test coverage detected