ulfs_quotacommon.h revision 1.3
11.3Sdholland/*	$NetBSD: ulfs_quotacommon.h,v 1.3 2013/06/06 00:49:28 dholland Exp $	*/
21.1Sdholland/*  from NetBSD: quota.h,v 1.30 2012/08/26 02:32:14 dholland Exp  */
31.1Sdholland
41.1Sdholland/*
51.1Sdholland * Copyright (c) 1982, 1986, 1993
61.1Sdholland *	The Regents of the University of California.  All rights reserved.
71.1Sdholland *
81.1Sdholland * This code is derived from software contributed to Berkeley by
91.1Sdholland * Robert Elz at The University of Melbourne.
101.1Sdholland *
111.1Sdholland * Redistribution and use in source and binary forms, with or without
121.1Sdholland * modification, are permitted provided that the following conditions
131.1Sdholland * are met:
141.1Sdholland * 1. Redistributions of source code must retain the above copyright
151.1Sdholland *    notice, this list of conditions and the following disclaimer.
161.1Sdholland * 2. Redistributions in binary form must reproduce the above copyright
171.1Sdholland *    notice, this list of conditions and the following disclaimer in the
181.1Sdholland *    documentation and/or other materials provided with the distribution.
191.1Sdholland * 3. Neither the name of the University nor the names of its contributors
201.1Sdholland *    may be used to endorse or promote products derived from this software
211.1Sdholland *    without specific prior written permission.
221.1Sdholland *
231.1Sdholland * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.1Sdholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.1Sdholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.1Sdholland * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.1Sdholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.1Sdholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.1Sdholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Sdholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Sdholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Sdholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Sdholland * SUCH DAMAGE.
341.1Sdholland *
351.1Sdholland *	@(#)quota.h	8.3 (Berkeley) 8/19/94
361.1Sdholland */
371.1Sdholland
381.2Sdholland#ifndef	_UFS_LFS_ULFS_QUOTACOMMON_H_
391.2Sdholland#define	_UFS_LFS_ULFS_QUOTACOMMON_H_
401.1Sdholland
411.1Sdholland/*
421.1Sdholland * These definitions are common to the original disk quota implementation
431.1Sdholland * (quota1) and the newer implementation (quota2)
441.1Sdholland */
451.1Sdholland
461.1Sdholland/*
471.1Sdholland * The following constants define the usage of the quota file array in the
481.2Sdholland * ulfsmount structure and dquot array in the inode structure.  The semantics
491.3Sdholland * of the elements of these arrays are defined in the routine lfs_getinoquota;
501.1Sdholland * the remainder of the quota code treats them generically and need not be
511.1Sdholland * inspected when changing the size of the array.
521.1Sdholland */
531.2Sdholland#define	ULFS_MAXQUOTAS	2
541.2Sdholland#define	ULFS_USRQUOTA	0	/* element used for user quotas */
551.2Sdholland#define	ULFS_GRPQUOTA	1	/* element used for group quotas */
561.1Sdholland
571.1Sdholland/*
581.1Sdholland * Initializer for the strings corresponding to the quota ID types.
591.1Sdholland * (in quota1 these are also the default names of the quota files)
601.1Sdholland */
611.1Sdholland#define INITQFNAMES { \
621.2Sdholland	"user",		/* ULFS_USRQUOTA */ \
631.2Sdholland	"group",	/* ULFS_GRPQUOTA */ \
641.1Sdholland}
651.1Sdholland
661.1Sdholland#if !defined(HAVE_NBTOOL_CONFIG_H)
671.1Sdholland#include <sys/quota.h>
681.1Sdholland__inline static int __unused
691.2Sdhollandquota_idtype_to_ulfs(int idtype)
701.1Sdholland{
711.1Sdholland	switch (idtype) {
721.1Sdholland	case QUOTA_IDTYPE_USER:
731.2Sdholland		return ULFS_USRQUOTA;
741.1Sdholland	case QUOTA_IDTYPE_GROUP:
751.2Sdholland		return ULFS_GRPQUOTA;
761.1Sdholland	default:
771.1Sdholland		return -1;
781.1Sdholland	}
791.1Sdholland}
801.1Sdholland
811.1Sdhollandstatic __inline int __unused
821.2Sdhollandquota_idtype_from_ulfs(int ulfstype)
831.1Sdholland{
841.2Sdholland	switch (ulfstype) {
851.2Sdholland	case ULFS_USRQUOTA:
861.1Sdholland		return QUOTA_IDTYPE_USER;
871.2Sdholland	case ULFS_GRPQUOTA:
881.1Sdholland		return QUOTA_IDTYPE_GROUP;
891.1Sdholland	default:
901.1Sdholland		return -1;
911.1Sdholland	}
921.1Sdholland}
931.1Sdholland#endif /* !defined(HAVE_NBTOOL_CONFIG_H) */
941.1Sdholland
951.1Sdholland#ifdef _KERNEL
961.1Sdholland
971.1Sdholland#include <sys/cdefs.h>
981.1Sdholland
991.1Sdholland__BEGIN_DECLS
1001.3Sdhollandvoid	lfs_dqinit(void);
1011.3Sdhollandvoid	lfs_dqreinit(void);
1021.3Sdhollandvoid	lfs_dqdone(void);
1031.1Sdholland__END_DECLS
1041.1Sdholland#endif /* _KERNEL */
1051.1Sdholland
1061.2Sdholland#endif /* !_UFS_LFS_ULFS_QUOTACOMMON_H_ */
107