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

Annotation of src/sys/ufs/ufs/quota1_subr.c, Revision 1.3.2.2

1.3.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: #include <sys/cdefs.h>
        !            31: __KERNEL_RCSID(0, "$NetBSD$");
        !            32:
        !            33: #include <sys/types.h>
        !            34: #include <machine/limits.h>
        !            35:
        !            36: #include <quota/quotaprop.h>
        !            37: #include <ufs/ufs/quota1.h>
        !            38:
        !            39: static uint64_t
        !            40: dqblk2q2e_limit(uint32_t lim)
        !            41: {
        !            42:        if (lim == 0)
        !            43:                return UQUAD_MAX;
        !            44:        else
        !            45:                return (lim - 1);
        !            46: }
        !            47:
        !            48: static uint32_t
        !            49: q2e2dqblk_limit(uint64_t lim)
        !            50: {
        !            51:        if (lim == UQUAD_MAX)
        !            52:                return 0;
        !            53:        else
        !            54:                return (lim + 1);
        !            55: }
        !            56:
        !            57: void
        !            58: dqblk2ufsqe(const struct dqblk *dqblk, struct ufs_quota_entry *qe)
        !            59: {
        !            60:        qe[QUOTA_LIMIT_BLOCK].ufsqe_hardlimit =
        !            61:            dqblk2q2e_limit(dqblk->dqb_bhardlimit);
        !            62:        qe[QUOTA_LIMIT_BLOCK].ufsqe_softlimit =
        !            63:            dqblk2q2e_limit(dqblk->dqb_bsoftlimit);
        !            64:        qe[QUOTA_LIMIT_BLOCK].ufsqe_cur       = dqblk->dqb_curblocks;
        !            65:        qe[QUOTA_LIMIT_BLOCK].ufsqe_time      = dqblk->dqb_btime;
        !            66:
        !            67:        qe[QUOTA_LIMIT_FILE].ufsqe_hardlimit =
        !            68:            dqblk2q2e_limit(dqblk->dqb_ihardlimit);
        !            69:        qe[QUOTA_LIMIT_FILE].ufsqe_softlimit =
        !            70:            dqblk2q2e_limit(dqblk->dqb_isoftlimit);
        !            71:        qe[QUOTA_LIMIT_FILE].ufsqe_cur       = dqblk->dqb_curinodes;
        !            72:        qe[QUOTA_LIMIT_FILE].ufsqe_time      = dqblk->dqb_itime;
        !            73: }
        !            74:
        !            75: void
        !            76: ufsqe2dqblk(const struct ufs_quota_entry *qe, struct dqblk *dqblk)
        !            77: {
        !            78:        dqblk->dqb_bhardlimit =
        !            79:            q2e2dqblk_limit(qe[QUOTA_LIMIT_BLOCK].ufsqe_hardlimit);
        !            80:        dqblk->dqb_bsoftlimit =
        !            81:            q2e2dqblk_limit(qe[QUOTA_LIMIT_BLOCK].ufsqe_softlimit);
        !            82:        dqblk->dqb_curblocks  = qe[QUOTA_LIMIT_BLOCK].ufsqe_cur;
        !            83:        dqblk->dqb_btime      = qe[QUOTA_LIMIT_BLOCK].ufsqe_time;
        !            84:
        !            85:        dqblk->dqb_ihardlimit =
        !            86:            q2e2dqblk_limit(qe[QUOTA_LIMIT_FILE].ufsqe_hardlimit);
        !            87:        dqblk->dqb_isoftlimit =
        !            88:            q2e2dqblk_limit(qe[QUOTA_LIMIT_FILE].ufsqe_softlimit);
        !            89:        dqblk->dqb_curinodes  = qe[QUOTA_LIMIT_FILE].ufsqe_cur;
        !            90:        dqblk->dqb_itime      = qe[QUOTA_LIMIT_FILE].ufsqe_time;
        !            91: }
        !            92:

CVSweb <webmaster@jp.NetBSD.org>