ctdb-protocol: Add new capability
[Samba.git] / tests / oldquotas.c
blobbdb2bebb0756d1e377aed5d9a69fbe870a30e06b
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.
4 */
6 #ifndef HAVE_SYS_QUOTAS
8 /* just a quick hack because sysquotas.h is included before linux/quota.h */
9 #ifdef QUOTABLOCK_SIZE
10 #undef QUOTABLOCK_SIZE
11 #endif
13 #ifdef WITH_QUOTAS
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)
24 #include <fcntl.h>
25 #include <sys/param.h>
26 #if defined(SUNOS5)
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>
32 #include <mntent.h>
33 #endif
35 #if defined(SUNOS5)
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 ****************************************************************************/
43 #include <rpc/rpc.h>
44 #include <rpc/types.h>
45 #include <rpcsvc/rquota.h>
46 #include <rpc/nettype.h>
47 #include <rpc/xdr.h>
49 static bool nfs_quotas(char *nfspath, uid_t euser_id, uint64_t *bsize,
50 uint64_t *dfree, uint64_t *dsize)
52 CLIENT *clnt;
53 clnt = clnt_create("host", RQUOTAPROG, RQUOTAVERS, "udp");
54 return true;
56 #endif
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,
64 uint64_t *dsize)
66 int ret;
67 #if defined(SUNOS5)
68 struct quotctl command;
69 #else /* SunOS4 */
70 struct mntent *mnt;
71 #endif
72 #if defined(SUNOS5)
73 nfs_quotas("", 0, bsize, dfree, dsize);
75 command.op = Q_GETQUOTA;
76 command.uid = 0;
77 command.addr = NULL;
78 ret = ioctl(1, Q_QUOTACTL, &command);
79 #else
80 ret = quotactl(Q_GETQUOTA, "", 0, NULL);
81 #endif
83 #if defined(SUNOS5) && defined(VXFS_QUOTA)
84 disk_quotas_vxfs("", path, bsize, dfree, dsize);
85 #endif
86 return true;
89 #else
91 #if AIX
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>
101 #endif /* AIX 5.3 */
102 #else /* !AIX */
103 #include <sys/quota.h>
104 #include <devnm.h>
105 #endif
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,
112 uint64_t *dsize)
114 struct dqblk D;
115 #if defined(AIX)
116 #ifdef _AIXVERSION_530
117 quota64_t user_quota;
118 quotactl(path, QCMD(Q_J2GETQUOTA, USRQUOTA), 0, (char *)&user_quota);
119 #endif /* AIX 5.3 */
120 quotactl(path, QCMD(Q_GETQUOTA, USRQUOTA), 0, (char *)&D);
121 #else /* !AIX */
122 quotactl(Q_GETQUOTA, "", 0, &D);
123 #endif /* !AIX */
124 return (true);
127 #endif
129 #if defined(VXFS_QUOTA)
131 #if defined(SUNOS5)
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)
143 struct vx_dqblk D;
144 struct vx_quotctl quotabuf;
145 struct vx_genioctl genbuf;
147 genbuf.ioc_cmd = VX_QUOTACTL;
148 genbuf.ioc_up = (void *)&quotabuf;
150 quotabuf.cmd = VX_GETQUOTA;
151 quotabuf.uid = 0;
152 quotabuf.addr = (caddr_t)&D;
153 ret = ioctl(1, VX_ADMIN_IOCTL, &genbuf);
155 return true;
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); }