forked from len0rd/rockbox
rb_namespace add logf
add logging to the namespace file to allow debug of root redirect Change-Id: I6032aea880998c05dacf3d0d2e0d222205b9376e
This commit is contained in:
parent
20b9ce5497
commit
a5c16d2990
3 changed files with 76 additions and 5 deletions
|
@ -24,6 +24,15 @@
|
|||
#include "rb_namespace.h"
|
||||
#include "file_internal.h"
|
||||
|
||||
/* Define LOGF_ENABLE to enable logf output in this file */
|
||||
//#define LOGF_ENABLE
|
||||
#include "logf.h"
|
||||
|
||||
#if !defined(HAVE_MULTIVOLUME) && defined(LOGF_ENABLE)
|
||||
int volume = 0;
|
||||
#endif
|
||||
|
||||
|
||||
#define ROOT_CONTENTS_INDEX (NUM_VOLUMES)
|
||||
#define NUM_ROOT_ITEMS (NUM_VOLUMES+1)
|
||||
|
||||
|
@ -53,12 +62,14 @@ static void get_mount_point_entry(IF_MV(int volume,) struct DIRENT *entry)
|
|||
entry->info.wrtdate = 0;
|
||||
entry->info.wrttime = 0;
|
||||
#endif /* is dirinfo_native */
|
||||
logf("%s: vol:%d, %s", __func__, volume, entry->d_name);
|
||||
}
|
||||
|
||||
/* unmount the directory that enumerates into the root namespace */
|
||||
static void unmount_item(int item)
|
||||
{
|
||||
unsigned int state = get_root_item_state(item);
|
||||
logf("%s: state: %u", __func__, state);
|
||||
if (!state)
|
||||
return;
|
||||
|
||||
|
@ -83,13 +94,18 @@ int root_mount_path(const char *path, unsigned int flags)
|
|||
return -ENOENT;
|
||||
#else
|
||||
if (!path_is_absolute(path))
|
||||
{
|
||||
logf("Path not absolute %s", path);
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif /* HAVE_MULTIVOLUME */
|
||||
|
||||
bool contents = flags & NSITEM_CONTENTS;
|
||||
int item = contents ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume);
|
||||
unsigned int state = get_root_item_state(item);
|
||||
|
||||
logf("%s: item:%d, st:%u, %s", __func__, item, state, path);
|
||||
|
||||
if (state)
|
||||
return -EBUSY;
|
||||
|
||||
|
@ -122,6 +138,7 @@ int root_mount_path(const char *path, unsigned int flags)
|
|||
/* inform root that an entire volume is being unmounted */
|
||||
void root_unmount_volume(IF_MV_NONVOID(int volume))
|
||||
{
|
||||
logf("%s: vol: %d", __func__, volume);
|
||||
FOR_EACH_VOLUME(volume, item)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
|
@ -143,6 +160,7 @@ void root_unmount_volume(IF_MV_NONVOID(int volume))
|
|||
/* parse the root part of a path */
|
||||
int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp)
|
||||
{
|
||||
logf("%s: path: %s", __func__, path);
|
||||
int volume = ROOT_VOLUME;
|
||||
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
|
@ -151,19 +169,35 @@ int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp)
|
|||
const char *p;
|
||||
volume = path_strip_volume(path, &p, false);
|
||||
if (volume != ROOT_VOLUME && !CHECK_VOL(volume))
|
||||
{
|
||||
logf("vol: %d is not root", volume);
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif /* HAVE_MULTIVOLUME */
|
||||
|
||||
/* set name to start at last leading separator; name of root will
|
||||
* be returned as "/", volume specifiers as "/<fooN>" */
|
||||
*pathp = GOBBLE_PATH_SEPCH(path) - 1;
|
||||
*lenp = IF_MV( volume < NUM_VOLUMES ? p - *pathp : ) 1;
|
||||
|
||||
#ifdef LOGF_ENABLE
|
||||
if (volume == INT_MAX)
|
||||
logf("vol: ROOT(%d) %s", volume, *pathp);
|
||||
else
|
||||
logf("vol: %d %s", volume, *pathp);
|
||||
#endif
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
if (*lenp > MAX_COMPNAME+1)
|
||||
{
|
||||
logf("%s: path too long %s", __func__, path);
|
||||
return -ENAMETOOLONG;
|
||||
}
|
||||
#endif
|
||||
#ifdef LOGF_ENABLE
|
||||
if (volume == INT_MAX)
|
||||
logf("%s: vol: ROOT(%d) path: %s", __func__, volume, path);
|
||||
else
|
||||
logf("%s: vol: %d path: %s", __func__, volume, path);
|
||||
#endif
|
||||
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
@ -183,7 +217,7 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
|
|||
|
||||
int item = sysroot ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume);
|
||||
unsigned int state = get_root_item_state(item);
|
||||
|
||||
logf("%s: Vol:%d St:%d", __func__, item, state);
|
||||
if (sysroot)
|
||||
{
|
||||
*attrp = ATTR_SYSTEM_ROOT;
|
||||
|
@ -191,7 +225,10 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
|
|||
if (state)
|
||||
*infop = root_bindp->info;
|
||||
else
|
||||
{
|
||||
logf("%s: SysRoot Vol:%d St:%d NOT mounted", __func__, item, state);
|
||||
*callflagsp = callflags | FF_NOFS; /* contents not mounted */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -201,7 +238,10 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
|
|||
return -ENOENT; /* regular open requires having been mounted */
|
||||
#if CONFIG_PLATFORM & PLATFORM_NATIVE
|
||||
if (fat_open_rootdir(IF_MV(volume,) &infop->fatfile) < 0)
|
||||
{
|
||||
logf("%s: DevPath Vol:%d St:%d NOT mounted", __func__, item, state);
|
||||
return -ENOENT; /* not mounted */
|
||||
}
|
||||
#endif
|
||||
get_rootinfo_internal(infop);
|
||||
}
|
||||
|
@ -216,6 +256,7 @@ int root_readdir_dirent(struct filestr_base *stream,
|
|||
int rc = 0;
|
||||
|
||||
int item = scanp->item;
|
||||
logf("%s: item: %d", __func__, item);
|
||||
|
||||
/* skip any not-mounted or hidden items */
|
||||
unsigned int state;
|
||||
|
@ -226,7 +267,10 @@ int root_readdir_dirent(struct filestr_base *stream,
|
|||
|
||||
state = get_root_item_state(item);
|
||||
if ((state & (NSITEM_MOUNTED|NSITEM_HIDDEN)) == NSITEM_MOUNTED)
|
||||
{
|
||||
logf("Found mounted item: %d %s", item, entry->d_name);
|
||||
break;
|
||||
}
|
||||
|
||||
item++;
|
||||
}
|
||||
|
@ -238,13 +282,17 @@ int root_readdir_dirent(struct filestr_base *stream,
|
|||
FILE_ERROR(ERRNO, rc * 10 - 1);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
logf("Found root item: %d %s", item, entry->d_name);
|
||||
item++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
get_mount_point_entry(IF_MV(item,) entry);
|
||||
item++;
|
||||
rc = 1;
|
||||
logf("Found mp item:%d %s", item, entry->d_name);
|
||||
}
|
||||
|
||||
scanp->item = item;
|
||||
|
@ -255,6 +303,7 @@ file_eod:
|
|||
empty_dirent(entry);
|
||||
#endif
|
||||
file_error:
|
||||
logf("%s: status: %d", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -262,6 +311,7 @@ file_error:
|
|||
int ns_open_stream(const char *path, unsigned int callflags,
|
||||
struct filestr_base *stream, struct ns_scan_info *scanp)
|
||||
{
|
||||
logf("%s: path: %s", __func__, path);
|
||||
/* stream still needs synchronization even if we don't have a stream */
|
||||
static struct mutex no_contents_mtx SHAREDBSS_ATTR;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue