netatalk  4.4.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
etc/afpd/unix.h
Go to the documentation of this file.
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(HAVE_SYS_VFS_H)
10#include <sys/vfs.h>
11#endif /* HAVE_SYS_VFS_H */
12
13#if defined(__svr4__) || defined(__NetBSD__)
14#include <sys/statvfs.h>
15#define statfs statvfs
16#else
17#define f_frsize f_bsize
18#endif /* __svr4__ || __NetBSD__ */
19
20#if defined(__svr4__) || defined(HAVE_SYS_MNTTAB_H)
21#include <sys/mnttab.h>
22#endif /* __svr4__ || HAVE_SYS_MNTTAB_H */
23
24#if defined(__DragonFly__)
25#define dqblk ufs_dqblk
26#endif
27
28#if defined(HAVE_SYS_MOUNT_H) || defined(BSD4_4) || defined(__linux__)
29#include <sys/mount.h>
30#endif /* HAVE_SYS_MOUNT_H || BSD4_4 || __linux__ */
31
32#if defined(__linux__) || defined(HAVE_MNTENT_H)
33#include <mntent.h>
34#endif /* linux || HAVE_MNTENT_H */
35
36#ifndef NO_QUOTA_SUPPORT
37#if !defined(HAVE_LIBQUOTA)
38
39#if !(defined(__svr4__) || defined(HAVE_DQB_BTIMELIMIT))
40#define dqb_btimelimit dqb_btime
41#endif /* ! __svr4__ || HAVE_DQB_BTIMELIMIT */
42
43#if defined(__linux__) || defined(HAVE_QUOTA_H)
44#include <asm/types.h>
45#include <asm/unistd.h>
46#include <linux/quota.h>
47#endif /* linux || HAVE_QUOTA_H */
48
49#ifdef __svr4__
50#include <sys/fs/ufs_quota.h>
51#endif /* __svr4__ */
52
53#ifdef BSD4_4
54#if defined(__DragonFly__)
55#include <vfs/ufs/quota.h>
56#elif defined(__NetBSD__)
57#include <ufs/ufs/quota.h>
58#include <ufs/ufs/quota1.h>
59#include <ufs/ufs/quota2.h>
60#elif defined(__APPLE__)
61#include <sys/quota.h>
62#define dqb_curblocks dqb_curbytes
63#else /* DragonFly */
64#include <ufs/ufs/quota.h>
65#endif /* DragonFly */
66#endif /* BSD4_4 */
67
68#ifdef HAVE_UFS_QUOTA_H
69#include <ufs/quota.h>
70#endif /* HAVE_UFS_QUOTA_H */
71
72#include <unistd.h>
73#include <sys/types.h>
74#include <sys/stat.h>
75#include "directory.h"
76
77#if defined (__linux__)
78
79/* definitions from sys/quota.h */
80#define USRQUOTA 0
81#define GRPQUOTA 1
82
83/*
84 * Command definitions for the 'quotactl' system call.
85 * The commands are broken into a main command defined below
86 * and a subcommand that is used to convey the type of
87 * quota that is being manipulated (see above).
88 */
89#define SUBCMDMASK 0x00ff
90#define SUBCMDSHIFT 8
91#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
92
93/* declare an internal version of the quota block struct */
94typedef u_int64_t qsize_t;
95typedef u_int32_t qid_t;
96
97struct dqblk {
98 qsize_t bsize;
99 qsize_t dqb_ihardlimit;
100 qsize_t dqb_isoftlimit;
101 qsize_t dqb_curinodes;
102 qsize_t dqb_bhardlimit;
103 qsize_t dqb_bsoftlimit;
104 qsize_t dqb_curblocks;
105 time_t dqb_btime;
106 time_t dqb_itime;
107};
108
109/* API v1 command definitions */
110#define Q_V1_GETQUOTA 0x0300
111#define Q_V1_SYNC 0x0600
112#define Q_V1_SETQLIM 0x0700
113#define Q_V1_GETSTATS 0x0800
114/* API v2 command definitions */
115#define Q_V2_SYNC 0x0600
116#define Q_V2_SETQLIM 0x0700
117#define Q_V2_GETQUOTA 0x0D00
118#define Q_V2_GETSTATS 0x1100
119/* proc API command definitions */
120#define Q_V3_SYNC 0x800001
121#define Q_V3_GETQUOTA 0x800007
122#define Q_V3_SETQUOTA 0x800008
123
124/* Interface versions */
125#define IFACE_UNSET 0
126#define IFACE_VFSOLD 1
127#define IFACE_VFSV0 2
128#define IFACE_GENERIC 3
129
130#define DEV_QBSIZE 1024
131
132struct dqblk_v3 {
133 uint64_t dqb_bhardlimit;
134 uint64_t dqb_bsoftlimit;
135 uint64_t dqb_curspace;
136 uint64_t dqb_ihardlimit;
137 uint64_t dqb_isoftlimit;
138 uint64_t dqb_curinodes;
139 uint64_t dqb_btime;
140 uint64_t dqb_itime;
141 uint32_t dqb_valid;
142};
143
144struct dqblk_v2 {
145 unsigned int dqb_ihardlimit;
146 unsigned int dqb_isoftlimit;
147 unsigned int dqb_curinodes;
148 unsigned int dqb_bhardlimit;
149 unsigned int dqb_bsoftlimit;
150 qsize_t dqb_curspace;
151 time_t dqb_btime;
152 time_t dqb_itime;
153};
154
155struct dqstats_v2 {
156 uint32_t lookups;
157 uint32_t drops;
158 uint32_t reads;
159 uint32_t writes;
160 uint32_t cache_hits;
161 uint32_t allocated_dquots;
162 uint32_t free_dquots;
163 uint32_t syncs;
164 uint32_t version;
165};
166
167struct dqblk_v1 {
168 uint32_t dqb_bhardlimit;
169 uint32_t dqb_bsoftlimit;
170 uint32_t dqb_curblocks;
171 uint32_t dqb_ihardlimit;
172 uint32_t dqb_isoftlimit;
173 uint32_t dqb_curinodes;
174 time_t dqb_btime;
175 time_t dqb_itime;
176};
177
178extern long quotactl(unsigned int, const char *, int, caddr_t);
179
180
181
182#endif /* linux */
183
184extern int getnfsquota(struct vol *, const int, const uint32_t,
185 struct dqblk *);
186
187#endif /* ! HAVE_LIBQUOTA */
188extern int uquota_getvolspace(const AFPObj *obj, struct vol *, VolSpace *,
189 VolSpace *, const uint32_t);
190#endif /* NO_QUOTA_SUPPORT */
191
192extern struct afp_options default_options;
193
194extern int setdirunixmode(const struct vol *, char *, mode_t);
195extern int setdirmode(const struct vol *, const char *, mode_t);
196extern int setdirowner(const struct vol *, const char *, const uid_t,
197 const gid_t);
198extern int setfilunixmode(const struct vol *, struct path *, const mode_t);
199extern int setfilowner(const struct vol *, const uid_t, const gid_t,
200 struct path *);
201extern void accessmode(const AFPObj *obj, const struct vol *, char *,
202 struct maccess *, struct dir *, struct stat *);
203
204#ifdef AFS
205#define accessmode afsmode
206#endif
207
208#endif /* UNIX_H */
static char * version
Definition a2boot.c:60
void accessmode(const AFPObj *obj, const struct vol *, char *, struct maccess *, struct dir *, struct stat *)
Calculate the mode for a directory using a stat() call to estimate permission.
Definition etc/afpd/unix.c:132
int setdirowner(const struct vol *, const char *, const uid_t, const gid_t)
Definition etc/afpd/unix.c:258
int setfilowner(const struct vol *, const uid_t, const gid_t, struct path *)
Definition etc/afpd/unix.c:235
int setdirmode(const struct vol *, const char *, mode_t)
int uquota_getvolspace(const AFPObj *obj, struct vol *, VolSpace *, VolSpace *, const uint32_t)
Definition quota.c:114
int setfilunixmode(const struct vol *, struct path *, const mode_t)
Definition etc/afpd/unix.c:181
int setdirunixmode(const struct vol *, char *, mode_t)
Definition etc/afpd/unix.c:203
struct afp_options default_options
uint64_t VolSpace
Definition include/atalk/volume.h:21
static AFPObj obj
Definition netatalk.c:62
int getnfsquota(struct vol *vol, const int uid, const uint32_t bsize, struct dqblk *dqp)
Definition nfsquota.c:108
Definition globals.h:154
Definition globals.h:93
Definition include/atalk/directory.h:56
Definition etc/afpd/directory.h:68
Definition include/atalk/directory.h:81
Definition include/atalk/volume.h:30