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/types.h>
28 #include <arpa/inet.h>
31 /* sys/types.h usually snarfs in major/minor macros. if they don't
34 #include <sys/sysmacros.h>
37 #include <atalk/directory.h>
38 #include <atalk/globals.h>
43 #define DIRPBIT_ATTR 0
44 #define DIRPBIT_PDID 1
45 #define DIRPBIT_CDATE 2
46 #define DIRPBIT_MDATE 3
47 #define DIRPBIT_BDATE 4
48 #define DIRPBIT_FINFO 5
49 #define DIRPBIT_LNAME 6
50 #define DIRPBIT_SNAME 7
52 #define DIRPBIT_OFFCNT 9
53 #define DIRPBIT_UID 10
54 #define DIRPBIT_GID 11
55 #define DIRPBIT_ACCESS 12
56 #define DIRPBIT_PDINFO 13 /* ProDOS Info */
57 #define DIRPBIT_UNIXPR 15
59 #define FILDIRBIT_ISDIR (1 << 7) /* is a directory */
60 #define FILDIRBIT_ISFILE (0) /* is a file */
62 /* file/directory ids. what a mess. we scramble things in a vain attempt
63 * to get something meaningful */
67 #define CNID_XOR(a) (((a) >> 16) ^ (a))
68 #define CNID_DEV(a) ((((CNID_XOR(major((a)->st_dev)) & 0xf) << 3) | \
69 (CNID_XOR(minor((a)->st_dev)) & 0x7)) << 24)
70 #define CNID_INODE(a) (((a)->st_ino ^ (((a)->st_ino & 0xff000000) >> 8)) \
72 #define CNID_FILE(a) (((a) & 0x1) << 31)
73 #define CNID(a,b) (CNID_DEV(a) | CNID_INODE(a) | CNID_FILE(b))
76 #define CNID(a,b) ((a)->st_ino & 0xffffffff)
79 #define CNID(a,b) (((a)->st_ino & 0x7fffffff) | CNID_FILE(b))
89 #define AR_USEARCH (1<<0)
90 #define AR_UREAD (1<<1)
91 #define AR_UWRITE (1<<2)
92 #define AR_UOWN (1<<7)
94 q_t *invalid_dircache_entries;
96 typedef int (*dir_loop)(struct dirent *, char *, void *);
98 extern void dir_free_invalid_q(void);
99 extern struct dir *dir_new(const char *mname, const char *uname, const struct vol *,
100 cnid_t pdid, cnid_t did, bstring fullpath, struct stat *);
101 extern void dir_free (struct dir *);
102 extern struct dir *dir_add(struct vol *, const struct dir *, struct path *, int);
103 extern int dir_modify(const struct vol *vol, struct dir *dir, cnid_t pdid, cnid_t did,
104 const char *new_mname, const char *new_uname, bstring pdir_fullpath);
105 extern int dir_remove(const struct vol *vol, struct dir *dir);
106 extern struct dir *dirlookup (const struct vol *, cnid_t);
107 extern struct dir *dirlookup_bypath(const struct vol *vol, const char *path);
109 extern int movecwd (const struct vol *, struct dir *);
110 extern struct path *cname (struct vol *, struct dir *, char **);
112 extern int deletecurdir (struct vol *);
113 extern mode_t mtoumode (struct maccess *);
114 extern int getdirparams (const AFPObj *obj, const struct vol *, uint16_t, struct path *,
115 struct dir *, char *, size_t *);
117 extern int setdirparams(struct vol *, struct path *, uint16_t, char *);
118 extern int renamedir(const struct vol *, int, char *, char *, struct dir *,
119 struct dir *, char *);
120 extern int path_error(struct path *, int error);
121 extern void setdiroffcnt(struct dir *dir, struct stat *st, uint32_t count);
122 extern int dirreenumerate(struct dir *dir, struct stat *st);
123 extern int for_each_dirent(const struct vol *, char *, dir_loop , void *);
124 extern int check_access(const AFPObj *obj, struct vol *, char *name , int mode);
125 extern int file_access(const AFPObj *obj, struct vol *vol, struct path *path, int mode);
126 extern int netatalk_unlink (const char *name);
128 /* from enumerate.c */
129 extern char *check_dirent (const struct vol *, char *);
132 int afp_createdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
133 int afp_opendir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
134 int afp_setdirparams (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
135 int afp_closedir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
136 int afp_mapid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
137 int afp_mapname (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
138 int afp_syncdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
140 /* from enumerate.c */
141 int afp_enumerate (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
142 int afp_enumerate_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
143 int afp_enumerate_ext2 (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
145 /* from catsearch.c */
146 int afp_catsearch (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
147 int afp_catsearch_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);