-
- fm->h_namelen = nodeData->cnm_length;
-
- nodeData->cnm_flags |= kCatNameIsConsumed;
- nodeData->cnm_flags &= ~kCatNameIsAllocated;
- nodeData->cnm_length = 0;
- nodeData->cnm_nameptr = (char *)0;
- nodeData->cnm_namespace[0] = 0;
-
- /* Lastly, free the old, if set */
- if (fname != NULL)
- FREE(fname, M_TEMP);
-}
-
-
-
-unsigned long DerivePermissionSummary(uid_t obj_uid, gid_t obj_gid, mode_t obj_mode, struct mount *mp, struct ucred *cred, struct proc *p) {
- register gid_t *gp;
- unsigned long permissions;
- int i;
-
- /* User id 0 (root) always gets access. */
- if (cred->cr_uid == 0) {
- permissions = R_OK | W_OK | X_OK;
- goto Exit;
- };
-
- /* Otherwise, check the owner. */
- if (hfs_catalogentry_owner_rights(obj_uid, mp, cred, p, false) == 0) {
- permissions = ((unsigned long)obj_mode & S_IRWXU) >> 6;
- goto Exit;
- }
-
- /* Otherwise, check the groups. */
- if (! (mp->mnt_flag & MNT_UNKNOWNPERMISSIONS)) {
- for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++) {
- if (obj_gid == *gp) {
- permissions = ((unsigned long)obj_mode & S_IRWXG) >> 3;
- goto Exit;
- }
- };
- };
-
- /* Otherwise, settle for 'others' access. */
- permissions = (unsigned long)obj_mode & S_IRWXO;
-
-Exit:
- return permissions;
-}
-
-
-
-int AttributeBlockSize(struct attrlist *attrlist) {
- int size;
- attrgroup_t a;
-
-#if ((ATTR_CMN_NAME | ATTR_CMN_DEVID | ATTR_CMN_FSID | ATTR_CMN_OBJTYPE | \
- ATTR_CMN_OBJTAG | ATTR_CMN_OBJID | ATTR_CMN_OBJPERMANENTID | ATTR_CMN_PAROBJID | \
- ATTR_CMN_SCRIPT | ATTR_CMN_CRTIME | ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME | \
- ATTR_CMN_ACCTIME | ATTR_CMN_BKUPTIME | ATTR_CMN_FNDRINFO | ATTR_CMN_OWNERID | \
- ATTR_CMN_GRPID | ATTR_CMN_ACCESSMASK | ATTR_CMN_NAMEDATTRCOUNT | ATTR_CMN_NAMEDATTRLIST| \
- ATTR_CMN_FLAGS | ATTR_CMN_USERACCESS) != ATTR_CMN_VALIDMASK)
-#error AttributeBlockSize: Missing bits in common mask computation!
-#endif
- DBG_ASSERT((attrlist->commonattr & ~ATTR_CMN_VALIDMASK) == 0);
-
-#if ((ATTR_VOL_FSTYPE | ATTR_VOL_SIGNATURE | ATTR_VOL_SIZE | ATTR_VOL_SPACEFREE | \
- ATTR_VOL_SPACEAVAIL | ATTR_VOL_MINALLOCATION | ATTR_VOL_ALLOCATIONCLUMP | ATTR_VOL_IOBLOCKSIZE | \
- ATTR_VOL_OBJCOUNT | ATTR_VOL_FILECOUNT | ATTR_VOL_DIRCOUNT | ATTR_VOL_MAXOBJCOUNT | \
- ATTR_VOL_MOUNTPOINT | ATTR_VOL_NAME | ATTR_VOL_MOUNTFLAGS | ATTR_VOL_INFO | \
- ATTR_VOL_MOUNTEDDEVICE| ATTR_VOL_ENCODINGSUSED | ATTR_VOL_CAPABILITIES | ATTR_VOL_ATTRIBUTES) != ATTR_VOL_VALIDMASK)
-#error AttributeBlockSize: Missing bits in volume mask computation!
-#endif
- DBG_ASSERT((attrlist->volattr & ~ATTR_VOL_VALIDMASK) == 0);
-
-#if ((ATTR_DIR_LINKCOUNT | ATTR_DIR_ENTRYCOUNT | ATTR_DIR_MOUNTSTATUS) != ATTR_DIR_VALIDMASK)
-#error AttributeBlockSize: Missing bits in directory mask computation!
-#endif
- DBG_ASSERT((attrlist->dirattr & ~ATTR_DIR_VALIDMASK) == 0);
-#if ((ATTR_FILE_LINKCOUNT | ATTR_FILE_TOTALSIZE | ATTR_FILE_ALLOCSIZE | ATTR_FILE_IOBLOCKSIZE | \
- ATTR_FILE_CLUMPSIZE | ATTR_FILE_DEVTYPE | ATTR_FILE_FILETYPE | ATTR_FILE_FORKCOUNT | \
- ATTR_FILE_FORKLIST | ATTR_FILE_DATALENGTH | ATTR_FILE_DATAALLOCSIZE | ATTR_FILE_DATAEXTENTS | \
- ATTR_FILE_RSRCLENGTH | ATTR_FILE_RSRCALLOCSIZE | ATTR_FILE_RSRCEXTENTS) != ATTR_FILE_VALIDMASK)
-#error AttributeBlockSize: Missing bits in file mask computation!
-#endif
- DBG_ASSERT((attrlist->fileattr & ~ATTR_FILE_VALIDMASK) == 0);
-
-#if ((ATTR_FORK_TOTALSIZE | ATTR_FORK_ALLOCSIZE) != ATTR_FORK_VALIDMASK)
-#error AttributeBlockSize: Missing bits in fork mask computation!
-#endif
- DBG_ASSERT((attrlist->forkattr & ~ATTR_FORK_VALIDMASK) == 0);
-
- size = 0;
-
- if ((a = attrlist->commonattr) != 0) {
- if (a & ATTR_CMN_NAME) size += sizeof(struct attrreference);
- if (a & ATTR_CMN_DEVID) size += sizeof(dev_t);
- if (a & ATTR_CMN_FSID) size += sizeof(fsid_t);
- if (a & ATTR_CMN_OBJTYPE) size += sizeof(fsobj_type_t);
- if (a & ATTR_CMN_OBJTAG) size += sizeof(fsobj_tag_t);
- if (a & ATTR_CMN_OBJID) size += sizeof(fsobj_id_t);
- if (a & ATTR_CMN_OBJPERMANENTID) size += sizeof(fsobj_id_t);
- if (a & ATTR_CMN_PAROBJID) size += sizeof(fsobj_id_t);
- if (a & ATTR_CMN_SCRIPT) size += sizeof(text_encoding_t);
- if (a & ATTR_CMN_CRTIME) size += sizeof(struct timespec);
- if (a & ATTR_CMN_MODTIME) size += sizeof(struct timespec);
- if (a & ATTR_CMN_CHGTIME) size += sizeof(struct timespec);
- if (a & ATTR_CMN_ACCTIME) size += sizeof(struct timespec);
- if (a & ATTR_CMN_BKUPTIME) size += sizeof(struct timespec);
- if (a & ATTR_CMN_FNDRINFO) size += 32 * sizeof(UInt8);
- if (a & ATTR_CMN_OWNERID) size += sizeof(uid_t);
- if (a & ATTR_CMN_GRPID) size += sizeof(gid_t);
- if (a & ATTR_CMN_ACCESSMASK) size += sizeof(u_long);
- if (a & ATTR_CMN_NAMEDATTRCOUNT) size += sizeof(u_long);
- if (a & ATTR_CMN_NAMEDATTRLIST) size += sizeof(struct attrreference);
- if (a & ATTR_CMN_FLAGS) size += sizeof(u_long);
- if (a & ATTR_CMN_USERACCESS) size += sizeof(u_long);
- };
- if ((a = attrlist->volattr) != 0) {
- if (a & ATTR_VOL_FSTYPE) size += sizeof(u_long);
- if (a & ATTR_VOL_SIGNATURE) size += sizeof(u_long);
- if (a & ATTR_VOL_SIZE) size += sizeof(off_t);
- if (a & ATTR_VOL_SPACEFREE) size += sizeof(off_t);
- if (a & ATTR_VOL_SPACEAVAIL) size += sizeof(off_t);
- if (a & ATTR_VOL_MINALLOCATION) size += sizeof(off_t);
- if (a & ATTR_VOL_ALLOCATIONCLUMP) size += sizeof(off_t);
- if (a & ATTR_VOL_IOBLOCKSIZE) size += sizeof(u_long);
- if (a & ATTR_VOL_OBJCOUNT) size += sizeof(u_long);
- if (a & ATTR_VOL_FILECOUNT) size += sizeof(u_long);
- if (a & ATTR_VOL_DIRCOUNT) size += sizeof(u_long);
- if (a & ATTR_VOL_MAXOBJCOUNT) size += sizeof(u_long);
- if (a & ATTR_VOL_MOUNTPOINT) size += sizeof(struct attrreference);
- if (a & ATTR_VOL_NAME) size += sizeof(struct attrreference);
- if (a & ATTR_VOL_MOUNTFLAGS) size += sizeof(u_long);
- if (a & ATTR_VOL_MOUNTEDDEVICE) size += sizeof(struct attrreference);
- if (a & ATTR_VOL_ENCODINGSUSED) size += sizeof(unsigned long long);
- if (a & ATTR_VOL_CAPABILITIES) size += sizeof(vol_capabilities_attr_t);
- if (a & ATTR_VOL_ATTRIBUTES) size += sizeof(vol_attributes_attr_t);
- };
- if ((a = attrlist->dirattr) != 0) {
- if (a & ATTR_DIR_LINKCOUNT) size += sizeof(u_long);
- if (a & ATTR_DIR_ENTRYCOUNT) size += sizeof(u_long);
- if (a & ATTR_DIR_MOUNTSTATUS) size += sizeof(u_long);
- };
- if ((a = attrlist->fileattr) != 0) {
- if (a & ATTR_FILE_LINKCOUNT) size += sizeof(u_long);
- if (a & ATTR_FILE_TOTALSIZE) size += sizeof(off_t);
- if (a & ATTR_FILE_ALLOCSIZE) size += sizeof(off_t);
- if (a & ATTR_FILE_IOBLOCKSIZE) size += sizeof(size_t);
- if (a & ATTR_FILE_CLUMPSIZE) size += sizeof(off_t);
- if (a & ATTR_FILE_DEVTYPE) size += sizeof(u_long);
- if (a & ATTR_FILE_FILETYPE) size += sizeof(u_long);
- if (a & ATTR_FILE_FORKCOUNT) size += sizeof(u_long);
- if (a & ATTR_FILE_FORKLIST) size += sizeof(struct attrreference);
- if (a & ATTR_FILE_DATALENGTH) size += sizeof(off_t);
- if (a & ATTR_FILE_DATAALLOCSIZE) size += sizeof(off_t);
- if (a & ATTR_FILE_DATAEXTENTS) size += sizeof(extentrecord);
- if (a & ATTR_FILE_RSRCLENGTH) size += sizeof(off_t);
- if (a & ATTR_FILE_RSRCALLOCSIZE) size += sizeof(off_t);
- if (a & ATTR_FILE_RSRCEXTENTS) size += sizeof(extentrecord);
- };
- if ((a = attrlist->forkattr) != 0) {
- if (a & ATTR_FORK_TOTALSIZE) size += sizeof(off_t);
- if (a & ATTR_FORK_ALLOCSIZE) size += sizeof(off_t);
- };
-
- return size;