Format the code via clang-format

This commit is contained in:
Maschell 2022-02-13 12:12:26 +01:00
parent 96be7edd0e
commit 3bdd79b69e
8 changed files with 174 additions and 67 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

25
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: CI-PR
on: [pull_request]
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include
build-lib:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build lib
run: |
docker build . -f Dockerfile.buildlocal -t builder
docker run --rm -v ${PWD}:/project builder make
- uses: actions/upload-artifact@master
with:
name: lib
path: "lib/*.a"

View File

@ -4,8 +4,16 @@ on:
branches: branches:
- main - main
jobs: jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: clang-format
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Get release version - name: Get release version
@ -23,4 +31,3 @@ jobs:
snapshot: true snapshot: true
cache: true cache: true
tags: "latest, ${{ env.RELEASE_VERSION }}" tags: "latest, ${{ env.RELEASE_VERSION }}"
dockerfile: Dockerfile

View File

@ -1,4 +1,4 @@
FROM wiiuenv/devkitppc:20210920 FROM wiiuenv/devkitppc:20211229
WORKDIR tmp_build WORKDIR tmp_build
COPY . . COPY . .

3
Dockerfile.buildlocal Normal file
View File

@ -0,0 +1,3 @@
FROM wiiuenv/devkitppc:20211229
WORKDIR project

View File

@ -1,3 +1,5 @@
[![Publish Docker Image](https://github.com/wiiu-env/libromfs_wiiu/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/libromfs_wiiu/actions/workflows/push_image.yml)
# libromfs # libromfs
Ported from [libnx](https://github.com/switchbrew/libnx/blob/e5ae43f4c2cca5320559d9c27ce256b2901aed40/nx/source/runtime/devices/romfs_dev.c) Ported from [libnx](https://github.com/switchbrew/libnx/blob/e5ae43f4c2cca5320559d9c27ce256b2901aed40/nx/source/runtime/devices/romfs_dev.c)
@ -16,3 +18,7 @@ COPY --from=wiiuenv/libromfs_wiiu:[tag] /artifacts $DEVKITPRO
``` ```
Replace [tag] with a tag you want to use, a list of tags can be found [here](https://hub.docker.com/r/wiiuenv/libromfs_wiiu/tags). Replace [tag] with a tag you want to use, a list of tags can be found [here](https://hub.docker.com/r/wiiuenv/libromfs_wiiu/tags).
It's highly recommended to pin the version to the **latest date** instead of using `latest`. It's highly recommended to pin the version to the **latest date** instead of using `latest`.
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include -i`

View File

@ -34,7 +34,7 @@ typedef struct {
uint32_t childFile; ///< Offset of the first file. uint32_t childFile; ///< Offset of the first file.
uint32_t nextHash; ///< Directory hash table pointer. uint32_t nextHash; ///< Directory hash table pointer.
uint32_t nameLen; ///< Name length. uint32_t nameLen; ///< Name length.
uint8_t name[]; ///< Name. (UTF-8) uint8_t name[]; ///< Name. (UTF-8)
} romfs_dir; } romfs_dir;
/// RomFS file. /// RomFS file.
@ -45,7 +45,7 @@ typedef struct {
uint64_t dataSize; ///< Length of the file's data. uint64_t dataSize; ///< Length of the file's data.
uint32_t nextHash; ///< File hash table pointer. uint32_t nextHash; ///< File hash table pointer.
uint32_t nameLen; ///< Name length. uint32_t nameLen; ///< Name length.
uint8_t name[]; ///< Name. (UTF-8) uint8_t name[]; ///< Name. (UTF-8)
} romfs_file; } romfs_file;
#ifdef __cplusplus #ifdef __cplusplus
@ -76,7 +76,7 @@ int32_t romfsUnmount(const char *name);
/// RomFS file. /// RomFS file.
typedef struct { typedef struct {
uint64_t length; ///< Offset of the file's data. uint64_t length; ///< Offset of the file's data.
uint64_t offset; ///< Length of the file's data. uint64_t offset; ///< Length of the file's data.
} romfs_fileInfo; } romfs_fileInfo;
@ -85,4 +85,3 @@ int romfsGetFileInfoPerPath(const char *romfs, const char *path, romfs_fileInfo
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,16 +1,16 @@
#include <coreinit/cache.h>
#include <coreinit/filesystem.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <malloc.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/dirent.h> #include <sys/dirent.h>
#include <sys/iosupport.h> #include <sys/iosupport.h>
#include <sys/param.h> #include <sys/param.h>
#include <unistd.h> #include <unistd.h>
#include <stdbool.h>
#include <malloc.h>
#include <coreinit/cache.h>
#include <coreinit/filesystem.h>
#include "romfs_dev.h" #include "romfs_dev.h"
@ -37,8 +37,8 @@ extern char **__system_argv;
//static char __thread __component[PATH_MAX+1]; //static char __thread __component[PATH_MAX+1];
static char __component[PATH_MAX + 1]; static char __component[PATH_MAX + 1];
#define romFS_root(m) ((romfs_dir*)(m)->dirTable) #define romFS_root(m) ((romfs_dir *) (m)->dirTable)
#define romFS_none ((uint32_t)~0) #define romFS_none ((uint32_t) ~0)
#define romFS_dir_mode (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) #define romFS_dir_mode (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH)
#define romFS_file_mode (S_IFREG | S_IRUSR | S_IRGRP | S_IROTH) #define romFS_file_mode (S_IFREG | S_IRUSR | S_IRGRP | S_IROTH)
@ -147,8 +147,8 @@ static const devoptab_t romFS_devoptab =
.dirnext_r = romfs_dirnext, .dirnext_r = romfs_dirnext,
.dirclose_r = romfs_dirclose, .dirclose_r = romfs_dirclose,
// symlinks aren't supported so alias lstat to stat // symlinks aren't supported so alias lstat to stat
.lstat_r = romfs_stat, .lstat_r = romfs_stat,
}; };
static bool romfs_initialised = false; static bool romfs_initialised = false;
static romfs_mount romfs_mounts[32]; static romfs_mount romfs_mounts[32];
@ -162,9 +162,9 @@ static void romfsInitMtime(romfs_mount *mount);
static void _romfsResetMount(romfs_mount *mount, int32_t id) { static void _romfsResetMount(romfs_mount *mount, int32_t id) {
memset(mount, 0, sizeof(*mount)); memset(mount, 0, sizeof(*mount));
memcpy(&mount->device, &romFS_devoptab, sizeof(romFS_devoptab)); memcpy(&mount->device, &romFS_devoptab, sizeof(romFS_devoptab));
mount->device.name = mount->name; mount->device.name = mount->name;
mount->device.deviceData = mount; mount->device.deviceData = mount;
mount->id = id; mount->id = id;
DCFlushRange(mount, sizeof(*mount)); DCFlushRange(mount, sizeof(*mount));
} }
@ -183,7 +183,7 @@ static void _romfsInit(void) {
static romfs_mount *romfsFindMount(const char *name) { static romfs_mount *romfsFindMount(const char *name) {
uint32_t i; uint32_t i;
uint32_t total = sizeof(romfs_mounts) / sizeof(romfs_mount); uint32_t total = sizeof(romfs_mounts) / sizeof(romfs_mount);
romfs_mount *mount = NULL; romfs_mount *mount = NULL;
_romfsInit(); _romfsInit();
@ -294,10 +294,10 @@ int32_t romfsMountCommon(const char *name, romfs_mount *mount) {
goto fail_io; goto fail_io;
} }
mount->dirHashTable = NULL; mount->dirHashTable = NULL;
mount->dirTable = NULL; mount->dirTable = NULL;
mount->fileHashTable = NULL; mount->fileHashTable = NULL;
mount->fileTable = NULL; mount->fileTable = NULL;
mount->dirHashTable = (uint32_t *) memalign(0x40, mount->header.dirHashTableSize); mount->dirHashTable = (uint32_t *) memalign(0x40, mount->header.dirHashTableSize);
if (!mount->dirHashTable) { if (!mount->dirHashTable) {
@ -341,11 +341,11 @@ int32_t romfsMountCommon(const char *name, romfs_mount *mount) {
DCFlushRange(mount, sizeof(*mount)); DCFlushRange(mount, sizeof(*mount));
return 0; return 0;
fail_oom: fail_oom:
romfs_mountclose(mount); romfs_mountclose(mount);
return 9; return 9;
fail_io: fail_io:
romfs_mountclose(mount); romfs_mountclose(mount);
return 10; return 10;
} }
@ -408,8 +408,8 @@ static bool comparePaths(const uint8_t *name1, const uint8_t *name2, uint32_t na
static int searchForDir(romfs_mount *mount, romfs_dir *parent, const uint8_t *name, uint32_t namelen, romfs_dir **out) { static int searchForDir(romfs_mount *mount, romfs_dir *parent, const uint8_t *name, uint32_t namelen, romfs_dir **out) {
uint64_t parentOff = (uintptr_t) parent - (uintptr_t) mount->dirTable; uint64_t parentOff = (uintptr_t) parent - (uintptr_t) mount->dirTable;
uint32_t hash = calcHash(parentOff, name, namelen, mount->header.dirHashTableSize / 4); uint32_t hash = calcHash(parentOff, name, namelen, mount->header.dirHashTableSize / 4);
romfs_dir *curDir = NULL; romfs_dir *curDir = NULL;
uint32_t curOff; uint32_t curOff;
*out = NULL; *out = NULL;
for (curOff = mount->dirHashTable[hash]; curOff != romFS_none; curOff = curDir->nextHash) { for (curOff = mount->dirHashTable[hash]; curOff != romFS_none; curOff = curDir->nextHash) {
@ -431,8 +431,8 @@ static int searchForDir(romfs_mount *mount, romfs_dir *parent, const uint8_t *na
} }
static int searchForFile(romfs_mount *mount, romfs_dir *parent, const uint8_t *name, uint32_t namelen, romfs_file **out) { static int searchForFile(romfs_mount *mount, romfs_dir *parent, const uint8_t *name, uint32_t namelen, romfs_file **out) {
uint64_t parentOff = (uintptr_t) parent - (uintptr_t) mount->dirTable; uint64_t parentOff = (uintptr_t) parent - (uintptr_t) mount->dirTable;
uint32_t hash = calcHash(parentOff, name, namelen, mount->header.fileHashTableSize / 4); uint32_t hash = calcHash(parentOff, name, namelen, mount->header.fileHashTableSize / 4);
romfs_file *curFile = NULL; romfs_file *curFile = NULL;
uint32_t curOff; uint32_t curOff;
*out = NULL; *out = NULL;
@ -471,7 +471,7 @@ static int navigateToDir(romfs_mount *mount, romfs_dir **ppDir, const char **pPa
} }
while (**pPath) { while (**pPath) {
char *slashPos = strchr(*pPath, '/'); char *slashPos = strchr(*pPath, '/');
char *component = __component; char *component = __component;
if (slashPos) { if (slashPos) {
@ -485,7 +485,7 @@ static int navigateToDir(romfs_mount *mount, romfs_dir **ppDir, const char **pPa
memcpy(component, *pPath, len); memcpy(component, *pPath, len);
component[len] = 0; component[len] = 0;
*pPath = slashPos + 1; *pPath = slashPos + 1;
} else if (isDir) { } else if (isDir) {
component = (char *) *pPath; component = (char *) *pPath;
*pPath += strlen(component); *pPath += strlen(component);
@ -522,7 +522,7 @@ static off_t dir_size(romfs_dir *dir) {
} }
static nlink_t dir_nlink(romfs_mount *mount, romfs_dir *dir) { static nlink_t dir_nlink(romfs_mount *mount, romfs_dir *dir) {
nlink_t count = 2; // one for self, one for parent nlink_t count = 2; // one for self, one for parent
uint32_t offset = dir->childDir; uint32_t offset = dir->childDir;
while (offset != romFS_none) { while (offset != romFS_none) {
@ -556,12 +556,12 @@ int romfsGetFileInfoPerPath(const char *romfs, const char *path, romfs_fileInfo
return -2; return -2;
} }
romfs_dir *curDir = NULL; romfs_dir *curDir = NULL;
int errno2 = navigateToDir(mount, &curDir, &path, false); int errno2 = navigateToDir(mount, &curDir, &path, false);
if (errno2 != 0) { if (errno2 != 0) {
return -3; return -3;
} }
romfs_file *file = NULL; romfs_file *file = NULL;
int err = searchForFile(mount, curDir, (uint8_t *) path, strlen(path), &file); int err = searchForFile(mount, curDir, (uint8_t *) path, strlen(path), &file);
if (err != 0) { if (err != 0) {
return -4; return -4;
} }
@ -586,13 +586,13 @@ int romfs_open(struct _reent *r, void *fileStruct, const char *path, int flags,
} }
romfs_dir *curDir = NULL; romfs_dir *curDir = NULL;
r->_errno = navigateToDir(fileobj->mount, &curDir, &path, false); r->_errno = navigateToDir(fileobj->mount, &curDir, &path, false);
if (r->_errno != 0) { if (r->_errno != 0) {
return -1; return -1;
} }
romfs_file *file = NULL; romfs_file *file = NULL;
int ret = searchForFile(fileobj->mount, curDir, (uint8_t *) path, strlen(path), &file); int ret = searchForFile(fileobj->mount, curDir, (uint8_t *) path, strlen(path), &file);
if (ret != 0) { if (ret != 0) {
if (ret == ENOENT && (flags & O_CREAT)) { if (ret == ENOENT && (flags & O_CREAT)) {
r->_errno = EROFS; r->_errno = EROFS;
@ -605,9 +605,9 @@ int romfs_open(struct _reent *r, void *fileStruct, const char *path, int flags,
return -1; return -1;
} }
fileobj->file = file; fileobj->file = file;
fileobj->offset = fileobj->mount->header.fileDataOff + file->dataOff; fileobj->offset = fileobj->mount->header.fileDataOff + file->dataOff;
fileobj->pos = 0; fileobj->pos = 0;
return 0; return 0;
} }
@ -618,7 +618,7 @@ int romfs_close(struct _reent *r, void *fd) {
ssize_t romfs_read(struct _reent *r, void *fd, char *ptr, size_t len) { ssize_t romfs_read(struct _reent *r, void *fd, char *ptr, size_t len) {
romfs_fileobj *file = (romfs_fileobj *) fd; romfs_fileobj *file = (romfs_fileobj *) fd;
uint64_t endPos = file->pos + len; uint64_t endPos = file->pos + len;
/* check if past end-of-file */ /* check if past end-of-file */
if (file->pos >= file->file->dataSize) { if (file->pos >= file->file->dataSize) {
@ -669,7 +669,7 @@ off_t romfs_seek(struct _reent *r, void *fd, off_t pos, int dir) {
return -1; return -1;
} }
} }
/* check for overflow */ /* check for overflow */
else if (INT64_MAX - pos < start) { else if (INT64_MAX - pos < start) {
r->_errno = EOVERFLOW; r->_errno = EOVERFLOW;
return -1; return -1;
@ -681,23 +681,23 @@ off_t romfs_seek(struct _reent *r, void *fd, off_t pos, int dir) {
static void fillDir(struct stat *st, romfs_mount *mount, romfs_dir *dir) { static void fillDir(struct stat *st, romfs_mount *mount, romfs_dir *dir) {
memset(st, 0, sizeof(*st)); memset(st, 0, sizeof(*st));
st->st_ino = dir_inode(mount, dir); st->st_ino = dir_inode(mount, dir);
st->st_mode = romFS_dir_mode; st->st_mode = romFS_dir_mode;
st->st_nlink = dir_nlink(mount, dir); st->st_nlink = dir_nlink(mount, dir);
st->st_size = dir_size(dir); st->st_size = dir_size(dir);
st->st_blksize = 512; st->st_blksize = 512;
st->st_blocks = (st->st_blksize + 511) / 512; st->st_blocks = (st->st_blksize + 511) / 512;
st->st_atime = st->st_mtime = st->st_ctime = mount->mtime; st->st_atime = st->st_mtime = st->st_ctime = mount->mtime;
} }
static void fillFile(struct stat *st, romfs_mount *mount, romfs_file *file) { static void fillFile(struct stat *st, romfs_mount *mount, romfs_file *file) {
memset(st, 0, sizeof(struct stat)); memset(st, 0, sizeof(struct stat));
st->st_ino = file_inode(mount, file); st->st_ino = file_inode(mount, file);
st->st_mode = romFS_file_mode; st->st_mode = romFS_file_mode;
st->st_nlink = 1; st->st_nlink = 1;
st->st_size = (off_t) file->dataSize; st->st_size = (off_t) file->dataSize;
st->st_blksize = 512; st->st_blksize = 512;
st->st_blocks = (st->st_blksize + 511) / 512; st->st_blocks = (st->st_blksize + 511) / 512;
st->st_atime = st->st_mtime = st->st_ctime = mount->mtime; st->st_atime = st->st_mtime = st->st_ctime = mount->mtime;
} }
@ -710,8 +710,8 @@ int romfs_fstat(struct _reent *r, void *fd, struct stat *st) {
int romfs_stat(struct _reent *r, const char *path, struct stat *st) { int romfs_stat(struct _reent *r, const char *path, struct stat *st) {
romfs_mount *mount = (romfs_mount *) r->deviceData; romfs_mount *mount = (romfs_mount *) r->deviceData;
romfs_dir *curDir = NULL; romfs_dir *curDir = NULL;
r->_errno = navigateToDir(mount, &curDir, &path, false); r->_errno = navigateToDir(mount, &curDir, &path, false);
if (r->_errno != 0) { if (r->_errno != 0) {
return -1; return -1;
} }
@ -722,8 +722,8 @@ int romfs_stat(struct _reent *r, const char *path, struct stat *st) {
} }
romfs_dir *dir = NULL; romfs_dir *dir = NULL;
int ret = 0; int ret = 0;
ret = searchForDir(mount, curDir, (uint8_t *) path, strlen(path), &dir); ret = searchForDir(mount, curDir, (uint8_t *) path, strlen(path), &dir);
if (ret != 0 && ret != ENOENT) { if (ret != 0 && ret != ENOENT) {
r->_errno = ret; r->_errno = ret;
return -1; return -1;
@ -735,7 +735,7 @@ int romfs_stat(struct _reent *r, const char *path, struct stat *st) {
} }
romfs_file *file = NULL; romfs_file *file = NULL;
ret = searchForFile(mount, curDir, (uint8_t *) path, strlen(path), &file); ret = searchForFile(mount, curDir, (uint8_t *) path, strlen(path), &file);
if (ret != 0 && ret != ENOENT) { if (ret != 0 && ret != ENOENT) {
r->_errno = ret; r->_errno = ret;
return -1; return -1;
@ -751,8 +751,8 @@ int romfs_stat(struct _reent *r, const char *path, struct stat *st) {
int romfs_chdir(struct _reent *r, const char *path) { int romfs_chdir(struct _reent *r, const char *path) {
romfs_mount *mount = (romfs_mount *) r->deviceData; romfs_mount *mount = (romfs_mount *) r->deviceData;
romfs_dir *curDir = NULL; romfs_dir *curDir = NULL;
r->_errno = navigateToDir(mount, &curDir, &path, true); r->_errno = navigateToDir(mount, &curDir, &path, true);
if (r->_errno != 0) { if (r->_errno != 0) {
return -1; return -1;
} }
@ -763,17 +763,17 @@ int romfs_chdir(struct _reent *r, const char *path) {
DIR_ITER *romfs_diropen(struct _reent *r, DIR_ITER *dirState, const char *path) { DIR_ITER *romfs_diropen(struct _reent *r, DIR_ITER *dirState, const char *path) {
romfs_diriter *iter = (romfs_diriter *) (dirState->dirStruct); romfs_diriter *iter = (romfs_diriter *) (dirState->dirStruct);
romfs_dir *curDir = NULL; romfs_dir *curDir = NULL;
iter->mount = (romfs_mount *) r->deviceData; iter->mount = (romfs_mount *) r->deviceData;
r->_errno = navigateToDir(iter->mount, &curDir, &path, true); r->_errno = navigateToDir(iter->mount, &curDir, &path, true);
if (r->_errno != 0) { if (r->_errno != 0) {
return NULL; return NULL;
} }
iter->dir = curDir; iter->dir = curDir;
iter->state = 0; iter->state = 0;
iter->childDir = curDir->childDir; iter->childDir = curDir->childDir;
iter->childFile = curDir->childFile; iter->childFile = curDir->childFile;
return dirState; return dirState;
@ -782,8 +782,8 @@ DIR_ITER *romfs_diropen(struct _reent *r, DIR_ITER *dirState, const char *path)
int romfs_dirreset(struct _reent *r, DIR_ITER *dirState) { int romfs_dirreset(struct _reent *r, DIR_ITER *dirState) {
romfs_diriter *iter = (romfs_diriter *) (dirState->dirStruct); romfs_diriter *iter = (romfs_diriter *) (dirState->dirStruct);
iter->state = 0; iter->state = 0;
iter->childDir = iter->dir->childDir; iter->childDir = iter->dir->childDir;
iter->childFile = iter->dir->childFile; iter->childFile = iter->dir->childFile;
return 0; return 0;
@ -795,7 +795,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s
if (iter->state == 0) { if (iter->state == 0) {
/* '.' entry */ /* '.' entry */
memset(filestat, 0, sizeof(*filestat)); memset(filestat, 0, sizeof(*filestat));
filestat->st_ino = dir_inode(iter->mount, iter->dir); filestat->st_ino = dir_inode(iter->mount, iter->dir);
filestat->st_mode = romFS_dir_mode; filestat->st_mode = romFS_dir_mode;
strcpy(filename, "."); strcpy(filename, ".");
@ -810,7 +810,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s
} }
memset(filestat, 0, sizeof(*filestat)); 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; filestat->st_mode = romFS_dir_mode;
strcpy(filename, ".."); strcpy(filename, "..");
@ -828,7 +828,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s
iter->childDir = dir->sibling; iter->childDir = dir->sibling;
memset(filestat, 0, sizeof(*filestat)); 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; filestat->st_mode = romFS_dir_mode;
memset(filename, 0, NAME_MAX); memset(filename, 0, NAME_MAX);
@ -851,7 +851,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s
iter->childFile = file->sibling; iter->childFile = file->sibling;
memset(filestat, 0, sizeof(*filestat)); memset(filestat, 0, sizeof(*filestat));
filestat->st_ino = file_inode(iter->mount, file); filestat->st_ino = file_inode(iter->mount, file);
filestat->st_mode = romFS_file_mode; filestat->st_mode = romFS_file_mode;
memset(filename, 0, NAME_MAX); memset(filename, 0, NAME_MAX);