netatalk  4.4.0dev
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 /* element used for user quotas */
81#define GRPQUOTA 1 /* element used for group quotas */
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 */
94
95/* Type in which we store size limitations */
96typedef uint64_t qsize_t;
97/* Type in which we store ids in memory */
98typedef uint32_t qid_t;
99
100struct dqblk {
101 qsize_t bsize;
102 qsize_t dqb_ihardlimit; /* absolute limit on allocated inodes */
103 qsize_t dqb_isoftlimit; /* preferred inode limit */
104 qsize_t dqb_curinodes; /* current # allocated inodes */
105 qsize_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
106 qsize_t dqb_bsoftlimit; /* preferred limit on disk blks */
107 qsize_t dqb_curblocks; /* current block count */
108 time_t dqb_btime; /* time limit for excessive disk use */
109 time_t dqb_itime; /* time limit for excessive inode use */
110};
111
112/* API v1 command definitions */
113#define Q_V1_GETQUOTA 0x0300
114#define Q_V1_SYNC 0x0600
115#define Q_V1_SETQLIM 0x0700
116#define Q_V1_GETSTATS 0x0800
117/* API v2 command definitions */
118#define Q_V2_SYNC 0x0600
119#define Q_V2_SETQLIM 0x0700
120#define Q_V2_GETQUOTA 0x0D00
121#define Q_V2_GETSTATS 0x1100
122/* proc API command definitions */
123#define Q_V3_SYNC 0x800001
124#define Q_V3_GETQUOTA 0x800007
125#define Q_V3_SETQUOTA 0x800008
126
127/* Interface versions */
128#define IFACE_UNSET 0
129#define IFACE_VFSOLD 1
130#define IFACE_VFSV0 2
131#define IFACE_GENERIC 3
132
133#define DEV_QBSIZE 1024
134
135struct dqblk_v3 {
136 uint64_t dqb_bhardlimit;
137 uint64_t dqb_bsoftlimit;
138 uint64_t dqb_curspace;
139 uint64_t dqb_ihardlimit;
140 uint64_t dqb_isoftlimit;
141 uint64_t dqb_curinodes;
142 uint64_t dqb_btime;
143 uint64_t dqb_itime;
144 uint32_t dqb_valid;
145};
146
147struct dqblk_v2 {
148 unsigned int dqb_ihardlimit;
149 unsigned int dqb_isoftlimit;
150 unsigned int dqb_curinodes;
151 unsigned int dqb_bhardlimit;
152 unsigned int dqb_bsoftlimit;
153 qsize_t dqb_curspace;
154 time_t dqb_btime;
155 time_t dqb_itime;
156};
157
158struct dqstats_v2 {
159 uint32_t lookups;
160 uint32_t drops;
161 uint32_t reads;
162 uint32_t writes;
163 uint32_t cache_hits;
164 uint32_t allocated_dquots;
165 uint32_t free_dquots;
166 uint32_t syncs;
167 uint32_t version;
168};
169
170struct dqblk_v1 {
171 uint32_t dqb_bhardlimit;
172 uint32_t dqb_bsoftlimit;
173 uint32_t dqb_curblocks;
174 uint32_t dqb_ihardlimit;
175 uint32_t dqb_isoftlimit;
176 uint32_t dqb_curinodes;
177 time_t dqb_btime;
178 time_t dqb_itime;
179};
180
181extern long quotactl(unsigned int, const char *, int, caddr_t);
182
183
184
185#endif /* linux */
186
187extern int getnfsquota(struct vol *, const int, const uint32_t,
188 struct dqblk *);
189
190#endif /* ! HAVE_LIBQUOTA */
191extern int uquota_getvolspace(const AFPObj *obj, struct vol *, VolSpace *,
192 VolSpace *, const uint32_t);
193#endif /* NO_QUOTA_SUPPORT */
194
195extern struct afp_options default_options;
196
197extern int setdirunixmode(const struct vol *, char *, mode_t);
198extern int setdirmode(const struct vol *, const char *, mode_t);
199extern int setdirowner(const struct vol *, const char *, const uid_t,
200 const gid_t);
201extern int setfilunixmode(const struct vol *, struct path *, const mode_t);
202extern int setfilowner(const struct vol *, const uid_t, const gid_t,
203 struct path *);
204extern void accessmode(const AFPObj *obj, const struct vol *, char *,
205 struct maccess *, struct dir *, struct stat *);
206
207#ifdef AFS
208#define accessmode afsmode
209#endif
210
211#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 *)
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:725
int setfilunixmode(const struct vol *, struct path *, const mode_t)
Definition etc/afpd/unix.c:181
int getnfsquota(struct vol *, const int, const uint32_t, struct dqblk *)
Definition nfsquota.c:108
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:23
static AFPObj obj
Definition netatalk.c:62
Definition globals.h:154
Definition globals.h:93
Definition include/atalk/directory.h:62
Definition etc/afpd/directory.h:68
Definition include/atalk/directory.h:97
Definition include/atalk/volume.h:32