1 #ifndef AFPD_UNIX_H 2 #define AFPD_UNIX_H 3 4 #include <arpa/inet.h> 5 6 #include "config.h" 7 #include "volume.h" 8 9 #if defined( sun ) && !defined( __svr4__ ) 10 #ifdef i386 11 typedef int mode_t; 12 #endif /*i386*/ 13 #endif /*sun __svr4__*/ 14 15 #if defined(HAVE_SYS_VFS_H) || defined( sun ) || defined( ibm032 ) 16 #include <sys/vfs.h> 17 #endif /* HAVE_SYS_VFS_H || sun || ibm032 */ 18 19 #if defined(_IBMR2) || defined(HAVE_STATFS_H) 20 #include <sys/statfs.h> 21 /* this might not be right. */ 22 #define f_mntfromname f_fname 23 #endif /* _IBMR2 || HAVE_STATFS_H */ 24 25 #if defined(TRU64) 26 #define f_frsize f_fsize 27 #else /* TRU64 */ 28 /* temp fix, was: defined(HAVE_SYS_STATVFS) || defined(__svr4__) */ 29 #if defined(__svr4__) || (defined(__NetBSD__) && (__NetBSD_Version__ >= 200040000)) 30 #include <sys/statvfs.h> 31 #define statfs statvfs 32 #else /* HAVE_SYS_STATVFS || __svr4__ */ 33 #define f_frsize f_bsize 34 #endif /* USE_STATVFS_H */ 35 #endif /* TRU64 */ 36 37 #if defined(__svr4__) || defined(HAVE_SYS_MNTTAB_H) 38 #include <sys/mnttab.h> 39 #endif /* __svr4__ || HAVE_SYS_MNTTAB_H */ 40 41 #if defined(__DragonFly__) 42 #define dqblk ufs_dqblk 43 #endif 44 45 #if defined(HAVE_SYS_MOUNT_H) || defined(BSD4_4) || \ 46 defined(linux) || defined(ultrix) 47 #include <sys/mount.h> 48 #endif /* HAVE_SYS_MOUNT_H || BSD4_4 || linux || ultrix */ 49 50 #if defined(linux) || defined(HAVE_MNTENT_H) 51 #include <mntent.h> 52 #endif /* linux || HAVE_MNTENT_H */ 53 54 55 #ifndef NO_QUOTA_SUPPORT 56 #if !defined(HAVE_LIBQUOTA) 57 58 #if !(defined(__svr4__) || defined(HAVE_DQB_BTIMELIMIT)) 59 #define dqb_btimelimit dqb_btime 60 #endif /* ! __svr4__ || HAVE_DQB_BTIMELIMIT */ 61 62 #if defined(linux) || defined(ultrix) || defined(HAVE_QUOTA_H) 63 #ifndef NEED_QUOTACTL_WRAPPER 64 /*#include <sys/quota.h>*/ 65 /*long quotactl (int, const char *, unsigned int, caddr_t); */ 66 /* extern long quotactl (int, const char *, long, caddr_t); */ 67 68 #else /* ! NEED_QUOTACTL_WRAPPER */ 69 #include <asm/types.h> 70 #include <asm/unistd.h> 71 #include <linux/quota.h> 72 #endif /* ! NEED_QUOTACTL_WRAPPER */ 73 #endif /* linux || ultrix || HAVE_QUOTA_H */ 74 75 #ifdef __svr4__ 76 #include <sys/fs/ufs_quota.h> 77 #endif /* __svr4__ */ 78 79 #ifdef BSD4_4 80 #include <ufs/ufs/quota.h> 81 #endif /* BSD4_4 */ 82 83 #ifdef HAVE_UFS_QUOTA_H 84 #include <ufs/quota.h> 85 #endif /* HAVE_UFS_QUOTA_H */ 86 87 #ifdef _IBMR2 88 #include <jfs/quota.h> 89 #endif /* _IBMR2 */ 90 91 #include <unistd.h> 92 #include <sys/types.h> 93 #include <sys/stat.h> 94 #include "directory.h" 95 96 97 #if defined (linux) 98 99 #define MAXQUOTAS 2 100 101 /* definitions from sys/quota.h */ 102 #define USRQUOTA 0 /* element used for user quotas */ 103 #define GRPQUOTA 1 /* element used for group quotas */ 104 105 /* 106 * Command definitions for the 'quotactl' system call. 107 * The commands are broken into a main command defined below 108 * and a subcommand that is used to convey the type of 109 * quota that is being manipulated (see above). 110 */ 111 #define SUBCMDMASK 0x00ff 112 #define SUBCMDSHIFT 8 113 #define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) 114 115 /* declare an internal version of the quota block struct */ 116 typedef u_int64_t qsize_t; /* Type in which we store size limitations */ 117 typedef u_int32_t qid_t; /* Type in which we store ids in memory */ 118 119 struct dqblk { 120 qsize_t bsize; 121 qsize_t dqb_ihardlimit; /* absolute limit on allocated inodes */ 122 qsize_t dqb_isoftlimit; /* preferred inode limit */ 123 qsize_t dqb_curinodes; /* current # allocated inodes */ 124 qsize_t dqb_bhardlimit; /* absolute limit on disk blks alloc */ 125 qsize_t dqb_bsoftlimit; /* preferred limit on disk blks */ 126 qsize_t dqb_curblocks; /* current block count */ 127 time_t dqb_btime; /* time limit for excessive disk use */ 128 time_t dqb_itime; /* time limit for excessive inode use */ 129 }; 130 131 /* API v1 command definitions */ 132 #define Q_V1_GETQUOTA 0x0300 133 #define Q_V1_SYNC 0x0600 134 #define Q_V1_SETQLIM 0x0700 135 #define Q_V1_GETSTATS 0x0800 136 /* API v2 command definitions */ 137 #define Q_V2_SYNC 0x0600 138 #define Q_V2_SETQLIM 0x0700 139 #define Q_V2_GETQUOTA 0x0D00 140 #define Q_V2_GETSTATS 0x1100 141 /* proc API command definitions */ 142 #define Q_V3_SYNC 0x800001 143 #define Q_V3_GETQUOTA 0x800007 144 #define Q_V3_SETQUOTA 0x800008 145 146 /* Interface versions */ 147 #define IFACE_UNSET 0 148 #define IFACE_VFSOLD 1 149 #define IFACE_VFSV0 2 150 #define IFACE_GENERIC 3 151 152 #define DEV_QBSIZE 1024 153 154 struct dqblk_v3 { 155 u_int64_t dqb_bhardlimit; 156 u_int64_t dqb_bsoftlimit; 157 u_int64_t dqb_curspace; 158 u_int64_t dqb_ihardlimit; 159 u_int64_t dqb_isoftlimit; 160 u_int64_t dqb_curinodes; 161 u_int64_t dqb_btime; 162 u_int64_t dqb_itime; 163 u_int32_t dqb_valid; 164 }; 165 166 struct dqblk_v2 { 167 unsigned int dqb_ihardlimit; 168 unsigned int dqb_isoftlimit; 169 unsigned int dqb_curinodes; 170 unsigned int dqb_bhardlimit; 171 unsigned int dqb_bsoftlimit; 172 qsize_t dqb_curspace; 173 time_t dqb_btime; 174 time_t dqb_itime; 175 }; 176 177 struct dqstats_v2 { 178 u_int32_t lookups; 179 u_int32_t drops; 180 u_int32_t reads; 181 u_int32_t writes; 182 u_int32_t cache_hits; 183 u_int32_t allocated_dquots; 184 u_int32_t free_dquots; 185 u_int32_t syncs; 186 u_int32_t version; 187 }; 188 189 struct dqblk_v1 { 190 u_int32_t dqb_bhardlimit; 191 u_int32_t dqb_bsoftlimit; 192 u_int32_t dqb_curblocks; 193 u_int32_t dqb_ihardlimit; 194 u_int32_t dqb_isoftlimit; 195 u_int32_t dqb_curinodes; 196 time_t dqb_btime; 197 time_t dqb_itime; 198 }; 199 200 extern long quotactl (unsigned int, const char *, int, caddr_t); 201 202 203 204 #endif /* linux */ 205 206 extern int getnfsquota (struct vol *, const int, const uint32_t, 207 struct dqblk *); 208 209 #endif /* ! HAVE_LIBQUOTA */ 210 extern int uquota_getvolspace (const AFPObj *obj, struct vol *, VolSpace *, VolSpace *, 211 const uint32_t); 212 #endif /* NO_QUOTA_SUPPORT */ 213 214 extern struct afp_options default_options; 215 216 extern int setdirunixmode (const struct vol *, char *, mode_t); 217 extern int setdirmode (const struct vol *, const char *, mode_t); 218 extern int setdirowner (const struct vol *, const char *, const uid_t, const gid_t); 219 extern int setfilunixmode (const struct vol *, struct path*, const mode_t); 220 extern int setfilowner (const struct vol *, const uid_t, const gid_t, struct path*); 221 extern void accessmode (const AFPObj *obj, const struct vol *, char *, struct maccess *, struct dir *, struct stat *); 222 223 #ifdef AFS 224 #define accessmode afsmode 225 #endif 226 227 #endif /* UNIX_H */ 228