Home | History | Annotate | Line # | Download | only in lfs
ulfs_quota.h revision 1.4.2.2
      1  1.4.2.2  tls /*	$NetBSD: ulfs_quota.h,v 1.4.2.2 2013/06/23 06:18:39 tls Exp $	*/
      2  1.4.2.2  tls /*  from NetBSD: ufs_quota.h,v 1.21 2012/02/18 06:13:23 matt Exp  */
      3  1.4.2.2  tls 
      4  1.4.2.2  tls /*
      5  1.4.2.2  tls  * Copyright (c) 1982, 1986, 1990, 1993, 1995
      6  1.4.2.2  tls  *	The Regents of the University of California.  All rights reserved.
      7  1.4.2.2  tls  *
      8  1.4.2.2  tls  * This code is derived from software contributed to Berkeley by
      9  1.4.2.2  tls  * Robert Elz at The University of Melbourne.
     10  1.4.2.2  tls  *
     11  1.4.2.2  tls  * Redistribution and use in source and binary forms, with or without
     12  1.4.2.2  tls  * modification, are permitted provided that the following conditions
     13  1.4.2.2  tls  * are met:
     14  1.4.2.2  tls  * 1. Redistributions of source code must retain the above copyright
     15  1.4.2.2  tls  *    notice, this list of conditions and the following disclaimer.
     16  1.4.2.2  tls  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.4.2.2  tls  *    notice, this list of conditions and the following disclaimer in the
     18  1.4.2.2  tls  *    documentation and/or other materials provided with the distribution.
     19  1.4.2.2  tls  * 3. Neither the name of the University nor the names of its contributors
     20  1.4.2.2  tls  *    may be used to endorse or promote products derived from this software
     21  1.4.2.2  tls  *    without specific prior written permission.
     22  1.4.2.2  tls  *
     23  1.4.2.2  tls  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.4.2.2  tls  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.4.2.2  tls  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.4.2.2  tls  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.4.2.2  tls  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.4.2.2  tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.4.2.2  tls  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.4.2.2  tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.4.2.2  tls  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.4.2.2  tls  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.4.2.2  tls  * SUCH DAMAGE.
     34  1.4.2.2  tls  *
     35  1.4.2.2  tls  *	@(#)ufs_quota.c	8.5 (Berkeley) 5/20/95
     36  1.4.2.2  tls  */
     37  1.4.2.2  tls #include <ufs/lfs/ulfs_quota1.h>
     38  1.4.2.2  tls #include <ufs/lfs/ulfs_quota2.h>
     39  1.4.2.2  tls 
     40  1.4.2.2  tls struct quotakcursor; /* from <sys/quotactl.h> */
     41  1.4.2.2  tls 
     42  1.4.2.2  tls 
     43  1.4.2.2  tls /* link to this quota in the quota inode (for QUOTA2) */
     44  1.4.2.2  tls struct dq2_desc {
     45  1.4.2.2  tls 	uint64_t dq2_lblkno; /* logical disk block holding this quota */
     46  1.4.2.2  tls 	u_int    dq2_blkoff; /* offset in disk block holding this quota */
     47  1.4.2.2  tls };
     48  1.4.2.2  tls 
     49  1.4.2.2  tls /*
     50  1.4.2.2  tls  * The following structure records disk usage for a user or group on a
     51  1.4.2.2  tls  * filesystem. There is one allocated for each quota that exists on any
     52  1.4.2.2  tls  * filesystem for the current user or group. A cache is kept of recently
     53  1.4.2.2  tls  * used entries.
     54  1.4.2.2  tls  * Field markings and the corresponding locks:
     55  1.4.2.2  tls  * h:	dqlock
     56  1.4.2.2  tls  * d:	dq_interlock
     57  1.4.2.2  tls  *
     58  1.4.2.2  tls  * Lock order is: dq_interlock -> dqlock
     59  1.4.2.2  tls  *                dq_interlock -> dqvp
     60  1.4.2.2  tls  */
     61  1.4.2.2  tls struct dquot {
     62  1.4.2.2  tls 	LIST_ENTRY(dquot) dq_hash;	/* h: hash list */
     63  1.4.2.2  tls 	u_int16_t dq_flags;		/* d: flags, see below */
     64  1.4.2.2  tls 	u_int16_t dq_type;		/* d: quota type of this dquot */
     65  1.4.2.2  tls 	u_int32_t dq_cnt;		/* h: count of active references */
     66  1.4.2.2  tls 	u_int32_t dq_id;		/* d: identifier this applies to */
     67  1.4.2.2  tls 	struct	ulfsmount *dq_ump;	/* d: filesystem this is taken from */
     68  1.4.2.2  tls 	kmutex_t dq_interlock;		/* d: lock this dquot */
     69  1.4.2.2  tls 	union {
     70  1.4.2.2  tls 		struct dqblk dq1_dqb;	/* d: actual usage & quotas */
     71  1.4.2.2  tls 		struct dq2_desc dq2_desc; /* d: pointer to quota data */
     72  1.4.2.2  tls 	} dq_un;
     73  1.4.2.2  tls };
     74  1.4.2.2  tls 
     75  1.4.2.2  tls /*
     76  1.4.2.2  tls  * Flag values.
     77  1.4.2.2  tls  */
     78  1.4.2.2  tls #define	DQ_MOD		0x04		/* this quota modified since read */
     79  1.4.2.2  tls #define	DQ_FAKE		0x08		/* no limits here, just usage */
     80  1.4.2.2  tls #define	DQ_WARN(ltype)	(0x10 << ltype)	/* has been warned about "type" limit */
     81  1.4.2.2  tls /*
     82  1.4.2.2  tls  * Shorthand notation.
     83  1.4.2.2  tls  */
     84  1.4.2.2  tls #define	dq_bhardlimit	dq_un.dq1_dqb.dqb_bhardlimit
     85  1.4.2.2  tls #define	dq_bsoftlimit	dq_un.dq1_dqb.dqb_bsoftlimit
     86  1.4.2.2  tls #define	dq_curblocks	dq_un.dq1_dqb.dqb_curblocks
     87  1.4.2.2  tls #define	dq_ihardlimit	dq_un.dq1_dqb.dqb_ihardlimit
     88  1.4.2.2  tls #define	dq_isoftlimit	dq_un.dq1_dqb.dqb_isoftlimit
     89  1.4.2.2  tls #define	dq_curinodes	dq_un.dq1_dqb.dqb_curinodes
     90  1.4.2.2  tls #define	dq_btime	dq_un.dq1_dqb.dqb_btime
     91  1.4.2.2  tls #define	dq_itime	dq_un.dq1_dqb.dqb_itime
     92  1.4.2.2  tls 
     93  1.4.2.2  tls #define dq2_lblkno	dq_un.dq2_desc.dq2_lblkno
     94  1.4.2.2  tls #define dq2_blkoff	dq_un.dq2_desc.dq2_blkoff
     95  1.4.2.2  tls /*
     96  1.4.2.2  tls  * If the system has never checked for a quota for this file, then it is
     97  1.4.2.2  tls  * set to NODQUOT.  Once a write attempt is made the inode pointer is set
     98  1.4.2.2  tls  * to reference a dquot structure.
     99  1.4.2.2  tls  */
    100  1.4.2.2  tls #define	NODQUOT		NULL
    101  1.4.2.2  tls 
    102  1.4.2.2  tls extern kmutex_t lfs_dqlock;
    103  1.4.2.2  tls extern kcondvar_t lfs_dqcv;
    104  1.4.2.2  tls /*
    105  1.4.2.2  tls  * Quota name to error message mapping.
    106  1.4.2.2  tls  */
    107  1.4.2.2  tls extern const char *lfs_quotatypes[ULFS_MAXQUOTAS];
    108  1.4.2.2  tls 
    109  1.4.2.2  tls int  lfs_getinoquota(struct inode *);
    110  1.4.2.2  tls int  lfs_dqget(struct vnode *, u_long, struct ulfsmount *, int, struct dquot **);
    111  1.4.2.2  tls void lfs_dqref(struct dquot *);
    112  1.4.2.2  tls void lfs_dqrele(struct vnode *, struct dquot *);
    113  1.4.2.2  tls void lfs_dqflush(struct vnode *);
    114  1.4.2.2  tls 
    115  1.4.2.2  tls int lfs_chkdq1(struct inode *, int64_t, kauth_cred_t, int);
    116  1.4.2.2  tls int lfs_chkiq1(struct inode *, int32_t, kauth_cred_t, int);
    117  1.4.2.2  tls int lfs_q1sync(struct mount *);
    118  1.4.2.2  tls int lfs_dq1get(struct vnode *, u_long, struct ulfsmount *, int, struct dquot *);
    119  1.4.2.2  tls int lfs_dq1sync(struct vnode *, struct dquot *);
    120  1.4.2.2  tls int lfsquota1_handle_cmd_get(struct ulfsmount *, const struct quotakey *,
    121  1.4.2.2  tls     struct quotaval *);
    122  1.4.2.2  tls int lfsquota1_handle_cmd_put(struct ulfsmount *, const struct quotakey *,
    123  1.4.2.2  tls     const struct quotaval *);
    124  1.4.2.2  tls int lfsquota1_handle_cmd_quotaon(struct lwp *, struct ulfsmount *, int,
    125  1.4.2.2  tls     const char *);
    126  1.4.2.2  tls int lfsquota1_handle_cmd_quotaoff(struct lwp *, struct ulfsmount *, int);
    127  1.4.2.2  tls 
    128  1.4.2.2  tls int lfs_chkdq2(struct inode *, int64_t, kauth_cred_t, int);
    129  1.4.2.2  tls int lfs_chkiq2(struct inode *, int32_t, kauth_cred_t, int);
    130  1.4.2.2  tls int lfsquota2_handle_cmd_get(struct ulfsmount *, const struct quotakey *,
    131  1.4.2.2  tls     struct quotaval *);
    132  1.4.2.2  tls int lfsquota2_handle_cmd_put(struct ulfsmount *, const struct quotakey *,
    133  1.4.2.2  tls     const struct quotaval *);
    134  1.4.2.2  tls int lfsquota2_handle_cmd_delete(struct ulfsmount *, const struct quotakey *);
    135  1.4.2.2  tls int lfsquota2_handle_cmd_cursorget(struct ulfsmount *, struct quotakcursor *,
    136  1.4.2.2  tls     struct quotakey *, struct quotaval *, unsigned, unsigned *);
    137  1.4.2.2  tls int lfsquota2_handle_cmd_cursoropen(struct ulfsmount *, struct quotakcursor *);
    138  1.4.2.2  tls int lfsquota2_handle_cmd_cursorclose(struct ulfsmount *, struct quotakcursor *);
    139  1.4.2.2  tls int lfsquota2_handle_cmd_cursorskipidtype(struct ulfsmount *, struct quotakcursor *,
    140  1.4.2.2  tls     int);
    141  1.4.2.2  tls int lfsquota2_handle_cmd_cursoratend(struct ulfsmount *, struct quotakcursor *,
    142  1.4.2.2  tls     int *);
    143  1.4.2.2  tls int lfsquota2_handle_cmd_cursorrewind(struct ulfsmount *, struct quotakcursor *);
    144  1.4.2.2  tls int lfs_q2sync(struct mount *);
    145  1.4.2.2  tls int lfs_dq2get(struct vnode *, u_long, struct ulfsmount *, int, struct dquot *);
    146  1.4.2.2  tls int lfs_dq2sync(struct vnode *, struct dquot *);
    147