1/* $NetBSD: quotapvt.h,v 1.13 2012/02/01 05:34:41 dholland Exp $ */ 2/*- 3 * Copyright (c) 2011 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#define QUOTA_MODE_NFS 1 32#define QUOTA_MODE_OLDFILES 2 33#define QUOTA_MODE_KERNEL 3 34 35struct quotahandle { 36 char *qh_mountpoint; 37 char *qh_mountdevice; 38 int qh_mode; 39 40 /* these are used only by quota_oldfiles */ 41 int qh_oldfilesopen; 42 int qh_userfile; 43 int qh_groupfile; 44}; 45 46struct quotacursor { 47 struct quotahandle *qc_qh; 48 enum { QC_OLDFILES, QC_KERNEL } qc_type; 49 union { 50 struct oldfiles_quotacursor *qc_oldfiles; 51 struct kernel_quotacursor *qc_kernel; 52 } u; 53}; 54 55 56/* new non-proplib kernel interface */ 57const char *__quota_kernel_getimplname(struct quotahandle *); 58unsigned __quota_kernel_getrestrictions(struct quotahandle *); 59int __quota_kernel_getnumidtypes(struct quotahandle *); 60const char *__quota_kernel_idtype_getname(struct quotahandle *, int idtype); 61int __quota_kernel_getnumobjtypes(struct quotahandle *); 62const char *__quota_kernel_objtype_getname(struct quotahandle *, int objtype); 63int __quota_kernel_objtype_isbytes(struct quotahandle *, int objtype); 64int __quota_kernel_quotaon(struct quotahandle *, int idtype); 65int __quota_kernel_quotaoff(struct quotahandle *, int idtype); 66int __quota_kernel_get(struct quotahandle *qh, const struct quotakey *qk, 67 struct quotaval *qv); 68int __quota_kernel_put(struct quotahandle *qh, const struct quotakey *qk, 69 const struct quotaval *qv); 70int __quota_kernel_delete(struct quotahandle *qh, const struct quotakey *qk); 71struct kernel_quotacursor *__quota_kernel_cursor_create(struct quotahandle *); 72void __quota_kernel_cursor_destroy(struct quotahandle *, 73 struct kernel_quotacursor *); 74int __quota_kernel_cursor_skipidtype(struct quotahandle *, 75 struct kernel_quotacursor *, 76 int idtype); 77int __quota_kernel_cursor_get(struct quotahandle *, 78 struct kernel_quotacursor *, 79 struct quotakey *, struct quotaval *); 80int __quota_kernel_cursor_getn(struct quotahandle *, 81 struct kernel_quotacursor *, 82 struct quotakey *, struct quotaval *, 83 unsigned maxnum); 84int __quota_kernel_cursor_atend(struct quotahandle *, 85 struct kernel_quotacursor *); 86int __quota_kernel_cursor_rewind(struct quotahandle *, 87 struct kernel_quotacursor *); 88 89/* nfs rquotad interface */ 90int __quota_nfs_get(struct quotahandle *qh, const struct quotakey *qk, 91 struct quotaval *qv); 92 93 94/* direct interface to old (quota1-type) files */ 95void __quota_oldfiles_load_fstab(void); 96int __quota_oldfiles_infstab(const char *); 97int __quota_oldfiles_initialize(struct quotahandle *qh); 98const char *__quota_oldfiles_getimplname(struct quotahandle *); 99const char *__quota_oldfiles_getquotafile(struct quotahandle *, int idtype, 100 char *buf, size_t maxlen); 101int __quota_oldfiles_quotaon(struct quotahandle *, int idtype); 102int __quota_oldfiles_get(struct quotahandle *qh, const struct quotakey *qk, 103 struct quotaval *qv); 104int __quota_oldfiles_put(struct quotahandle *qh, const struct quotakey *qk, 105 const struct quotaval *qv); 106int __quota_oldfiles_delete(struct quotahandle *qh, const struct quotakey *qk); 107struct oldfiles_quotacursor * 108 __quota_oldfiles_cursor_create(struct quotahandle *); 109void __quota_oldfiles_cursor_destroy(struct oldfiles_quotacursor *); 110int __quota_oldfiles_cursor_skipidtype(struct oldfiles_quotacursor *, 111 int idtype); 112int __quota_oldfiles_cursor_get(struct quotahandle *, 113 struct oldfiles_quotacursor *, 114 struct quotakey *, struct quotaval *); 115int __quota_oldfiles_cursor_getn(struct quotahandle *, 116 struct oldfiles_quotacursor *, 117 struct quotakey *, struct quotaval *, 118 unsigned); 119int __quota_oldfiles_cursor_atend(struct oldfiles_quotacursor *); 120int __quota_oldfiles_cursor_rewind(struct oldfiles_quotacursor *); 121 122 123/* compat for old library */ 124int __quota_getquota(const char *path, struct quotaval *qv, uid_t id, 125 const char *class); 126 127