]> arthur.barton.de Git - netatalk.git/blob - include/atalk/directory.h
Merge from branch-2-1
[netatalk.git] / include / atalk / directory.h
1 /*
2  * $Id: directory.h,v 1.3.2.1 2010-02-01 10:56:08 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 #include <stdint.h>
34
35 #include <atalk/cnid.h>
36 #include <atalk/bstrlib.h>
37 #include <atalk/queue.h>
38
39 /* setgid directories */
40 #ifndef DIRBITS
41 # ifdef AFS
42 #  define DIRBITS 0
43 # else /* AFS */
44 #  define DIRBITS S_ISGID
45 # endif /* AFS */
46 #endif /* DIRBITS */
47
48 /* reserved directory id's */
49 #define DIRDID_ROOT_PARENT    htonl(1)  /* parent directory of root */
50 #define DIRDID_ROOT           htonl(2)  /* root directory */
51
52 struct dir {
53     bstring     d_fullpath;          /* complete unix path to dir */
54     bstring     d_m_name;            /* mac name */
55     bstring     d_u_name;            /* unix name                                          */
56                                      /* be careful here! if d_m_name == d_u_name, d_u_name */
57                                      /* will just point to the same storage as d_m_name !! */
58     ucs2_t      *d_m_name_ucs2;       /* mac name as UCS2 */
59     qnode_t     *qidx_node;           /* pointer to position in queue index */
60     void        *d_ofork;             /* oforks using this directory. */
61     time_t      ctime;                /* inode ctime */
62     int         d_flags;              /* directory flags */
63     cnid_t      d_pdid;               /* CNID of parent directory */
64     cnid_t      d_did;                /* CNID of directory */
65     uint32_t    offcnt;               /* offspring count */
66     uint16_t    d_vid;                /* only needed in the dircache, because
67                                          we put all directories in one cache. */
68 };
69
70 struct path {
71     int         m_type;             /* mac name type (long name, unicode */
72     char        *m_name;            /* mac name */
73     char        *u_name;            /* unix name */
74     cnid_t      id;                 /* file id (only for getmetadata) */
75     struct dir  *d_dir;             /* */
76     int         st_valid;           /* does st_errno and st set */
77     int         st_errno;
78     struct stat st;
79 };
80
81 static inline int path_isadir(struct path *o_path)
82 {
83     return o_path->d_dir != NULL;
84 #if 0
85     return o_path->m_name == '\0' || /* we are in a it */
86            !o_path->st_valid ||      /* in cache but we can't chdir in it */ 
87            (!o_path->st_errno && S_ISDIR(o_path->st.st_mode)); /* not in cache an can't chdir */
88 #endif
89 }
90
91 #endif /* ATALK_DIRECTORY_H */