Migrate one last leftover bit (used only by the kernel now) to

sys/ufs/ufs and remove the old quota headers and no-longer-used shared
code. Ok by releng.
This commit is contained in:
dholland 2012-02-05 14:19:02 +00:00
parent 430a952206
commit 7609b9bc56
13 changed files with 49 additions and 431 deletions

View File

@ -1,6 +0,0 @@
# $NetBSD: Makefile,v 1.1 2011/03/24 17:05:39 bouyer Exp $
INCS= quotaprop.h quota.h
INCSDIR= /usr/include/quota
.include <bsd.prog.mk>

View File

@ -1,51 +0,0 @@
/* $NetBSD: quota.h,v 1.5 2012/02/01 17:52:07 dholland Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _QUOTA_QUOTA_H_
#define _QUOTA_QUOTA_H_
#include <sys/types.h>
#include <sys/quota.h>
/*
* Return codes for quota_check_limit()
*/
#define QL_S_ALLOW_OK 0x00 /* below soft limit */
#define QL_S_ALLOW_SOFT 0x01 /* over soft limit */
#define QL_S_DENY_GRACE 0x02 /* over soft limit, grace time expired */
#define QL_S_DENY_HARD 0x03 /* over hard limit */
#define QL_F_CROSS 0x80 /* crossing soft limit */
#define QL_STATUS(x) ((x) & 0x0f)
#define QL_FLAGS(x) ((x) & 0xf0)
/* check a quota usage against limits (assumes UFS semantic) */
int quota_check_limit(uint64_t, uint64_t, uint64_t, uint64_t, time_t, time_t);
#endif /* _QUOTA_QUOTA_H_ */

View File

@ -1,87 +0,0 @@
/* $NetBSD: quotaprop.h,v 1.4 2012/02/01 05:34:38 dholland Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _QUOTA_QUOTAPROP_H_
#define _QUOTA_QUOTAPROP_H_
#include <prop/proplib.h>
/* strings used in dictionary for the different quota class */
#define QUOTADICT_CLASS_USER "user"
#define QUOTADICT_CLASS_GROUP "group"
/* strings used in dictionary for the different limit types */
#define QUOTADICT_LTYPE_BLOCK "block"
#define QUOTADICT_LTYPE_FILE "file"
/* strings used in dictionary for the different limit and usage values */
#define QUOTADICT_LIMIT_SOFT "soft"
#define QUOTADICT_LIMIT_HARD "hard"
#define QUOTADICT_LIMIT_GTIME "grace time"
#define QUOTADICT_LIMIT_USAGE "usage"
#define QUOTADICT_LIMIT_ETIME "expire time"
/* array of strings for the above */
#define UFS_QUOTA_ENTRY_NAMES \
{QUOTADICT_LIMIT_HARD, \
QUOTADICT_LIMIT_SOFT, \
QUOTADICT_LIMIT_USAGE, \
QUOTADICT_LIMIT_ETIME, \
QUOTADICT_LIMIT_GTIME \
}
#define UFS_QUOTA_NENTRIES 5
extern const char *ufs_quota_entry_names[];
/* array of strings for limit types and associated #define */
extern const char *ufs_quota_limit_names[];
#define QUOTA_LIMIT_BLOCK 0
#define QUOTA_LIMIT_FILE 1
#define QUOTA_NLIMITS 2
#define QUOTA_LIMIT_NAMES { QUOTADICT_LTYPE_BLOCK, QUOTADICT_LTYPE_FILE }
/* array of strings for quota class and associated #define */
extern const char *ufs_quota_class_names[];
#define QUOTA_CLASS_USER 0
#define QUOTA_CLASS_GROUP 1
#define QUOTA_NCLASS 2
#define QUOTA_CLASS_NAMES { QUOTADICT_CLASS_USER, QUOTADICT_CLASS_GROUP }
int quotaprop_dict_get_uint64(prop_dictionary_t, uint64_t[],
const char *[], int, bool);
int proptoquota64(prop_dictionary_t, uint64_t *[], const char *[], int,
const char *[], int);
int quota_get_cmds(prop_dictionary_t, prop_array_t *);
prop_dictionary_t quota_prop_create(void);
bool quota_prop_add_command(prop_array_t, const char *, const char *,
prop_array_t);
prop_dictionary_t limits64toprop(uint64_t[], const char *[], int);
prop_dictionary_t quota64toprop(uid_t, int, uint64_t *[], const char *[], int,
const char *[], int);
#endif /* _QUOTA_QUOTAPROP_H_ */

View File

@ -1,4 +0,0 @@
# $NetBSD: Makefile.inc,v 1.1 2011/03/24 17:05:39 bouyer Exp $
.PATH.c: ${.PARSEDIR}
SRCS+= quotaprop.c quotasubr.c

View File

@ -1,214 +0,0 @@
/* $NetBSD: quotaprop.c,v 1.2 2011/06/07 14:56:12 bouyer Exp $ */
/*-
* Copyright (c) 2011 Manuel Bouyer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/time.h>
#include <sys/inttypes.h>
#include <sys/errno.h>
#include <quota/quotaprop.h>
/*
* update values from value[] using dict entries whose key is stored
* in name[]. Unknown keys are ignored. If update is false,
* a key in name[] but not in dict is an error.
* name[] may have NULL pointers to skip a value[]
*/
int
quotaprop_dict_get_uint64(prop_dictionary_t dict, uint64_t value[],
const char *name[], int nvalues, bool update)
{
int i;
uint64_t v;
for (i = 0; i < nvalues; i++) {
if (name[i] == NULL)
continue;
if (!prop_dictionary_get_uint64(dict, name[i], &v)) {
if (!update)
return EINVAL;
}
value[i] = v;
}
return 0;
}
/*
* convert a quota entry dictionary to in-memory array of uint64_t's
*/
int
proptoquota64(prop_dictionary_t data, uint64_t *values[], const char *valname[],
int nvalues, const char *limname[], int nlimits)
{
int i, error;
prop_dictionary_t val;
for (i = 0; i < nlimits; i++) {
if (limname[i] == NULL)
continue;
if (!prop_dictionary_get_dict(data, limname[i], &val))
return EINVAL;
error = quotaprop_dict_get_uint64(val, values[i],
valname, nvalues, false);
if (error)
return error;
}
return 0;
}
int
quota_get_cmds(prop_dictionary_t qdict, prop_array_t *cmds)
{
prop_number_t pn;
prop_object_t o;
pn = prop_dictionary_get(qdict, "interface version");
if (pn == NULL)
return EINVAL;
if (prop_number_integer_value(pn) != 1)
return EINVAL;
o = prop_dictionary_get(qdict, "commands");
if (o == NULL)
return ENOMEM;
if(prop_object_type(o) != PROP_TYPE_ARRAY)
return EINVAL;
*cmds = o;
return 0;
}
prop_dictionary_t
quota_prop_create(void)
{
prop_dictionary_t dict = prop_dictionary_create();
if (dict == NULL)
return NULL;
if (!prop_dictionary_set_uint8(dict, "interface version", 1)) {
goto err;
}
return dict;
err:
prop_object_release(dict);
return NULL;
}
bool
quota_prop_add_command(prop_array_t arrcmd, const char *cmd, const char *type,
prop_array_t data)
{
prop_dictionary_t dict;
dict = prop_dictionary_create();
if (dict == NULL) {
return false;
}
if (!prop_dictionary_set_cstring(dict, "type", type)) {
goto err;
}
if (!prop_dictionary_set_cstring(dict, "command", cmd)) {
goto err;
}
if (!prop_dictionary_set_and_rel(dict, "data", data)) {
goto err;
}
if (!prop_array_add(arrcmd, dict)) {
goto err;
}
prop_object_release(dict);
return true;
err:
prop_object_release(dict);
return false;
}
/* construct a dictionary using array of values and corresponding keys */
prop_dictionary_t
limits64toprop(uint64_t value[], const char *name[], int nvalues)
{
int i;
prop_dictionary_t dict1 = prop_dictionary_create();
if (dict1 == NULL)
return NULL;
for (i = 0; i < nvalues; i++) {
if (name[i] == NULL)
continue;
if (!prop_dictionary_set_uint64(dict1, name[i], value[i])) {
prop_object_release(dict1);
return NULL;
}
}
return dict1;
}
/*
* construct a quota entry using provided array of values, array of values
* names
*/
prop_dictionary_t
quota64toprop(uid_t uid, int def, uint64_t *values[], const char *valname[],
int nvalues, const char *limname[], int nlimits)
{
prop_dictionary_t dict1 = prop_dictionary_create();
prop_dictionary_t dict2;
int i;
if (dict1 == NULL)
return NULL;
if (def) {
if (!prop_dictionary_set_cstring_nocopy(dict1, "id",
"default")) {
goto err;
}
} else {
if (!prop_dictionary_set_uint32(dict1, "id", uid)) {
goto err;
}
}
for (i = 0; i < nlimits; i++) {
if (limname[i] == NULL)
continue;
dict2 = limits64toprop(values[i], valname, nvalues);
if (dict2 == NULL)
goto err;
if (!prop_dictionary_set_and_rel(dict1, limname[i],
dict2))
goto err;
}
return dict1;
err:
prop_object_release(dict1);
return NULL;
}
const char *ufs_quota_entry_names[] = UFS_QUOTA_ENTRY_NAMES;
const char *ufs_quota_limit_names[] = QUOTA_LIMIT_NAMES;
const char *ufs_quota_class_names[] = QUOTA_CLASS_NAMES;

View File

@ -1,52 +0,0 @@
/* $NetBSD: quotasubr.c,v 1.2 2011/06/07 14:56:12 bouyer Exp $ */
/*-
* Copyright (c) 2011 Manuel Bouyer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/time.h>
#include <sys/inttypes.h>
#include <sys/errno.h>
#include <quota/quota.h>
int
quota_check_limit(uint64_t cur, uint64_t change, uint64_t soft, uint64_t hard,
time_t expire, time_t now)
{
if (cur + change > hard) {
if (cur <= soft)
return (QL_F_CROSS | QL_S_DENY_HARD);
return QL_S_DENY_HARD;
} else if (cur + change > soft) {
if (cur <= soft)
return (QL_F_CROSS | QL_S_ALLOW_SOFT);
if (now > expire) {
return QL_S_DENY_GRACE;
}
return QL_S_ALLOW_SOFT;
}
return QL_S_ALLOW_OK;
}

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.979 2012/02/03 22:18:04 joerg Exp $
# $NetBSD: mi,v 1.980 2012/02/05 14:19:04 dholland Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@ -889,7 +889,7 @@
./usr/include/ppath base-c-usr
./usr/include/prop base-c-usr
./usr/include/protocols base-c-usr
./usr/include/quota base-c-usr
./usr/include/quota base-obsolete obsolete
./usr/include/readline base-c-usr
./usr/include/rpc base-c-usr
./usr/include/rpcsvc base-c-usr

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1729 2012/02/01 05:34:38 dholland Exp $
# $NetBSD: mi,v 1.1730 2012/02/05 14:19:05 dholland Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -2215,8 +2215,8 @@
./usr/include/puffsdump.h comp-puffs-include
./usr/include/pwd.h comp-c-include
./usr/include/quota.h comp-c-include
./usr/include/quota/quota.h comp-c-include
./usr/include/quota/quotaprop.h comp-c-include
./usr/include/quota/quota.h comp-obsolete obsolete
./usr/include/quota/quotaprop.h comp-obsolete obsolete
./usr/include/radlib.h comp-c-include
./usr/include/radlib_vs.h comp-c-include
./usr/include/randomid.h comp-c-include

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.137 2012/01/09 15:19:45 dholland Exp $
# $NetBSD: Makefile,v 1.138 2012/02/05 14:19:02 dholland Exp $
# @(#)Makefile 8.2 (Berkeley) 1/4/94
# Doing a make includes builds /usr/include
@ -45,7 +45,6 @@ INCSDIR= /usr/include
SUBDIR= rpc
SUBDIR+= ../common/include/prop
SUBDIR+= ../common/include/ppath
SUBDIR+= ../common/include/quota
.include <bsd.prog.mk>
.include <bsd.subdir.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.libkern,v 1.16 2012/01/20 00:25:29 joerg Exp $
# $NetBSD: Makefile.libkern,v 1.17 2012/02/05 14:19:03 dholland Exp $
#
# Variable definitions for libkern.
@ -33,7 +33,6 @@ CPPFLAGS+= -I$M ${KERNCPPFLAGS} ${KERNMISCCPPFLAGS}
.include "${.PARSEDIR}/../../../common/lib/libutil/Makefile.inc"
.include "${.PARSEDIR}/../../../common/lib/libprop/Makefile.inc"
.include "${.PARSEDIR}/../../../common/lib/libppath/Makefile.inc"
.include "${.PARSEDIR}/../../../common/lib/libquota/Makefile.inc"
CPPFLAGS+= -I${KERNDIR}/../../../common/include

View File

@ -1,4 +1,4 @@
/* $NetBSD: quota2.h,v 1.8 2012/01/29 07:20:27 dholland Exp $ */
/* $NetBSD: quota2.h,v 1.9 2012/02/05 14:19:04 dholland Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@ -107,4 +107,21 @@ void quota2_create_blk0(uint64_t, void *bp, int, int, int);
void quota2_ufs_rwq2v(const struct quota2_val *, struct quota2_val *, int);
void quota2_ufs_rwq2e(const struct quota2_entry *, struct quota2_entry *, int);
/*
* Return codes for quota_check_limit()
*/
#define QL_S_ALLOW_OK 0x00 /* below soft limit */
#define QL_S_ALLOW_SOFT 0x01 /* over soft limit */
#define QL_S_DENY_GRACE 0x02 /* over soft limit, grace time expired */
#define QL_S_DENY_HARD 0x03 /* over hard limit */
#define QL_F_CROSS 0x80 /* crossing soft limit */
#define QL_STATUS(x) ((x) & 0x0f)
#define QL_FLAGS(x) ((x) & 0xf0)
/* check a quota usage against limits (assumes UFS semantic) */
int quota_check_limit(uint64_t, uint64_t, uint64_t, uint64_t, time_t, time_t);
#endif /* _UFS_UFS_QUOTA2_H_ */

View File

@ -1,6 +1,6 @@
/* $NetBSD: quota2_subr.c,v 1.4 2011/06/07 14:56:13 bouyer Exp $ */
/* $NetBSD: quota2_subr.c,v 1.5 2012/02/05 14:19:04 dholland Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* Copyright (c) 2010, 2011 Manuel Bouyer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.4 2011/06/07 14:56:13 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.5 2012/02/05 14:19:04 dholland Exp $");
#include <sys/param.h>
#include <sys/time.h>
@ -106,3 +106,22 @@ int needswap)
needswap);
d->q2e_uid = ufs_rw32(s->q2e_uid, needswap);
}
int
quota_check_limit(uint64_t cur, uint64_t change, uint64_t soft, uint64_t hard,
time_t expire, time_t now)
{
if (cur + change > hard) {
if (cur <= soft)
return (QL_F_CROSS | QL_S_DENY_HARD);
return QL_S_DENY_HARD;
} else if (cur + change > soft) {
if (cur <= soft)
return (QL_F_CROSS | QL_S_ALLOW_SOFT);
if (now > expire) {
return QL_S_DENY_GRACE;
}
return QL_S_ALLOW_SOFT;
}
return QL_S_ALLOW_OK;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_quota2.c,v 1.32 2012/02/01 05:43:54 dholland Exp $ */
/* $NetBSD: ufs_quota2.c,v 1.33 2012/02/05 14:19:04 dholland Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.32 2012/02/01 05:43:54 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.33 2012/02/05 14:19:04 dholland Exp $");
#include <sys/buf.h>
#include <sys/param.h>
@ -51,8 +51,6 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.32 2012/02/01 05:43:54 dholland Exp
#include <ufs/ufs/ufs_quota.h>
#include <ufs/ufs/ufs_wapbl.h>
#include <quota/quota.h> /* XXX for quota_check_limit */
/*
* LOCKING:
* Data in the entries are protected by the associated struct dquot's