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