]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/directory.h
Convert afp_moveandrename and all called funcs to XXXat semantics if available
[netatalk.git] / etc / afpd / directory.h
1 /*
2  * $Id: directory.h,v 1.34 2010-03-12 15:16:49 franklahm Exp $
3  *
4  * Copyright (c) 1990,1991 Regents of The University of Michigan.
5  * All Rights Reserved.
6  *
7  * Permission to use, copy, modify, and distribute this software and
8  * its documentation for any purpose and without fee is hereby granted,
9  * provided that the above copyright notice appears in all copies and
10  * that both that copyright notice and this permission notice appear
11  * in supporting documentation, and that the name of The University
12  * of Michigan not be used in advertising or publicity pertaining to
13  * distribution of the software without specific, written prior
14  * permission. This software is supplied as is without expressed or
15  * implied warranties of any kind.
16  *
17  *      Research Systems Unix Group
18  *      The University of Michigan
19  *      c/o Mike Clark
20  *      535 W. William Street
21  *      Ann Arbor, Michigan
22  *      +1-313-763-0525
23  *      netatalk@itd.umich.edu
24  */
25
26 #ifndef AFPD_DIRECTORY_H
27 #define AFPD_DIRECTORY_H 1
28
29 #include <sys/cdefs.h>
30 #include <sys/types.h>
31 /*#include <sys/stat.h>*/ /* including it here causes some confusion */
32 #include <netatalk/endian.h>
33 #include <dirent.h>
34
35 /* sys/types.h usually snarfs in major/minor macros. if they don't
36  * try this file. */
37 #ifndef major
38 #include <sys/sysmacros.h>
39 #endif
40
41 #include <atalk/directory.h>
42
43 #include "globals.h"
44 #include "volume.h"
45
46 #define DIRTREE_COLOR_RED    0
47 #define DIRTREE_COLOR_BLACK  1
48
49 #define DIRF_FSMASK     (3<<0)
50 #define DIRF_NOFS       (0<<0)
51 #define DIRF_AFS        (1<<0)
52 #define DIRF_UFS        (2<<0)
53
54 #define DIRF_OFFCNT     (1<<4)  /* offsprings count is valid */
55 #define DIRF_CNID       (1<<5)  /* renumerate id */
56
57 #define AFPDIR_READ     (1<<0)
58
59 /* directory bits */
60 #define DIRPBIT_ATTR    0
61 #define DIRPBIT_PDID    1
62 #define DIRPBIT_CDATE   2
63 #define DIRPBIT_MDATE   3
64 #define DIRPBIT_BDATE   4
65 #define DIRPBIT_FINFO   5
66 #define DIRPBIT_LNAME   6
67 #define DIRPBIT_SNAME   7
68 #define DIRPBIT_DID     8
69 #define DIRPBIT_OFFCNT  9
70 #define DIRPBIT_UID     10
71 #define DIRPBIT_GID     11
72 #define DIRPBIT_ACCESS  12
73 #define DIRPBIT_PDINFO  13         /* ProDOS Info */
74 #define DIRPBIT_UNIXPR  15
75
76 #define FILDIRBIT_ISDIR        (1 << 7) /* is a directory */
77 #define FILDIRBIT_ISFILE       (0)      /* is a file */
78
79 /* reserved directory id's */
80 #define DIRDID_ROOT_PARENT    htonl(1)  /* parent directory of root */
81 #define DIRDID_ROOT           htonl(2)  /* root directory */
82
83 /* file/directory ids. what a mess. we scramble things in a vain attempt
84  * to get something meaningful */
85 #ifndef AFS
86
87 #if 0
88 #define CNID_XOR(a)  (((a) >> 16) ^ (a))
89 #define CNID_DEV(a)   ((((CNID_XOR(major((a)->st_dev)) & 0xf) << 3) | \
90         (CNID_XOR(minor((a)->st_dev)) & 0x7)) << 24)
91 #define CNID_INODE(a) (((a)->st_ino ^ (((a)->st_ino & 0xff000000) >> 8)) \
92                                        & 0x00ffffff)
93 #define CNID_FILE(a)  (((a) & 0x1) << 31)
94 #define CNID(a,b)     (CNID_DEV(a) | CNID_INODE(a) | CNID_FILE(b))
95 #endif
96
97 #define CNID(a,b)     ((a)->st_ino & 0xffffffff)
98
99 #else /* AFS */
100 #define CNID(a,b)     (((a)->st_ino & 0x7fffffff) | CNID_FILE(b))
101 #endif /* AFS */
102
103
104 struct maccess {
105     u_char      ma_user;
106     u_char      ma_world;
107     u_char      ma_group;
108     u_char      ma_owner;
109 };
110
111 #define AR_USEARCH      (1<<0)
112 #define AR_UREAD        (1<<1)
113 #define AR_UWRITE       (1<<2)
114 #define AR_UOWN         (1<<7)
115
116 extern struct dir       *dirnew (const char *, const char *);
117 extern void             dirfreename (struct dir *);
118 extern void             dirfree (struct dir *);
119 extern struct dir       *dirsearch (const struct vol *, u_int32_t);
120 extern struct dir       *dirlookup (struct vol *, u_int32_t);
121 extern struct dir       *dirsearch_byname (const struct vol *, struct dir *,char *);
122
123 extern struct dir       *adddir (struct vol *, struct dir *, 
124                                                struct path *);
125
126 extern int              movecwd (struct vol *, struct dir *);
127 extern int              deletecurdir (struct vol *);
128 extern struct path      *cname (struct vol *, struct dir *,
129                              char **);
130 extern mode_t           mtoumode (struct maccess *);
131 extern void             utommode (struct stat *, struct maccess *);
132 extern int getdirparams (const struct vol *, u_int16_t, struct path *,
133                                  struct dir *, char *, size_t *);
134 extern int setdirparams (struct vol *, struct path *, u_int16_t, char *);
135 extern int renamedir(const struct vol *, int, char *, char *, struct dir *,
136                      struct dir *, char *);
137 extern int path_error (struct path *, int error);
138
139 extern void setdiroffcnt (struct dir *dir, struct stat *st,  u_int32_t count);
140 extern int dirreenumerate (struct dir *dir, struct stat *st);
141
142 typedef int (*dir_loop)(struct dirent *, char *, void *);
143
144 extern int  for_each_dirent (const struct vol *, char *, dir_loop , void *);
145
146 extern int  check_access (char *name , int mode);
147 extern int file_access   (struct path *path, int mode);
148
149 extern int netatalk_unlink (const char *name);
150
151 extern int caseenumerate (const struct vol *, struct path *, struct dir *);
152
153 extern hash_t *dirhash (void);
154 /* from enumerate.c */
155 extern char *check_dirent (const struct vol *, char *);
156
157 /* FP functions */
158 int afp_createdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
159 int afp_opendir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
160 int afp_setdirparams (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
161 int afp_closedir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
162 int afp_mapid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
163 int afp_mapname (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
164 int afp_syncdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
165
166 /* from enumerate.c */
167 int afp_enumerate (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
168 int afp_enumerate_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
169 int afp_enumerate_ext2 (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
170
171 /* from catsearch.c */
172 int afp_catsearch (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
173 int afp_catsearch_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
174
175 #endif