#ifndef FS_PORTLFS_PORTLFS_H_
#define FS_PORTLFS_PORTLFS_H_

#include <stdint.h>
#include <stdbool.h>
#include "fs/littlefs/lfs.h"
#include "sysdefs/fs.h"

#define LITTLEFS_BLOCK_SIZE 512

struct VfsMountPoint;
struct VfsObj;

typedef struct {
  lfs_t instance;
} LittleFs;

int32_t littlefs_cleanup(struct VfsMountPoint *vmp);
struct VfsObj *littlefs_open(struct VfsMountPoint *vmp, const char *path, uint32_t flags);
int32_t littlefs_stat(struct VfsMountPoint *vmp, const char *path, FsStat *statbuf);
int32_t littlefs_fetchdirent(struct VfsMountPoint *vmp, const char *path, FsDirent *direntbuf, size_t idx);
int32_t littlefs_mkdir(struct VfsMountPoint *vmp, const char *path);
int32_t littlefs_delete(struct VfsMountPoint *vmp, const char *path);

int portlfs_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size);
int portlfs_prog(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size);
int portlfs_erase(const struct lfs_config *c, lfs_block_t block);
int portlfs_sync(const struct lfs_config *c);

#endif // FS_PORTLFS_PORTLFS_H_
