]> arthur.barton.de Git - netatalk.git/blob - include/atalk/directory.h
Use way faster hashing algorithm for dirs
[netatalk.git] / include / atalk / directory.h
1 /*
2  * $Id: directory.h,v 1.2 2009-11-19 10:37:44 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 ATALK_DIRECTORY_H
27 #define ATALK_DIRECTORY_H 1
28
29 #include <sys/cdefs.h>
30 #include <sys/types.h>
31 #include <netatalk/endian.h>
32 #include <dirent.h>
33
34 #include <atalk/cnid.h>
35 #include <atalk/directory.h>
36
37 /* setgid directories */
38 #ifndef DIRBITS
39 # ifdef AFS
40 #  define DIRBITS 0
41 # else /* AFS */
42 #  define DIRBITS S_ISGID
43 # endif /* AFS */
44 #endif /* DIRBITS */
45
46 /* the did tree is now a red-black tree while the parent/child
47  * tree is a circular doubly-linked list. how exciting. */
48 struct dir {
49     struct dir  *d_left, *d_right, *d_back; /* for red-black tree */
50     int         d_color;
51     struct dir  *d_parent, *d_child; /* parent-child */
52     struct dir  *d_prev, *d_next;    /* siblings */
53     void        *d_ofork;            /* oforks using this directory. */
54     u_int32_t   d_did;
55     int         d_flags;
56
57     time_t      ctime;                /* inode ctime */
58     u_int32_t   offcnt;               /* offspring count */
59
60     char        *d_m_name;            /* mac name */
61     char        *d_u_name;            /* unix name */
62     size_t      d_u_name_len;         /* Length of unix name
63                                          MUST be initialized from d_u_name !!*/
64     ucs2_t      *d_m_name_ucs2;       /* mac name as UCS2 */
65 };
66
67 struct path {
68     int         m_type;             /* mac name type (long name, unicode */
69     char        *m_name;            /* mac name */
70     char        *u_name;            /* unix name */
71     cnid_t      id;                 /* file id (only for getmetadata) */
72     struct dir  *d_dir;             /* */
73     int         st_valid;           /* does st_errno and st set */
74     int         st_errno;
75     struct stat st;
76 };
77
78 static inline int path_isadir(struct path *o_path)
79 {
80     return o_path->d_dir != NULL;
81 #if 0
82     return o_path->m_name == '\0' || /* we are in a it */
83            !o_path->st_valid ||      /* in cache but we can't chdir in it */ 
84            (!o_path->st_errno && S_ISDIR(o_path->st.st_mode)); /* not in cache an can't chdir */
85 #endif
86 }
87
88
89 #endif /* ATALK_DIRECTORY_H */