xref: /netbsd/lib/libquota/quotapvt.h (revision 2f739562)
1*2f739562Sdholland /*	$NetBSD: quotapvt.h,v 1.14 2012/02/01 05:46:46 dholland Exp $	*/
25a065375Sdholland /*-
35a065375Sdholland  * Copyright (c) 2011 The NetBSD Foundation, Inc.
45a065375Sdholland  * All rights reserved.
55a065375Sdholland  *
65a065375Sdholland  * This code is derived from software contributed to The NetBSD Foundation
75a065375Sdholland  * by David A. Holland.
85a065375Sdholland  *
95a065375Sdholland  * Redistribution and use in source and binary forms, with or without
105a065375Sdholland  * modification, are permitted provided that the following conditions
115a065375Sdholland  * are met:
125a065375Sdholland  * 1. Redistributions of source code must retain the above copyright
135a065375Sdholland  *    notice, this list of conditions and the following disclaimer.
145a065375Sdholland  * 2. Redistributions in binary form must reproduce the above copyright
155a065375Sdholland  *    notice, this list of conditions and the following disclaimer in the
165a065375Sdholland  *    documentation and/or other materials provided with the distribution.
175a065375Sdholland  *
185a065375Sdholland  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
195a065375Sdholland  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
205a065375Sdholland  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
215a065375Sdholland  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
225a065375Sdholland  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
235a065375Sdholland  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
245a065375Sdholland  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
255a065375Sdholland  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
265a065375Sdholland  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
275a065375Sdholland  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
285a065375Sdholland  * POSSIBILITY OF SUCH DAMAGE.
295a065375Sdholland  */
305a065375Sdholland 
31dfd45e1cSdholland #define QUOTA_MODE_NFS		1
32abf0121aSdholland #define QUOTA_MODE_OLDFILES	2
33abf0121aSdholland #define QUOTA_MODE_KERNEL	3
34dfd45e1cSdholland 
355a065375Sdholland struct quotahandle {
365a065375Sdholland 	char *qh_mountpoint;
3701237e81Sdholland 	char *qh_mountdevice;
38dfd45e1cSdholland 	int qh_mode;
392b7e44b3Sdholland 
402b7e44b3Sdholland 	/* these are used only by quota_oldfiles */
41dfd45e1cSdholland 	int qh_oldfilesopen;
422b7e44b3Sdholland 	int qh_userfile;
432b7e44b3Sdholland 	int qh_groupfile;
445a065375Sdholland };
455a065375Sdholland 
460599112cSdholland struct quotacursor {
470599112cSdholland 	struct quotahandle *qc_qh;
48abf0121aSdholland 	enum { QC_OLDFILES, QC_KERNEL } qc_type;
490599112cSdholland 	union {
502b7e44b3Sdholland 		struct oldfiles_quotacursor *qc_oldfiles;
51abf0121aSdholland 		struct kernel_quotacursor *qc_kernel;
520599112cSdholland 	} u;
530599112cSdholland };
540599112cSdholland 
550599112cSdholland 
56abf0121aSdholland /* new non-proplib kernel interface */
57abf0121aSdholland const char *__quota_kernel_getimplname(struct quotahandle *);
58abf0121aSdholland unsigned __quota_kernel_getrestrictions(struct quotahandle *);
59*2f739562Sdholland int __quota_kernel_getnumidtypes(struct quotahandle *);
60abf0121aSdholland const char *__quota_kernel_idtype_getname(struct quotahandle *, int idtype);
61*2f739562Sdholland int __quota_kernel_getnumobjtypes(struct quotahandle *);
62abf0121aSdholland const char *__quota_kernel_objtype_getname(struct quotahandle *, int objtype);
63abf0121aSdholland int __quota_kernel_objtype_isbytes(struct quotahandle *, int objtype);
64abf0121aSdholland int __quota_kernel_quotaon(struct quotahandle *, int idtype);
65abf0121aSdholland int __quota_kernel_quotaoff(struct quotahandle *, int idtype);
66abf0121aSdholland int __quota_kernel_get(struct quotahandle *qh, const struct quotakey *qk,
675a065375Sdholland 			struct quotaval *qv);
68abf0121aSdholland int __quota_kernel_put(struct quotahandle *qh, const struct quotakey *qk,
69f38061f1Sdholland 			const struct quotaval *qv);
70abf0121aSdholland int __quota_kernel_delete(struct quotahandle *qh, const struct quotakey *qk);
71abf0121aSdholland struct kernel_quotacursor *__quota_kernel_cursor_create(struct quotahandle *);
72abf0121aSdholland void __quota_kernel_cursor_destroy(struct quotahandle *,
73abf0121aSdholland 				   struct kernel_quotacursor *);
74abf0121aSdholland int __quota_kernel_cursor_skipidtype(struct quotahandle *,
75abf0121aSdholland 				     struct kernel_quotacursor *,
76*2f739562Sdholland 				     int idtype);
77abf0121aSdholland int __quota_kernel_cursor_get(struct quotahandle *,
78abf0121aSdholland 			      struct kernel_quotacursor *,
790599112cSdholland 			      struct quotakey *, struct quotaval *);
80abf0121aSdholland int __quota_kernel_cursor_getn(struct quotahandle *,
81abf0121aSdholland 				struct kernel_quotacursor *,
820599112cSdholland 				struct quotakey *, struct quotaval *,
83*2f739562Sdholland 				unsigned maxnum);
84abf0121aSdholland int __quota_kernel_cursor_atend(struct quotahandle *,
85abf0121aSdholland 				struct kernel_quotacursor *);
86abf0121aSdholland int __quota_kernel_cursor_rewind(struct quotahandle *,
87abf0121aSdholland 				 struct kernel_quotacursor *);
8801237e81Sdholland 
8901237e81Sdholland /* nfs rquotad interface */
9001237e81Sdholland int __quota_nfs_get(struct quotahandle *qh, const struct quotakey *qk,
9101237e81Sdholland 		    struct quotaval *qv);
9201237e81Sdholland 
930599112cSdholland 
942b7e44b3Sdholland /* direct interface to old (quota1-type) files */
95dfd45e1cSdholland void __quota_oldfiles_load_fstab(void);
96dfd45e1cSdholland int __quota_oldfiles_infstab(const char *);
972b7e44b3Sdholland int __quota_oldfiles_initialize(struct quotahandle *qh);
982b7e44b3Sdholland const char *__quota_oldfiles_getimplname(struct quotahandle *);
9940d87db9Sdholland const char *__quota_oldfiles_getquotafile(struct quotahandle *, int idtype,
10040d87db9Sdholland 					  char *buf, size_t maxlen);
10140d87db9Sdholland int __quota_oldfiles_quotaon(struct quotahandle *, int idtype);
1022b7e44b3Sdholland int __quota_oldfiles_get(struct quotahandle *qh, const struct quotakey *qk,
1032b7e44b3Sdholland 			struct quotaval *qv);
1048bd46637Sdholland int __quota_oldfiles_put(struct quotahandle *qh, const struct quotakey *qk,
1058bd46637Sdholland 			const struct quotaval *qv);
1068bd46637Sdholland int __quota_oldfiles_delete(struct quotahandle *qh, const struct quotakey *qk);
1072b7e44b3Sdholland struct oldfiles_quotacursor *
1082b7e44b3Sdholland 	__quota_oldfiles_cursor_create(struct quotahandle *);
1092b7e44b3Sdholland void __quota_oldfiles_cursor_destroy(struct oldfiles_quotacursor *);
1102b7e44b3Sdholland int __quota_oldfiles_cursor_skipidtype(struct oldfiles_quotacursor *,
111*2f739562Sdholland 				      int idtype);
1122b7e44b3Sdholland int __quota_oldfiles_cursor_get(struct quotahandle *,
1132b7e44b3Sdholland 			       struct oldfiles_quotacursor *,
1142b7e44b3Sdholland 			       struct quotakey *, struct quotaval *);
1152b7e44b3Sdholland int __quota_oldfiles_cursor_getn(struct quotahandle *,
1162b7e44b3Sdholland 				struct oldfiles_quotacursor *,
1172b7e44b3Sdholland 				struct quotakey *, struct quotaval *,
1182b7e44b3Sdholland 				unsigned);
1192b7e44b3Sdholland int __quota_oldfiles_cursor_atend(struct oldfiles_quotacursor *);
1202b7e44b3Sdholland int __quota_oldfiles_cursor_rewind(struct oldfiles_quotacursor *);
1212b7e44b3Sdholland 
1222b7e44b3Sdholland 
1235082b605Sdholland /* compat for old library */
1245082b605Sdholland int __quota_getquota(const char *path, struct quotaval *qv, uid_t id,
1255082b605Sdholland 		     const char *class);
1265082b605Sdholland 
127