]> arthur.barton.de Git - netatalk.git/blob - include/atalk/directory.h
Merge master
[netatalk.git] / include / atalk / directory.h
1 /*
2  * Copyright (c) 1990,1991 Regents of The University of Michigan.
3  * All Rights Reserved.
4  *
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.
14  *
15  *      Research Systems Unix Group
16  *      The University of Michigan
17  *      c/o Mike Clark
18  *      535 W. William Street
19  *      Ann Arbor, Michigan
20  *      +1-313-763-0525
21  *      netatalk@itd.umich.edu
22  */
23
24 #ifndef ATALK_DIRECTORY_H
25 #define ATALK_DIRECTORY_H 1
26
27 #include <sys/types.h>
28 #include <arpa/inet.h>
29 #include <dirent.h>
30 #include <stdint.h>
31
32 #include <atalk/cnid.h>
33 #include <atalk/bstrlib.h>
34 #include <atalk/queue.h>
35
36 /* setgid directories */
37 #ifndef DIRBITS
38 # ifdef AFS
39 #  define DIRBITS 0
40 # else /* AFS */
41 #  define DIRBITS S_ISGID
42 # endif /* AFS */
43 #endif /* DIRBITS */
44
45 /* reserved directory id's */
46 #define DIRDID_ROOT_PARENT    htonl(1)  /* parent directory of root */
47 #define DIRDID_ROOT           htonl(2)  /* root directory */
48
49 /* struct dir.d_flags */
50 #define DIRF_FSMASK        (3<<0)
51 #define DIRF_NOFS          (0<<0)
52 #define DIRF_AFS           (1<<0)
53 #define DIRF_UFS           (1<<1)
54 #define DIRF_ISFILE    (1<<3) /* it's cached file, not a directory */
55 #define DIRF_OFFCNT    (1<<4) /* offsprings count is valid */
56 #define DIRF_CNID          (1<<5) /* renumerate id */
57
58 struct dir {
59     bstring     d_fullpath;          /* complete unix path to dir (or file) */
60     bstring     d_m_name;            /* mac name */
61     bstring     d_u_name;            /* unix name                                          */
62                                      /* be careful here! if d_m_name == d_u_name, d_u_name */
63                                      /* will just point to the same storage as d_m_name !! */
64     ucs2_t      *d_m_name_ucs2;       /* mac name as UCS2 */
65     qnode_t     *qidx_node;           /* pointer to position in queue index */
66     time_t      d_ctime;                /* inode ctime, used and modified by reenumeration */
67
68     int         d_flags;              /* directory flags */
69     cnid_t      d_pdid;               /* CNID of parent directory */
70     cnid_t      d_did;                /* CNID of directory */
71     uint32_t    d_offcnt;             /* offspring count */
72     uint16_t    d_vid;                /* only needed in the dircache, because
73                                          we put all directories in one cache. */
74     uint32_t    d_rights_cache;       /* cached rights combinded from mode and possible ACL */
75
76     /* Stuff used in the dircache */
77     time_t      dcache_ctime;         /* inode ctime, used and modified by dircache */
78     ino_t       dcache_ino;           /* inode number, used to detect changes in the dircache */
79 };
80
81 struct path {
82     int         m_type;             /* mac name type (long name, unicode */
83     char        *m_name;            /* mac name */
84     char        *u_name;            /* unix name */
85     cnid_t      id;                 /* file id (only for getmetadata) */
86     struct dir  *d_dir;             /* */
87     int         st_valid;           /* does st_errno and st set */
88     int         st_errno;
89     struct stat st;
90 };
91
92 static inline int path_isadir(struct path *o_path)
93 {
94     return o_path->d_dir != NULL;
95 #if 0
96     return o_path->m_name == '\0' || /* we are in a it */
97            !o_path->st_valid ||      /* in cache but we can't chdir in it */ 
98            (!o_path->st_errno && S_ISDIR(o_path->st.st_mode)); /* not in cache an can't chdir */
99 #endif
100 }
101
102 #endif /* ATALK_DIRECTORY_H */