mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
When the sd card is mounted into the root namespace the database picks up files through both paths previously we hid the mounted drive but this causes issues with users databases when the drive letter changes Adds a way to keep track of volumes mounted in the root namespace Hides the enumerated volume in root Database: we can just parse the root directory ('/') and get to any mounted volume but we can also enumerate a volume in the root directory when this occurs it leads to multiple entries since the files can be reached through multiple paths ex, /Foo could also be /SD1/Foo Instead we will attempt to rewrite the root with any non-hidden volumes failing that just leave the paths alone Change-Id: I7bdba8cfaf63902d2a3852d28484bcf8ca317ebd
82 lines
2.8 KiB
C
82 lines
2.8 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2017 by Michael Sevakis
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
#ifndef RB_NAMESPACE_H
|
|
#define RB_NAMESPACE_H
|
|
|
|
#include "file_internal.h"
|
|
|
|
enum ns_item_flags
|
|
{
|
|
NSITEM_MOUNTED = 0x01, /* item is mounted */
|
|
NSITEM_HIDDEN = 0x02, /* item is not enumerated */
|
|
NSITEM_CONTENTS = 0x04, /* contents enumerate */
|
|
};
|
|
|
|
struct ns_scan_info
|
|
{
|
|
struct dirscan_info scan; /* dirscan info - first! */
|
|
int item; /* current item in parent */
|
|
};
|
|
|
|
/* root functions */
|
|
#define ROOT_MAX_REALPATH 80
|
|
const char* root_get_realpath(void);
|
|
int root_mount_path(const char *path, unsigned int flags);
|
|
void root_unmount_volume(IF_MV_NONVOID(int volume));
|
|
int root_readdir_dirent(struct filestr_base *stream,
|
|
struct ns_scan_info *scanp,
|
|
struct DIRENT *entry);
|
|
|
|
/* namespace functions */
|
|
int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp);
|
|
int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
|
|
struct file_base_info *infop, uint16_t *attrp);
|
|
int ns_open_stream(const char *path, unsigned int callflags,
|
|
struct filestr_base *stream, struct ns_scan_info *scanp);
|
|
bool ns_volume_is_visible(IF_MV_NONVOID(int volume));
|
|
|
|
/* closes the namespace stream */
|
|
static inline int ns_close_stream(struct filestr_base *stream)
|
|
{
|
|
return close_stream_internal(stream);
|
|
}
|
|
|
|
#include "dircache_redirect.h"
|
|
|
|
static inline void ns_dirscan_rewind(struct ns_scan_info *scanp)
|
|
{
|
|
rewinddir_dirent(&scanp->scan);
|
|
if (scanp->item != -1)
|
|
scanp->item = 0;
|
|
}
|
|
|
|
static inline int ns_readdir_dirent(struct filestr_base *stream,
|
|
struct ns_scan_info *scanp,
|
|
struct dirent *entry)
|
|
|
|
{
|
|
if (scanp->item == -1)
|
|
return readdir_dirent(stream, &scanp->scan, entry);
|
|
else
|
|
return root_readdir_dirent(stream, scanp, entry);
|
|
}
|
|
|
|
#endif /* RB_NAMESPACE_H */
|