wutdevoptab: Implement devoptab using FSA functions

This commit is contained in:
Maschell
2022-08-09 12:53:58 +02:00
committed by Dave Murphy
parent e492c31d06
commit 4083224b51
28 changed files with 928 additions and 541 deletions

View File

@@ -1,34 +1,40 @@
#include "devoptab_fsa.h"
int
__wut_fs_stat(struct _reent *r,
const char *path,
struct stat *st) {
FSStatus status;
FSCmdBlock cmd;
FSStat fsStat;
__wut_fsa_stat(struct _reent *r,
const char *path,
struct stat *st) {
FSError status;
FSAStat fsStat;
__wut_fsa_device_t *deviceData;
if (!path || !st) {
r->_errno = EINVAL;
return -1;
}
char *fixedPath = __wut_fs_fixpath(r, path);
char *fixedPath = __wut_fsa_fixpath(r, path);
if (!fixedPath) {
r->_errno = ENOMEM;
return -1;
}
FSInitCmdBlock(&cmd);
deviceData = (__wut_fsa_device_t *) r->deviceData;
status = FSGetStat(__wut_devoptab_fs_client, &cmd, fixedPath, &fsStat, FS_ERROR_FLAG_ALL);
status = FSAGetStat(deviceData->clientHandle, fixedPath, &fsStat);
if (status < 0) {
if (status != FS_ERROR_NOT_FOUND) {
WUT_DEBUG_REPORT("FSAGetStat(0x%08X, %s, 0x%08X) failed: %s\n",
deviceData->clientHandle, fixedPath, &fsStat, FSAGetStatusStr(status));
}
free(fixedPath);
r->_errno = __wut_fs_translate_error(status);
r->_errno = __wut_fsa_translate_error(status);
return -1;
}
ino_t ino = __wut_fsa_hashstring(fixedPath);
free(fixedPath);
__wut_fs_translate_stat(&fsStat, st);
__wut_fsa_translate_stat(deviceData->clientHandle, &fsStat, ino, st);
return 0;
}