Hello user process
This commit is contained in:
@ -9,7 +9,6 @@
|
||||
#define CHECK(err) \
|
||||
do { \
|
||||
int ok = (err); \
|
||||
kprintf("ok = %d\n", ok); \
|
||||
if (ok < 0) goto bad; \
|
||||
} while(0)
|
||||
|
||||
@ -27,7 +26,29 @@ int32_t littlefs_read(struct VfsMountPoint *vmp, const char *path, uint8_t *cons
|
||||
return E_OK;
|
||||
bad:
|
||||
spinlock_release(&vmp->spinlock);
|
||||
return E_GENERIC_ERROR;
|
||||
return E_BADIO;
|
||||
}
|
||||
|
||||
int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, struct VfsStat *stat) {
|
||||
spinlock_acquire(&vmp->spinlock);
|
||||
|
||||
LittleFs *fs = &vmp->fs.littlefs;
|
||||
struct lfs_info stat1;
|
||||
CHECK(lfs_stat(&fs->instance, path, &stat1));
|
||||
|
||||
if (stat1.type == LFS_TYPE_REG) {
|
||||
stat->type = VFS_TYPE_FILE;
|
||||
} else if (stat1.type == LFS_TYPE_DIR) {
|
||||
stat->type = VFS_TYPE_DIR;
|
||||
}
|
||||
|
||||
stat->size = stat1.size;
|
||||
|
||||
spinlock_release(&vmp->spinlock);
|
||||
return E_OK;
|
||||
bad:
|
||||
spinlock_release(&vmp->spinlock);
|
||||
return E_BADIO;
|
||||
}
|
||||
|
||||
int32_t littlefs_write(struct VfsMountPoint *vmp, const char *path, const uint8_t *const buffer, size_t n, size_t off) {
|
||||
@ -44,7 +65,7 @@ int32_t littlefs_write(struct VfsMountPoint *vmp, const char *path, const uint8_
|
||||
return E_OK;
|
||||
bad:
|
||||
spinlock_release(&vmp->spinlock);
|
||||
return E_GENERIC_ERROR;
|
||||
return E_BADIO;
|
||||
}
|
||||
|
||||
int32_t littlefs_remove(struct VfsMountPoint *vmp, const char *path) {
|
||||
@ -57,7 +78,7 @@ int32_t littlefs_remove(struct VfsMountPoint *vmp, const char *path) {
|
||||
return E_OK;
|
||||
bad:
|
||||
spinlock_release(&vmp->spinlock);
|
||||
return E_GENERIC_ERROR;
|
||||
return E_BADIO;
|
||||
}
|
||||
|
||||
int32_t littlefs_cleanup(struct VfsMountPoint *vmp) {
|
||||
@ -67,7 +88,7 @@ int32_t littlefs_cleanup(struct VfsMountPoint *vmp) {
|
||||
return err;
|
||||
}
|
||||
err = lfs_unmount(&vmp->fs.littlefs.instance);
|
||||
if (err < 0) { return E_GENERIC_ERROR; }
|
||||
if (err < 0) { return E_BADIO; }
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
@ -76,10 +97,10 @@ int32_t littlefs_create(struct VfsMountPoint *vmp, const char *path, int32_t typ
|
||||
|
||||
LittleFs *fs = &vmp->fs.littlefs;
|
||||
switch (type) {
|
||||
case VFS_CREATE_DIR:
|
||||
case VFS_TYPE_DIR:
|
||||
CHECK(lfs_mkdir(&fs->instance, path));
|
||||
break;
|
||||
case VFS_CREATE_FILE: {
|
||||
case VFS_TYPE_FILE: {
|
||||
lfs_file_t file;
|
||||
CHECK(lfs_file_open(&fs->instance, &file, path, LFS_O_CREAT | LFS_O_WRONLY));
|
||||
CHECK(lfs_file_close(&fs->instance, &file));
|
||||
@ -90,7 +111,7 @@ int32_t littlefs_create(struct VfsMountPoint *vmp, const char *path, int32_t typ
|
||||
return E_OK;
|
||||
bad:
|
||||
spinlock_release(&vmp->spinlock);
|
||||
return E_GENERIC_ERROR;
|
||||
return E_BADIO;
|
||||
}
|
||||
|
||||
bool littlefs_check(void) {
|
||||
|
Reference in New Issue
Block a user