Home | History | Annotate | Line # | Download | only in kern
      1 /*	$NetBSD: vfs_quotactl.c,v 1.40 2014/06/28 22:27:50 dholland Exp $	*/
      2 /*-
      3  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by David A. Holland.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  * POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #include <sys/cdefs.h>
     32 __KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.40 2014/06/28 22:27:50 dholland Exp $$");
     33 
     34 #include <sys/mount.h>
     35 #include <sys/quotactl.h>
     36 
     37 int
     38 vfs_quotactl_stat(struct mount *mp, struct quotastat *info)
     39 {
     40 	struct quotactl_args args;
     41 
     42 	args.qc_op = QUOTACTL_STAT;
     43 	args.u.stat.qc_info = info;
     44 	return VFS_QUOTACTL(mp, &args);
     45 }
     46 
     47 int
     48 vfs_quotactl_idtypestat(struct mount *mp, int idtype,
     49     struct quotaidtypestat *info)
     50 {
     51 	struct quotactl_args args;
     52 
     53 	args.qc_op = QUOTACTL_IDTYPESTAT;
     54 	args.u.idtypestat.qc_idtype = idtype;
     55 	args.u.idtypestat.qc_info = info;
     56 	return VFS_QUOTACTL(mp, &args);
     57 }
     58 
     59 int
     60 vfs_quotactl_objtypestat(struct mount *mp, int objtype,
     61     struct quotaobjtypestat *info)
     62 {
     63 	struct quotactl_args args;
     64 
     65 	args.qc_op = QUOTACTL_OBJTYPESTAT;
     66 	args.u.objtypestat.qc_objtype = objtype;
     67 	args.u.objtypestat.qc_info = info;
     68 	return VFS_QUOTACTL(mp, &args);
     69 }
     70 
     71 int
     72 vfs_quotactl_get(struct mount *mp, const struct quotakey *key,
     73     struct quotaval *val)
     74 {
     75 	struct quotactl_args args;
     76 
     77 	args.qc_op = QUOTACTL_GET;
     78 	args.u.get.qc_key = key;
     79 	args.u.get.qc_val = val;
     80 	return VFS_QUOTACTL(mp, &args);
     81 }
     82 
     83 int
     84 vfs_quotactl_put(struct mount *mp, const struct quotakey *key,
     85     const struct quotaval *val)
     86 {
     87 	struct quotactl_args args;
     88 
     89 	args.qc_op = QUOTACTL_PUT;
     90 	args.u.put.qc_key = key;
     91 	args.u.put.qc_val = val;
     92 	return VFS_QUOTACTL(mp, &args);
     93 }
     94 
     95 int
     96 vfs_quotactl_del(struct mount *mp, const struct quotakey *key)
     97 {
     98 	struct quotactl_args args;
     99 
    100 	args.qc_op = QUOTACTL_DEL;
    101 	args.u.del.qc_key = key;
    102 	return VFS_QUOTACTL(mp, &args);
    103 }
    104 
    105 int
    106 vfs_quotactl_cursoropen(struct mount *mp, struct quotakcursor *cursor)
    107 {
    108 	struct quotactl_args args;
    109 
    110 	args.qc_op = QUOTACTL_CURSOROPEN;
    111 	args.u.cursoropen.qc_cursor = cursor;
    112 	return VFS_QUOTACTL(mp, &args);
    113 }
    114 
    115 int
    116 vfs_quotactl_cursorclose(struct mount *mp, struct quotakcursor *cursor)
    117 {
    118 	struct quotactl_args args;
    119 
    120 	args.qc_op = QUOTACTL_CURSORCLOSE;
    121 	args.u.cursorclose.qc_cursor = cursor;
    122 	return VFS_QUOTACTL(mp, &args);
    123 }
    124 
    125 int
    126 vfs_quotactl_cursorskipidtype(struct mount *mp, struct quotakcursor *cursor,
    127     int idtype)
    128 {
    129 	struct quotactl_args args;
    130 
    131 	args.qc_op = QUOTACTL_CURSORSKIPIDTYPE;
    132 	args.u.cursorskipidtype.qc_cursor = cursor;
    133 	args.u.cursorskipidtype.qc_idtype = idtype;
    134 	return VFS_QUOTACTL(mp, &args);
    135 }
    136 
    137 int
    138 vfs_quotactl_cursorget(struct mount *mp, struct quotakcursor *cursor,
    139     struct quotakey *keys, struct quotaval *vals, unsigned maxnum,
    140     unsigned *ret)
    141 {
    142 	struct quotactl_args args;
    143 
    144 	args.qc_op = QUOTACTL_CURSORGET;
    145 	args.u.cursorget.qc_cursor = cursor;
    146 	args.u.cursorget.qc_keys = keys;
    147 	args.u.cursorget.qc_vals = vals;
    148 	args.u.cursorget.qc_maxnum = maxnum;
    149 	args.u.cursorget.qc_ret = ret;
    150 	return VFS_QUOTACTL(mp, &args);
    151 }
    152 
    153 int
    154 vfs_quotactl_cursoratend(struct mount *mp, struct quotakcursor *cursor,
    155     int *ret)
    156 {
    157 	struct quotactl_args args;
    158 
    159 	args.qc_op = QUOTACTL_CURSORATEND;
    160 	args.u.cursoratend.qc_cursor = cursor;
    161 	args.u.cursoratend.qc_ret = ret;
    162 	return VFS_QUOTACTL(mp, &args);
    163 }
    164 
    165 int
    166 vfs_quotactl_cursorrewind(struct mount *mp, struct quotakcursor *cursor)
    167 {
    168 	struct quotactl_args args;
    169 
    170 	args.qc_op = QUOTACTL_CURSORREWIND;
    171 	args.u.cursorrewind.qc_cursor = cursor;
    172 	return VFS_QUOTACTL(mp, &args);
    173 }
    174 
    175 int
    176 vfs_quotactl_quotaon(struct mount *mp, int idtype, const char *path)
    177 {
    178 	struct quotactl_args args;
    179 
    180 	args.qc_op = QUOTACTL_QUOTAON;
    181 	args.u.quotaon.qc_idtype = idtype;
    182 	args.u.quotaon.qc_quotafile = path;
    183 	return VFS_QUOTACTL(mp, &args);
    184 }
    185 
    186 int
    187 vfs_quotactl_quotaoff(struct mount *mp, int idtype)
    188 {
    189 	struct quotactl_args args;
    190 
    191 	args.qc_op = QUOTACTL_QUOTAOFF;
    192 	args.u.quotaoff.qc_idtype = idtype;
    193 	return VFS_QUOTACTL(mp, &args);
    194 }
    195