| 1 | /* $NetBSD: quota.h,v 1.30 2012/08/26 02:32:14 dholland Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 1982, 1986, 1993 |
| 5 | * The Regents of the University of California. All rights reserved. |
| 6 | * |
| 7 | * This code is derived from software contributed to Berkeley by |
| 8 | * Robert Elz at The University of Melbourne. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * 3. Neither the name of the University nor the names of its contributors |
| 19 | * may be used to endorse or promote products derived from this software |
| 20 | * without specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 32 | * SUCH DAMAGE. |
| 33 | * |
| 34 | * @(#)quota.h 8.3 (Berkeley) 8/19/94 |
| 35 | */ |
| 36 | |
| 37 | #ifndef _UFS_UFS_QUOTA_H_ |
| 38 | #define _UFS_UFS_QUOTA_H_ |
| 39 | |
| 40 | /* |
| 41 | * These definitions are common to the original disk quota implementation |
| 42 | * (quota1) and the newer implementation (quota2) |
| 43 | */ |
| 44 | |
| 45 | /* |
| 46 | * The following constants define the usage of the quota file array in the |
| 47 | * ufsmount structure and dquot array in the inode structure. The semantics |
| 48 | * of the elements of these arrays are defined in the routine getinoquota; |
| 49 | * the remainder of the quota code treats them generically and need not be |
| 50 | * inspected when changing the size of the array. |
| 51 | */ |
| 52 | #define MAXQUOTAS 2 |
| 53 | #define USRQUOTA 0 /* element used for user quotas */ |
| 54 | #define GRPQUOTA 1 /* element used for group quotas */ |
| 55 | |
| 56 | /* |
| 57 | * Initializer for the strings corresponding to the quota ID types. |
| 58 | * (in quota1 these are also the default names of the quota files) |
| 59 | */ |
| 60 | #define INITQFNAMES { \ |
| 61 | "user", /* USRQUOTA */ \ |
| 62 | "group", /* GRPQUOTA */ \ |
| 63 | } |
| 64 | |
| 65 | #if !defined(HAVE_NBTOOL_CONFIG_H) |
| 66 | #include <sys/quota.h> |
| 67 | __inline static int __unused |
| 68 | quota_idtype_to_ufs(int idtype) |
| 69 | { |
| 70 | switch (idtype) { |
| 71 | case QUOTA_IDTYPE_USER: |
| 72 | return USRQUOTA; |
| 73 | case QUOTA_IDTYPE_GROUP: |
| 74 | return GRPQUOTA; |
| 75 | default: |
| 76 | return -1; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | static __inline int __unused |
| 81 | quota_idtype_from_ufs(int ufstype) |
| 82 | { |
| 83 | switch (ufstype) { |
| 84 | case USRQUOTA: |
| 85 | return QUOTA_IDTYPE_USER; |
| 86 | case GRPQUOTA: |
| 87 | return QUOTA_IDTYPE_GROUP; |
| 88 | default: |
| 89 | return -1; |
| 90 | } |
| 91 | } |
| 92 | #endif /* !defined(HAVE_NBTOOL_CONFIG_H) */ |
| 93 | |
| 94 | #ifdef _KERNEL |
| 95 | |
| 96 | #include <sys/cdefs.h> |
| 97 | |
| 98 | __BEGIN_DECLS |
| 99 | void dqinit(void); |
| 100 | void dqreinit(void); |
| 101 | void dqdone(void); |
| 102 | __END_DECLS |
| 103 | #endif /* _KERNEL */ |
| 104 | |
| 105 | #endif /* !_UFS_UFS_QUOTA_H_ */ |
| 106 | |