diff options
Diffstat (limited to 'firmware/common/rb_namespace.c')
-rw-r--r-- | firmware/common/rb_namespace.c | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/firmware/common/rb_namespace.c b/firmware/common/rb_namespace.c index beaaf78bed..ff5ad0f6db 100644 --- a/firmware/common/rb_namespace.c +++ b/firmware/common/rb_namespace.c | |||
@@ -24,6 +24,15 @@ | |||
24 | #include "rb_namespace.h" | 24 | #include "rb_namespace.h" |
25 | #include "file_internal.h" | 25 | #include "file_internal.h" |
26 | 26 | ||
27 | /* Define LOGF_ENABLE to enable logf output in this file */ | ||
28 | //#define LOGF_ENABLE | ||
29 | #include "logf.h" | ||
30 | |||
31 | #if !defined(HAVE_MULTIVOLUME) && defined(LOGF_ENABLE) | ||
32 | int volume = 0; | ||
33 | #endif | ||
34 | |||
35 | |||
27 | #define ROOT_CONTENTS_INDEX (NUM_VOLUMES) | 36 | #define ROOT_CONTENTS_INDEX (NUM_VOLUMES) |
28 | #define NUM_ROOT_ITEMS (NUM_VOLUMES+1) | 37 | #define NUM_ROOT_ITEMS (NUM_VOLUMES+1) |
29 | 38 | ||
@@ -53,12 +62,14 @@ static void get_mount_point_entry(IF_MV(int volume,) struct DIRENT *entry) | |||
53 | entry->info.wrtdate = 0; | 62 | entry->info.wrtdate = 0; |
54 | entry->info.wrttime = 0; | 63 | entry->info.wrttime = 0; |
55 | #endif /* is dirinfo_native */ | 64 | #endif /* is dirinfo_native */ |
65 | logf("%s: vol:%d, %s", __func__, volume, entry->d_name); | ||
56 | } | 66 | } |
57 | 67 | ||
58 | /* unmount the directory that enumerates into the root namespace */ | 68 | /* unmount the directory that enumerates into the root namespace */ |
59 | static void unmount_item(int item) | 69 | static void unmount_item(int item) |
60 | { | 70 | { |
61 | unsigned int state = get_root_item_state(item); | 71 | unsigned int state = get_root_item_state(item); |
72 | logf("%s: state: %u", __func__, state); | ||
62 | if (!state) | 73 | if (!state) |
63 | return; | 74 | return; |
64 | 75 | ||
@@ -83,13 +94,18 @@ int root_mount_path(const char *path, unsigned int flags) | |||
83 | return -ENOENT; | 94 | return -ENOENT; |
84 | #else | 95 | #else |
85 | if (!path_is_absolute(path)) | 96 | if (!path_is_absolute(path)) |
97 | { | ||
98 | logf("Path not absolute %s", path); | ||
86 | return -ENOENT; | 99 | return -ENOENT; |
100 | } | ||
87 | #endif /* HAVE_MULTIVOLUME */ | 101 | #endif /* HAVE_MULTIVOLUME */ |
88 | 102 | ||
89 | bool contents = flags & NSITEM_CONTENTS; | 103 | bool contents = flags & NSITEM_CONTENTS; |
90 | int item = contents ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume); | 104 | int item = contents ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume); |
91 | unsigned int state = get_root_item_state(item); | 105 | unsigned int state = get_root_item_state(item); |
92 | 106 | ||
107 | logf("%s: item:%d, st:%u, %s", __func__, item, state, path); | ||
108 | |||
93 | if (state) | 109 | if (state) |
94 | return -EBUSY; | 110 | return -EBUSY; |
95 | 111 | ||
@@ -122,6 +138,7 @@ int root_mount_path(const char *path, unsigned int flags) | |||
122 | /* inform root that an entire volume is being unmounted */ | 138 | /* inform root that an entire volume is being unmounted */ |
123 | void root_unmount_volume(IF_MV_NONVOID(int volume)) | 139 | void root_unmount_volume(IF_MV_NONVOID(int volume)) |
124 | { | 140 | { |
141 | logf("%s: vol: %d", __func__, volume); | ||
125 | FOR_EACH_VOLUME(volume, item) | 142 | FOR_EACH_VOLUME(volume, item) |
126 | { | 143 | { |
127 | #ifdef HAVE_MULTIVOLUME | 144 | #ifdef HAVE_MULTIVOLUME |
@@ -143,6 +160,7 @@ void root_unmount_volume(IF_MV_NONVOID(int volume)) | |||
143 | /* parse the root part of a path */ | 160 | /* parse the root part of a path */ |
144 | int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp) | 161 | int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp) |
145 | { | 162 | { |
163 | logf("%s: path: %s", __func__, path); | ||
146 | int volume = ROOT_VOLUME; | 164 | int volume = ROOT_VOLUME; |
147 | 165 | ||
148 | #ifdef HAVE_MULTIVOLUME | 166 | #ifdef HAVE_MULTIVOLUME |
@@ -151,19 +169,35 @@ int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp) | |||
151 | const char *p; | 169 | const char *p; |
152 | volume = path_strip_volume(path, &p, false); | 170 | volume = path_strip_volume(path, &p, false); |
153 | if (volume != ROOT_VOLUME && !CHECK_VOL(volume)) | 171 | if (volume != ROOT_VOLUME && !CHECK_VOL(volume)) |
172 | { | ||
173 | logf("vol: %d is not root", volume); | ||
154 | return -ENOENT; | 174 | return -ENOENT; |
175 | } | ||
155 | #endif /* HAVE_MULTIVOLUME */ | 176 | #endif /* HAVE_MULTIVOLUME */ |
156 | 177 | ||
157 | /* set name to start at last leading separator; name of root will | 178 | /* set name to start at last leading separator; name of root will |
158 | * be returned as "/", volume specifiers as "/<fooN>" */ | 179 | * be returned as "/", volume specifiers as "/<fooN>" */ |
159 | *pathp = GOBBLE_PATH_SEPCH(path) - 1; | 180 | *pathp = GOBBLE_PATH_SEPCH(path) - 1; |
160 | *lenp = IF_MV( volume < NUM_VOLUMES ? p - *pathp : ) 1; | 181 | *lenp = IF_MV( volume < NUM_VOLUMES ? p - *pathp : ) 1; |
161 | 182 | #ifdef LOGF_ENABLE | |
183 | if (volume == INT_MAX) | ||
184 | logf("vol: ROOT(%d) %s", volume, *pathp); | ||
185 | else | ||
186 | logf("vol: %d %s", volume, *pathp); | ||
187 | #endif | ||
162 | #ifdef HAVE_MULTIVOLUME | 188 | #ifdef HAVE_MULTIVOLUME |
163 | if (*lenp > MAX_COMPNAME+1) | 189 | if (*lenp > MAX_COMPNAME+1) |
190 | { | ||
191 | logf("%s: path too long %s", __func__, path); | ||
164 | return -ENAMETOOLONG; | 192 | return -ENAMETOOLONG; |
193 | } | ||
194 | #endif | ||
195 | #ifdef LOGF_ENABLE | ||
196 | if (volume == INT_MAX) | ||
197 | logf("%s: vol: ROOT(%d) path: %s", __func__, volume, path); | ||
198 | else | ||
199 | logf("%s: vol: %d path: %s", __func__, volume, path); | ||
165 | #endif | 200 | #endif |
166 | |||
167 | return volume; | 201 | return volume; |
168 | } | 202 | } |
169 | 203 | ||
@@ -183,7 +217,7 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp, | |||
183 | 217 | ||
184 | int item = sysroot ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume); | 218 | int item = sysroot ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume); |
185 | unsigned int state = get_root_item_state(item); | 219 | unsigned int state = get_root_item_state(item); |
186 | 220 | logf("%s: Vol:%d St:%d", __func__, item, state); | |
187 | if (sysroot) | 221 | if (sysroot) |
188 | { | 222 | { |
189 | *attrp = ATTR_SYSTEM_ROOT; | 223 | *attrp = ATTR_SYSTEM_ROOT; |
@@ -191,7 +225,10 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp, | |||
191 | if (state) | 225 | if (state) |
192 | *infop = root_bindp->info; | 226 | *infop = root_bindp->info; |
193 | else | 227 | else |
228 | { | ||
229 | logf("%s: SysRoot Vol:%d St:%d NOT mounted", __func__, item, state); | ||
194 | *callflagsp = callflags | FF_NOFS; /* contents not mounted */ | 230 | *callflagsp = callflags | FF_NOFS; /* contents not mounted */ |
231 | } | ||
195 | } | 232 | } |
196 | else | 233 | else |
197 | { | 234 | { |
@@ -201,7 +238,10 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp, | |||
201 | return -ENOENT; /* regular open requires having been mounted */ | 238 | return -ENOENT; /* regular open requires having been mounted */ |
202 | #if CONFIG_PLATFORM & PLATFORM_NATIVE | 239 | #if CONFIG_PLATFORM & PLATFORM_NATIVE |
203 | if (fat_open_rootdir(IF_MV(volume,) &infop->fatfile) < 0) | 240 | if (fat_open_rootdir(IF_MV(volume,) &infop->fatfile) < 0) |
241 | { | ||
242 | logf("%s: DevPath Vol:%d St:%d NOT mounted", __func__, item, state); | ||
204 | return -ENOENT; /* not mounted */ | 243 | return -ENOENT; /* not mounted */ |
244 | } | ||
205 | #endif | 245 | #endif |
206 | get_rootinfo_internal(infop); | 246 | get_rootinfo_internal(infop); |
207 | } | 247 | } |
@@ -216,6 +256,7 @@ int root_readdir_dirent(struct filestr_base *stream, | |||
216 | int rc = 0; | 256 | int rc = 0; |
217 | 257 | ||
218 | int item = scanp->item; | 258 | int item = scanp->item; |
259 | logf("%s: item: %d", __func__, item); | ||
219 | 260 | ||
220 | /* skip any not-mounted or hidden items */ | 261 | /* skip any not-mounted or hidden items */ |
221 | unsigned int state; | 262 | unsigned int state; |
@@ -226,7 +267,10 @@ int root_readdir_dirent(struct filestr_base *stream, | |||
226 | 267 | ||
227 | state = get_root_item_state(item); | 268 | state = get_root_item_state(item); |
228 | if ((state & (NSITEM_MOUNTED|NSITEM_HIDDEN)) == NSITEM_MOUNTED) | 269 | if ((state & (NSITEM_MOUNTED|NSITEM_HIDDEN)) == NSITEM_MOUNTED) |
270 | { | ||
271 | logf("Found mounted item: %d %s", item, entry->d_name); | ||
229 | break; | 272 | break; |
273 | } | ||
230 | 274 | ||
231 | item++; | 275 | item++; |
232 | } | 276 | } |
@@ -238,13 +282,17 @@ int root_readdir_dirent(struct filestr_base *stream, | |||
238 | FILE_ERROR(ERRNO, rc * 10 - 1); | 282 | FILE_ERROR(ERRNO, rc * 10 - 1); |
239 | 283 | ||
240 | if (rc == 0) | 284 | if (rc == 0) |
285 | { | ||
286 | logf("Found root item: %d %s", item, entry->d_name); | ||
241 | item++; | 287 | item++; |
288 | } | ||
242 | } | 289 | } |
243 | else | 290 | else |
244 | { | 291 | { |
245 | get_mount_point_entry(IF_MV(item,) entry); | 292 | get_mount_point_entry(IF_MV(item,) entry); |
246 | item++; | 293 | item++; |
247 | rc = 1; | 294 | rc = 1; |
295 | logf("Found mp item:%d %s", item, entry->d_name); | ||
248 | } | 296 | } |
249 | 297 | ||
250 | scanp->item = item; | 298 | scanp->item = item; |
@@ -255,6 +303,7 @@ file_eod: | |||
255 | empty_dirent(entry); | 303 | empty_dirent(entry); |
256 | #endif | 304 | #endif |
257 | file_error: | 305 | file_error: |
306 | logf("%s: status: %d", __func__, rc); | ||
258 | return rc; | 307 | return rc; |
259 | } | 308 | } |
260 | 309 | ||
@@ -262,6 +311,7 @@ file_error: | |||
262 | int ns_open_stream(const char *path, unsigned int callflags, | 311 | int ns_open_stream(const char *path, unsigned int callflags, |
263 | struct filestr_base *stream, struct ns_scan_info *scanp) | 312 | struct filestr_base *stream, struct ns_scan_info *scanp) |
264 | { | 313 | { |
314 | logf("%s: path: %s", __func__, path); | ||
265 | /* stream still needs synchronization even if we don't have a stream */ | 315 | /* stream still needs synchronization even if we don't have a stream */ |
266 | static struct mutex no_contents_mtx SHAREDBSS_ATTR; | 316 | static struct mutex no_contents_mtx SHAREDBSS_ATTR; |
267 | 317 | ||