[BACK]Return to quota2.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ufs

Annotation of src/sys/ufs/ufs/quota2.h, Revision 1.8

1.8     ! dholland    1: /* $NetBSD: quota2.h,v 1.7 2012/01/29 07:17:41 dholland Exp $ */
1.2       bouyer      2: /*-
                      3:   * Copyright (c) 2010 Manuel Bouyer
                      4:   * All rights reserved.
                      5:   *
                      6:   * Redistribution and use in source and binary forms, with or without
                      7:   * modification, are permitted provided that the following conditions
                      8:   * are met:
                      9:   * 1. Redistributions of source code must retain the above copyright
                     10:   *    notice, this list of conditions and the following disclaimer.
                     11:   * 2. Redistributions in binary form must reproduce the above copyright
                     12:   *    notice, this list of conditions and the following disclaimer in the
                     13:   *    documentation and/or other materials provided with the distribution.
                     14:   *
                     15:   * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     16:   * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     17:   * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     18:   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     19:   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     20:   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     21:   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     22:   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     23:   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     24:   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     25:   * POSSIBILITY OF SUCH DAMAGE.
                     26:   */
                     27:
                     28: #ifndef _UFS_UFS_QUOTA2_H_
                     29: #define _UFS_UFS_QUOTA2_H_
                     30: #include <ufs/ufs/quota.h>
                     31:
                     32:
                     33: /* New disk quota implementation. In this implementation, the quota datas
                     34:  * (default values, user limits and current usage) are part of the filesystem
                     35:  * metadata. On FFS, this will be in a hidden, unlinked inode. fsck_ffs is
                     36:  * responsible for checking quotas with the rest of the filesystem integrity,
                     37:  * and quotas metadata are also covered by the filesystem journal if any.
                     38:  * quota enable/disable is done on a filesystem basis via flags in the
                     39:  * superblock
                     40:  */
                     41:
                     42: /*
                     43:  * The quota file is comprised of 2 parts, the header and the entries.
                     44:  * The header contains global informations, and head of list of quota entries.
                     45:  * A quota entry can either be in the free list, or one of the hash lists.
                     46:  */
                     47:
                     48: /* description of a block or inode quota */
                     49: struct quota2_val {
                     50:        uint64_t q2v_hardlimit; /* absolute limit */
                     51:        uint64_t q2v_softlimit; /* overflowable limit */
                     52:        uint64_t q2v_cur; /* current usage */
                     53:        int64_t q2v_time; /* grace expiration date for softlimit overflow */
                     54:        int64_t q2v_grace; /* allowed time for softlimit overflow */
                     55: };
                     56:
                     57: /*
                     58:  * On-disk description of a user or group quota
                     59:  * These entries are keept as linked list, either in one of the hash HEAD,
                     60:  * or in the free list.
                     61:  */
                     62:
1.4       bouyer     63: #define N_QL 2
                     64: #define QL_BLOCK 0
                     65: #define QL_FILE 1
1.6       dholland   66: #define INITQLNAMES { \
                     67:        [QL_BLOCK] = "block",   \
                     68:        [QL_FILE] =  "file",    \
                     69: }
1.4       bouyer     70:
1.2       bouyer     71: struct quota2_entry {
                     72:        /* block & inode limits and status */
                     73:        struct quota2_val q2e_val[N_QL];
                     74:        /* pointer to next entry for this list (offset in the file) */
                     75:        uint64_t q2e_next;
1.3       dholland   76:        /* ownership information */
1.2       bouyer     77:        uint32_t q2e_uid;
                     78:        uint32_t q2e_pad;
                     79: };
                     80:
                     81: /* header present at the start of the quota file */
                     82: struct quota2_header {
                     83:        uint32_t q2h_magic_number;
                     84:        uint8_t  q2h_type; /* quota type, see below */
                     85:        uint8_t  q2h_hash_shift; /* bytes used for hash index */
                     86:        uint16_t q2h_hash_size; /* size of hash table */
                     87:        /* default values applied to new entries */
                     88:        struct quota2_entry q2h_defentry;
                     89:        /* head of free quota2_entry list */
                     90:        uint64_t q2h_free;
                     91:        /* variable-sized hash table */
                     92:        uint64_t q2h_entries[0];
                     93: };
                     94:
                     95: #define Q2_HEAD_MAGIC  0xb746915e
                     96:
                     97: /* superblock flags */
                     98: #define FS_Q2_DO_TYPE(type)    (0x01 << (type))
                     99:
                    100: #define off2qindex(hsize, off) (((off) - (hsize)) / sizeof(struct quota2_entry))
                    101: #define qindex2off(hsize, idx) \
                    102:        ((daddr_t)(idx) * sizeof(struct quota2_entry) + (hsize))
                    103:
                    104: /* quota2_subr.c */
                    105: void quota2_addfreeq2e(struct quota2_header *, void *, uint64_t, uint64_t, int);
                    106: void quota2_create_blk0(uint64_t, void *bp, int, int, int);
                    107: void quota2_ufs_rwq2v(const struct quota2_val *, struct quota2_val *, int);
                    108: void quota2_ufs_rwq2e(const struct quota2_entry *, struct quota2_entry *, int);
                    109:
                    110: #endif /*  _UFS_UFS_QUOTA2_H_ */

CVSweb <webmaster@jp.NetBSD.org>