summaryrefslogtreecommitdiff
path: root/firmware/include
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-08-20 21:54:00 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-08-20 21:54:00 -0400
commitf850bbbbc4b7345bebde241f651bad1c5c28df66 (patch)
tree1574bcca604f0617130aa9f1c426cfcdc097c901 /firmware/include
parentbd744059cf959c8b9086978b32660efef5925b7d (diff)
downloadrockbox-f850bbbbc4b7345bebde241f651bad1c5c28df66.tar.gz
rockbox-f850bbbbc4b7345bebde241f651bad1c5c28df66.zip
Revert root_redirect :(
This reverts commit 31fc46ded69be7438cca2ba2c2b93c1f200165a6. Change-Id: Ia78618c0e8b25ca65f7c8ae0db1cb9c9b321bad9
Diffstat (limited to 'firmware/include')
-rw-r--r--firmware/include/dircache_redirect.h58
-rw-r--r--firmware/include/file_internal.h22
-rw-r--r--firmware/include/fileobj_mgr.h5
-rw-r--r--firmware/include/fs_defines.h11
-rw-r--r--firmware/include/rb_namespace.h79
5 files changed, 12 insertions, 163 deletions
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h
index e8cf8dc8f5..9fae16b551 100644
--- a/firmware/include/dircache_redirect.h
+++ b/firmware/include/dircache_redirect.h
@@ -20,16 +20,7 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21#ifndef _DIRCACHE_REDIRECT_H_ 21#ifndef _DIRCACHE_REDIRECT_H_
22 22
23#include "rbpaths.h"
24#include "pathfuncs.h"
25#include "dir.h" 23#include "dir.h"
26#include "dircache.h"
27
28#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR)
29#include "rb-loader.h"
30#include "bootdata.h"
31#include "crc32.h"
32#endif
33 24
34/*** 25/***
35 ** Internal redirects that depend upon whether or not dircache is made 26 ** Internal redirects that depend upon whether or not dircache is made
@@ -132,56 +123,10 @@ static inline void fileop_onsync_internal(struct filestr_base *stream)
132 123
133static inline void volume_onmount_internal(IF_MV_NONVOID(int volume)) 124static inline void volume_onmount_internal(IF_MV_NONVOID(int volume))
134{ 125{
135#ifdef HAVE_MULTIVOLUME
136 char path[VOL_MAX_LEN+2];
137 make_volume_root(volume, path);
138#else
139 const char *path = PATH_ROOTSTR;
140#endif
141
142#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR)
143 static char rtpath[VOL_MAX_LEN+2] = RB_ROOT_CONTENTS_DIR;
144 static bool redirected = false;
145 int boot_volume = 0;
146 unsigned int crc = 0;
147
148 crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff);
149 if (crc == boot_data.crc)
150 {
151 root_mount_path(path, 0); /*root could be different folder don't hide*/
152 boot_volume = boot_data.boot_volume; /* boot volume contained in uint8_t payload */
153 //root_mount_path(path, volume == boot_volume ? NSITEM_HIDDEN : 0);
154 if (!redirected && volume == boot_volume)
155 {
156 if (get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "") < 0)
157 { /* Error occurred, card removed? Set root to default */
158 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
159 }
160 else
161 redirected = true;
162 }
163 if (redirected && volume == boot_volume)
164 root_mount_path(rtpath, NSITEM_CONTENTS);
165 } /*CRC OK*/
166 else
167 {
168 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0);
169 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false))
170 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
171 }
172#else
173
174 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0);
175#ifdef HAVE_MULTIVOLUME
176 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false))
177#endif
178 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
179
180#endif /* HAVE_MULTIBOOT */
181
182#ifdef HAVE_DIRCACHE 126#ifdef HAVE_DIRCACHE
183 dircache_mount(); 127 dircache_mount();
184#endif 128#endif
129 IF_MV( (void)volume; )
185} 130}
186 131
187static inline void volume_onunmount_internal(IF_MV_NONVOID(int volume)) 132static inline void volume_onunmount_internal(IF_MV_NONVOID(int volume))
@@ -190,7 +135,6 @@ static inline void volume_onunmount_internal(IF_MV_NONVOID(int volume))
190 /* First, to avoid update of something about to be destroyed anyway */ 135 /* First, to avoid update of something about to be destroyed anyway */
191 dircache_unmount(IF_MV(volume)); 136 dircache_unmount(IF_MV(volume));
192#endif 137#endif
193 root_unmount_volume(IF_MV(volume));
194 fileobj_mgr_unmount(IF_MV(volume)); 138 fileobj_mgr_unmount(IF_MV(volume));
195} 139}
196 140
diff --git a/firmware/include/file_internal.h b/firmware/include/file_internal.h
index f4bd8bb8c2..d62b5a8541 100644
--- a/firmware/include/file_internal.h
+++ b/firmware/include/file_internal.h
@@ -72,18 +72,16 @@ enum fildes_and_obj_flags
72 /* used in descriptor and common */ 72 /* used in descriptor and common */
73 FDO_BUSY = 0x0001, /* descriptor/object is in use */ 73 FDO_BUSY = 0x0001, /* descriptor/object is in use */
74 /* only used in individual stream descriptor */ 74 /* only used in individual stream descriptor */
75 FD_VALID = 0x0002, /* descriptor is valid but not registered */ 75 FD_WRITE = 0x0002, /* descriptor has write mode */
76 FD_WRITE = 0x0004, /* descriptor has write mode */ 76 FD_WRONLY = 0x0004, /* descriptor is write mode only */
77 FD_WRONLY = 0x0008, /* descriptor is write mode only */ 77 FD_APPEND = 0x0008, /* descriptor is append mode */
78 FD_APPEND = 0x0010, /* descriptor is append mode */
79 FD_NONEXIST = 0x8000, /* closed but not freed (uncombined) */ 78 FD_NONEXIST = 0x8000, /* closed but not freed (uncombined) */
80 /* only used as common flags */ 79 /* only used as common flags */
81 FO_DIRECTORY = 0x0020, /* fileobj is a directory */ 80 FO_DIRECTORY = 0x0010, /* fileobj is a directory */
82 FO_TRUNC = 0x0040, /* fileobj is opened to be truncated */ 81 FO_TRUNC = 0x0020, /* fileobj is opened to be truncated */
83 FO_REMOVED = 0x0080, /* fileobj was deleted while open */ 82 FO_REMOVED = 0x0040, /* fileobj was deleted while open */
84 FO_SINGLE = 0x0100, /* fileobj has only one stream open */ 83 FO_SINGLE = 0x0080, /* fileobj has only one stream open */
85 FO_MOUNTTARGET = 0x0200, /* fileobj kept open as a mount target */ 84 FDO_MASK = 0x00ff,
86 FDO_MASK = 0x03ff,
87 FDO_CHG_MASK = FO_TRUNC, /* fileobj permitted external change */ 85 FDO_CHG_MASK = FO_TRUNC, /* fileobj permitted external change */
88 /* bitflags that instruct various 'open' functions how to behave; 86 /* bitflags that instruct various 'open' functions how to behave;
89 * saved in stream flags (only) but not used by manager */ 87 * saved in stream flags (only) but not used by manager */
@@ -97,9 +95,7 @@ enum fildes_and_obj_flags
97 FF_CACHEONLY = 0x00200000, /* succeed only if in dircache */ 95 FF_CACHEONLY = 0x00200000, /* succeed only if in dircache */
98 FF_INFO = 0x00400000, /* return info on self */ 96 FF_INFO = 0x00400000, /* return info on self */
99 FF_PARENTINFO = 0x00800000, /* return info on parent */ 97 FF_PARENTINFO = 0x00800000, /* return info on parent */
100 FF_DEVPATH = 0x01000000, /* path is a device path, not root-based */ 98 FF_MASK = 0x00ff0000,
101 FF_NOFS = 0x02000000, /* no filesystem mounted here */
102 FF_MASK = 0x03ff0000,
103}; 99};
104 100
105/** Common data structures used throughout **/ 101/** Common data structures used throughout **/
diff --git a/firmware/include/fileobj_mgr.h b/firmware/include/fileobj_mgr.h
index 0db3520d34..627d2df341 100644
--- a/firmware/include/fileobj_mgr.h
+++ b/firmware/include/fileobj_mgr.h
@@ -29,11 +29,6 @@ void file_binding_remove(struct file_base_binding *bindp);
29void file_binding_remove_next(struct file_base_binding *prevp, 29void file_binding_remove_next(struct file_base_binding *prevp,
30 struct file_base_binding *bindp); 30 struct file_base_binding *bindp);
31 31
32bool fileobj_mount(const struct file_base_info *srcinfop,
33 unsigned int callflags,
34 struct file_base_binding **bindpp);
35void fileobj_unmount(struct file_base_binding *bindp);
36
37void fileobj_fileop_open(struct filestr_base *stream, 32void fileobj_fileop_open(struct filestr_base *stream,
38 const struct file_base_info *srcinfop, 33 const struct file_base_info *srcinfop,
39 unsigned int callflags); 34 unsigned int callflags);
diff --git a/firmware/include/fs_defines.h b/firmware/include/fs_defines.h
index aee6daff6a..538c4b36cd 100644
--- a/firmware/include/fs_defines.h
+++ b/firmware/include/fs_defines.h
@@ -51,19 +51,12 @@
51/* internal functions open streams as well; make sure they don't fail if all 51/* internal functions open streams as well; make sure they don't fail if all
52 user descs are busy; this needs to be at least the greatest quantity needed 52 user descs are busy; this needs to be at least the greatest quantity needed
53 at once by all internal functions */ 53 at once by all internal functions */
54/* internal functions open streams as well; make sure they don't fail if all
55 user descs are busy; this needs to be at least the greatest quantity needed
56 at once by all internal functions */
57#define MOUNT_AUX_FILEOBJS 1
58
59#ifdef HAVE_DIRCACHE 54#ifdef HAVE_DIRCACHE
60#define DIRCACHE_AUX_FILEOBJS 1 55#define AUX_FILEOBJS 3
61#else 56#else
62#define DIRCACHE_AUX_FILEOBJS 0 57#define AUX_FILEOBJS 2
63#endif 58#endif
64 59
65#define AUX_FILEOBJS (2+DIRCACHE_AUX_FILEOBJS+MOUNT_AUX_FILEOBJS)
66
67/* number of components statically allocated to handle the vast majority 60/* number of components statically allocated to handle the vast majority
68 of path depths; should maybe be tuned for >= 90th percentile but for now, 61 of path depths; should maybe be tuned for >= 90th percentile but for now,
69 imma just guessing based on something like: 62 imma just guessing based on something like:
diff --git a/firmware/include/rb_namespace.h b/firmware/include/rb_namespace.h
deleted file mode 100644
index 4d7a125c7b..0000000000
--- a/firmware/include/rb_namespace.h
+++ /dev/null
@@ -1,79 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2017 by Michael Sevakis
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef RB_NAMESPACE_H
22#define RB_NAMESPACE_H
23
24#include "file_internal.h"
25
26enum ns_item_flags
27{
28 NSITEM_MOUNTED = 0x01, /* item is mounted */
29 NSITEM_HIDDEN = 0x02, /* item is not enumerated */
30 NSITEM_CONTENTS = 0x04, /* contents enumerate */
31};
32
33struct ns_scan_info
34{
35 struct dirscan_info scan; /* dirscan info - first! */
36 int item; /* current item in parent */
37};
38
39/* root functions */
40int root_mount_path(const char *path, unsigned int flags);
41void root_unmount_volume(IF_MV_NONVOID(int volume));
42int root_readdir_dirent(struct filestr_base *stream,
43 struct ns_scan_info *scanp,
44 struct dirent *entry);
45
46/* namespace functions */
47int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp);
48int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
49 struct file_base_info *infop, uint16_t *attrp);
50int ns_open_stream(const char *path, unsigned int callflags,
51 struct filestr_base *stream, struct ns_scan_info *scanp);
52
53/* closes the namespace stream */
54static inline int ns_close_stream(struct filestr_base *stream)
55{
56 return close_stream_internal(stream);
57}
58
59#include "dircache_redirect.h"
60
61static inline void ns_dirscan_rewind(struct ns_scan_info *scanp)
62{
63 rewinddir_dirent(&scanp->scan);
64 if (scanp->item != -1)
65 scanp->item = 0;
66}
67
68static inline int ns_readdir_dirent(struct filestr_base *stream,
69 struct ns_scan_info *scanp,
70 struct dirent *entry)
71
72{
73 if (scanp->item == -1)
74 return readdir_dirent(stream, &scanp->scan, entry);
75 else
76 return root_readdir_dirent(stream, scanp, entry);
77}
78
79#endif /* RB_NAMESPACE_H */