2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 * Test for filesystem features on given mount point or device
35 * -q test for quota support (kernel compile option)
36 * -u test for user quota enforcement support (mount option)
37 * -g test for group quota enforcement support (mount option)
38 * -U test for user quota accounting support (mount option)
39 * -G test for group quota accounting support (mount option)
40 * Return code: 0 is true, anything else is error/not supported
44 #include <sys/quota.h>
52 fprintf(stderr, "Usage: feature [-v] -<q|u|g|U|G> <filesystem>\n");
57 hasxfsquota(int type, int q, char *device)
59 fs_quota_stat_t qstat;
62 memset(&qstat, 0, sizeof(fs_quota_stat_t));
63 qcmd = QCMD(Q_XGETQSTAT, type);
64 if (quotactl(qcmd, device, 0, (caddr_t)&qstat) < 0) {
71 else if (q == XFS_QUOTA_UDQ_ENFD && qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)
73 else if (q == XFS_QUOTA_GDQ_ENFD && qstat.qs_flags & XFS_QUOTA_GDQ_ENFD)
75 else if (q == XFS_QUOTA_UDQ_ACCT && qstat.qs_flags & XFS_QUOTA_UDQ_ACCT)
77 else if (q == XFS_QUOTA_GDQ_ACCT && qstat.qs_flags & XFS_QUOTA_GDQ_ACCT)
80 fprintf(stderr, "quota type (%d) not available\n", q);
85 main(int argc, char **argv)
95 while ((c = getopt(argc, argv, "gGquUv")) != EOF) {
120 if (!uflag && !gflag && !qflag && !Uflag && !Gflag)
122 if (optind != argc-1)
127 return(hasxfsquota(0, 0, fs));
129 return(hasxfsquota(GRPQUOTA, XFS_QUOTA_GDQ_ENFD, fs));
131 return(hasxfsquota(USRQUOTA, XFS_QUOTA_UDQ_ENFD, fs));
133 return(hasxfsquota(GRPQUOTA, XFS_QUOTA_GDQ_ACCT, fs));
135 return(hasxfsquota(USRQUOTA, XFS_QUOTA_UDQ_ACCT, fs));
137 fprintf(stderr, "feature: dunno what you're doing?\n");