]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/directory.h
First working IPC reconnect
[netatalk.git] / etc / afpd / directory.h
1 /*
2  * Copyright (c) 1990,1991 Regents of The University of Michigan.
3  * All Rights Reserved.
4  *
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.
14  *
15  *      Research Systems Unix Group
16  *      The University of Michigan
17  *      c/o Mike Clark
18  *      535 W. William Street
19  *      Ann Arbor, Michigan
20  *      +1-313-763-0525
21  *      netatalk@itd.umich.edu
22  */
23
24 #ifndef AFPD_DIRECTORY_H
25 #define AFPD_DIRECTORY_H 1
26
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>
31 #include <dirent.h>
32
33 /* sys/types.h usually snarfs in major/minor macros. if they don't
34  * try this file. */
35 #ifndef major
36 #include <sys/sysmacros.h>
37 #endif
38
39 #include <atalk/directory.h>
40 #include <atalk/globals.h>
41
42 #include "volume.h"
43
44 /* directory bits */
45 #define DIRPBIT_ATTR    0
46 #define DIRPBIT_PDID    1
47 #define DIRPBIT_CDATE   2
48 #define DIRPBIT_MDATE   3
49 #define DIRPBIT_BDATE   4
50 #define DIRPBIT_FINFO   5
51 #define DIRPBIT_LNAME   6
52 #define DIRPBIT_SNAME   7
53 #define DIRPBIT_DID     8
54 #define DIRPBIT_OFFCNT  9
55 #define DIRPBIT_UID     10
56 #define DIRPBIT_GID     11
57 #define DIRPBIT_ACCESS  12
58 #define DIRPBIT_PDINFO  13         /* ProDOS Info */
59 #define DIRPBIT_UNIXPR  15
60
61 #define FILDIRBIT_ISDIR        (1 << 7) /* is a directory */
62 #define FILDIRBIT_ISFILE       (0)      /* is a file */
63
64 /* file/directory ids. what a mess. we scramble things in a vain attempt
65  * to get something meaningful */
66 #ifndef AFS
67
68 #if 0
69 #define CNID_XOR(a)  (((a) >> 16) ^ (a))
70 #define CNID_DEV(a)   ((((CNID_XOR(major((a)->st_dev)) & 0xf) << 3) | \
71         (CNID_XOR(minor((a)->st_dev)) & 0x7)) << 24)
72 #define CNID_INODE(a) (((a)->st_ino ^ (((a)->st_ino & 0xff000000) >> 8)) \
73                                        & 0x00ffffff)
74 #define CNID_FILE(a)  (((a) & 0x1) << 31)
75 #define CNID(a,b)     (CNID_DEV(a) | CNID_INODE(a) | CNID_FILE(b))
76 #endif
77
78 #define CNID(a,b)     ((a)->st_ino & 0xffffffff)
79
80 #else /* AFS */
81 #define CNID(a,b)     (((a)->st_ino & 0x7fffffff) | CNID_FILE(b))
82 #endif /* AFS */
83
84 struct maccess {
85     u_char      ma_user;
86     u_char      ma_world;
87     u_char      ma_group;
88     u_char      ma_owner;
89 };
90
91 #define AR_USEARCH      (1<<0)
92 #define AR_UREAD        (1<<1)
93 #define AR_UWRITE       (1<<2)
94 #define AR_UOWN         (1<<7)
95
96 q_t *invalid_dircache_entries;
97
98 typedef int (*dir_loop)(struct dirent *, char *, void *);
99
100 extern void        dir_free_invalid_q(void);
101 extern struct dir  *dir_new(const char *mname, const char *uname, const struct vol *,
102                             cnid_t pdid, cnid_t did, bstring fullpath, struct stat *);
103 extern void        dir_free (struct dir *);
104 extern struct dir  *dir_add(struct vol *, const struct dir *, struct path *, int);
105 extern int         dir_modify(const struct vol *vol, struct dir *dir, cnid_t pdid, cnid_t did,
106                               const char *new_mname, const char *new_uname, bstring pdir_fullpath);
107 extern int         dir_remove(const struct vol *vol, struct dir *dir);
108 extern struct dir  *dirlookup (const struct vol *, cnid_t);
109 extern struct dir *dirlookup_bypath(const struct vol *vol, const char *path);
110
111 extern int         movecwd (const struct vol *, struct dir *);
112 extern struct path *cname (struct vol *, struct dir *, char **);
113
114 extern int         deletecurdir (struct vol *);
115 extern mode_t      mtoumode (struct maccess *);
116 extern void        utommode (struct stat *, struct maccess *);
117 extern int         getdirparams (const struct vol *, u_int16_t, struct path *,
118                                  struct dir *, char *, size_t *);
119
120 extern int         setdirparams(struct vol *, struct path *, u_int16_t, char *);
121 extern int         renamedir(const struct vol *, int, char *, char *, struct dir *,
122                              struct dir *, char *);
123 extern int         path_error(struct path *, int error);
124 extern void        setdiroffcnt(struct dir *dir, struct stat *st,  u_int32_t count);
125 extern int         dirreenumerate(struct dir *dir, struct stat *st);
126 extern int         for_each_dirent(const struct vol *, char *, dir_loop , void *);
127 extern int         check_access(char *name , int mode);
128 extern int         file_access(struct path *path, int mode);
129 extern int         netatalk_unlink (const char *name);
130 extern int         caseenumerate (const struct vol *, struct path *, struct dir *);
131
132 /* from enumerate.c */
133 extern char        *check_dirent (const struct vol *, char *);
134
135 /* FP functions */
136 int afp_createdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
137 int afp_opendir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
138 int afp_setdirparams (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
139 int afp_closedir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
140 int afp_mapid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
141 int afp_mapname (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
142 int afp_syncdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
143
144 /* from enumerate.c */
145 int afp_enumerate (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
146 int afp_enumerate_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
147 int afp_enumerate_ext2 (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
148
149 /* from catsearch.c */
150 int afp_catsearch (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
151 int afp_catsearch_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);
152
153 #endif