2 * $Id: directory.h,v 1.33.4.1 2010-02-01 10:56:08 franklahm Exp $
4 * Copyright (c) 1990,1991 Regents of The University of Michigan.
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.
17 * Research Systems Unix Group
18 * The University of Michigan
20 * 535 W. William Street
23 * netatalk@itd.umich.edu
26 #ifndef AFPD_DIRECTORY_H
27 #define AFPD_DIRECTORY_H 1
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>
35 /* sys/types.h usually snarfs in major/minor macros. if they don't
38 #include <sys/sysmacros.h>
41 #include <atalk/directory.h>
46 #define DIRF_FSMASK (3<<0)
47 #define DIRF_NOFS (0<<0)
48 #define DIRF_AFS (1<<0)
49 #define DIRF_UFS (2<<0)
51 #define DIRF_OFFCNT (1<<4) /* offsprings count is valid */
52 #define DIRF_CNID (1<<5) /* renumerate id */
54 #define AFPDIR_READ (1<<0)
57 #define DIRPBIT_ATTR 0
58 #define DIRPBIT_PDID 1
59 #define DIRPBIT_CDATE 2
60 #define DIRPBIT_MDATE 3
61 #define DIRPBIT_BDATE 4
62 #define DIRPBIT_FINFO 5
63 #define DIRPBIT_LNAME 6
64 #define DIRPBIT_SNAME 7
66 #define DIRPBIT_OFFCNT 9
67 #define DIRPBIT_UID 10
68 #define DIRPBIT_GID 11
69 #define DIRPBIT_ACCESS 12
70 #define DIRPBIT_PDINFO 13 /* ProDOS Info */
71 #define DIRPBIT_UNIXPR 15
73 #define FILDIRBIT_ISDIR (1 << 7) /* is a directory */
74 #define FILDIRBIT_ISFILE (0) /* is a file */
76 /* file/directory ids. what a mess. we scramble things in a vain attempt
77 * to get something meaningful */
81 #define CNID_XOR(a) (((a) >> 16) ^ (a))
82 #define CNID_DEV(a) ((((CNID_XOR(major((a)->st_dev)) & 0xf) << 3) | \
83 (CNID_XOR(minor((a)->st_dev)) & 0x7)) << 24)
84 #define CNID_INODE(a) (((a)->st_ino ^ (((a)->st_ino & 0xff000000) >> 8)) \
86 #define CNID_FILE(a) (((a) & 0x1) << 31)
87 #define CNID(a,b) (CNID_DEV(a) | CNID_INODE(a) | CNID_FILE(b))
90 #define CNID(a,b) ((a)->st_ino & 0xffffffff)
93 #define CNID(a,b) (((a)->st_ino & 0x7fffffff) | CNID_FILE(b))
103 #define AR_USEARCH (1<<0)
104 #define AR_UREAD (1<<1)
105 #define AR_UWRITE (1<<2)
106 #define AR_UOWN (1<<7)
108 typedef int (*dir_loop)(struct dirent *, char *, void *);
110 extern struct dir *dir_new(const char *mname, const char *uname, const struct vol *, cnid_t pdid, cnid_t did, bstring fullpath); /* volume.c needs it once */
111 extern void dir_free (struct dir *);
112 extern struct dir *dir_add(const struct vol *, const struct dir *, struct path *, int);
113 extern int dir_modify(const struct vol *vol, struct dir *dir, cnid_t pdid, cnid_t did, const char *new_mname, const char *new_uname, bstring pdir_fullpath);
114 extern int dir_remove(const struct vol *vol, struct dir *dir);
115 extern struct dir *dirlookup (const struct vol *, cnid_t);
116 extern int movecwd (const struct vol *, struct dir *);
117 extern struct path *cname (struct vol *, struct dir *, char **);
119 extern int deletecurdir (struct vol *);
120 extern mode_t mtoumode (struct maccess *);
121 extern void utommode (struct stat *, struct maccess *);
122 extern int getdirparams (const struct vol *, u_int16_t, struct path *,
123 struct dir *, char *, size_t *);
124 extern int setdirparams (struct vol *, struct path *, u_int16_t, char *);
125 extern int renamedir (const struct vol *, char *, char *, struct dir *,
126 struct dir *, char *);
127 extern int path_error (struct path *, int error);
128 extern void setdiroffcnt (struct dir *dir, struct stat *st, u_int32_t count);
129 extern int dirreenumerate (struct dir *dir, struct stat *st);
130 extern int for_each_dirent (const struct vol *, char *, dir_loop , void *);
131 extern int check_access (char *name , int mode);
132 extern int file_access (struct path *path, int mode);
133 extern int netatalk_unlink (const char *name);
134 extern int caseenumerate (const struct vol *, struct path *, struct dir *);
135 /* from enumerate.c */
136 extern char *check_dirent (const struct vol *, char *);
139 int afp_createdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
140 int afp_opendir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
141 int afp_setdirparams (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
142 int afp_closedir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
143 int afp_mapid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
144 int afp_mapname (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
145 int afp_syncdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
147 /* from enumerate.c */
148 int afp_enumerate (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
149 int afp_enumerate_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
150 int afp_enumerate_ext2 (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
152 /* from catsearch.c */
153 int afp_catsearch (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);
154 int afp_catsearch_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen);