Lines Matching refs:cp
65 int hfs_makelink(struct hfsmount *hfsmp, struct vnode *src_vp, struct cnode *cp,
126 * Make a link to the cnode cp in the directory dp
128 * corresponds to 'cp' which was part of the arguments to
131 * The cnodes cp and dcp must be locked.
134 hfs_makelink(struct hfsmount *hfsmp, struct vnode *src_vp, struct cnode *cp,
152 type = S_ISDIR(cp->c_mode) ? DIR_HARDLINKS : FILE_HARDLINKS;
178 orig_cnid = cp->c_desc.cd_cnid;
184 if ((cp->c_linkcount == 2) && !(cp->c_flag & C_HARDLINK)) {
188 to_desc.cd_cnid = cp->c_fileid;
194 indnodeno = cp->c_fileid;
200 indnodeno = cp->c_fileid;
211 retval = cat_rename(hfsmp, &cp->c_desc, &hfsmp->hfs_private_desc[type],
216 inodename, retval, cp->c_fileid);
227 link_desc.cd_nameptr = cp->c_desc.cd_nameptr;
228 link_desc.cd_namelen = cp->c_desc.cd_namelen;
229 link_desc.cd_parentcnid = cp->c_parentcnid;
230 link_desc.cd_flags = S_ISDIR(cp->c_mode) ? CD_ISDIR : 0;
237 cp->c_desc.cd_cnid = orig_cnid;
240 err = cat_rename(hfsmp, &to_desc, &dcp->c_desc, &cp->c_desc, NULL);
245 cp->c_attr.ca_linkref = indnodeno;
246 cp->c_desc.cd_cnid = linkcnid;
249 if (setfirstlink(hfsmp, cp->c_fileid, linkcnid) == 0)
250 cp->c_attr.ca_recflags |= kHFSHasAttributesMask;
252 cp->c_attr.ca_firstlink = linkcnid;
254 cp->c_attr.ca_recflags |= kHFSHasLinkChainMask;
256 indnodeno = cp->c_attr.ca_linkref;
267 link_desc.cd_flags = S_ISDIR(cp->c_mode) ? CD_ISDIR : 0;
271 retval = getfirstlink(hfsmp, cp->c_fileid, &orig_firstlink);
273 orig_firstlink = cp->c_attr.ca_firstlink;
278 (cp->c_attr.ca_recflags & kHFSHasLinkChainMask));
283 (void) cat_delete(hfsmp, &cp->c_desc, &cp->c_attr);
286 cp->c_desc.cd_cnid = orig_cnid;
289 err = cat_rename(hfsmp, &to_desc, &dcp->c_desc, &cp->c_desc, NULL);
293 cp->c_attr.ca_linkref = 0;
298 if (cp->c_attr.ca_recflags & kHFSHasLinkChainMask) {
303 if (setfirstlink(hfsmp, cp->c_fileid, linkcnid) == 0)
304 cp->c_attr.ca_recflags |= kHFSHasAttributesMask;
306 cp->c_attr.ca_firstlink = linkcnid;
334 cp->c_flag |= C_HARDLINK;
353 if ((vp = cp->c_vp) != NULLVP) {
361 cp->c_flag |= C_NEED_DVNODE_PUT;
365 if ((vp = cp->c_rsrc_vp) != NULLVP) {
372 cp->c_flag |= C_NEED_RVNODE_PUT;
376 cp->c_touch_chgtime = TRUE;
377 cp->c_flag |= C_FORCEUPDATE;
409 struct cnode *cp;
478 cp = VTOC(vp);
480 parentcnid = hfs_currentparent(cp);
502 if (cp->c_linkcount >= HFS_LINK_MAX) {
506 if (cp->c_bsdflags & (IMMUTABLE | APPEND)) {
510 if (cp->c_flag & (C_NOEXISTS | C_DELETED)) {
538 if (cp->c_flag & C_HARDLINK) {
542 if ((cat_idlookup(hfsmp, cp->c_fileid, 0, 0, NULL, &cattr, NULL) != 0) ||
543 (cattr.ca_fileid != cp->c_fileid)) {
551 if ((cat_lookup(hfsmp, &cp->c_desc, 0, NULL, NULL, NULL, &fileid) != 0) ||
552 (fileid != cp->c_fileid)) {
573 cat_check_link_ancestry(hfsmp, tdcp->c_fileid, cp->c_fileid)) {
581 cp->c_linkcount++;
582 cp->c_touch_chgtime = TRUE;
583 error = hfs_makelink(hfsmp, vp, cp, tdcp, cnp);
585 cp->c_linkcount--;
640 cp->c_flag |= C_FORCEUPDATE;
658 hfs_unlockfour(tdcp, cp, fdcp, NULL);
660 hfs_unlockpair(tdcp, cp);
677 struct cnode *cp;
691 cp = VTOC(vp);
708 * the cp->c_desc which may have changed).
715 cndesc.cd_encoding = cp->c_desc.cd_encoding;
738 hfs_relorigin(cp, dcp->c_fileid);
740 hfs_relorigin(cp, dcp->c_cnid);
765 --cp->c_linkcount;
766 if (cp->c_linkcount < 1) {
782 if (cp->c_entries != 0) {
783 panic("hfs_unlink: dir not empty (id %d, %d entries)", cp->c_fileid, cp->c_entries);
786 cp->c_attr.ca_linkref);
792 cp->c_attr.ca_linkref);
799 from_desc.cd_cnid = cp->c_fileid;
801 MAKE_DELETED_NAME(delname, sizeof(delname), cp->c_fileid);
805 to_desc.cd_cnid = cp->c_fileid;
810 cp->c_flag |= C_DELETED;
811 cp->c_attr.ca_recflags &= ~kHFSHasLinkChainMask;
812 cp->c_attr.ca_firstlink = 0;
836 getfirstlink(hfsmp, cp->c_fileid, &firstlink) == 0 &&
838 if (setfirstlink(hfsmp, cp->c_fileid, nextlinkid) == 0)
839 cp->c_attr.ca_recflags |= kHFSHasAttributesMask;
840 } else if (vnode_isreg(vp) && cp->c_attr.ca_firstlink == cndesc.cd_cnid) {
841 cp->c_attr.ca_firstlink = nextlinkid;
854 cp->c_ctime = tv.tv_sec;
855 (void) cat_update(hfsmp, &cp->c_desc, &cp->c_attr, NULL, NULL);
871 cat_releasedesc(&cp->c_desc);
1053 hfs_savelinkorigin(cnode_t *cp, cnid_t parentcnid)
1058 int maxorigins = (S_ISDIR(cp->c_mode)) ? MAX_CACHED_ORIGINS : MAX_CACHED_FILE_ORIGINS;
1062 TAILQ_FOREACH(origin, &cp->c_originlist, lo_link) {
1065 TAILQ_REMOVE(&cp->c_originlist, origin, lo_link);
1072 origin = TAILQ_LAST(&cp->c_originlist, hfs_originhead);
1073 TAILQ_REMOVE(&cp->c_originlist, origin, lo_link);
1079 origin->lo_cnid = cp->c_cnid;
1081 TAILQ_INSERT_HEAD(&cp->c_originlist, origin, lo_link);
1091 hfs_relorigins(struct cnode *cp)
1095 TAILQ_FOREACH_SAFE(origin, &cp->c_originlist, lo_link, prev) {
1098 TAILQ_INIT(&cp->c_originlist);
1108 hfs_relorigin(struct cnode *cp, cnid_t parentcnid)
1113 TAILQ_FOREACH_SAFE(origin, &cp->c_originlist, lo_link, prev) {
1116 TAILQ_REMOVE(&cp->c_originlist, origin, lo_link);
1130 hfs_haslinkorigin(cnode_t *cp)
1132 if (cp->c_flag & C_HARDLINK) {
1136 TAILQ_FOREACH(origin, &cp->c_originlist, lo_link) {
1152 hfs_currentparent(cnode_t *cp)
1154 if (cp->c_flag & C_HARDLINK) {
1158 TAILQ_FOREACH(origin, &cp->c_originlist, lo_link) {
1164 return (cp->c_parentcnid);
1174 hfs_currentcnid(cnode_t *cp)
1176 if (cp->c_flag & C_HARDLINK) {
1180 TAILQ_FOREACH(origin, &cp->c_originlist, lo_link) {
1186 return (cp->c_cnid);