quotapvt.h revision 1.14.4.2 1 /* $NetBSD: quotapvt.h,v 1.14.4.2 2012/04/17 00:05:32 yamt 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
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
46 struct 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 */
57 const char *__quota_kernel_getimplname(struct quotahandle *);
58 unsigned __quota_kernel_getrestrictions(struct quotahandle *);
59 int __quota_kernel_getnumidtypes(struct quotahandle *);
60 const char *__quota_kernel_idtype_getname(struct quotahandle *, int idtype);
61 int __quota_kernel_getnumobjtypes(struct quotahandle *);
62 const char *__quota_kernel_objtype_getname(struct quotahandle *, int objtype);
63 int __quota_kernel_objtype_isbytes(struct quotahandle *, int objtype);
64 int __quota_kernel_quotaon(struct quotahandle *, int idtype);
65 int __quota_kernel_quotaoff(struct quotahandle *, int idtype);
66 int __quota_kernel_get(struct quotahandle *qh, const struct quotakey *qk,
67 struct quotaval *qv);
68 int __quota_kernel_put(struct quotahandle *qh, const struct quotakey *qk,
69 const struct quotaval *qv);
70 int __quota_kernel_delete(struct quotahandle *qh, const struct quotakey *qk);
71 struct kernel_quotacursor *__quota_kernel_cursor_create(struct quotahandle *);
72 void __quota_kernel_cursor_destroy(struct quotahandle *,
73 struct kernel_quotacursor *);
74 int __quota_kernel_cursor_skipidtype(struct quotahandle *,
75 struct kernel_quotacursor *,
76 int idtype);
77 int __quota_kernel_cursor_get(struct quotahandle *,
78 struct kernel_quotacursor *,
79 struct quotakey *, struct quotaval *);
80 int __quota_kernel_cursor_getn(struct quotahandle *,
81 struct kernel_quotacursor *,
82 struct quotakey *, struct quotaval *,
83 unsigned maxnum);
84 int __quota_kernel_cursor_atend(struct quotahandle *,
85 struct kernel_quotacursor *);
86 int __quota_kernel_cursor_rewind(struct quotahandle *,
87 struct kernel_quotacursor *);
88
89 /* nfs rquotad interface */
90 int __quota_nfs_get(struct quotahandle *qh, const struct quotakey *qk,
91 struct quotaval *qv);
92
93
94 /* direct interface to old (quota1-type) files */
95 void __quota_oldfiles_load_fstab(void);
96 int __quota_oldfiles_infstab(const char *);
97 int __quota_oldfiles_initialize(struct quotahandle *qh);
98 const char *__quota_oldfiles_getimplname(struct quotahandle *);
99 const char *__quota_oldfiles_getquotafile(struct quotahandle *, int idtype,
100 char *buf, size_t maxlen);
101 int __quota_oldfiles_quotaon(struct quotahandle *, int idtype);
102 int __quota_oldfiles_get(struct quotahandle *qh, const struct quotakey *qk,
103 struct quotaval *qv);
104 int __quota_oldfiles_put(struct quotahandle *qh, const struct quotakey *qk,
105 const struct quotaval *qv);
106 int __quota_oldfiles_delete(struct quotahandle *qh, const struct quotakey *qk);
107 struct oldfiles_quotacursor *
108 __quota_oldfiles_cursor_create(struct quotahandle *);
109 void __quota_oldfiles_cursor_destroy(struct oldfiles_quotacursor *);
110 int __quota_oldfiles_cursor_skipidtype(struct oldfiles_quotacursor *,
111 int idtype);
112 int __quota_oldfiles_cursor_get(struct quotahandle *,
113 struct oldfiles_quotacursor *,
114 struct quotakey *, struct quotaval *);
115 int __quota_oldfiles_cursor_getn(struct quotahandle *,
116 struct oldfiles_quotacursor *,
117 struct quotakey *, struct quotaval *,
118 unsigned);
119 int __quota_oldfiles_cursor_atend(struct oldfiles_quotacursor *);
120 int __quota_oldfiles_cursor_rewind(struct oldfiles_quotacursor *);
121
122
123 /* compat for old library */
124 int __quota_getquota(const char *path, struct quotaval *qv, uid_t id,
125 const char *class);
126
127