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
|
@ -31,6 +31,15 @@
|
||||||
#include "rb_namespace.h"
|
#include "rb_namespace.h"
|
||||||
#include "string-extra.h"
|
#include "string-extra.h"
|
||||||
|
|
||||||
|
/* Define LOGF_ENABLE to enable logf output in this file */
|
||||||
|
//#define LOGF_ENABLE
|
||||||
|
#ifdef LOGF_ENABLE
|
||||||
|
#include "logf.h"
|
||||||
|
#undef DEBUGF
|
||||||
|
#define DEBUGF logf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These functions provide a roughly POSIX-compatible file I/O API.
|
* These functions provide a roughly POSIX-compatible file I/O API.
|
||||||
*/
|
*/
|
||||||
|
@ -600,8 +609,10 @@ static inline ssize_t readwrite_partial(struct filestr_desc *file,
|
||||||
static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte,
|
static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte,
|
||||||
bool write)
|
bool write)
|
||||||
{
|
{
|
||||||
|
#ifndef LOGF_ENABLE /* wipes out log before you can save it */
|
||||||
DEBUGF("readwrite(%p,%lx,%lu,%s)\n",
|
DEBUGF("readwrite(%p,%lx,%lu,%s)\n",
|
||||||
file, (long)buf, (unsigned long)nbyte, write ? "write" : "read");
|
file, (long)buf, (unsigned long)nbyte, write ? "write" : "read");
|
||||||
|
#endif
|
||||||
|
|
||||||
const file_size_t size = *file->sizep;
|
const file_size_t size = *file->sizep;
|
||||||
file_size_t filerem;
|
file_size_t filerem;
|
||||||
|
@ -766,8 +777,9 @@ file_error:;
|
||||||
/* error or not, update the file offset and size if anything was
|
/* error or not, update the file offset and size if anything was
|
||||||
transferred */
|
transferred */
|
||||||
file->offset += done;
|
file->offset += done;
|
||||||
|
#ifndef LOGF_ENABLE /* wipes out log before you can save it */
|
||||||
DEBUGF("file offset: %ld\n", file->offset);
|
DEBUGF("file offset: %ld\n", file->offset);
|
||||||
|
#endif
|
||||||
/* adjust file size to length written */
|
/* adjust file size to length written */
|
||||||
if (write && file->offset > size)
|
if (write && file->offset > size)
|
||||||
*file->sizep = file->offset;
|
*file->sizep = file->offset;
|
||||||
|
@ -901,8 +913,9 @@ file_error:
|
||||||
/* move the read/write file offset */
|
/* move the read/write file offset */
|
||||||
off_t lseek(int fildes, off_t offset, int whence)
|
off_t lseek(int fildes, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
|
#ifndef LOGF_ENABLE /* wipes out log before you can save it */
|
||||||
DEBUGF("lseek(fd=%d,ofs=%ld,wh=%d)\n", fildes, (long)offset, whence);
|
DEBUGF("lseek(fd=%d,ofs=%ld,wh=%d)\n", fildes, (long)offset, whence);
|
||||||
|
#endif
|
||||||
struct filestr_desc * const file = GET_FILESTR(READER, fildes);
|
struct filestr_desc * const file = GET_FILESTR(READER, fildes);
|
||||||
if (!file)
|
if (!file)
|
||||||
FILE_ERROR_RETURN(ERRNO, -1);
|
FILE_ERROR_RETURN(ERRNO, -1);
|
||||||
|
|
|
@ -30,6 +30,14 @@
|
||||||
#include "string-extra.h"
|
#include "string-extra.h"
|
||||||
#include "rbunicode.h"
|
#include "rbunicode.h"
|
||||||
|
|
||||||
|
/* Define LOGF_ENABLE to enable logf output in this file */
|
||||||
|
//#define LOGF_ENABLE
|
||||||
|
#ifdef LOGF_ENABLE
|
||||||
|
#include "logf.h"
|
||||||
|
#undef DEBUGF
|
||||||
|
#define DEBUGF logf
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Internal common filesystem service functions **/
|
/** Internal common filesystem service functions **/
|
||||||
|
|
||||||
/* for internal functions' scanning use to save quite a bit of stack space -
|
/* for internal functions' scanning use to save quite a bit of stack space -
|
||||||
|
|
|
@ -24,6 +24,15 @@
|
||||||
#include "rb_namespace.h"
|
#include "rb_namespace.h"
|
||||||
#include "file_internal.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 ROOT_CONTENTS_INDEX (NUM_VOLUMES)
|
||||||
#define NUM_ROOT_ITEMS (NUM_VOLUMES+1)
|
#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.wrtdate = 0;
|
||||||
entry->info.wrttime = 0;
|
entry->info.wrttime = 0;
|
||||||
#endif /* is dirinfo_native */
|
#endif /* is dirinfo_native */
|
||||||
|
logf("%s: vol:%d, %s", __func__, volume, entry->d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unmount the directory that enumerates into the root namespace */
|
/* unmount the directory that enumerates into the root namespace */
|
||||||
static void unmount_item(int item)
|
static void unmount_item(int item)
|
||||||
{
|
{
|
||||||
unsigned int state = get_root_item_state(item);
|
unsigned int state = get_root_item_state(item);
|
||||||
|
logf("%s: state: %u", __func__, state);
|
||||||
if (!state)
|
if (!state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -83,13 +94,18 @@ int root_mount_path(const char *path, unsigned int flags)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
#else
|
#else
|
||||||
if (!path_is_absolute(path))
|
if (!path_is_absolute(path))
|
||||||
|
{
|
||||||
|
logf("Path not absolute %s", path);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
}
|
||||||
#endif /* HAVE_MULTIVOLUME */
|
#endif /* HAVE_MULTIVOLUME */
|
||||||
|
|
||||||
bool contents = flags & NSITEM_CONTENTS;
|
bool contents = flags & NSITEM_CONTENTS;
|
||||||
int item = contents ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume);
|
int item = contents ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume);
|
||||||
unsigned int state = get_root_item_state(item);
|
unsigned int state = get_root_item_state(item);
|
||||||
|
|
||||||
|
logf("%s: item:%d, st:%u, %s", __func__, item, state, path);
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
return -EBUSY;
|
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 */
|
/* inform root that an entire volume is being unmounted */
|
||||||
void root_unmount_volume(IF_MV_NONVOID(int volume))
|
void root_unmount_volume(IF_MV_NONVOID(int volume))
|
||||||
{
|
{
|
||||||
|
logf("%s: vol: %d", __func__, volume);
|
||||||
FOR_EACH_VOLUME(volume, item)
|
FOR_EACH_VOLUME(volume, item)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MULTIVOLUME
|
#ifdef HAVE_MULTIVOLUME
|
||||||
|
@ -143,6 +160,7 @@ void root_unmount_volume(IF_MV_NONVOID(int volume))
|
||||||
/* parse the root part of a path */
|
/* parse the root part of a path */
|
||||||
int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp)
|
int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp)
|
||||||
{
|
{
|
||||||
|
logf("%s: path: %s", __func__, path);
|
||||||
int volume = ROOT_VOLUME;
|
int volume = ROOT_VOLUME;
|
||||||
|
|
||||||
#ifdef HAVE_MULTIVOLUME
|
#ifdef HAVE_MULTIVOLUME
|
||||||
|
@ -151,19 +169,35 @@ int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp)
|
||||||
const char *p;
|
const char *p;
|
||||||
volume = path_strip_volume(path, &p, false);
|
volume = path_strip_volume(path, &p, false);
|
||||||
if (volume != ROOT_VOLUME && !CHECK_VOL(volume))
|
if (volume != ROOT_VOLUME && !CHECK_VOL(volume))
|
||||||
|
{
|
||||||
|
logf("vol: %d is not root", volume);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
}
|
||||||
#endif /* HAVE_MULTIVOLUME */
|
#endif /* HAVE_MULTIVOLUME */
|
||||||
|
|
||||||
/* set name to start at last leading separator; name of root will
|
/* set name to start at last leading separator; name of root will
|
||||||
* be returned as "/", volume specifiers as "/<fooN>" */
|
* be returned as "/", volume specifiers as "/<fooN>" */
|
||||||
*pathp = GOBBLE_PATH_SEPCH(path) - 1;
|
*pathp = GOBBLE_PATH_SEPCH(path) - 1;
|
||||||
*lenp = IF_MV( volume < NUM_VOLUMES ? p - *pathp : ) 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
|
#ifdef HAVE_MULTIVOLUME
|
||||||
if (*lenp > MAX_COMPNAME+1)
|
if (*lenp > MAX_COMPNAME+1)
|
||||||
|
{
|
||||||
|
logf("%s: path too long %s", __func__, path);
|
||||||
return -ENAMETOOLONG;
|
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
|
#endif
|
||||||
|
|
||||||
return volume;
|
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);
|
int item = sysroot ? ROOT_CONTENTS_INDEX : IF_MV_VOL(volume);
|
||||||
unsigned int state = get_root_item_state(item);
|
unsigned int state = get_root_item_state(item);
|
||||||
|
logf("%s: Vol:%d St:%d", __func__, item, state);
|
||||||
if (sysroot)
|
if (sysroot)
|
||||||
{
|
{
|
||||||
*attrp = ATTR_SYSTEM_ROOT;
|
*attrp = ATTR_SYSTEM_ROOT;
|
||||||
|
@ -191,8 +225,11 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
|
||||||
if (state)
|
if (state)
|
||||||
*infop = root_bindp->info;
|
*infop = root_bindp->info;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
logf("%s: SysRoot Vol:%d St:%d NOT mounted", __func__, item, state);
|
||||||
*callflagsp = callflags | FF_NOFS; /* contents not mounted */
|
*callflagsp = callflags | FF_NOFS; /* contents not mounted */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*attrp = ATTR_MOUNT_POINT;
|
*attrp = ATTR_MOUNT_POINT;
|
||||||
|
@ -201,7 +238,10 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
|
||||||
return -ENOENT; /* regular open requires having been mounted */
|
return -ENOENT; /* regular open requires having been mounted */
|
||||||
#if CONFIG_PLATFORM & PLATFORM_NATIVE
|
#if CONFIG_PLATFORM & PLATFORM_NATIVE
|
||||||
if (fat_open_rootdir(IF_MV(volume,) &infop->fatfile) < 0)
|
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 */
|
return -ENOENT; /* not mounted */
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
get_rootinfo_internal(infop);
|
get_rootinfo_internal(infop);
|
||||||
}
|
}
|
||||||
|
@ -216,6 +256,7 @@ int root_readdir_dirent(struct filestr_base *stream,
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
int item = scanp->item;
|
int item = scanp->item;
|
||||||
|
logf("%s: item: %d", __func__, item);
|
||||||
|
|
||||||
/* skip any not-mounted or hidden items */
|
/* skip any not-mounted or hidden items */
|
||||||
unsigned int state;
|
unsigned int state;
|
||||||
|
@ -226,7 +267,10 @@ int root_readdir_dirent(struct filestr_base *stream,
|
||||||
|
|
||||||
state = get_root_item_state(item);
|
state = get_root_item_state(item);
|
||||||
if ((state & (NSITEM_MOUNTED|NSITEM_HIDDEN)) == NSITEM_MOUNTED)
|
if ((state & (NSITEM_MOUNTED|NSITEM_HIDDEN)) == NSITEM_MOUNTED)
|
||||||
|
{
|
||||||
|
logf("Found mounted item: %d %s", item, entry->d_name);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
item++;
|
item++;
|
||||||
}
|
}
|
||||||
|
@ -238,13 +282,17 @@ int root_readdir_dirent(struct filestr_base *stream,
|
||||||
FILE_ERROR(ERRNO, rc * 10 - 1);
|
FILE_ERROR(ERRNO, rc * 10 - 1);
|
||||||
|
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
|
{
|
||||||
|
logf("Found root item: %d %s", item, entry->d_name);
|
||||||
item++;
|
item++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
get_mount_point_entry(IF_MV(item,) entry);
|
get_mount_point_entry(IF_MV(item,) entry);
|
||||||
item++;
|
item++;
|
||||||
rc = 1;
|
rc = 1;
|
||||||
|
logf("Found mp item:%d %s", item, entry->d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanp->item = item;
|
scanp->item = item;
|
||||||
|
@ -255,6 +303,7 @@ file_eod:
|
||||||
empty_dirent(entry);
|
empty_dirent(entry);
|
||||||
#endif
|
#endif
|
||||||
file_error:
|
file_error:
|
||||||
|
logf("%s: status: %d", __func__, rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +311,7 @@ file_error:
|
||||||
int ns_open_stream(const char *path, unsigned int callflags,
|
int ns_open_stream(const char *path, unsigned int callflags,
|
||||||
struct filestr_base *stream, struct ns_scan_info *scanp)
|
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 */
|
/* stream still needs synchronization even if we don't have a stream */
|
||||||
static struct mutex no_contents_mtx SHAREDBSS_ATTR;
|
static struct mutex no_contents_mtx SHAREDBSS_ATTR;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue