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
11 #endif /* defined(QUOTABLOCK_SIZE) */
15 #if defined(SUNOS5) /* Solaris */
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 ****************************************************************************/
30 #include <rpc/types.h>
31 #include <rpcsvc/rquota.h>
32 #include <rpc/nettype.h>
35 static bool nfs_quotas(char *nfspath
, uid_t euser_id
, uint64_t *bsize
,
36 uint64_t *dfree
, uint64_t *dsize
)
39 clnt
= clnt_create("host", RQUOTAPROG
, RQUOTAVERS
, "udp");
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
,
52 struct quotctl command
;
53 nfs_quotas("", 0, bsize
, dfree
, dsize
);
55 command
.op
= Q_GETQUOTA
;
58 ret
= ioctl(1, Q_QUOTACTL
, &command
);
63 #else /* not SunOS / Solaris */
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>
76 #else /* !AIX - HP-UX */
77 #include <sys/quota.h>
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
,
90 #ifdef _AIXVERSION_530
92 quotactl(path
, QCMD(Q_J2GETQUOTA
, USRQUOTA
), 0, (char *)&user_quota
);
94 quotactl(path
, QCMD(Q_GETQUOTA
, USRQUOTA
), 0, (char *)&D
);
96 quotactl(Q_GETQUOTA
, "", 0, &D
);
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() { return disk_quotas(NULL
, NULL
, NULL
, NULL
); }