quotapvt.h revision 1.9 1 /* $NetBSD: quotapvt.h,v 1.9 2012/01/25 01:22:57 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 struct quotahandle {
32 char *qh_mountpoint;
33 char *qh_mountdevice;
34 int qh_isnfs;
35
36 /* these are used only by quota_oldfiles */
37 int qh_hasoldfiles;
38 int qh_userfile;
39 int qh_groupfile;
40
41 char spare[14*sizeof(char *) + 12 * sizeof(int)];
42 };
43
44 struct quotacursor {
45 struct quotahandle *qc_qh;
46 enum { QC_PROPLIB, QC_OLDFILES } qc_type;
47 union {
48 struct proplib_quotacursor *qc_proplib;
49 struct oldfiles_quotacursor *qc_oldfiles;
50 } u;
51 };
52
53
54 /* proplib kernel interface */
55 int __quota_proplib_getversion(struct quotahandle *qh, int8_t *version_ret);
56 const char *__quota_proplib_getimplname(struct quotahandle *);
57 unsigned __quota_proplib_getnumidtypes(void);
58 const char *__quota_proplib_idtype_getname(int idtype);
59 unsigned __quota_proplib_getnumobjtypes(void);
60 const char *__quota_proplib_objtype_getname(int objtype);
61 int __quota_proplib_objtype_isbytes(int objtype);
62 int __quota_proplib_get(struct quotahandle *qh, const struct quotakey *qk,
63 struct quotaval *qv);
64 int __quota_proplib_put(struct quotahandle *qh, const struct quotakey *qk,
65 const struct quotaval *qv);
66 int __quota_proplib_delete(struct quotahandle *qh, const struct quotakey *qk);
67 struct proplib_quotacursor *__quota_proplib_cursor_create(void);
68 void __quota_proplib_cursor_destroy(struct proplib_quotacursor *);
69 int __quota_proplib_cursor_skipidtype(struct proplib_quotacursor *,
70 unsigned idtype);
71 int __quota_proplib_cursor_get(struct quotahandle *,
72 struct proplib_quotacursor *,
73 struct quotakey *, struct quotaval *);
74 int __quota_proplib_cursor_getn(struct quotahandle *,
75 struct proplib_quotacursor *,
76 struct quotakey *, struct quotaval *,
77 unsigned);
78 int __quota_proplib_cursor_atend(struct quotahandle *,
79 struct proplib_quotacursor *);
80 int __quota_proplib_cursor_rewind(struct proplib_quotacursor *);
81
82
83 /* nfs rquotad interface */
84 int __quota_nfs_get(struct quotahandle *qh, const struct quotakey *qk,
85 struct quotaval *qv);
86
87
88 /* direct interface to old (quota1-type) files */
89 int __quota_oldfiles_initialize(struct quotahandle *qh);
90 const char *__quota_oldfiles_getimplname(struct quotahandle *);
91 int __quota_oldfiles_get(struct quotahandle *qh, const struct quotakey *qk,
92 struct quotaval *qv);
93 int __quota_oldfiles_put(struct quotahandle *qh, const struct quotakey *qk,
94 const struct quotaval *qv);
95 int __quota_oldfiles_delete(struct quotahandle *qh, const struct quotakey *qk);
96 struct oldfiles_quotacursor *
97 __quota_oldfiles_cursor_create(struct quotahandle *);
98 void __quota_oldfiles_cursor_destroy(struct oldfiles_quotacursor *);
99 int __quota_oldfiles_cursor_skipidtype(struct oldfiles_quotacursor *,
100 unsigned idtype);
101 int __quota_oldfiles_cursor_get(struct quotahandle *,
102 struct oldfiles_quotacursor *,
103 struct quotakey *, struct quotaval *);
104 int __quota_oldfiles_cursor_getn(struct quotahandle *,
105 struct oldfiles_quotacursor *,
106 struct quotakey *, struct quotaval *,
107 unsigned);
108 int __quota_oldfiles_cursor_atend(struct oldfiles_quotacursor *);
109 int __quota_oldfiles_cursor_rewind(struct oldfiles_quotacursor *);
110
111
112 /* compat for old library */
113 int __quota_getquota(const char *path, struct quotaval *qv, uid_t id,
114 const char *class);
115
116