]> arthur.barton.de Git - netatalk.git/blob - include/atalk/directory.h
17e5d08762468e2555d2b2396a5baba3e052da93
[netatalk.git] / include / atalk / directory.h
1 /*
2  * $Id: directory.h,v 1.3 2010-01-10 10:58:25 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     ucs2_t      *d_m_name_ucs2;       /* mac name as UCS2 */
63 };
64
65 struct path {
66     int         m_type;             /* mac name type (long name, unicode */
67     char        *m_name;            /* mac name */
68     char        *u_name;            /* unix name */
69     cnid_t      id;                 /* file id (only for getmetadata) */
70     struct dir  *d_dir;             /* */
71     int         st_valid;           /* does st_errno and st set */
72     int         st_errno;
73     struct stat st;
74 };
75
76 static inline int path_isadir(struct path *o_path)
77 {
78     return o_path->d_dir != NULL;
79 #if 0
80     return o_path->m_name == '\0' || /* we are in a it */
81            !o_path->st_valid ||      /* in cache but we can't chdir in it */ 
82            (!o_path->st_errno && S_ISDIR(o_path->st.st_mode)); /* not in cache an can't chdir */
83 #endif
84 }
85
86
87 #endif /* ATALK_DIRECTORY_H */