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