2 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * Permission to use, copy, modify, and distribute this software and
6 * its documentation for any purpose and without fee is hereby granted,
7 * provided that the above copyright notice appears in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation, and that the name of The University
10 * of Michigan not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. This software is supplied as is without expressed or
13 * implied warranties of any kind.
15 * Research Systems Unix Group
16 * The University of Michigan
18 * 535 W. William Street
21 * netatalk@itd.umich.edu
24 #ifndef AFPD_DIRECTORY_H
25 #define AFPD_DIRECTORY_H 1
27 #include <sys/cdefs.h>
28 #include <sys/types.h>
29 /*#include <sys/stat.h>*/ /* including it here causes some confusion */
30 #include <netatalk/endian.h>
32 /* sys/types.h usually snarfs in major/minor macros. if they don't
35 #include <sys/sysmacros.h>
41 /* the did tree is now a red-black tree while the parent/child
42 * tree is a circular doubly-linked list. how exciting. */
44 struct dir *d_left, *d_right, *d_back; /* for red-black tree */
46 struct dir *d_parent, *d_child; /* parent-child */
47 struct dir *d_prev, *d_next; /* siblings */
48 void *d_ofork; /* oforks using this directory. */
54 /* child addition/removal macros */
55 #define dirchildadd(a, b) do { \
59 (b)->d_next = (a)->d_child; \
60 (b)->d_prev = (b)->d_next->d_prev; \
61 (b)->d_next->d_prev = (b); \
62 (b)->d_prev->d_next = (b); \
66 #define dirchildremove(a,b) do { \
67 if ((a)->d_child == (b)) \
68 (a)->d_child = ((b) == (b)->d_next) ? NULL : (b)->d_next; \
69 (b)->d_next->d_prev = (b)->d_prev; \
70 (b)->d_prev->d_next = (b)->d_next; \
71 (b)->d_next = (b)->d_prev = (b); \
74 #define DIRTREE_COLOR_RED 0
75 #define DIRTREE_COLOR_BLACK 1
77 /* setgid directories */
79 #define DIRBITS S_ISGID
82 #define DIRF_FSMASK (3<<0)
83 #define DIRF_NOFS (0<<0)
84 #define DIRF_AFS (1<<0)
85 #define DIRF_UFS (2<<0)
87 #define AFPDIR_READ (1<<0)
90 #define DIRPBIT_ATTR 0
91 #define DIRPBIT_PDID 1
92 #define DIRPBIT_CDATE 2
93 #define DIRPBIT_MDATE 3
94 #define DIRPBIT_BDATE 4
95 #define DIRPBIT_FINFO 5
96 #define DIRPBIT_LNAME 6
97 #define DIRPBIT_SNAME 7
99 #define DIRPBIT_OFFCNT 9
100 #define DIRPBIT_UID 10
101 #define DIRPBIT_GID 11
102 #define DIRPBIT_ACCESS 12
103 #define DIRPBIT_PDINFO 13 /* ProDOS Info */
105 /* directory attribute bits (see file.h for other bits) */
106 #define ATTRBIT_EXPFOLDER (1 << 1) /* shared point */
107 #define ATTRBIT_MOUNTED (1 << 3) /* mounted share point by non-admin */
108 #define ATTRBIT_INEXPFOLDER (1 << 4) /* folder in a shared area */
110 #define FILDIRBIT_ISDIR (1 << 7) /* is a directory */
111 #define FILDIRBIT_ISFILE (0) /* is a file */
113 /* reserved directory id's */
114 #define DIRDID_ROOT_PARENT htonl(1) /* parent directory of root */
115 #define DIRDID_ROOT htonl(2) /* root directory */
117 /* file/directory ids. what a mess. we scramble things in a vain attempt
118 * to get something meaningful */
120 #define CNID_XOR(a) (((a) >> 16) ^ (a))
121 #define CNID_DEV(a) ((((CNID_XOR(major((a)->st_dev)) & 0xf) << 3) | \
122 (CNID_XOR(minor((a)->st_dev)) & 0x7)) << 24)
123 #define CNID_INODE(a) (((a)->st_ino ^ (((a)->st_ino & 0xff000000) >> 8)) \
125 #define CNID_FILE(a) (((a) & 0x1) << 31)
126 #define CNID(a,b) (CNID_DEV(a) | CNID_INODE(a) | CNID_FILE(b))
128 #define CNID(a,b) (((a)->st_ino & 0x7fffffff) | CNID_FILE(b))
139 #define AR_USEARCH (1<<0)
140 #define AR_UREAD (1<<1)
141 #define AR_UWRITE (1<<2)
142 #define AR_UOWN (1<<7)
144 extern struct dir *dirnew __P((const int));
145 extern void dirfree __P((struct dir *));
146 extern struct dir *dirsearch __P((const struct vol *, u_int32_t));
147 extern struct dir *adddir __P((struct vol *, struct dir *, char *,
148 int, char *, int, struct stat *));
149 extern struct dir *dirinsert __P((struct vol *, struct dir *));
150 extern int movecwd __P((const struct vol *, struct dir *));
151 extern int deletecurdir __P((const struct vol *, char *, int));
152 extern char *cname __P((const struct vol *, struct dir *,
154 extern mode_t mtoumode __P((struct maccess *));
155 extern void utommode __P((struct stat *, struct maccess *));
156 extern int getdirparams __P((const struct vol *, u_int16_t, char *,
157 struct dir *, struct stat *, char *, int *));
158 extern int setdirparams __P((const struct vol *, char *, u_int16_t, char *));
159 extern int renamedir __P((char *, char *, struct dir *,
160 struct dir *, char *, const int));
164 extern int afp_createdir __P((AFPObj *, char *, int, char *, int *));
165 extern int afp_opendir __P((AFPObj *, char *, int, char *, int *));
166 extern int afp_setdirparams __P((AFPObj *, char *, int, char *, int *));
167 extern int afp_closedir __P((AFPObj *, char *, int, char *, int *));
168 extern int afp_mapid __P((AFPObj *, char *, int, char *, int *));
169 extern int afp_mapname __P((AFPObj *, char *, int, char *, int *));
171 /* from enumerate.c */
172 extern int afp_enumerate __P((AFPObj *, char *, int, char *, int *));
173 extern int afp_catsearch __P((AFPObj *, char *, int, char *, int *));