xref: /netbsd/sys/sys/quotactl.h (revision 30cc8b98)
1 /*	$NetBSD: quotactl.h,v 1.38 2014/06/28 22:27:50 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 #ifndef _SYS_QUOTACTL_H_
32 #define _SYS_QUOTACTL_H_
33 
34 #include <sys/stdint.h>
35 
36 /*
37  * Note - this is an internal interface. Application code (and,
38  * really, anything that isn't libquota or inside the kernel) should
39  * use the <quota.h> API instead.
40  */
41 
42 /* Size of random quota strings */
43 #define QUOTA_NAMELEN   32
44 
45 /*
46  * Structure for QUOTACTL_STAT.
47  */
48 struct quotastat {
49 	char qs_implname[QUOTA_NAMELEN];
50 	int qs_numidtypes;
51 	int qs_numobjtypes;
52 	unsigned qs_restrictions;	/* semantic restriction codes */
53 };
54 
55 /*
56  * Structures for QUOTACTL_IDTYPESTAT and QUOTACTL_OBJTYPESTAT.
57  */
58 struct quotaidtypestat {
59 	char qis_name[QUOTA_NAMELEN];
60 };
61 struct quotaobjtypestat {
62 	char qos_name[QUOTA_NAMELEN];
63 	int qos_isbytes;
64 };
65 
66 /*
67  * Semi-opaque structure for cursors. This holds the cursor state in
68  * userland; the size is exposed only to libquota, not to client code,
69  * and is meant to be large enough to accommodate all likely future
70  * expansion without being unduly bloated, as it will need to be
71  * copied in and out for every call using it.
72  */
73 struct quotakcursor {
74 	union {
75 		char qkc_space[64];
76 		uintmax_t __qkc_forcealign;
77 	} u;
78 };
79 
80 /* Command codes. */
81 #define QUOTACTL_STAT		0
82 #define QUOTACTL_IDTYPESTAT	1
83 #define QUOTACTL_OBJTYPESTAT	2
84 #define QUOTACTL_GET		3
85 #define QUOTACTL_PUT		4
86 #define QUOTACTL_DEL		5
87 #define QUOTACTL_CURSOROPEN	6
88 #define QUOTACTL_CURSORCLOSE	7
89 #define QUOTACTL_CURSORSKIPIDTYPE 8
90 #define QUOTACTL_CURSORGET	9
91 #define QUOTACTL_CURSORATEND	10
92 #define QUOTACTL_CURSORREWIND	11
93 #define QUOTACTL_QUOTAON	12
94 #define QUOTACTL_QUOTAOFF	13
95 
96 /* Argument encoding. */
97 struct quotactl_args {
98 	unsigned qc_op;
99 	union {
100 		struct {
101 			struct quotastat *qc_info;
102 		} stat;
103 		struct {
104 			int qc_idtype;
105 			struct quotaidtypestat *qc_info;
106 		} idtypestat;
107 		struct {
108 			int qc_objtype;
109 			struct quotaobjtypestat *qc_info;
110 		} objtypestat;
111 		struct {
112 			const struct quotakey *qc_key;
113 			struct quotaval *qc_val;
114 		} get;
115 		struct {
116 			const struct quotakey *qc_key;
117 			const struct quotaval *qc_val;
118 		} put;
119 		struct {
120 			const struct quotakey *qc_key;
121 		} del;
122 		struct {
123 			struct quotakcursor *qc_cursor;
124 		} cursoropen;
125 		struct {
126 			struct quotakcursor *qc_cursor;
127 		} cursorclose;
128 		struct {
129 			struct quotakcursor *qc_cursor;
130 			int qc_idtype;
131 		} cursorskipidtype;
132 		struct {
133 			struct quotakcursor *qc_cursor;
134 			struct quotakey *qc_keys;
135 			struct quotaval *qc_vals;
136 			unsigned qc_maxnum;
137 			unsigned *qc_ret;
138 		} cursorget;
139 		struct {
140 			struct quotakcursor *qc_cursor;
141 			int *qc_ret; /* really boolean */
142 		} cursoratend;
143 		struct {
144 			struct quotakcursor *qc_cursor;
145 		} cursorrewind;
146 		struct {
147 			int qc_idtype;
148 			const char *qc_quotafile;
149 		} quotaon;
150 		struct {
151 			int qc_idtype;
152 		} quotaoff;
153 	} u;
154 };
155 
156 #if !defined(_KERNEL) && !defined(_STANDALONE)
157 __BEGIN_DECLS
158 int __quotactl(const char *, struct quotactl_args *);
159 __END_DECLS
160 #endif
161 
162 #endif /* _SYS_QUOTACTL_H_ */
163