1*01e782f3Sdholland /* $NetBSD: quotactl.h,v 1.38 2014/06/28 22:27:50 dholland Exp $ */ 2c76cce74Sdholland /*- 3c76cce74Sdholland * Copyright (c) 2011 The NetBSD Foundation, Inc. 4c76cce74Sdholland * All rights reserved. 5c76cce74Sdholland * 6c76cce74Sdholland * This code is derived from software contributed to The NetBSD Foundation 7c76cce74Sdholland * by David A. Holland. 8c76cce74Sdholland * 9c76cce74Sdholland * Redistribution and use in source and binary forms, with or without 10c76cce74Sdholland * modification, are permitted provided that the following conditions 11c76cce74Sdholland * are met: 12c76cce74Sdholland * 1. Redistributions of source code must retain the above copyright 13c76cce74Sdholland * notice, this list of conditions and the following disclaimer. 14c76cce74Sdholland * 2. Redistributions in binary form must reproduce the above copyright 15c76cce74Sdholland * notice, this list of conditions and the following disclaimer in the 16c76cce74Sdholland * documentation and/or other materials provided with the distribution. 17c76cce74Sdholland * 18c76cce74Sdholland * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19c76cce74Sdholland * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20c76cce74Sdholland * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21c76cce74Sdholland * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22c76cce74Sdholland * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23c76cce74Sdholland * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24c76cce74Sdholland * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25c76cce74Sdholland * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26c76cce74Sdholland * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27c76cce74Sdholland * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28c76cce74Sdholland * POSSIBILITY OF SUCH DAMAGE. 29c76cce74Sdholland */ 30c76cce74Sdholland 31c76cce74Sdholland #ifndef _SYS_QUOTACTL_H_ 32c76cce74Sdholland #define _SYS_QUOTACTL_H_ 33c76cce74Sdholland 3459b296daSdholland #include <sys/stdint.h> 3559b296daSdholland 36c76cce74Sdholland /* 37c76cce74Sdholland * Note - this is an internal interface. Application code (and, 38c76cce74Sdholland * really, anything that isn't libquota or inside the kernel) should 39c76cce74Sdholland * use the <quota.h> API instead. 40c76cce74Sdholland */ 41c76cce74Sdholland 427f2ebd20Sdholland /* Size of random quota strings */ 437f2ebd20Sdholland #define QUOTA_NAMELEN 32 447f2ebd20Sdholland 457f2ebd20Sdholland /* 467f2ebd20Sdholland * Structure for QUOTACTL_STAT. 477f2ebd20Sdholland */ 487f2ebd20Sdholland struct quotastat { 497f2ebd20Sdholland char qs_implname[QUOTA_NAMELEN]; 50832d4ca7Sdholland int qs_numidtypes; 51832d4ca7Sdholland int qs_numobjtypes; 528dfe0a7bSdholland unsigned qs_restrictions; /* semantic restriction codes */ 537f2ebd20Sdholland }; 547f2ebd20Sdholland 5508387c5dSdholland /* 5629b925e0Sdholland * Structures for QUOTACTL_IDTYPESTAT and QUOTACTL_OBJTYPESTAT. 5729b925e0Sdholland */ 5829b925e0Sdholland struct quotaidtypestat { 5929b925e0Sdholland char qis_name[QUOTA_NAMELEN]; 6029b925e0Sdholland }; 6129b925e0Sdholland struct quotaobjtypestat { 6229b925e0Sdholland char qos_name[QUOTA_NAMELEN]; 6329b925e0Sdholland int qos_isbytes; 6429b925e0Sdholland }; 6529b925e0Sdholland 6629b925e0Sdholland /* 6708387c5dSdholland * Semi-opaque structure for cursors. This holds the cursor state in 6808387c5dSdholland * userland; the size is exposed only to libquota, not to client code, 69e3f283b6Smbalmer * and is meant to be large enough to accommodate all likely future 7008387c5dSdholland * expansion without being unduly bloated, as it will need to be 7108387c5dSdholland * copied in and out for every call using it. 7208387c5dSdholland */ 7308387c5dSdholland struct quotakcursor { 7408387c5dSdholland union { 7508387c5dSdholland char qkc_space[64]; 7608387c5dSdholland uintmax_t __qkc_forcealign; 7708387c5dSdholland } u; 7808387c5dSdholland }; 7908387c5dSdholland 80bfbd24c6Sdholland /* Command codes. */ 817f2ebd20Sdholland #define QUOTACTL_STAT 0 8229b925e0Sdholland #define QUOTACTL_IDTYPESTAT 1 8329b925e0Sdholland #define QUOTACTL_OBJTYPESTAT 2 8429b925e0Sdholland #define QUOTACTL_GET 3 8529b925e0Sdholland #define QUOTACTL_PUT 4 86*01e782f3Sdholland #define QUOTACTL_DEL 5 8729b925e0Sdholland #define QUOTACTL_CURSOROPEN 6 8829b925e0Sdholland #define QUOTACTL_CURSORCLOSE 7 8929b925e0Sdholland #define QUOTACTL_CURSORSKIPIDTYPE 8 9029b925e0Sdholland #define QUOTACTL_CURSORGET 9 9129b925e0Sdholland #define QUOTACTL_CURSORATEND 10 9229b925e0Sdholland #define QUOTACTL_CURSORREWIND 11 9329b925e0Sdholland #define QUOTACTL_QUOTAON 12 9429b925e0Sdholland #define QUOTACTL_QUOTAOFF 13 95c76cce74Sdholland 9677f413b0Sdholland /* Argument encoding. */ 9759b296daSdholland struct quotactl_args { 982246330bSdholland unsigned qc_op; 9977f413b0Sdholland union { 10077f413b0Sdholland struct { 101d2d6fa0aSdholland struct quotastat *qc_info; 1027f2ebd20Sdholland } stat; 1032ce5210dSdholland struct { 10429b925e0Sdholland int qc_idtype; 10529b925e0Sdholland struct quotaidtypestat *qc_info; 10629b925e0Sdholland } idtypestat; 10729b925e0Sdholland struct { 10829b925e0Sdholland int qc_objtype; 10929b925e0Sdholland struct quotaobjtypestat *qc_info; 11029b925e0Sdholland } objtypestat; 11129b925e0Sdholland struct { 112ea83d914Sdholland const struct quotakey *qc_key; 113d2d6fa0aSdholland struct quotaval *qc_val; 1142ce5210dSdholland } get; 1156bee945aSdholland struct { 1163ba1349dSdholland const struct quotakey *qc_key; 117cacecc23Sdholland const struct quotaval *qc_val; 118de768ec2Sdholland } put; 1199ab480f5Sdholland struct { 12012763e32Sdholland const struct quotakey *qc_key; 121*01e782f3Sdholland } del; 12208387c5dSdholland struct { 12308387c5dSdholland struct quotakcursor *qc_cursor; 12408387c5dSdholland } cursoropen; 12508387c5dSdholland struct { 12608387c5dSdholland struct quotakcursor *qc_cursor; 12708387c5dSdholland } cursorclose; 128081da308Sdholland struct { 129081da308Sdholland struct quotakcursor *qc_cursor; 130832d4ca7Sdholland int qc_idtype; 131a6c55fc2Sdholland } cursorskipidtype; 132a6c55fc2Sdholland struct { 133a6c55fc2Sdholland struct quotakcursor *qc_cursor; 134de22be5eSdholland struct quotakey *qc_keys; 135de22be5eSdholland struct quotaval *qc_vals; 136de22be5eSdholland unsigned qc_maxnum; 137de22be5eSdholland unsigned *qc_ret; 138a6c55fc2Sdholland } cursorget; 139a6c55fc2Sdholland struct { 140a6c55fc2Sdholland struct quotakcursor *qc_cursor; 141a6c55fc2Sdholland int *qc_ret; /* really boolean */ 142a6c55fc2Sdholland } cursoratend; 143a6c55fc2Sdholland struct { 144a6c55fc2Sdholland struct quotakcursor *qc_cursor; 145a6c55fc2Sdholland } cursorrewind; 1467302da53Sdholland struct { 1477302da53Sdholland int qc_idtype; 1487302da53Sdholland const char *qc_quotafile; 1497302da53Sdholland } quotaon; 1508e8ca4e5Sdholland struct { 1518e8ca4e5Sdholland int qc_idtype; 1528e8ca4e5Sdholland } quotaoff; 15377f413b0Sdholland } u; 15477f413b0Sdholland }; 15577f413b0Sdholland 15659b296daSdholland #if !defined(_KERNEL) && !defined(_STANDALONE) 15759b296daSdholland __BEGIN_DECLS 15859b296daSdholland int __quotactl(const char *, struct quotactl_args *); 15959b296daSdholland __END_DECLS 16059b296daSdholland #endif 16159b296daSdholland 162c76cce74Sdholland #endif /* _SYS_QUOTACTL_H_ */ 163