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 * -c test for 32bit chown support (via libc)
36 * -q test for quota support (kernel compile option)
37 * -u test for user quota enforcement support (mount option)
38 * -g test for group quota enforcement support (mount option)
39 * -U test for user quota accounting support (mount option)
40 * -G test for group quota accounting support (mount option)
41 * Return code: 0 is true, anything else is error/not supported
45 #include <sys/quota.h>
53 fprintf(stderr, "Usage: feature [-v] -<q|u|g|U|G> <filesystem>\n");
54 fprintf(stderr, " feature [-v] -c <file>\n");
58 int check_big_ID(char *filename)
62 memset(&sbuf, 0, sizeof(struct stat64));
63 if (lstat64(filename, &sbuf) < 0) {
64 fprintf(stderr, "lstat64 failed on ");
69 /* 98789 is greater than 2^16 (65536) */
70 if ((__u32)sbuf.st_uid == 98789 || (__u32)sbuf.st_gid == 98789)
73 fprintf(stderr, "lstat64 on %s gave uid=%d, gid=%d\n",
74 filename, sbuf.st_uid, sbuf.st_gid);
79 haschown32(char *filename)
81 if (check_big_ID(filename) == 0)
84 if (chown(filename, 98789, 98789) < 0) {
85 fprintf(stderr, "chown failed on ");
90 if (check_big_ID(filename) == 0)
96 hasxfsquota(int type, int q, char *device)
98 fs_quota_stat_t qstat;
101 memset(&qstat, 0, sizeof(fs_quota_stat_t));
102 qcmd = QCMD(Q_XGETQSTAT, type);
103 if (quotactl(qcmd, device, 0, (caddr_t)&qstat) < 0) {
110 else if (q == XFS_QUOTA_UDQ_ENFD && qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)
112 else if (q == XFS_QUOTA_GDQ_ENFD && qstat.qs_flags & XFS_QUOTA_GDQ_ENFD)
114 else if (q == XFS_QUOTA_UDQ_ACCT && qstat.qs_flags & XFS_QUOTA_UDQ_ACCT)
116 else if (q == XFS_QUOTA_GDQ_ACCT && qstat.qs_flags & XFS_QUOTA_GDQ_ACCT)
119 fprintf(stderr, "quota type (%d) not available\n", q);
124 main(int argc, char **argv)
135 while ((c = getopt(argc, argv, "cgGquUv")) != EOF) {
163 if (!cflag && !uflag && !gflag && !qflag && !Uflag && !Gflag)
165 if (optind != argc-1)
170 return(haschown32(fs));
172 return(hasxfsquota(0, 0, fs));
174 return(hasxfsquota(GRPQUOTA, XFS_QUOTA_GDQ_ENFD, fs));
176 return(hasxfsquota(USRQUOTA, XFS_QUOTA_UDQ_ENFD, fs));
178 return(hasxfsquota(GRPQUOTA, XFS_QUOTA_GDQ_ACCT, fs));
180 return(hasxfsquota(USRQUOTA, XFS_QUOTA_UDQ_ACCT, fs));
182 fprintf(stderr, "feature: dunno what you're doing?\n");