+ hfsmp = VTOHFS(tdvp);
+ /*
+ * Do special case checks here. If fvp == tvp then we need to check the
+ * cnode with locks held.
+ */
+ if (fvp == tvp) {
+ int is_hardlink = 0;
+ /*
+ * In this case, we do *NOT* ever emit a DELETE event.
+ * We may not necessarily emit a RENAME event
+ */
+ emit_delete = 0;
+ if ((error = hfs_lock(VTOC(fvp), HFS_SHARED_LOCK))) {
+ return error;
+ }
+ /* Check to see if the item is a hardlink or not */
+ is_hardlink = (VTOC(fvp)->c_flag & C_HARDLINK);
+ hfs_unlock (VTOC(fvp));
+
+ /*
+ * If the item is not a hardlink, then case sensitivity must be off, otherwise
+ * two names should not resolve to the same cnode unless they were case variants.
+ */
+ if (is_hardlink) {
+ emit_rename = 0;
+ /*
+ * Hardlinks are a little trickier. We only want to emit a rename event
+ * if the item is a hardlink, the parent directories are the same, case sensitivity
+ * is off, and the case folded names are the same. See the fvp == tvp case below for more
+ * info.
+ */
+
+ if ((fdvp == tdvp) && ((hfsmp->hfs_flags & HFS_CASE_SENSITIVE) == 0)) {
+ if (hfs_namecmp((const u_int8_t *)fcnp->cn_nameptr, fcnp->cn_namelen,
+ (const u_int8_t *)tcnp->cn_nameptr, tcnp->cn_namelen) == 0) {
+ /* Then in this case only it is ok to emit a rename */
+ emit_rename = 1;
+ }
+ }
+ }
+ }
+ if (emit_rename) {
+ check_for_tracked_file(fvp, orig_from_ctime, NAMESPACE_HANDLER_RENAME_OP, NULL);
+ }