[988] | 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
|
---|
| 12 |
|
---|
| 13 | #ifdef WITH_QUOTAS
|
---|
| 14 |
|
---|
| 15 | #if defined(VXFS_QUOTA)
|
---|
| 16 |
|
---|
| 17 | bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize,
|
---|
| 18 | uint64_t *dfree, uint64_t *dsize);
|
---|
| 19 |
|
---|
| 20 | #endif /* VXFS_QUOTA */
|
---|
| 21 |
|
---|
| 22 | #if defined(SUNOS5) || defined(SUNOS4)
|
---|
| 23 |
|
---|
| 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
|
---|
| 34 |
|
---|
| 35 | #if defined(SUNOS5)
|
---|
| 36 |
|
---|
| 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 | ****************************************************************************/
|
---|
| 42 |
|
---|
| 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>
|
---|
| 48 |
|
---|
| 49 | static bool nfs_quotas(char *nfspath, uid_t euser_id, uint64_t *bsize,
|
---|
| 50 | uint64_t *dfree, uint64_t *dsize)
|
---|
| 51 | {
|
---|
| 52 | CLIENT *clnt;
|
---|
| 53 | clnt = clnt_create("host", RQUOTAPROG, RQUOTAVERS, "udp");
|
---|
| 54 | return true;
|
---|
| 55 | }
|
---|
| 56 | #endif
|
---|
| 57 |
|
---|
| 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 | ****************************************************************************/
|
---|
| 62 |
|
---|
| 63 | bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree,
|
---|
| 64 | uint64_t *dsize)
|
---|
| 65 | {
|
---|
| 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);
|
---|
| 74 |
|
---|
| 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
|
---|
| 82 |
|
---|
| 83 | #if defined(SUNOS5) && defined(VXFS_QUOTA)
|
---|
| 84 | disk_quotas_vxfs("", path, bsize, dfree, dsize);
|
---|
| 85 | #endif
|
---|
| 86 | return true;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | #else
|
---|
| 90 |
|
---|
| 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
|
---|
| 106 |
|
---|
| 107 | /****************************************************************************
|
---|
| 108 | try to get the disk space from disk quotas - default version
|
---|
| 109 | ****************************************************************************/
|
---|
| 110 |
|
---|
| 111 | bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree,
|
---|
| 112 | uint64_t *dsize)
|
---|
| 113 | {
|
---|
| 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);
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | #endif
|
---|
| 128 |
|
---|
| 129 | #if defined(VXFS_QUOTA)
|
---|
| 130 |
|
---|
| 131 | #if defined(SUNOS5)
|
---|
| 132 |
|
---|
| 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>
|
---|
| 139 |
|
---|
| 140 | bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize,
|
---|
| 141 | uint64_t *dfree, uint64_t *dsize)
|
---|
| 142 | {
|
---|
| 143 | struct vx_dqblk D;
|
---|
| 144 | struct vx_quotctl quotabuf;
|
---|
| 145 | struct vx_genioctl genbuf;
|
---|
| 146 |
|
---|
| 147 | genbuf.ioc_cmd = VX_QUOTACTL;
|
---|
| 148 | genbuf.ioc_up = (void *)"abuf;
|
---|
| 149 |
|
---|
| 150 | quotabuf.cmd = VX_GETQUOTA;
|
---|
| 151 | quotabuf.uid = 0;
|
---|
| 152 | quotabuf.addr = (caddr_t)&D;
|
---|
| 153 | ret = ioctl(1, VX_ADMIN_IOCTL, &genbuf);
|
---|
| 154 |
|
---|
| 155 | return true;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | #endif /* SUNOS5 || ... */
|
---|
| 159 |
|
---|
| 160 | #endif /* VXFS_QUOTA */
|
---|
| 161 |
|
---|
| 162 | #else /* WITH_QUOTAS */
|
---|
| 163 |
|
---|
| 164 | #error "This test should be called with WITH_QUOTAS defined"
|
---|
| 165 |
|
---|
| 166 | #endif /* WITH_QUOTAS */
|
---|
| 167 |
|
---|
| 168 | #else /* HAVE_SYS_QUOTAS */
|
---|
| 169 |
|
---|
| 170 | #error "This test should not be called for systems with new quota interface"
|
---|
| 171 |
|
---|
| 172 | #endif /* HAVE_SYS_QUOTAS */
|
---|
| 173 |
|
---|
| 174 | int main() { return disk_quotas(NULL, NULL, NULL, NULL); }
|
---|