1 /* this test should find out whether legacy quota code in disk_quotas.c
2 * compiles. It is a stripped-down version of disk_quotas.c, with samba
3 * stuff removed and only system calls, header files, and constants left.
6 #ifndef HAVE_SYS_QUOTAS
8 /* just a quick hack because sysquotas.h is included before linux/quota.h */
10 #undef QUOTABLOCK_SIZE
15 #if defined(VXFS_QUOTA)
17 bool disk_quotas_vxfs(const char *name
, char *path
, uint64_t *bsize
,
18 uint64_t *dfree
, uint64_t *dsize
);
20 #endif /* VXFS_QUOTA */
22 #if defined(SUNOS5) || defined(SUNOS4)
25 #include <sys/param.h>
27 #include <sys/fs/ufs_quota.h>
28 #include <sys/mnttab.h>
29 #include <sys/mntent.h>
30 #else /* defined(SUNOS4) */
31 #include <ufs/quota.h>
37 /****************************************************************************
38 Allows querying of remote hosts for quotas on NFS mounted shares.
39 Supports normal NFS and AMD mounts.
40 Alan Romeril <a.romeril@ic.ac.uk> July 2K.
41 ****************************************************************************/
44 #include <rpc/types.h>
45 #include <rpcsvc/rquota.h>
46 #include <rpc/nettype.h>
49 static bool nfs_quotas(char *nfspath
, uid_t euser_id
, uint64_t *bsize
,
50 uint64_t *dfree
, uint64_t *dsize
)
53 clnt
= clnt_create("host", RQUOTAPROG
, RQUOTAVERS
, "udp");
58 /****************************************************************************
59 try to get the disk space from disk quotas (SunOS & Solaris2 version)
60 Quota code by Peter Urbanec (amiga@cse.unsw.edu.au).
61 ****************************************************************************/
63 bool disk_quotas(const char *path
, uint64_t *bsize
, uint64_t *dfree
,
68 struct quotctl command
;
73 nfs_quotas("", 0, bsize
, dfree
, dsize
);
75 command
.op
= Q_GETQUOTA
;
78 ret
= ioctl(1, Q_QUOTACTL
, &command
);
80 ret
= quotactl(Q_GETQUOTA
, "", 0, NULL
);
83 #if defined(SUNOS5) && defined(VXFS_QUOTA)
84 disk_quotas_vxfs("", path
, bsize
, dfree
, dsize
);
92 /* AIX quota patch from Ole Holm Nielsen <ohnielse@fysik.dtu.dk> */
93 #include <jfs/quota.h>
94 /* AIX 4.X: Rename members of the dqblk structure (ohnielse@fysik.dtu.dk) */
95 #define dqb_curfiles dqb_curinodes
96 #define dqb_fhardlimit dqb_ihardlimit
97 #define dqb_fsoftlimit dqb_isoftlimit
98 #ifdef _AIXVERSION_530
99 #include <sys/statfs.h>
100 #include <sys/vmount.h>
103 #include <sys/quota.h>
107 /****************************************************************************
108 try to get the disk space from disk quotas - default version
109 ****************************************************************************/
111 bool disk_quotas(const char *path
, uint64_t *bsize
, uint64_t *dfree
,
116 #ifdef _AIXVERSION_530
117 quota64_t user_quota
;
118 quotactl(path
, QCMD(Q_J2GETQUOTA
, USRQUOTA
), 0, (char *)&user_quota
);
120 quotactl(path
, QCMD(Q_GETQUOTA
, USRQUOTA
), 0, (char *)&D
);
122 quotactl(Q_GETQUOTA
, "", 0, &D
);
129 #if defined(VXFS_QUOTA)
133 #include <sys/fs/vx_solaris.h>
134 #include <sys/fs/vx_machdep.h>
135 #include <sys/fs/vx_layout.h>
136 #include <sys/fs/vx_quota.h>
137 #include <sys/fs/vx_aioctl.h>
138 #include <sys/fs/vx_ioctl.h>
140 bool disk_quotas_vxfs(const char *name
, char *path
, uint64_t *bsize
,
141 uint64_t *dfree
, uint64_t *dsize
)
144 struct vx_quotctl quotabuf
;
145 struct vx_genioctl genbuf
;
147 genbuf
.ioc_cmd
= VX_QUOTACTL
;
148 genbuf
.ioc_up
= (void *)"abuf
;
150 quotabuf
.cmd
= VX_GETQUOTA
;
152 quotabuf
.addr
= (caddr_t
)&D
;
153 ret
= ioctl(1, VX_ADMIN_IOCTL
, &genbuf
);
158 #endif /* SUNOS5 || ... */
160 #endif /* VXFS_QUOTA */
162 #else /* WITH_QUOTAS */
164 #error "This test should be called with WITH_QUOTAS defined"
166 #endif /* WITH_QUOTAS */
168 #else /* HAVE_SYS_QUOTAS */
170 #error "This test should not be called for systems with new quota interface"
172 #endif /* HAVE_SYS_QUOTAS */
174 int main() { return disk_quotas(NULL
, NULL
, NULL
, NULL
); }