pyldb: avoid segfault when adding an element with no name
[kamenim/samba-autobuild/.git] / tests / oldquotas.c
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  */
5
6 #ifndef HAVE_SYS_QUOTAS
7
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) */
12
13 #ifdef WITH_QUOTAS
14
15 #if defined(SUNOS5) /* Solaris */
16
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>
22
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 ****************************************************************************/
28
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>
34
35 static bool nfs_quotas(char *nfspath, uid_t euser_id, uint64_t *bsize,
36                        uint64_t *dfree, uint64_t *dsize)
37 {
38         CLIENT *clnt;
39         clnt = clnt_create("host", RQUOTAPROG, RQUOTAVERS, "udp");
40         return true;
41 }
42
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 ****************************************************************************/
47
48 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree,
49                  uint64_t *dsize)
50 {
51         int ret;
52         struct quotctl command;
53         nfs_quotas("", 0, bsize, dfree, dsize);
54
55         command.op = Q_GETQUOTA;
56         command.uid = 0;
57         command.addr = NULL;
58         ret = ioctl(1, Q_QUOTACTL, &command);
59
60         return true;
61 }
62
63 #else /* not SunOS / Solaris */
64
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 */
80
81 /****************************************************************************
82 try to get the disk space from disk quotas - default version
83 ****************************************************************************/
84
85 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree,
86                  uint64_t *dsize)
87 {
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);
99 }
100
101 #endif /* SunOS / Solaris */
102
103 #else /* WITH_QUOTAS */
104
105 #error "This test should be called with WITH_QUOTAS defined"
106
107 #endif /* WITH_QUOTAS */
108
109 #else /* HAVE_SYS_QUOTAS */
110
111 #error "This test should not be called for systems with new quota interface"
112
113 #endif /* HAVE_SYS_QUOTAS */
114
115 int main() { return disk_quotas(NULL, NULL, NULL, NULL); }