예제 #1
0
struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) {
  if (!SPIFFS_CHECK_MOUNT(d->fs)) {
    d->fs->errno = SPIFFS_ERR_NOT_MOUNTED;
    return 0;
  }
  SPIFFS_LOCK(fs);

  spiffs_block_ix bix;
  int entry;
  s32_t res;
  struct spiffs_dirent *ret = 0;

  res = spiffs_obj_lu_find_entry_visitor(d->fs,
      d->block,
      d->entry,
      SPIFFS_VIS_NO_WRAP,
      0,
      spiffs_read_dir_v,
      0,
      e,
      &bix,
      &entry);
  if (res == SPIFFS_OK) {
    d->block = bix;
    d->entry = entry + 1;
    ret = e;
  } else {
    d->fs->errno = res;
  }
  SPIFFS_UNLOCK(fs);
  return ret;
}
예제 #2
0
s32_t SPIFFS_format(spiffs *fs) {
#if SPIFFS_READ_ONLY
  (void)fs;
  return SPIFFS_ERR_RO_NOT_IMPL;
#else
  SPIFFS_API_CHECK_CFG(fs);
  if (SPIFFS_CHECK_MOUNT(fs)) {
    fs->err_code = SPIFFS_ERR_MOUNTED;
    return -1;
  }

  s32_t res;
  SPIFFS_LOCK(fs);

  spiffs_block_ix bix = 0;
  while (bix < fs->block_count) {
    fs->max_erase_count = 0;
    res = spiffs_erase_block(fs, bix);
    if (res != SPIFFS_OK) {
      res = SPIFFS_ERR_ERASE_FAIL;
    }
    SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
    bix++;
  }

  SPIFFS_UNLOCK(fs);

  return 0;
#endif // SPIFFS_READ_ONLY
}
예제 #3
0
s32_t SPIFFS_format(spiffs *fs) {
    SPIFFS_API_CHECK_CFG(fs);
    if (SPIFFS_CHECK_MOUNT(fs)) {
        fs->err_code = SPIFFS_ERR_MOUNTED;
        return -1;
    }

    s32_t res;
    SPIFFS_LOCK(fs);

    spiffs_block_ix bix = 0;
    while (bix < fs->block_count) {
        fs->max_erase_count = 0;
        res = spiffs_erase_block(fs, bix);
        if (res != SPIFFS_OK) {
            res = SPIFFS_ERR_ERASE_FAIL;
        }
        SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
        bix++;
    }

    SPIFFS_UNLOCK(fs);

    return 0;
}
예제 #4
0
spiffs_DIR *ICACHE_FLASH_ATTR SPIFFS_opendir(spiffs *fs, const char *name, spiffs_DIR *d) {
  if (!SPIFFS_CHECK_MOUNT(fs)) {
    fs->errnos = SPIFFS_ERR_NOT_MOUNTED;
    return 0;
  }
  d->fs = fs;
  d->block = 0;
  d->entry = 0;
  return d;
}
예제 #5
0
spiffs_DIR *SPIFFS_opendir(spiffs *fs, const char *name, spiffs_DIR *d) {
  (void)name;
  if (!SPIFFS_CHECK_MOUNT(fs)) {
    fs->errno = SPIFFS_ERR_NOT_MOUNTED;
    return 0;
  }
  d->fs = fs;
  d->block = 0;
  d->entry = 0;
  return d;
}
예제 #6
0
void SPIFFS_close(spiffs *fs, spiffs_file fh) {
  if (!SPIFFS_CHECK_MOUNT(fs)) {
    fs->errno = SPIFFS_ERR_NOT_MOUNTED;
    return;
  }
  SPIFFS_LOCK(fs);

#if SPIFFS_CACHE
  spiffs_fflush_cache(fs, fh);
#endif
  spiffs_fd_return(fs, fh);

  SPIFFS_UNLOCK(fs);
}
예제 #7
0
void SPIFFS_unmount(spiffs *fs) {
  if (!SPIFFS_CHECK_MOUNT(fs)) return;
  SPIFFS_LOCK(fs);
  u32_t i;
  spiffs_fd *fds = (spiffs_fd *)fs->fd_space;
  for (i = 0; i < fs->fd_count; i++) {
    spiffs_fd *cur_fd = &fds[i];
    if (cur_fd->file_nbr != 0) {
#if SPIFFS_CACHE
      (void)spiffs_fflush_cache(fs, cur_fd->file_nbr);
#endif
      spiffs_fd_return(fs, cur_fd->file_nbr);
    }
  }
  fs->block_count = 0;
  SPIFFS_UNLOCK(fs);
}
예제 #8
0
spiffs_DIR *spiffs_opendir(spiffs *fs, const char *name, spiffs_DIR *d) {
    (void)name;

    if (!SPIFFS_CHECK_CFG((fs))) {
        (fs)->err_code = SPIFFS_ERR_NOT_CONFIGURED;
        return 0;
    }

    if (!SPIFFS_CHECK_MOUNT(fs)) {
        fs->err_code = SPIFFS_ERR_NOT_MOUNTED;
        return 0;
    }

    d->fs = fs;
    d->block = 0;
    d->entry = 0;
    return d;
}
예제 #9
0
void ICACHE_FLASH_ATTR SPIFFS_close(spiffs *fs, spiffs_file fh) {
  if (!SPIFFS_CHECK_CFG((fs))) {
    (fs)->err_code = SPIFFS_ERR_NOT_CONFIGURED;
    return;
  }

  if (!SPIFFS_CHECK_MOUNT(fs)) {
    fs->err_code = SPIFFS_ERR_NOT_MOUNTED;
    return;
  }
  SPIFFS_LOCK(fs);

#if SPIFFS_CACHE
  spiffs_fflush_cache(fs, fh);
#endif
  spiffs_fd_return(fs, fh);

  SPIFFS_UNLOCK(fs);
}
예제 #10
0
u8_t SPIFFS_mounted(spiffs *fs) {
    return SPIFFS_CHECK_MOUNT(fs);
}
예제 #11
0
u8_t ICACHE_FLASH_ATTR SPIFFS_mounted(spiffs *fs) {
  return SPIFFS_CHECK_MOUNT(fs);
}