- /* Create the indirect link directly in the catalog */
- result = hfsCreate(vcb, linkPID, linkName, IFREG);
- if (result) return (result);
-
- /*
- * XXX SER Here is a good example where hfsCreate should pass in a catinfo and return
- * things like the hint and file ID there should be no reason to call lookup here
- */
- catInfo.hint = 0;
- INIT_CATALOGDATA(&catInfo.nodeData, kCatNameNoCopyName);
-
- result = hfs_getcatalog(vcb, linkPID, linkName, -1, &catInfo);
- if (result) goto errExit;
-
- fip = (struct FInfo *)&catInfo.nodeData.cnd_finderInfo;
- fip->fdType = kHardLinkFileType; /* 'hlnk' */
- fip->fdCreator = kHFSPlusCreator; /* 'hfs+' */
- fip->fdFlags |= kHasBeenInited;
-
- /* links are matched to data nodes by nodeID and to volumes by create date */
- catInfo.nodeData.cnd_iNodeNum = dnhp->h_meta->h_indnodeno;
- catInfo.nodeData.cnd_createDate = vcb->vcbCrDate;
-
- result = UpdateCatalogNode(vcb, linkPID, linkName, catInfo.hint, &catInfo.nodeData);
- if (result) goto errExit;
+ /* Setup the default attributes */
+ bzero(&attr, sizeof(attr));
+
+ /* links are matched to data nodes by link ID and to volumes by create date */
+ attr.ca_rdev = linknum; /* note: cat backend overloads ca_rdev to be the linknum when nlink = 0 */
+ attr.ca_itime = HFSTOVCB(hfsmp)->vcbCrDate;
+ attr.ca_mode = S_IFREG;
+
+ fip = (struct FndrFileInfo *)&attr.ca_finderinfo;
+ fip->fdType = SWAP_BE32 (kHardLinkFileType); /* 'hlnk' */
+ fip->fdCreator = SWAP_BE32 (kHFSPlusCreator); /* 'hfs+' */
+ fip->fdFlags = SWAP_BE16 (kHasBeenInited);
+
+ hfs_global_shared_lock_acquire(hfsmp);
+ if (hfsmp->jnl) {
+ if (journal_start_transaction(hfsmp->jnl) != 0) {
+ hfs_global_shared_lock_release(hfsmp);
+ return EINVAL;
+ }
+ }