#include <sys/unistd.h>
#include <sys/mount_internal.h>
#include <sys/kauth.h>
+#include <sys/fsctl.h>
#include <kern/locks.h>
* apply for the file system you are doing the readdirattr on. To make life
* simpler, this call will only return entries in its directory, hfs like.
*/
-__private_extern__
int
hfs_vnop_readdirattr(ap)
struct vnop_readdirattr_args /* {
(alist->forkattr != 0)) {
return (EINVAL);
}
+
+ if (VTOC(dvp)->c_flags & UF_COMPRESSED) {
+ int compressed = hfs_file_is_compressed(VTOC(dvp), 0); /* 0 == take the cnode lock */
+
+ if (!compressed) {
+ error = check_for_dataless_file(dvp, NAMESPACE_HANDLER_READ_OP);
+ if (error) {
+ return error;
+ }
+ }
+ }
+
+
/*
* Take an exclusive directory lock since we manipulate the directory hints
*/
/*
* Obtain vnode for our vnode_authorize() calls.
*/
- if (hfs_vget(hfsmp, cattrp->ca_fileid, &vp, 0) != 0) {
+ if (hfs_vget(hfsmp, cattrp->ca_fileid, &vp, 0, 0) != 0) {
vp = NULL;
}
} else if (!(ap->a_options & FSOPT_NOINMEMUPDATE)) {
/* Get in-memory cnode data (if any). */
- vp = hfs_chash_getvnode(hfsmp, cattrp->ca_fileid, 0, 0);
+ vp = hfs_chash_getvnode(hfsmp, cattrp->ca_fileid, 0, 0, 0);
}
if (vp != NULL) {
cp = VTOC(vp);
/*
* Pack cnode attributes into an attribute block.
*/
- __private_extern__
+__private_extern__
void
hfs_packattrblk(struct attrblock *abp,
struct hfsmount *hfsmp,
}
}
if (ATTR_CMN_FNDRINFO & attr) {
+ u_int8_t *finfo = NULL;
bcopy(&cap->ca_finderinfo, attrbufptr, sizeof(u_int8_t) * 32);
+ finfo = (u_int8_t*)attrbufptr;
+
/* Don't expose a symlink's private type/creator. */
if (S_ISLNK(cap->ca_mode)) {
struct FndrFileInfo *fip;
fip->fdType = 0;
fip->fdCreator = 0;
}
+
+ /* advance 16 bytes into the attrbuf */
+ finfo = finfo + 16;
+ if (S_ISREG(cap->ca_mode)) {
+ struct FndrExtendedFileInfo *extinfo = (struct FndrExtendedFileInfo *)finfo;
+ extinfo->date_added = 0;
+ }
+ else if (S_ISDIR(cap->ca_mode)) {
+ struct FndrExtendedDirInfo *extinfo = (struct FndrExtendedDirInfo *)finfo;
+ extinfo->date_added = 0;
+ }
+
attrbufptr = (char *)attrbufptr + sizeof(u_int8_t) * 32;
}
if (ATTR_CMN_OWNERID & attr) {
off_t datasize = datafork->cf_size;
off_t totalsize = datasize + rsrcfork->cf_size;
#if HFS_COMPRESSION
- if ( cattrp->ca_flags & UF_COMPRESSED ) {
+ int handle_compressed;
+ handle_compressed = (cattrp->ca_flags & UF_COMPRESSED);// && hfs_file_is_compressed(VTOC(vp), 1);
+
+ if (handle_compressed) {
if (attr & (ATTR_FILE_DATALENGTH|ATTR_FILE_TOTALSIZE)) {
if ( 0 == hfs_uncompressed_size_of_compressed_file(hfsmp, vp, cattrp->ca_fileid, &datasize, 1) ) { /* 1 == don't take the cnode lock */
/* total size of a compressed file is just the data size */
* passed by hfs_vnop_readdirattr() may be null.
*/
- if ( cattrp->ca_flags & UF_COMPRESSED ) {
+ if ( handle_compressed ) {
if (attr & ATTR_FILE_DATAALLOCSIZE) {
*((off_t *)attrbufptr) = (off_t)rsrcfork->cf_blocks * (off_t)allocblksize;
attrbufptr = ((off_t *)attrbufptr) + 1;
/*
* Calculate the total size of an attribute block.
*/
- __private_extern__
+__private_extern__
int
hfs_attrblksize(struct attrlist *attrlist)
{
}
-__private_extern__
u_int32_t
DerivePermissionSummary(uid_t obj_uid, gid_t obj_gid, mode_t obj_mode,
struct mount *mp, kauth_cred_t cred, __unused struct proc *p)