Lines Matching refs:cp
65 __inline__ int hfs_checkdeleted (struct cnode *cp) {
66 return ((cp->c_flag & (C_DELETED | C_NOEXISTS)) ? ENOENT : 0);
78 struct cnode *cp = NULL;
81 cp = VTOC(vp);
87 err = hfs_lock (cp, HFS_EXCLUSIVE_LOCK);
93 cp->c_flag |= C_BACKINGSTORE;
96 cp->c_flag &= ~C_BACKINGSTORE;
100 hfs_unlock (cp);
115 struct cnode *cp = NULL;
123 cp = VTOC(vp);
126 err = hfs_lock (cp, HFS_SHARED_LOCK);
131 if (cp->c_flag & C_BACKINGSTORE) {
139 hfs_unlock (cp);
174 * Assumes that both truncate and cnode locks for 'cp' are held.
181 struct cnode *cp;
193 cp = VTOC(vp);
195 if (cp->c_datafork) {
198 if (cp->c_rsrcfork) {
222 (cp->c_flag & C_DELETED) &&
224 hfs_unlock(cp);
227 (void) hfs_lock(cp, HFS_FORCE_LOCK);
241 (!ISSET(cp->c_flag, C_DELETED)) &&
242 (!ISSET(cp->c_flag, C_NOEXISTS)) &&
278 hfs_reldirhints(cp, 0);
280 if (cp->c_flag & C_HARDLINK) {
281 hfs_relorigins(cp);
312 (cp->c_flag & C_DELETED) &&
376 if ((cp->c_blocks > 0) && (forkcount == 1) && (vp != cp->c_rsrc_vp)) {
391 if (cp->c_desc.cd_namelen == 0) {
393 MAKE_DELETED_NAME (lookup_rsrc->lookup_name, HFS_TEMPLOOKUP_NAMELEN, cp->c_fileid);
398 lookup_rsrc->lookup_desc.cd_cnid = cp->c_cnid;
403 desc_ptr = &cp->c_desc;
420 * filefork. Fill in the cp, sysfileinfo and rangelist fields..
423 lookup_rsrc->lookup_fork.ff_cp = cp;
430 error = hfs_release_storage (hfsmp, NULL, &lookup_rsrc->lookup_fork, cp->c_fileid);
440 * zero out cp->c_blocks to indicate there is no data left in this file.
442 cp->c_blocks = 0;
462 if ((cp->c_attr.ca_recflags & kHFSHasAttributesMask) != 0 &&
463 (cp->c_flag & C_DELETED) &&
466 ea_error = hfs_removeallattr(hfsmp, cp->c_fileid);
475 if ((cp->c_flag & C_DELETED) && (forkcount <= 1)) {
480 // hfs_chash_mark_in_transit(hfsmp, cp);
485 hfs_chashremove(hfsmp, cp);
487 cp->c_flag |= C_NOEXISTS; // XXXdbg
488 cp->c_rdev = 0;
508 if (cp->c_blocks > 0) {
511 (int)cp->c_fileid, (int)cp->c_blocks);
521 cat_releasedesc(&cp->c_desc);
527 error = cat_delete(hfsmp, &cp->c_desc, &cp->c_attr);
550 (void)hfs_chkiq(cp, -1, NOCRED, 0);
554 cp->c_flag &= ~C_DELETED;
555 cp->c_touch_chgtime = TRUE;
556 cp->c_touch_modtime = TRUE;
572 if ((!ISSET(cp->c_flag, C_NOEXISTS)) &&
573 ((cp->c_flag & C_MODIFIED) || cp->c_touch_acctime ||
574 cp->c_touch_chgtime || cp->c_touch_modtime)) {
576 if ((cp->c_flag & C_MODIFIED) || cp->c_touch_modtime){
577 cp->c_flag |= C_FORCEUPDATE;
613 struct cprotect *entry = cp->c_cpentry;
615 if ((cp->c_cpentry->cp_flags & CP_KEY_FLUSHED) == 0) {
616 cp->c_cpentry->cp_flags |= CP_KEY_FLUSHED;
617 bzero (cp->c_cpentry->cp_cache_key, cp->c_cpentry->cp_cache_key_len);
618 bzero (cp->c_cpentry->cp_cache_iv_ctx, sizeof(aes_encrypt_ctx));
640 struct cnode *cp;
648 cp = VTOC(vp);
684 if (cp->c_flag & C_NOEXISTS) {
694 hfs_lock_truncate(cp, HFS_EXCLUSIVE_LOCK);
698 (void) hfs_lock(cp, HFS_FORCE_LOCK);
713 hfs_unlock_truncate(cp, 0);
716 hfs_unlock(cp);
731 struct cnode *cp;
741 cp = VTOC(vp);
774 if (cp->c_flag & C_SWAPINPROGRESS) {
778 hfs_unlock(cp);
780 hfs_lock(cp, HFS_FORCE_LOCK);
796 hfs_unlock(cp);
799 hfs_lock(cp, HFS_FORCE_LOCK);
800 cp->c_flag |= C_MODIFIED;
802 cp->c_flag &= ~C_ZFWANTSYNC;
803 cp->c_zftimeout = 0;
815 hfs_unlock(cp);
817 hfs_lock(cp, HFS_FORCE_LOCK);
824 if (cp->c_flag & C_MODIFIED) {
838 struct cnode *cp;
848 cp = VTOC(vp);
855 (void) hfs_lock (cp, HFS_FORCE_LOCK);
864 if (!ISSET(cp->c_flag, C_NOEXISTS)) {
873 !(cp->c_flag & (C_DELETED | C_NOEXISTS)) ) {
882 if (cp->c_vp == vp) {
883 fp = cp->c_datafork;
884 altfp = cp->c_rsrcfork;
886 cp->c_datafork = NULL;
887 cp->c_vp = NULL;
888 } else if (cp->c_rsrc_vp == vp) {
889 fp = cp->c_rsrcfork;
890 altfp = cp->c_datafork;
892 cp->c_rsrcfork = NULL;
893 cp->c_rsrc_vp = NULL;
895 panic("hfs_vnop_reclaim: vp points to wrong cnode (vp=%p cp->c_vp=%p cp->c_rsrc_vp=%p)\n", vp, cp->c_vp, cp->c_rsrc_vp);
902 if (hfs_chashremove(hfsmp, cp) == 0)
908 hfs_reldirhints(cp, 0);
911 if(cp->c_flag & C_HARDLINK) {
912 hfs_relorigins(cp);
928 hfs_chashwakeup(hfsmp, cp, H_ALLOC | H_TRANSIT);
929 hfs_reclaim_cnode(cp);
936 hfs_unlock(cp);
972 struct cnode *cp = NULL;
1028 cp = hfs_chash_getcnode(hfsmp, attrp->ca_fileid, vpp, wantrsrc,
1032 * If the id is no longer valid for lookups we'll get back a NULL cp.
1034 if (cp == NULL) {
1055 if (!(hfs_checkdeleted(cp))) {
1056 if ((cp->c_flag & C_HARDLINK) && descp->cd_nameptr && descp->cd_namelen > 0) {
1058 if ((descp->cd_cnid == cp->c_attr.ca_fileid) &&
1059 (attrp->ca_linkcount != cp->c_attr.ca_linkcount)){
1066 hfs_unlock(cp);
1089 hfs_chashwakeup(hfsmp, cp, hflags);
1103 replace_desc(cp, descp);
1116 if (ISSET(cp->c_hflag, H_ALLOC)) {
1117 lck_rw_init(&cp->c_truncatelock, hfs_rwlock_group, hfs_lock_attr);
1119 cp->c_decmp = NULL;
1125 if (!hfs_valid_cnode (hfsmp, dvp, (wantrsrc ? NULL : cnp), cp->c_fileid, attrp, &error)) {
1126 hfs_chash_abort(hfsmp, cp);
1127 hfs_reclaim_cnode(cp);
1156 bcopy(attrp, &cp->c_attr, sizeof(struct cat_attr));
1157 bcopy(descp, &cp->c_desc, sizeof(struct cat_desc));
1168 cp->c_flag |= C_HARDLINK;
1187 (cp->c_attr.ca_linkcount > 1)) {
1188 if (cp->c_attr.ca_entries == 0)
1189 cp->c_attr.ca_dircount = 0;
1191 cp->c_attr.ca_dircount = cp->c_attr.ca_linkcount - 2;
1193 cp->c_attr.ca_linkcount = 1;
1194 cp->c_attr.ca_recflags |= kHFSHasFolderCountMask;
1196 cp->c_flag |= C_MODIFIED;
1201 cp->c_dquot[i] = NODQUOT;
1209 if (cp->c_vp != NULL)
1211 cvpp = &cp->c_vp;
1220 fp->ff_cp = cp;
1229 if (cp->c_rsrcfork != NULL)
1231 if (cp->c_rsrc_vp != NULL)
1233 cp->c_rsrcfork = fp;
1234 cvpp = &cp->c_rsrc_vp;
1235 if ( (tvp = cp->c_vp) != NULLVP )
1236 cp->c_flag |= C_NEED_DVNODE_PUT;
1238 if (cp->c_datafork != NULL)
1240 if (cp->c_vp != NULL)
1242 cp->c_datafork = fp;
1243 cvpp = &cp->c_vp;
1244 if ( (tvp = cp->c_rsrc_vp) != NULLVP)
1245 cp->c_flag |= C_NEED_RVNODE_PUT;
1271 cp->c_flag &= ~(C_NEED_RVNODE_PUT | C_NEED_DVNODE_PUT);
1276 if ((cp->c_flag & C_HARDLINK) && (vtype == VDIR)) {
1283 vfsp.vnfs_fsnode = cp;
1327 if (fp == cp->c_datafork)
1328 cp->c_datafork = NULL;
1330 cp->c_rsrcfork = NULL;
1338 if ((cp->c_vp == NULL) && (cp->c_rsrc_vp == NULL)) {
1339 hfs_chash_abort(hfsmp, cp);
1340 hfs_reclaim_cnode(cp);
1343 hfs_chashwakeup(hfsmp, cp, H_ALLOC | H_ATTACH);
1345 hfs_unlock(cp);
1353 if (cp->c_flag & C_HARDLINK) {
1363 KERNEL_DEBUG_CONSTANT((FSDBG_CODE(DBG_FSRW, 37)), cp->c_vp, cp->c_rsrc_vp, 0, 0, 0);
1371 hfs_chashwakeup(hfsmp, cp, H_ALLOC | H_ATTACH);
1381 /* Initialize the cp data structures. The key should be in place now. */
1383 cp_entry_init(cp, mp);
1393 hfs_reclaim_cnode(struct cnode *cp)
1399 if (cp->c_dquot[i] != NODQUOT) {
1400 dqreclaim(cp->c_dquot[i]);
1401 cp->c_dquot[i] = NODQUOT;
1409 if ((cp->c_desc.cd_flags & CD_HASBUF) && (cp->c_desc.cd_nameptr != 0)) {
1412 nameptr = (const char *) cp->c_desc.cd_nameptr;
1413 cp->c_desc.cd_nameptr = 0;
1414 cp->c_desc.cd_flags &= ~CD_HASBUF;
1415 cp->c_desc.cd_namelen = 0;
1428 lck_rw_destroy(&cp->c_rwlock, hfs_rwlock_group);
1429 lck_rw_destroy(&cp->c_truncatelock, hfs_rwlock_group);
1431 if (cp->c_decmp) {
1432 decmpfs_cnode_destroy(cp->c_decmp);
1433 FREE_ZONE(cp->c_decmp, sizeof(*(cp->c_decmp)), M_DECMPFS_CNODE);
1437 cp_entry_destroy(&cp->c_cpentry);
1441 bzero(cp, sizeof(struct cnode));
1442 FREE_ZONE(cp, sizeof(struct cnode), M_HFSNODE);
1608 u_int32_t hfs_get_dateadded (struct cnode *cp) {
1612 if ((cp->c_attr.ca_recflags & kHFSHasDateAddedMask) == 0) {
1619 finfo = (u_int8_t*)cp->c_finderinfo;
1626 if (S_ISREG(cp->c_attr.ca_mode)) {
1630 else if (S_ISDIR(cp->c_attr.ca_mode)) {
1646 hfs_touchtimes(struct hfsmount *hfsmp, struct cnode* cp)
1651 cp->c_touch_acctime = FALSE;
1652 cp->c_touch_chgtime = FALSE;
1653 cp->c_touch_modtime = FALSE;
1658 cp->c_touch_acctime = FALSE;
1669 if (cp->c_touch_acctime) {
1673 (cp->c_vp && ((vnode_israge(cp->c_vp) || (vfs_ctx_skipatime(ctx)))))) {
1675 cp->c_touch_acctime = FALSE;
1678 if (cp->c_touch_acctime || cp->c_touch_chgtime ||
1679 cp->c_touch_modtime || (cp->c_flag & C_NEEDS_DATEADDED)) {
1685 if (cp->c_touch_acctime) {
1686 cp->c_atime = tv.tv_sec;
1692 if ((((u_int32_t)cp->c_atime - (u_int32_t)(cp)->c_attr.ca_atimeondisk) >
1694 cp->c_flag |= C_MODIFIED;
1696 cp->c_touch_acctime = FALSE;
1698 if (cp->c_touch_modtime) {
1699 cp->c_mtime = tv.tv_sec;
1700 cp->c_touch_modtime = FALSE;
1701 cp->c_flag |= C_MODIFIED;
1708 cp->c_mtime += 3600;
1712 if (cp->c_touch_chgtime) {
1713 cp->c_ctime = tv.tv_sec;
1714 cp->c_touch_chgtime = FALSE;
1715 cp->c_flag |= C_MODIFIED;
1719 if (cp->c_flag & C_NEEDS_DATEADDED) {
1720 hfs_write_dateadded (&(cp->c_attr), tv.tv_sec);
1721 cp->c_flag |= C_MODIFIED;
1723 cp->c_flag &= ~C_NEEDS_DATEADDED;
1739 hfs_lock(struct cnode *cp, enum hfslocktype locktype)
1743 if (cp->c_lockowner == thread) {
1747 if ((cp->c_fileid == kHFSExtentsFileID) ||
1748 (cp->c_fileid == kHFSAllocationFileID)) {
1749 cp->c_syslockcount++;
1754 lck_rw_lock_shared(&cp->c_rwlock);
1755 cp->c_lockowner = HFS_SHARED_OWNER;
1758 lck_rw_lock_exclusive(&cp->c_rwlock);
1759 cp->c_lockowner = thread;
1764 if ((cp->c_fileid == kHFSExtentsFileID) ||
1765 (cp->c_fileid == kHFSAllocationFileID)) {
1766 cp->c_syslockcount = 1;
1775 if (!(cp->c_desc.cd_flags & CD_ISMETA) &&
1776 ((cp->c_fileid > kHFSFirstUserCatalogNodeID) || (cp->c_fileid == kHFSRootFolderID))) {
1780 if (cp->c_vp != NULLVP && VTOC(cp->c_vp) == cp) {
1781 vp = cp->c_vp;
1782 } else if (cp->c_rsrc_vp != NULLVP && VTOC(cp->c_rsrc_vp) == cp) {
1783 vp = cp->c_rsrc_vp;
1809 ((cp->c_desc.cd_flags & CD_ISMETA) == 0) &&
1810 (cp->c_flag & C_NOEXISTS)) {
1811 hfs_unlock(cp);
1942 hfs_unlock(struct cnode *cp)
1952 if ((cp->c_fileid == kHFSExtentsFileID) ||
1953 (cp->c_fileid == kHFSAllocationFileID)) {
1954 if (--cp->c_syslockcount > 0) {
1958 c_flag = cp->c_flag;
1959 cp->c_flag &= ~(C_NEED_DVNODE_PUT | C_NEED_RVNODE_PUT | C_NEED_DATA_SETSIZE | C_NEED_RSRC_SETSIZE);
1962 vp = cp->c_vp;
1965 rvp = cp->c_rsrc_vp;
1968 lockowner = cp->c_lockowner;
1970 cp->c_lockowner = NULL;
1971 lck_rw_unlock_exclusive(&cp->c_rwlock);
1973 lck_rw_unlock_shared(&cp->c_rwlock);
2055 hfs_lock_truncate(struct cnode *cp, enum hfslocktype locktype)
2059 if (cp->c_truncatelockowner == thread) {
2071 panic("hfs_lock_truncate: cnode %p locked!", cp);
2076 lck_rw_lock_shared(&cp->c_truncatelock);
2077 cp->c_truncatelockowner = HFS_SHARED_OWNER;
2080 lck_rw_lock_exclusive(&cp->c_truncatelock);
2081 cp->c_truncatelockowner = thread;
2092 int hfs_try_trunclock (struct cnode *cp, enum hfslocktype locktype) {
2096 if (cp->c_truncatelockowner == thread) {
2108 panic("hfs_lock_truncate: cnode %p locked!", cp);
2113 didlock = lck_rw_try_lock(&cp->c_truncatelock, LCK_RW_TYPE_SHARED);
2115 cp->c_truncatelockowner = HFS_SHARED_OWNER;
2119 didlock = lck_rw_try_lock (&cp->c_truncatelock, LCK_RW_TYPE_EXCLUSIVE);
2121 cp->c_truncatelockowner = thread;
2136 hfs_unlock_truncate(struct cnode *cp, int been_recursed)
2152 if (cp->c_truncatelockowner == thread) {
2158 if (thread == cp->c_truncatelockowner) {
2159 cp->c_truncatelockowner = NULL;
2160 lck_rw_unlock_exclusive(&cp->c_truncatelock);
2164 lck_rw_unlock_shared(&cp->c_truncatelock);