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