netatalk: directory.h Source File

netatalk 4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
include/atalk/directory.h
Go to the documentation of this file.
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 <arpa/inet.h>
28#include <dirent.h>
29#include <stdint.h>
30#include <sys/types.h>
31
32#include <bstrlib.h>
33
34#include <atalk/cnid.h>
35#include <atalk/queue.h>
36#include <atalk/unicode.h>
37
38/* setgid directories */
39#ifndef DIRBITS
40# define DIRBITS S_ISGID
41#endif /* DIRBITS */
42
43/* reserved directory id's */
44#define DIRDID_ROOT_PARENT htonl(1)
45#define DIRDID_ROOT htonl(2)
46
47/* struct dir.d_flags */
48#define DIRF_FSMASK (3<<0)
49#define DIRF_NOFS (0<<0)
50#define DIRF_UFS (1<<1)
51#define DIRF_ISFILE (1<<3)
52#define DIRF_OFFCNT (1<<4)
53#define DIRF_CNID (1<<5)
54#define DIRF_ARC_GHOST (1<<6)
55
56 struct dir { // NOSONAR (max 20 fields) — fields are intentionally grouped for cache locality
57 /* Fields requiring 8-byte alignment: pointers, time_t, ino_t, off_t */
58 bstring d_fullpath;
59 /* be careful here! if d_m_name == d_u_name, d_u_name
60 * will just point to the same storage as d_m_name !! */
61 bstring d_m_name;
62 bstring d_u_name;
63 ucs2_t *d_m_name_ucs2;
64 qnode_t *qidx_node;
65
66 /* Tier 2: Resource Fork data cache.
67 * Dynamically allocated buffer containing dcache_rlen bytes of rfork data.
68 * Freed automatically when the struct dir entry is evicted from dircache.
69 * Only populated for files with resource forks <= rfork_max_entry_size.
70 * NULL = not cached (may or may not have an rfork on disk).
71 * Buffer size is always dcache_rlen (Tier 1) — no separate size field needed.
72 * INVARIANT: dcache_rfork_buf != NULL implies dcache_rlen >= 0. */
73 void *dcache_rfork_buf;
74 qnode_t *rfork_lru_node;
75
76 time_t d_ctime;
78 time_t dcache_ctime;
80 ino_t dcache_ino;
82 time_t dcache_mtime;
83 off_t dcache_size;
84 off_t dcache_rlen;
88
89 /* Fields requiring 4-byte alignment: int, uint32_t, cnid_t, mode_t, uid_t, gid_t */
90 int d_flags;
91 cnid_t d_pdid;
92 cnid_t d_did;
93 uint32_t d_offcnt;
94 uint32_t d_rights_cache;
98 mode_t dcache_mode;
99 uid_t dcache_uid;
100 gid_t dcache_gid;
101
102 /* Fields requiring 2-byte alignment */
103 uint16_t d_vid;
105
106 /* === 1-byte + byte arrays (no alignment requirement, packed densely) === */
107 uint8_t
108 arc_list;
109
110 /* Cached AppleDouble metadata (Tier 1 AD cache).
111 * Populated from ad_metadata() via ad_store_to_cache().
112 * dcache_filedatesi stores the SERVED representation (not raw AD):
113 * the AD_DATE_MODIFY slot contains max(ad_mdate, st_mtime).
114 * Trusted implicitly (same model as stat fields). Invalidated by
115 * ctime-based validation or dir_modify(DCMOD_AD_INV) on AFP writes.
116 * Zero-initialized by calloc — zeros are valid defaults. */
117 uint8_t dcache_afpfilei[4];
118 uint8_t dcache_finderinfo[32];
119 uint8_t
120 dcache_filedatesi[16];
121};
122
123 struct path {
124 int m_type;
125 char *m_name;
126 char *u_name;
127 cnid_t id;
128 struct dir *d_dir;
129 int st_valid;
130 int st_errno;
131 struct stat st;
132};
133
134 static inline int path_isadir(struct path *o_path)
135{
136 return o_path->d_dir != NULL;
137#if 0
138 return o_path->m_name == '\0' || /* we are in a it */
139 !o_path->st_valid || /* in cache but we can't chdir in it */
140 /* not in cache and can't chdir */
141 (!o_path->st_errno && S_ISDIR(o_path->st.st_mode));
142#endif
143}
144
145/* directory.c */
146extern struct dir rootParent;
147
148#endif /* ATALK_DIRECTORY_H */
cnid_t
uint32_t cnid_t
Definition adouble.h:156
bstrlib.h
C implementaion of bstring functions.
bstring
struct tagbstring * bstring
Definition bstrlib.h:86
cnid.h
rootParent
struct dir rootParent
Definition directory.c:72
path_isadir
static int path_isadir(struct path *o_path)
Definition include/atalk/directory.h:134
queue.h
qnode_t
struct qnode qnode_t
dir
Definition include/atalk/directory.h:56
dir::d_ctime
time_t d_ctime
Definition include/atalk/directory.h:76
dir::d_vid
uint16_t d_vid
Definition include/atalk/directory.h:103
dir::dcache_ctime
time_t dcache_ctime
Definition include/atalk/directory.h:78
dir::dcache_size
off_t dcache_size
Definition include/atalk/directory.h:83
dir::dcache_ino
ino_t dcache_ino
Definition include/atalk/directory.h:80
dir::dcache_finderinfo
uint8_t dcache_finderinfo[32]
Definition include/atalk/directory.h:118
dir::dcache_rfork_buf
void * dcache_rfork_buf
Definition include/atalk/directory.h:73
dir::d_did
cnid_t d_did
Definition include/atalk/directory.h:92
dir::dcache_mode
mode_t dcache_mode
Definition include/atalk/directory.h:98
dir::dcache_uid
uid_t dcache_uid
Definition include/atalk/directory.h:99
dir::dcache_afpfilei
uint8_t dcache_afpfilei[4]
Definition include/atalk/directory.h:117
dir::qidx_node
qnode_t * qidx_node
Definition include/atalk/directory.h:64
dir::d_fullpath
bstring d_fullpath
Definition include/atalk/directory.h:58
dir::d_m_name_ucs2
ucs2_t * d_m_name_ucs2
Definition include/atalk/directory.h:63
dir::d_rights_cache
uint32_t d_rights_cache
Definition include/atalk/directory.h:94
dir::dcache_mtime
time_t dcache_mtime
Definition include/atalk/directory.h:82
dir::dcache_gid
gid_t dcache_gid
Definition include/atalk/directory.h:100
dir::d_flags
int d_flags
Definition include/atalk/directory.h:90
dir::rfork_lru_node
qnode_t * rfork_lru_node
Definition include/atalk/directory.h:74
dir::arc_list
uint8_t arc_list
Definition include/atalk/directory.h:108
dir::d_offcnt
uint32_t d_offcnt
Definition include/atalk/directory.h:93
dir::dcache_filedatesi
uint8_t dcache_filedatesi[16]
Definition include/atalk/directory.h:120
dir::d_m_name
bstring d_m_name
Definition include/atalk/directory.h:61
dir::d_u_name
bstring d_u_name
Definition include/atalk/directory.h:62
dir::d_pdid
cnid_t d_pdid
Definition include/atalk/directory.h:91
dir::dcache_rlen
off_t dcache_rlen
Definition include/atalk/directory.h:84
path
Definition include/atalk/directory.h:123
path::u_name
char * u_name
Definition include/atalk/directory.h:126
path::st_valid
int st_valid
Definition include/atalk/directory.h:129
path::st
struct stat st
Definition include/atalk/directory.h:131
path::m_type
int m_type
Definition include/atalk/directory.h:124
path::st_errno
int st_errno
Definition include/atalk/directory.h:130
path::id
cnid_t id
Definition include/atalk/directory.h:127
path::d_dir
struct dir * d_dir
Definition include/atalk/directory.h:128
path::m_name
char * m_name
Definition include/atalk/directory.h:125
unicode.h
ucs2_t
#define ucs2_t
Definition unicode.h:8
NULL
#define NULL
Definition utf8util.c:47