build: Fix LIBCLI_SAMR dependencies
[samba4-gss.git] / tests / oldquotas.c
blob37d4e2d37c11a1a78a9ec14fa93a5194b7a206b4
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 /* defined(QUOTABLOCK_SIZE) */
13 #ifdef WITH_QUOTAS
15 #if defined(SUNOS5) /* Solaris */
17 #include <fcntl.h>
18 #include <sys/param.h>
19 #include <sys/fs/ufs_quota.h>
20 #include <sys/mnttab.h>
21 #include <sys/mntent.h>
23 /****************************************************************************
24 Allows querying of remote hosts for quotas on NFS mounted shares.
25 Supports normal NFS and AMD mounts.
26 Alan Romeril <a.romeril@ic.ac.uk> July 2K.
27 ****************************************************************************/
29 #include <rpc/rpc.h>
30 #include <rpc/types.h>
31 #include <rpcsvc/rquota.h>
32 #include <rpc/nettype.h>
33 #include <rpc/xdr.h>
35 static bool nfs_quotas(char *nfspath, uid_t euser_id, uint64_t *bsize,
36 uint64_t *dfree, uint64_t *dsize)
38 CLIENT *clnt;
39 clnt = clnt_create("host", RQUOTAPROG, RQUOTAVERS, "udp");
40 return true;
43 /****************************************************************************
44 try to get the disk space from disk quotas (SunOS & Solaris2 version)
45 Quota code by Peter Urbanec (amiga@cse.unsw.edu.au).
46 ****************************************************************************/
48 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree,
49 uint64_t *dsize)
51 int ret;
52 struct quotctl command;
53 nfs_quotas("", 0, bsize, dfree, dsize);
55 command.op = Q_GETQUOTA;
56 command.uid = 0;
57 command.addr = NULL;
58 ret = ioctl(1, Q_QUOTACTL, &command);
60 return true;
63 #else /* not SunOS / Solaris */
65 #if AIX
66 /* AIX quota patch from Ole Holm Nielsen <ohnielse@fysik.dtu.dk> */
67 #include <jfs/quota.h>
68 /* AIX 4.X: Rename members of the dqblk structure (ohnielse@fysik.dtu.dk) */
69 #define dqb_curfiles dqb_curinodes
70 #define dqb_fhardlimit dqb_ihardlimit
71 #define dqb_fsoftlimit dqb_isoftlimit
72 #ifdef _AIXVERSION_530
73 #include <sys/statfs.h>
74 #include <sys/vmount.h>
75 #endif /* AIX 5.3 */
76 #else /* !AIX - HP-UX */
77 #include <sys/quota.h>
78 #include <devnm.h>
79 #endif /* AIX */
81 /****************************************************************************
82 try to get the disk space from disk quotas - default version
83 ****************************************************************************/
85 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree,
86 uint64_t *dsize)
88 struct dqblk D;
89 #if defined(AIX)
90 #ifdef _AIXVERSION_530
91 quota64_t user_quota;
92 quotactl(path, QCMD(Q_J2GETQUOTA, USRQUOTA), 0, (char *)&user_quota);
93 #endif /* AIX 5.3 */
94 quotactl(path, QCMD(Q_GETQUOTA, USRQUOTA), 0, (char *)&D);
95 #else /* !AIX */
96 quotactl(Q_GETQUOTA, "", 0, &D);
97 #endif /* !AIX */
98 return (true);
101 #endif /* SunOS / Solaris */
103 #else /* WITH_QUOTAS */
105 #error "This test should be called with WITH_QUOTAS defined"
107 #endif /* WITH_QUOTAS */
109 #else /* HAVE_SYS_QUOTAS */
111 #error "This test should not be called for systems with new quota interface"
113 #endif /* HAVE_SYS_QUOTAS */
115 int main(void) { return disk_quotas(NULL, NULL, NULL, NULL); }