mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Fixed romfs_dir struct for the parent field and fixed romfs_dev.h formatting.
This commit is contained in:
parent
f5606bfb8a
commit
67af341594
@ -16,39 +16,40 @@
|
||||
/// RomFS header.
|
||||
typedef struct
|
||||
{
|
||||
u64 headerSize; ///< Size of the header.
|
||||
u64 dirHashTableOff; ///< Offset of the directory hash table.
|
||||
u64 dirHashTableSize; ///< Size of the directory hash table.
|
||||
u64 dirTableOff; ///< Offset of the directory table.
|
||||
u64 dirTableSize; ///< Size of the directory table.
|
||||
u64 fileHashTableOff; ///< Offset of the file hash table.
|
||||
u64 fileHashTableSize; ///< Size of the file hash table.
|
||||
u64 fileTableOff; ///< Offset of the file table.
|
||||
u64 fileTableSize; ///< Size of the file table.
|
||||
u64 fileDataOff; ///< Offset of the file data.
|
||||
u64 headerSize; ///< Size of the header.
|
||||
u64 dirHashTableOff; ///< Offset of the directory hash table.
|
||||
u64 dirHashTableSize; ///< Size of the directory hash table.
|
||||
u64 dirTableOff; ///< Offset of the directory table.
|
||||
u64 dirTableSize; ///< Size of the directory table.
|
||||
u64 fileHashTableOff; ///< Offset of the file hash table.
|
||||
u64 fileHashTableSize; ///< Size of the file hash table.
|
||||
u64 fileTableOff; ///< Offset of the file table.
|
||||
u64 fileTableSize; ///< Size of the file table.
|
||||
u64 fileDataOff; ///< Offset of the file data.
|
||||
} romfs_header;
|
||||
|
||||
/// RomFS directory.
|
||||
typedef struct
|
||||
{
|
||||
u32 sibling; ///< Offset of the next sibling directory.
|
||||
u32 childDir; ///< Offset of the first child directory.
|
||||
u32 childFile; ///< Offset of the first file.
|
||||
u32 nextHash; ///< Directory hash table pointer.
|
||||
u32 nameLen; ///< Name length.
|
||||
uint8_t name[]; ///< Name. (UTF-8)
|
||||
u32 parent; ///< Offset of the parent directory.
|
||||
u32 sibling; ///< Offset of the next sibling directory.
|
||||
u32 childDir; ///< Offset of the first child directory.
|
||||
u32 childFile; ///< Offset of the first file.
|
||||
u32 nextHash; ///< Directory hash table pointer.
|
||||
u32 nameLen; ///< Name length.
|
||||
uint8_t name[]; ///< Name. (UTF-8)
|
||||
} romfs_dir;
|
||||
|
||||
/// RomFS file.
|
||||
typedef struct
|
||||
{
|
||||
u32 parent; ///< Offset of the parent directory.
|
||||
u32 sibling; ///< Offset of the next sibling file.
|
||||
u64 dataOff; ///< Offset of the file's data.
|
||||
u64 dataSize; ///< Length of the file's data.
|
||||
u32 nextHash; ///< File hash table pointer.
|
||||
u32 nameLen; ///< Name length.
|
||||
uint8_t name[]; ///< Name. (UTF-8)
|
||||
u32 parent; ///< Offset of the parent directory.
|
||||
u32 sibling; ///< Offset of the next sibling file.
|
||||
u64 dataOff; ///< Offset of the file's data.
|
||||
u64 dataSize; ///< Length of the file's data.
|
||||
u32 nextHash; ///< File hash table pointer.
|
||||
u32 nameLen; ///< Name length.
|
||||
uint8_t name[]; ///< Name. (UTF-8)
|
||||
} romfs_file;
|
||||
|
||||
struct romfs_mount;
|
||||
@ -60,7 +61,7 @@ struct romfs_mount;
|
||||
Result romfsMount(struct romfs_mount **mount);
|
||||
static inline Result romfsInit(void)
|
||||
{
|
||||
return romfsMount(NULL);
|
||||
return romfsMount(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +73,7 @@ static inline Result romfsInit(void)
|
||||
Result romfsMountFromFile(FsFile file, u64 offset, struct romfs_mount **mount);
|
||||
static inline Result romfsInitFromFile(FsFile file, u64 offset)
|
||||
{
|
||||
return romfsMountFromFile(file, offset, NULL);
|
||||
return romfsMountFromFile(file, offset, NULL);
|
||||
}
|
||||
|
||||
/// Bind the RomFS mount
|
||||
@ -82,6 +83,6 @@ Result romfsBind(struct romfs_mount *mount);
|
||||
Result romfsUnmount(struct romfs_mount *mount);
|
||||
static inline Result romfsExit(void)
|
||||
{
|
||||
return romfsUnmount(NULL);
|
||||
return romfsUnmount(NULL);
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ Result romfsMountCommon(romfs_mount *mount)
|
||||
mount->dirTable = malloc(mount->header.dirTableSize);
|
||||
if (!mount->dirTable)
|
||||
goto fail;
|
||||
if (!_romfs_read_chk(mount, mount->header.dirTableOff + 4, mount->dirTable, mount->header.dirTableSize))
|
||||
if (!_romfs_read_chk(mount, mount->header.dirTableOff, mount->dirTable, mount->header.dirTableSize))
|
||||
goto fail;
|
||||
|
||||
mount->fileHashTable = (u32*)malloc(mount->header.fileHashTableSize);
|
||||
@ -411,7 +411,7 @@ static romfs_dir* searchForDir(romfs_mount *mount, romfs_dir* parent, const uint
|
||||
for (curOff = mount->dirHashTable[hash]; curOff != romFS_none; curOff = curDir->nextHash)
|
||||
{
|
||||
curDir = romFS_dir(mount, curOff);
|
||||
//if (curDir->parent != parentOff) continue;//TODO: How to handle parent here?
|
||||
if (curDir->parent != parentOff) continue;
|
||||
if (curDir->nameLen != namelen) continue;
|
||||
if (memcmp(curDir->name, name, namelen) != 0) continue;
|
||||
return curDir;
|
||||
@ -478,7 +478,7 @@ static int navigateToDir(romfs_mount *mount, romfs_dir** ppDir, const char** pPa
|
||||
if (!component[1]) continue;
|
||||
if (component[1]=='.' && !component[2])
|
||||
{
|
||||
//*ppDir = romFS_dir(mount, (*ppDir)->parent);//TODO: How to handle parent here?
|
||||
*ppDir = romFS_dir(mount, (*ppDir)->parent);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -762,10 +762,10 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s
|
||||
else if(iter->state == 1)
|
||||
{
|
||||
/* '..' entry */
|
||||
//romfs_dir* dir = romFS_dir(iter->mount, iter->dir->parent);//TODO: How to handle parent here?
|
||||
romfs_dir* dir = romFS_dir(iter->mount, iter->dir->parent);
|
||||
|
||||
memset(filestat, 0, sizeof(*filestat));
|
||||
//filestat->st_ino = dir_inode(iter->mount, dir);
|
||||
filestat->st_ino = dir_inode(iter->mount, dir);
|
||||
filestat->st_mode = romFS_dir_mode;
|
||||
|
||||
strcpy(filename, "..");
|
||||
|
Loading…
Reference in New Issue
Block a user