/*
- * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <sys/proc.h>
#include <sys/kauth.h>
#include <sys/vnode.h>
+#include <sys/vnode_internal.h>
#include <sys/quota.h>
#include <sys/proc_internal.h>
#include <kern/kalloc.h>
#include <hfs/hfs_quota.h>
#include <hfs/hfs_mount.h>
+
/*
* Quota name to error message mapping.
*/
int type;
{
register struct dquot *dq = cp->c_dquot[type];
- long ncurinodes;
+ unsigned long ncurinodes;
struct vnode *vp = cp->c_vp ? cp->c_vp : cp->c_rsrc_vp;
dqlock(dq);
int error = 0;
struct hfs_quotaon_cargs args;
+ /* Finish setting up quota structures. */
+ dqhashinit();
+
qfp = &hfsmp->hfs_qfiles[type];
if ( (qf_get(qfp, QTF_OPENING)) )
error = EACCES;
goto out;
}
- vfs_setflags(mp, (uint64_t)((unsigned int)MNT_QUOTA));
+ vfs_setflags(mp, (u_int64_t)((unsigned int)MNT_QUOTA));
+ HFS_MOUNT_LOCK(hfsmp, TRUE)
+ hfsmp->hfs_flags |= HFS_QUOTAS;
+ HFS_MOUNT_UNLOCK(hfsmp, TRUE);
vnode_setnoflush(vp);
/*
* Save the credential of the process that turned on quotas.
int error;
struct hfs_quotaoff_cargs args;
+ /*
+ * If quotas haven't been initialized, there's no work to be done.
+ */
+ if (!dqisinitialized())
+ return (0);
+
qfp = &hfsmp->hfs_qfiles[type];
if ( (qf_get(qfp, QTF_CLOSING)) )
for (type = 0; type < MAXQUOTAS; type++)
if (hfsmp->hfs_qfiles[type].qf_vp != NULLVP)
break;
- if (type == MAXQUOTAS)
- vfs_clearflags(mp, (uint64_t)((unsigned int)MNT_QUOTA));
+ if (type == MAXQUOTAS) {
+ vfs_clearflags(mp, (u_int64_t)((unsigned int)MNT_QUOTA));
+ HFS_MOUNT_LOCK(hfsmp, TRUE)
+ hfsmp->hfs_flags &= ~HFS_QUOTAS;
+ HFS_MOUNT_UNLOCK(hfsmp, TRUE);
+ }
qf_put(qfp, QTF_CLOSING);
struct hfsmount *hfsmp = VFSTOHFS(mp);
int i;
+ if (!dqisinitialized())
+ return (0);
+
/*
* Check if the mount point has any quotas.
* If not, simply return.