Initial maemo platform support
[maemo-rb.git] / firmware / include / dircache.h
blob87aaa008a7d40b65c5b51634c5ce5b1f33607b30
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Miika Pekkarinen
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef _DIRCACHE_H
22 #define _DIRCACHE_H
24 #include "config.h"
25 #include "dir_uncached.h"
27 #ifdef HAVE_DIRCACHE
29 #define DIRCACHE_RESERVE (1024*64)
30 #define DIRCACHE_LIMIT (1024*1024*6)
32 #define DIRCACHE_APPFLAG_TAGCACHE 0x0001
34 /* Internal structures. */
35 struct travel_data {
36 struct dircache_entry *first;
37 struct dircache_entry *ce;
38 struct dircache_entry *down_entry;
39 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
40 DIR_UNCACHED *dir, *newdir;
41 struct dirent_uncached *entry;
42 #else
43 struct fat_dir *dir;
44 struct fat_dir newdir;
45 struct fat_direntry entry;
46 #endif
47 int pathpos;
50 #define DIRCACHE_MAGIC 0x00d0c0a0
51 struct dircache_maindata {
52 long magic;
53 long size;
54 long entry_count;
55 long appflags;
56 struct dircache_entry *root_entry;
59 #define MAX_PENDING_BINDINGS 2
60 struct fdbind_queue {
61 char path[MAX_PATH];
62 int fd;
65 /* Exported structures. */
66 struct dircache_entry {
67 struct dirinfo info;
68 struct dircache_entry *next;
69 struct dircache_entry *up;
70 struct dircache_entry *down;
71 long startcluster;
72 unsigned long name_len;
73 char *d_name;
76 struct dirent_cached {
77 struct dirinfo info;
78 char *d_name;
79 long startcluster;
82 typedef struct {
83 bool busy;
84 struct dirent_cached theent; /* .attribute is set to -1 on init(opendir) */
85 struct dircache_entry *internal_entry; /* the current entry in the directory */
86 DIR_UNCACHED *regulardir;
87 } DIR_CACHED;
89 void dircache_init(void) INIT_ATTR;
90 int dircache_load(void);
91 int dircache_save(void);
92 int dircache_build(int last_size);
93 void* dircache_steal_buffer(long *size);
94 bool dircache_is_enabled(void);
95 bool dircache_is_initializing(void);
96 void dircache_set_appflag(long mask);
97 bool dircache_get_appflag(long mask);
98 int dircache_get_entry_count(void);
99 int dircache_get_cache_size(void);
100 int dircache_get_reserve_used(void);
101 int dircache_get_build_ticks(void);
102 void dircache_disable(void);
103 const struct dircache_entry *dircache_get_entry_ptr(const char *filename);
104 void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size);
106 void dircache_bind(int fd, const char *path);
107 void dircache_update_filesize(int fd, long newsize, long startcluster);
108 void dircache_update_filetime(int fd);
109 void dircache_mkdir(const char *path);
110 void dircache_rmdir(const char *path);
111 void dircache_remove(const char *name);
112 void dircache_rename(const char *oldpath, const char *newpath);
113 void dircache_add_file(const char *path, long startcluster);
115 DIR_CACHED* opendir_cached(const char* name);
116 struct dirent_cached* readdir_cached(DIR_CACHED* dir);
117 int closedir_cached(DIR_CACHED *dir);
118 int mkdir_cached(const char *name);
119 int rmdir_cached(const char* name);
120 #endif /* !HAVE_DIRCACHE */
122 #endif