Create a hard link to SRC_NAME aka SRC_DIRFD+SRC_RELNAME; the new link is at DST_NAME aka DST_DIRFD+DST_RELNAME. A null SRC_NAME stands for the file whose name is like DST_NAME except with DST_RELNAME replaced with SRC_RELNAME. Honor the REPLACE, VERBOSE and DEREFERENCE settings. Return true upon success. Otherwise, diagnose the failure and return false. If SRC_NAME is a symbol
| 1545 | If the system doesn't support hard links to symbolic links, then DST_NAME |
| 1546 | will be created as a symbolic link to SRC_NAME. */ |
| 1547 | static bool |
| 1548 | create_hard_link (char const *src_name, int src_dirfd, char const *src_relname, |
| 1549 | char const *dst_name, int dst_dirfd, char const *dst_relname, |
| 1550 | bool replace, bool verbose, bool dereference) |
| 1551 | { |
| 1552 | int err = force_linkat (src_dirfd, src_relname, dst_dirfd, dst_relname, |
| 1553 | dereference ? AT_SYMLINK_FOLLOW : 0, |
| 1554 | replace, -1); |
| 1555 | if (0 < err) |
| 1556 | { |
| 1557 | |
| 1558 | char *a_src_name = NULL; |
| 1559 | if (!src_name) |
| 1560 | src_name = a_src_name = subst_suffix (dst_name, dst_relname, |
| 1561 | src_relname); |
| 1562 | error (0, err, _("cannot create hard link %s to %s"), |
| 1563 | quoteaf_n (0, dst_name), quoteaf_n (1, src_name)); |
| 1564 | free (a_src_name); |
| 1565 | return false; |
| 1566 | } |
| 1567 | if (err < 0 && verbose) |
| 1568 | printf (_("removed %s\n"), quoteaf (dst_name)); |
| 1569 | return true; |
| 1570 | } |
| 1571 | |
| 1572 | /* Return true if the current file should be (tried to be) dereferenced: |
| 1573 | either for DEREF_ALWAYS or for DEREF_COMMAND_LINE_ARGUMENTS in the case |
no test coverage detected