summaryrefslogtreecommitdiffstats
path: root/firmware/include/dircache.h
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-01-08 17:14:10 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-01-17 14:35:36 -0500
commita931c76b3a46d1884e985a3bfc82b947521dab97 (patch)
tree1141cf9a9a8c123bde3d76d147ee1e910c7c6045 /firmware/include/dircache.h
parent0056ea8a256af0e2daaf451af43c00708a31d4df (diff)
downloadrockbox-a931c76b3a46d1884e985a3bfc82b947521dab97.tar.gz
rockbox-a931c76b3a46d1884e985a3bfc82b947521dab97.zip
Do some debug and preparatory work for ramcache and playlist
The file system rework introduced incompatibility between dircache and the tagcache ramcache and playlist dircache path caching. This update makes changes to filesystem code to reintegrate all that. It also fixes a couple bugs that were found when vetting all the code. The filestream cache was being reset without regard to the stream even if it was shared in write mode (made work of .playlist_control). Better handling of unmounting gives files a better go at force-closing them without risk to disk integrity. Did some miscellaneous pedantic changes. Improved efficiency of testing a file's existence (a little) since the path parser will be shared between file code and parsing for the sake of finding dircache references, not duplicated as before. This commit doesn't reenable said items just for the sake of keeping changes separate and related. Plan for the next is to enable dircache again for the playlists (easy peasy) and reenable tagcache ramcache but *without* the dircache path caching because it's rather substantial to change in itself. The ramcache will still function without dircache. Change-Id: I7e2a9910b866251fa8333e1275f72fcfc8425d2d
Diffstat (limited to 'firmware/include/dircache.h')
-rw-r--r--firmware/include/dircache.h40
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 @@
figure pessimistic */
typedef uint32_t dc_serial_t;
+/* these should agree with size of dc_serial_t */
+#define DC_SERHASH_START 0xffffffff
+
+/* I was originally using FNV hash but decided this is probably okay
+ (for now) */
+#define dc_hash_serialnum(s, h) \
+ ({ dc_serial_t __x = (s); crc_32(&(__x), sizeof(dc_serial_t), (h)); })
+#define DC_SERIAL_FMT "0x%08lX"
+
/**
****************************************************************************/
@@ -132,10 +141,33 @@ void dircache_fileop_sync(struct file_base_binding *infop,
const struct dirinfo_native *dinp);
-/** Dircache paths and files **/
-ssize_t dircache_get_path(const struct dircache_file *dcfilep, char *buf,
- size_t size);
-int dircache_get_file(const char *path, struct dircache_file *dcfilep);
+/** Dircache paths, files and shortcuts **/
+struct dircache_fileref
+{
+ struct dircache_file dcfile;
+ dc_serial_t serialhash; /* Hash of serialnumbers to root */
+};
+
+void dircache_fileref_init(struct dircache_fileref *dcfrefp);
+ssize_t dircache_get_fileref_path(const struct dircache_fileref *dcfrefp,
+ char *buf, size_t size);
+
+/* Bitflags for dircache_search() */
+enum dircache_search_flags
+{
+ DCS_FILEREF = 0x01, /* Check fileref existence and serial number */
+ _DCS_VERIFY_FLAG = 0x02, /* Internal: Only valid with DCS_FILEREF */
+ DCS_FILEREF_VERIFY = 0x03, /* Do DCS_FILEREF check + verify serial hash */
+ DCS_CACHED_PATH = 0x04, /* Check only cache for provided path */
+ _DCS_STORAGE_FLAG = 0x08, /* Internal: Only valid with DCS_CACHED_PATH */
+ DCS_STORAGE_PATH = 0x0c, /* Read-through if needed for provided path */
+ DCS_UPDATE_FILEREF = 0x10, /* If fileref is not valid but path is found or
+ searching a path, update the reference
+ information */
+};
+
+int dircache_search(unsigned int flags, struct dircache_fileref *dcfrefp,
+ const char *path);
/** Debug screen/info stuff **/