1 /* $NetBSD: ulfs_quota1_subr.c,v 1.3 2013/06/06 00:49:28 dholland Exp $ */
2 /* from NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp */
5 * Copyright (c) 2010 Manuel Bouyer
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: ulfs_quota1_subr.c,v 1.3 2013/06/06 00:49:28 dholland Exp $");
33 #include <sys/types.h>
34 #include <machine/limits.h>
36 #include <sys/quota.h>
37 #include <ufs/lfs/ulfs_quota1.h>
40 dqblk2q2e_limit(uint32_t lim
)
49 q2e2dqblk_limit(uint64_t lim
)
58 lfs_dqblk_to_quotavals(const struct dqblk
*dqblk
,
59 struct quotaval
*blocks
, struct quotaval
*files
)
61 /* XXX is qv_grace getting handled correctly? */
63 blocks
->qv_hardlimit
= dqblk2q2e_limit(dqblk
->dqb_bhardlimit
);
64 blocks
->qv_softlimit
= dqblk2q2e_limit(dqblk
->dqb_bsoftlimit
);
65 blocks
->qv_usage
= dqblk
->dqb_curblocks
;
66 blocks
->qv_expiretime
= dqblk
->dqb_btime
;
68 files
->qv_hardlimit
= dqblk2q2e_limit(dqblk
->dqb_ihardlimit
);
69 files
->qv_softlimit
= dqblk2q2e_limit(dqblk
->dqb_isoftlimit
);
70 files
->qv_usage
= dqblk
->dqb_curinodes
;
71 files
->qv_expiretime
= dqblk
->dqb_itime
;
75 lfs_quotavals_to_dqblk(const struct quotaval
*blocks
, const struct quotaval
*files
,
78 /* XXX is qv_grace getting handled correctly? */
80 dqblk
->dqb_bhardlimit
= q2e2dqblk_limit(blocks
->qv_hardlimit
);
81 dqblk
->dqb_bsoftlimit
= q2e2dqblk_limit(blocks
->qv_softlimit
);
82 dqblk
->dqb_curblocks
= blocks
->qv_usage
;
83 dqblk
->dqb_btime
= blocks
->qv_expiretime
;
85 dqblk
->dqb_ihardlimit
= q2e2dqblk_limit(files
->qv_hardlimit
);
86 dqblk
->dqb_isoftlimit
= q2e2dqblk_limit(files
->qv_softlimit
);
87 dqblk
->dqb_curinodes
= files
->qv_usage
;
88 dqblk
->dqb_itime
= files
->qv_expiretime
;