[BACK]Return to ufs_quota.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ufs

File: [cvs.NetBSD.org] / src / sys / ufs / ufs / ufs_quota.h (download)

Revision 1.22, Sat Jun 28 22:27:51 2014 UTC (9 years, 9 months ago) by dholland
Branch: MAIN
CVS Tags: tls-maxphys-base-20171202, tls-maxphys-base, tls-earlyentropy-base, thorpej-ifq-base, thorpej-ifq, thorpej-i2c-spi-conf2-base, thorpej-i2c-spi-conf2, thorpej-i2c-spi-conf-base, thorpej-i2c-spi-conf, thorpej-futex2-base, thorpej-futex2, thorpej-futex-base, thorpej-futex, thorpej-cfargs2-base, thorpej-cfargs2, thorpej-cfargs-base, thorpej-cfargs, thorpej-altq-separation-base, thorpej-altq-separation, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606, nick-nhusb-base-20150406, nick-nhusb-base, nick-nhusb, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, jdolecek-ncq-base, jdolecek-ncq, isaki-audio2-base, isaki-audio2, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, bouyer-sunxi-drm-base, bouyer-sunxi-drm, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, ad-namecache-base3, ad-namecache-base2, ad-namecache-base1, ad-namecache-base, ad-namecache, HEAD
Changes since 1.21: +2 -2 lines

Revert the following changes:

   src/sys/sys/quotactl.h 1.37
   src/sys/compat/netbsd32/netbsd32.h 1.101
   src/sys/compat/netbsd32/netbsd32_netbsd.c 1.188, 1.189
   src/sys/kern/vfs_quotactl.c 1.39
   src/sys/kern/vfs_syscalls.c 1.483
   src/sys/ufs/lfs/ulfs_quota.c 1.11
   src/sys/ufs/ufs/ufs_quota.c 1.116
   src/lib/libquota/quota_kernel.c 1.5

and do them correctly.

If you're going to change the name of something, you need to change
the name of *all* the things with the same name, not just a handful,
and you should change it to something similar so it still matches the
rest of the system rather than just picking an arbitrarily different
name.

Hi, Joerg.

To wit, rename the quotactl "delete" operation to "del", because
"delete" is a reserved word in C++ and for some reason Joerg wants to
run internal interfaces used only by C code through his C++ compiler.
Do not rename it to "remove" instead, because this doesn't match
libquota or the rest of the usage throughout the system; and rename
all the related identifiers, not just the ones that blew the mind of
Joerg's C++ compiler.

Because this is not a user-facing API (the only userland consumer
sys/quotactl.h is libquota) it is sort of ok to make arbitrary
source-incompatible changes; however, by the same token it's completely
unnecessary. If it *were* a user-facing API that someone might have a
semi-rational reason to want to run a C++ compiler on, it would be
incorrect to change it at this point.

/*	$NetBSD: ufs_quota.h,v 1.22 2014/06/28 22:27:51 dholland Exp $	*/

/*
 * Copyright (c) 1982, 1986, 1990, 1993, 1995
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Robert Elz at The University of Melbourne.
 *
 * 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.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
 *
 *	@(#)ufs_quota.c	8.5 (Berkeley) 5/20/95
 */
#include <ufs/ufs/quota1.h>
#include <ufs/ufs/quota2.h>

struct quotakcursor; /* from <sys/quotactl.h> */


/* link to this quota in the quota inode (for QUOTA2) */
struct dq2_desc {
	uint64_t dq2_lblkno; /* logical disk block holding this quota */
	u_int    dq2_blkoff; /* offset in disk block holding this quota */
};

/*
 * The following structure records disk usage for a user or group on a
 * filesystem. There is one allocated for each quota that exists on any
 * filesystem for the current user or group. A cache is kept of recently
 * used entries.
 * Field markings and the corresponding locks:
 * h:	dqlock
 * d:	dq_interlock
 *
 * Lock order is: dq_interlock -> dqlock
 *                dq_interlock -> dqvp
 */
struct dquot {
	LIST_ENTRY(dquot) dq_hash;	/* h: hash list */
	u_int16_t dq_flags;		/* d: flags, see below */
	u_int16_t dq_type;		/* d: quota type of this dquot */
	u_int32_t dq_cnt;		/* h: count of active references */
	u_int32_t dq_id;		/* d: identifier this applies to */
	struct	ufsmount *dq_ump;	/* d: filesystem this is taken from */
	kmutex_t dq_interlock;		/* d: lock this dquot */
	union {
		struct dqblk dq1_dqb;	/* d: actual usage & quotas */
		struct dq2_desc dq2_desc; /* d: pointer to quota data */
	} dq_un;
};

/*
 * Flag values.
 */
#define	DQ_MOD		0x04		/* this quota modified since read */
#define	DQ_FAKE		0x08		/* no limits here, just usage */
#define	DQ_WARN(ltype)	(0x10 << ltype)	/* has been warned about "type" limit */
/*
 * Shorthand notation.
 */
#define	dq_bhardlimit	dq_un.dq1_dqb.dqb_bhardlimit
#define	dq_bsoftlimit	dq_un.dq1_dqb.dqb_bsoftlimit
#define	dq_curblocks	dq_un.dq1_dqb.dqb_curblocks
#define	dq_ihardlimit	dq_un.dq1_dqb.dqb_ihardlimit
#define	dq_isoftlimit	dq_un.dq1_dqb.dqb_isoftlimit
#define	dq_curinodes	dq_un.dq1_dqb.dqb_curinodes
#define	dq_btime	dq_un.dq1_dqb.dqb_btime
#define	dq_itime	dq_un.dq1_dqb.dqb_itime

#define dq2_lblkno	dq_un.dq2_desc.dq2_lblkno
#define dq2_blkoff	dq_un.dq2_desc.dq2_blkoff
/*
 * If the system has never checked for a quota for this file, then it is
 * set to NODQUOT.  Once a write attempt is made the inode pointer is set
 * to reference a dquot structure.
 */
#define	NODQUOT		NULL

extern kmutex_t dqlock;
extern kcondvar_t dqcv;
/*
 * Quota name to error message mapping.
 */
extern const char *quotatypes[MAXQUOTAS];

int  getinoquota(struct inode *);
int  dqget(struct vnode *, u_long, struct ufsmount *, int, struct dquot **);
void dqref(struct dquot *);
void dqrele(struct vnode *, struct dquot *);
void dqflush(struct vnode *);

int chkdq1(struct inode *, int64_t, kauth_cred_t, int);
int chkiq1(struct inode *, int32_t, kauth_cred_t, int);
int q1sync(struct mount *);
int dq1get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
int dq1sync(struct vnode *, struct dquot *);
int quota1_handle_cmd_get(struct ufsmount *, const struct quotakey *,
    struct quotaval *);
int quota1_handle_cmd_put(struct ufsmount *, const struct quotakey *,
    const struct quotaval *);
int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int,
    const char *);
int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int);

int chkdq2(struct inode *, int64_t, kauth_cred_t, int);
int chkiq2(struct inode *, int32_t, kauth_cred_t, int);
int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *,
    struct quotaval *);
int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *,
    const struct quotaval *);
int quota2_handle_cmd_del(struct ufsmount *, const struct quotakey *);
int quota2_handle_cmd_cursorget(struct ufsmount *, struct quotakcursor *,
    struct quotakey *, struct quotaval *, unsigned, unsigned *);
int quota2_handle_cmd_cursoropen(struct ufsmount *, struct quotakcursor *);
int quota2_handle_cmd_cursorclose(struct ufsmount *, struct quotakcursor *);
int quota2_handle_cmd_cursorskipidtype(struct ufsmount *, struct quotakcursor *,
    int);
int quota2_handle_cmd_cursoratend(struct ufsmount *, struct quotakcursor *,
    int *);
int quota2_handle_cmd_cursorrewind(struct ufsmount *, struct quotakcursor *);
int q2sync(struct mount *);
int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
int dq2sync(struct vnode *, struct dquot *);