[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.4.2.2

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

CVSweb <webmaster@jp.NetBSD.org>