quota.h revision 1.1
11.1Sdholland/*-
21.1Sdholland * Copyright (c) 2011 The NetBSD Foundation, Inc.
31.1Sdholland * All rights reserved.
41.1Sdholland *
51.1Sdholland * This code is derived from software contributed to The NetBSD Foundation
61.1Sdholland * by David A. Holland.
71.1Sdholland *
81.1Sdholland * Redistribution and use in source and binary forms, with or without
91.1Sdholland * modification, are permitted provided that the following conditions
101.1Sdholland * are met:
111.1Sdholland * 1. Redistributions of source code must retain the above copyright
121.1Sdholland *    notice, this list of conditions and the following disclaimer.
131.1Sdholland * 2. Redistributions in binary form must reproduce the above copyright
141.1Sdholland *    notice, this list of conditions and the following disclaimer in the
151.1Sdholland *    documentation and/or other materials provided with the distribution.
161.1Sdholland *
171.1Sdholland * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
181.1Sdholland * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
191.1Sdholland * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
201.1Sdholland * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
211.1Sdholland * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
221.1Sdholland * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
231.1Sdholland * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
241.1Sdholland * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
251.1Sdholland * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
261.1Sdholland * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
271.1Sdholland * POSSIBILITY OF SUCH DAMAGE.
281.1Sdholland */
291.1Sdholland
301.1Sdholland#ifndef _QUOTA_H_
311.1Sdholland#define _QUOTA_H_
321.1Sdholland
331.1Sdholland#include <sys/types.h>
341.1Sdholland#include <sys/quota.h>
351.1Sdholland
361.1Sdhollandstruct quotahandle; /* Opaque. */
371.1Sdhollandstruct quotacursor; /* Opaque. */
381.1Sdholland
391.1Sdholland/* quota id types (entities being billed) */
401.1Sdholland#define QUOTA_IDTYPE_USER	0
411.1Sdholland#define QUOTA_IDTYPE_GROUP	1
421.1Sdholland
431.1Sdholland/* quota object types (things being limited) */
441.1Sdholland#define QUOTA_OBJTYPE_BLOCKS	0
451.1Sdholland#define QUOTA_OBJTYPE_FILES	1
461.1Sdholland
471.1Sdholland/* id value for "default" */
481.1Sdholland#define QUOTA_DEFAULTID		((id_t)-1)
491.1Sdholland
501.1Sdholland/* limit value for "no limit" */
511.1Sdholland#define QUOTA_NOLIMIT		((uint64_t)0xffffffffffffffffULL)
521.1Sdholland
531.1Sdholland/* time value for "no time" */
541.1Sdholland#define QUOTA_NOTIME		((time_t)-1)
551.1Sdholland
561.1Sdholland
571.1Sdhollandstruct quotakey {
581.1Sdholland	int qk_idtype;
591.1Sdholland	id_t qk_id;
601.1Sdholland	int qk_objtype;
611.1Sdholland};
621.1Sdholland
631.1Sdhollandvoid quotaval_clear(struct quotaval *);
641.1Sdholland
651.1Sdhollandstruct quotahandle *quota_open(const char *);
661.1Sdhollandvoid quota_close(struct quotahandle *);
671.1Sdholland
681.1Sdhollandconst char *quota_getmountpoint(struct quotahandle *);
691.1Sdhollandconst char *quota_getmountdevice(struct quotahandle *);
701.1Sdholland
711.1Sdhollandconst char *quota_getimplname(struct quotahandle *);
721.1Sdholland
731.1Sdhollandunsigned quota_getnumidtypes(struct quotahandle *);
741.1Sdhollandconst char *quota_idtype_getname(struct quotahandle *, int /*idtype*/);
751.1Sdholland
761.1Sdhollandunsigned quota_getnumobjtypes(struct quotahandle *);
771.1Sdhollandconst char *quota_objtype_getname(struct quotahandle *, int /*objtype*/);
781.1Sdhollandint quota_objtype_isbytes(struct quotahandle *, int /*objtype*/);
791.1Sdholland
801.1Sdhollandint quota_get(struct quotahandle *, const struct quotakey *,
811.1Sdholland	      struct quotaval *);
821.1Sdholland
831.1Sdhollandint quota_put(struct quotahandle *, const struct quotakey *,
841.1Sdholland	      const struct quotaval *);
851.1Sdholland
861.1Sdhollandint quota_delete(struct quotahandle *, const struct quotakey *);
871.1Sdholland
881.1Sdhollandstruct quotacursor *quota_opencursor(struct quotahandle *);
891.1Sdhollandvoid quotacursor_close(struct quotacursor *);
901.1Sdholland
911.1Sdhollandint quotacursor_skipidtype(struct quotacursor *, unsigned /*idtype*/);
921.1Sdholland
931.1Sdhollandint quotacursor_get(struct quotacursor *, struct quotakey *,
941.1Sdholland		    struct quotaval *);
951.1Sdholland
961.1Sdhollandint quotacursor_getn(struct quotacursor *, struct quotakey *,
971.1Sdholland		     struct quotaval *, unsigned /*maxnum*/);
981.1Sdholland
991.1Sdhollandint quotacursor_atend(struct quotacursor *);
1001.1Sdhollandint quotacursor_rewind(struct quotacursor *);
1011.1Sdholland
1021.1Sdholland#endif /* _QUOTA_H_ */
103