[5447b1]: etc / afpd / directory.h Maximize Restore History

Download this file

directory.h    242 lines (203 with data), 8.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
* $Id: directory.h,v 1.13.2.4.2.2.2.2 2009-09-07 11:35:04 franklahm Exp $
*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation, and that the name of The University
* of Michigan not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. This software is supplied as is without expressed or
* implied warranties of any kind.
*
* Research Systems Unix Group
* The University of Michigan
* c/o Mike Clark
* 535 W. William Street
* Ann Arbor, Michigan
* +1-313-763-0525
* netatalk@itd.umich.edu
*/
#ifndef AFPD_DIRECTORY_H
#define AFPD_DIRECTORY_H 1
#include <sys/cdefs.h>
#include <sys/types.h>
/*#include <sys/stat.h>*/ /* including it here causes some confusion */
#include <netatalk/endian.h>
#include <dirent.h>
/* sys/types.h usually snarfs in major/minor macros. if they don't
* try this file. */
#ifndef major
#include <sys/sysmacros.h>
#endif
#include "globals.h"
#include "volume.h"
/* the did tree is now a red-black tree while the parent/child
* tree is a circular doubly-linked list. how exciting. */
struct dir {
struct dir *d_left, *d_right, *d_back; /* for red-black tree */
int d_color;
struct dir *d_parent, *d_child; /* parent-child */
struct dir *d_prev, *d_next; /* siblings */
void *d_ofork; /* oforks using this directory. */
u_int32_t d_did;
int d_flags;
time_t ctime; /* inode ctime */
u_int32_t offcnt; /* offspring count */
char *d_m_name; /* mac name */
char *d_u_name; /* unix name */
};
struct path {
int m_type; /* mac name type (long name, unicode */
char *m_name; /* mac name */
char *u_name; /* unix name */
struct dir *d_dir; /* */
int st_valid; /* does st_errno and st set */
int st_errno;
struct stat st;
};
#ifndef ATACC
static inline int path_isadir(struct path *o_path)
{
return o_path->d_dir != NULL;
#if 0
return o_path->m_name == '\0' || /* we are in a it */
!o_path->st_valid || /* in cache but we can't chdir in it */
(!o_path->st_errno && S_ISDIR(o_path->st.st_mode)); /* not in cache an can't chdir */
#endif
}
#else
extern int path_isadir(struct path *o_path);
#endif
/* child addition/removal macros */
#define dirchildadd(a, b) do { \
if (!(a)->d_child) \
(a)->d_child = (b); \
else { \
(b)->d_next = (a)->d_child; \
(b)->d_prev = (b)->d_next->d_prev; \
(b)->d_next->d_prev = (b); \
(b)->d_prev->d_next = (b); \
} \
} while (0)
#define dirchildremove(a,b) do { \
if ((a)->d_child == (b)) \
(a)->d_child = ((b) == (b)->d_next) ? NULL : (b)->d_next; \
(b)->d_next->d_prev = (b)->d_prev; \
(b)->d_prev->d_next = (b)->d_next; \
(b)->d_next = (b)->d_prev = (b); \
} while (0)
#define DIRTREE_COLOR_RED 0
#define DIRTREE_COLOR_BLACK 1
/* setgid directories */
#ifndef DIRBITS
# ifdef AFS
# define DIRBITS 0
# else /* AFS */
# define DIRBITS S_ISGID
# endif /* AFS */
#endif /* DIRBITS */
#define DIRF_FSMASK (3<<0)
#define DIRF_NOFS (0<<0)
#define DIRF_AFS (1<<0)
#define DIRF_UFS (2<<0)
#define AFPDIR_READ (1<<0)
/* directory bits */
#define DIRPBIT_ATTR 0
#define DIRPBIT_PDID 1
#define DIRPBIT_CDATE 2
#define DIRPBIT_MDATE 3
#define DIRPBIT_BDATE 4
#define DIRPBIT_FINFO 5
#define DIRPBIT_LNAME 6
#define DIRPBIT_SNAME 7
#define DIRPBIT_DID 8
#define DIRPBIT_OFFCNT 9
#define DIRPBIT_UID 10
#define DIRPBIT_GID 11
#define DIRPBIT_ACCESS 12
#define DIRPBIT_PDINFO 13 /* ProDOS Info */
#define DIRPBIT_UNIXPR 15
/* directory attribute bits (see file.h for other bits) */
#define ATTRBIT_EXPFOLDER (1 << 1) /* shared point */
#define ATTRBIT_MOUNTED (1 << 3) /* mounted share point by non-admin */
#define ATTRBIT_INEXPFOLDER (1 << 4) /* folder in a shared area */
#define FILDIRBIT_ISDIR (1 << 7) /* is a directory */
#define FILDIRBIT_ISFILE (0) /* is a file */
/* reserved directory id's */
#define DIRDID_ROOT_PARENT htonl(1) /* parent directory of root */
#define DIRDID_ROOT htonl(2) /* root directory */
/* file/directory ids. what a mess. we scramble things in a vain attempt
* to get something meaningful */
#ifndef AFS
#if 0
#define CNID_XOR(a) (((a) >> 16) ^ (a))
#define CNID_DEV(a) ((((CNID_XOR(major((a)->st_dev)) & 0xf) << 3) | \
(CNID_XOR(minor((a)->st_dev)) & 0x7)) << 24)
#define CNID_INODE(a) (((a)->st_ino ^ (((a)->st_ino & 0xff000000) >> 8)) \
& 0x00ffffff)
#define CNID_FILE(a) (((a) & 0x1) << 31)
#define CNID(a,b) (CNID_DEV(a) | CNID_INODE(a) | CNID_FILE(b))
#endif
#define CNID(a,b) ((a)->st_ino & 0xffffffff)
#else /* AFS */
#define CNID(a,b) (((a)->st_ino & 0x7fffffff) | CNID_FILE(b))
#endif /* AFS */
struct maccess {
u_char ma_user;
u_char ma_world;
u_char ma_group;
u_char ma_owner;
};
#define AR_USEARCH (1<<0)
#define AR_UREAD (1<<1)
#define AR_UWRITE (1<<2)
#define AR_UOWN (1<<7)
extern struct dir *dirnew __P((const char *, const char *));
extern void dirfreename __P((struct dir *));
extern void dirfree __P((struct dir *));
extern struct dir *dirsearch __P((const struct vol *, u_int32_t));
extern struct dir *dirlookup __P((const struct vol *, u_int32_t));
extern struct dir *dirsearch_byname __P((struct dir *,const char *));
extern struct dir *adddir __P((struct vol *, struct dir *,
struct path *));
extern struct dir *dirinsert __P((struct vol *, struct dir *));
extern int movecwd __P((const struct vol *, struct dir *));
extern int deletecurdir __P((const struct vol *, char *));
extern struct path *cname __P((const struct vol *, struct dir *,
char **));
extern mode_t mtoumode __P((struct maccess *));
extern void utommode __P((struct stat *, struct maccess *));
extern int getdirparams __P((const struct vol *, u_int16_t, struct path *,
struct dir *, char *, int *));
extern int setdirparams __P((const struct vol *, struct path *, u_int16_t, char *));
extern int renamedir __P((const struct vol *, char *, char *, struct dir *,
struct dir *, char *));
extern int path_error __P((struct path *, int error));
typedef int (*dir_loop)(struct dirent *, char *, void *);
extern int for_each_dirent __P((const struct vol *, char *, dir_loop , void *));
extern int check_access __P((char *name , int mode));
extern int file_access __P((struct path *path, int mode));
extern int netatalk_unlink __P((const char *name));
/* from enumerate.c */
extern char *check_dirent __P((const struct vol *, char *));
/* FP functions */
extern int afp_createdir __P((AFPObj *, char *, int, char *, int *));
extern int afp_opendir __P((AFPObj *, char *, int, char *, int *));
extern int afp_setdirparams __P((AFPObj *, char *, int, char *, int *));
extern int afp_closedir __P((AFPObj *, char *, int, char *, int *));
extern int afp_mapid __P((AFPObj *, char *, int, char *, int *));
extern int afp_mapname __P((AFPObj *, char *, int, char *, int *));
extern int afp_syncdir __P((AFPObj *, char *, int, char *, int *));
/* from enumerate.c */
extern int afp_enumerate __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
extern int afp_enumerate_ext __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
extern int afp_enumerate_ext2 __P((AFPObj *, char *, unsigned int, char *, unsigned int *));
/* from catsearch.c */
extern int afp_catsearch __P((AFPObj *, char *, int, char *, int *));
extern int afp_catsearch_ext __P((AFPObj *, char *, int, char *, int *));
#endif