diff options
Diffstat (limited to 'firmware/include/dircache.h')
-rw-r--r-- | firmware/include/dircache.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h index 7e8c764e7f..d73c6f6e81 100644 --- a/firmware/include/dircache.h +++ b/firmware/include/dircache.h | |||
@@ -57,6 +57,15 @@ | |||
57 | figure pessimistic */ | 57 | figure pessimistic */ |
58 | typedef uint32_t dc_serial_t; | 58 | typedef uint32_t dc_serial_t; |
59 | 59 | ||
60 | /* these should agree with size of dc_serial_t */ | ||
61 | #define DC_SERHASH_START 0xffffffff | ||
62 | |||
63 | /* I was originally using FNV hash but decided this is probably okay | ||
64 | (for now) */ | ||
65 | #define dc_hash_serialnum(s, h) \ | ||
66 | ({ dc_serial_t __x = (s); crc_32(&(__x), sizeof(dc_serial_t), (h)); }) | ||
67 | #define DC_SERIAL_FMT "0x%08lX" | ||
68 | |||
60 | /** | 69 | /** |
61 | ****************************************************************************/ | 70 | ****************************************************************************/ |
62 | 71 | ||
@@ -132,10 +141,33 @@ void dircache_fileop_sync(struct file_base_binding *infop, | |||
132 | const struct dirinfo_native *dinp); | 141 | const struct dirinfo_native *dinp); |
133 | 142 | ||
134 | 143 | ||
135 | /** Dircache paths and files **/ | 144 | /** Dircache paths, files and shortcuts **/ |
136 | ssize_t dircache_get_path(const struct dircache_file *dcfilep, char *buf, | 145 | struct dircache_fileref |
137 | size_t size); | 146 | { |
138 | int dircache_get_file(const char *path, struct dircache_file *dcfilep); | 147 | struct dircache_file dcfile; |
148 | dc_serial_t serialhash; /* Hash of serialnumbers to root */ | ||
149 | }; | ||
150 | |||
151 | void dircache_fileref_init(struct dircache_fileref *dcfrefp); | ||
152 | ssize_t dircache_get_fileref_path(const struct dircache_fileref *dcfrefp, | ||
153 | char *buf, size_t size); | ||
154 | |||
155 | /* Bitflags for dircache_search() */ | ||
156 | enum dircache_search_flags | ||
157 | { | ||
158 | DCS_FILEREF = 0x01, /* Check fileref existence and serial number */ | ||
159 | _DCS_VERIFY_FLAG = 0x02, /* Internal: Only valid with DCS_FILEREF */ | ||
160 | DCS_FILEREF_VERIFY = 0x03, /* Do DCS_FILEREF check + verify serial hash */ | ||
161 | DCS_CACHED_PATH = 0x04, /* Check only cache for provided path */ | ||
162 | _DCS_STORAGE_FLAG = 0x08, /* Internal: Only valid with DCS_CACHED_PATH */ | ||
163 | DCS_STORAGE_PATH = 0x0c, /* Read-through if needed for provided path */ | ||
164 | DCS_UPDATE_FILEREF = 0x10, /* If fileref is not valid but path is found or | ||
165 | searching a path, update the reference | ||
166 | information */ | ||
167 | }; | ||
168 | |||
169 | int dircache_search(unsigned int flags, struct dircache_fileref *dcfrefp, | ||
170 | const char *path); | ||
139 | 171 | ||
140 | 172 | ||
141 | /** Debug screen/info stuff **/ | 173 | /** Debug screen/info stuff **/ |