Move string functions/utils from HAL to std/string
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
#include "storedev/storedev.h"
|
||||
#include "baseimg/baseimg.h"
|
||||
#include "dlmalloc/malloc.h"
|
||||
#include "std/string.h"
|
||||
|
||||
VfsTable VFS_TABLE;
|
||||
VfsBusyObjs VFS_BUSY_VOBJS;
|
||||
@ -19,16 +20,16 @@ VfsBusyObjs VFS_BUSY_VOBJS;
|
||||
#define CHECK_BUSY_VFSOBJ() \
|
||||
char *tmpbuf = dlmalloc(VFS_MOUNTPOINT_LABEL_MAX+1+VFS_PATH_MAX); \
|
||||
\
|
||||
hal_memset(tmpbuf, 0, VFS_MOUNTPOINT_LABEL_MAX+1+VFS_PATH_MAX); \
|
||||
hal_string_combine(tmpbuf, mountpoint); \
|
||||
hal_string_combine(tmpbuf, ":"); \
|
||||
hal_string_combine(tmpbuf, path); \
|
||||
memset(tmpbuf, 0, VFS_MOUNTPOINT_LABEL_MAX+1+VFS_PATH_MAX); \
|
||||
strcat(tmpbuf, mountpoint); \
|
||||
strcat(tmpbuf, ":"); \
|
||||
strcat(tmpbuf, path); \
|
||||
\
|
||||
bool busy = false; \
|
||||
VfsObj *vobj, *vobjtmp; \
|
||||
spinlock_acquire(&VFS_BUSY_VOBJS.spinlock); \
|
||||
LL_FOREACH_SAFE(VFS_BUSY_VOBJS.vobjs, vobj, vobjtmp) { \
|
||||
if (hal_strcmp(vobj->path, tmpbuf) == 0) { \
|
||||
if (strcmp(vobj->path, tmpbuf) == 0) { \
|
||||
busy = true; \
|
||||
break; \
|
||||
} \
|
||||
@ -39,7 +40,7 @@ VfsBusyObjs VFS_BUSY_VOBJS;
|
||||
|
||||
void vfs_init_littlefs(VfsMountPoint *mp, bool format) {
|
||||
struct lfs_config *cfg = dlmalloc(sizeof(*cfg));
|
||||
hal_memset(cfg, 0, sizeof(*cfg));
|
||||
memset(cfg, 0, sizeof(*cfg));
|
||||
cfg->context = mp;
|
||||
cfg->read = &portlfs_read;
|
||||
cfg->prog = &portlfs_prog;
|
||||
@ -147,7 +148,7 @@ int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool fo
|
||||
return E_NOMEMORY;
|
||||
}
|
||||
|
||||
hal_memcpy(mp->label, mountpoint, hal_strlen(mountpoint));
|
||||
memcpy(mp->label, mountpoint, strlen(mountpoint));
|
||||
mp->backingsd = backingsd;
|
||||
mp->fstype = fstype;
|
||||
switch (fstype) {
|
||||
@ -178,7 +179,7 @@ int32_t vfs_unmount(char *mountpoint) {
|
||||
spinlock_release(&mp->spinlock);
|
||||
return err;
|
||||
}
|
||||
hal_memset(mp, 0, sizeof(*mp));
|
||||
memset(mp, 0, sizeof(*mp));
|
||||
spinlock_release(&mp->spinlock);
|
||||
return E_OK;
|
||||
}
|
||||
@ -205,9 +206,9 @@ VfsObj *vfs_open(char *mountpoint, const char *path, uint32_t flags) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hal_string_combine(vobj1->path, mountpoint);
|
||||
hal_string_combine(vobj1->path, ":");
|
||||
hal_string_combine(vobj1->path, path);
|
||||
strcat(vobj1->path, mountpoint);
|
||||
strcat(vobj1->path, ":");
|
||||
strcat(vobj1->path, path);
|
||||
|
||||
spinlock_acquire(&VFS_BUSY_VOBJS.spinlock);
|
||||
LL_APPEND(VFS_BUSY_VOBJS.vobjs, vobj1);
|
||||
@ -224,9 +225,9 @@ void vfs_close(VfsObj *vobj) {
|
||||
}
|
||||
|
||||
void vfs_init(void) {
|
||||
hal_memset(&VFS_TABLE, 0, sizeof(VFS_TABLE));
|
||||
memset(&VFS_TABLE, 0, sizeof(VFS_TABLE));
|
||||
spinlock_init(&VFS_TABLE.spinlock);
|
||||
hal_memset(&VFS_BUSY_VOBJS, 0, sizeof(VFS_BUSY_VOBJS));
|
||||
memset(&VFS_BUSY_VOBJS, 0, sizeof(VFS_BUSY_VOBJS));
|
||||
spinlock_init(&VFS_BUSY_VOBJS.spinlock);
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user