浏览代码

Revert the last esp_littlefs merge (https://github.com/joltwallet/esp_littlefs/pull/16)
Needs additional work and it is not needed at the moment.
PlatformIO example update with showing the timestamps

lorol 4 年之前
父节点
当前提交
4b9c163814
共有 2 个文件被更改,包括 23 次插入134 次删除
  1. 23 16
      examples/LITTLEFS_PlatformIO/README.md
  2. 0 118
      src/esp_littlefs.c

+ 23 - 16
examples/LITTLEFS_PlatformIO/README.md

@@ -1,6 +1,6 @@
 # How to run on PlatformIO IDE
 
-- Download and extract to project root a **mklittlefs** executable for your OS from a zipped binary [here](https://github.com/earlephilhower/mklittlefs/releases) 
+- Download and extract to this project root a **mklittlefs** executable for your OS [from a zipped binary here](https://github.com/earlephilhower/mklittlefs/releases) 
 - Open **LITTLEFS_PlatformIO** folder
 - Run PlatformIO project task: **Upload Filesystem Image** 
 - Run PlatformIO project task: **Upload and Monitor**
@@ -8,33 +8,40 @@
 ```
 --- Miniterm on COM5  115200,8,N,1 ---
 --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
+ets Jun  8 2016 00:22:57
+
+rst:0x1 (POWERON_RESET),boot:0x13 (Snfigsip: 0, SPIWP:0xee
+clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
+mode:DIO, clock div:2
+load:0x3fff0018,len:4
+load:0x3fff001c,len:1044
+load:0x40078000,len:10044
+load:0x40080400,len:5872
+entry 0x400806ac
 Listing directory: /
-  FILE: /file1.txt      SIZE: 3
-  FILE: /test.txt       SIZE: 0
-  DIR : /testfolder
+  FILE: /file1.txt  SIZE: 3  LAST WRITE: 2020-10-06 15:10:33
+  DIR : /testfolder  LAST WRITE: 2020-10-06 15:10:33
 Creating Dir: /mydir
 Dir created
 Writing file: /mydir/hello2.txt
 - file written
 Listing directory: /
-  FILE: /file1.txt      SIZE: 3
-  DIR : /mydir
+  FILE: /file1.txt  SIZE: 3  LAST WRITE: 2020-10-06 15:10:33
+  DIR : /mydir  LAST WRITE: 1970-01-01 00:00:00
 Listing directory: /mydir
-  FILE: /mydir/hello2.txt       SIZE: 6
-  FILE: /test.txt       SIZE: 0
-  DIR : /testfolder
+  FILE: /mydir/hello2.txt  SIZE: 6  LAST WRITE: 1970-01-01 00:00:00
+  DIR : /testfolder  LAST WRITE: 2020-10-06 15:10:33
 Listing directory: /testfolder
-  FILE: /testfolder/test2.txt   SIZE: 3
+  FILE: /testfolder/test2.txt  SIZE: 3  LAST WRITE: 2020-10-06 15:10:33
 Deleting file: /mydir/hello2.txt
 - file deleted
 Removing Dir: /mydir
 Dir removed
 Listing directory: /
-  FILE: /file1.txt      SIZE: 3
-  FILE: /test.txt       SIZE: 0
-  DIR : /testfolder
+  FILE: /file1.txt  SIZE: 3  LAST WRITE: 2020-10-06 15:10:33
+  DIR : /testfolder  LAST WRITE: 2020-10-06 15:10:33
 Listing directory: /testfolder
-  FILE: /testfolder/test2.txt   SIZE: 3
+  FILE: /testfolder/test2.txt  SIZE: 3  LAST WRITE: 2020-10-06 15:10:33
 Writing file: /hello.txt
 - file written
 Appending to file: /hello.txt
@@ -51,9 +58,9 @@ Deleting file: /foo.txt
 - file deleted
 Testing file I/O with /test.txt
 - writing................................................................
- - 1048576 bytes written in 11369 ms
+ - 1048576 bytes written in 12006 ms
 - reading................................................................
-- 1048576 bytes read in 523 ms
+- 1048576 bytes read in 547 ms
 Deleting file: /test.txt
 - file deleted
 Test complete

+ 0 - 118
src/esp_littlefs.c

@@ -79,8 +79,6 @@ typedef struct {
 static int     vfs_littlefs_open(void* ctx, const char * path, int flags, int mode);
 static ssize_t vfs_littlefs_write(void* ctx, int fd, const void * data, size_t size);
 static ssize_t vfs_littlefs_read(void* ctx, int fd, void * dst, size_t size);
-static ssize_t vfs_littlefs_pwrite(void *ctx, int fd, const void *src, size_t size, off_t offset);
-static ssize_t vfs_littlefs_pread(void *ctx, int fd, void *dst, size_t size, off_t offset);
 static int     vfs_littlefs_close(void* ctx, int fd);
 static off_t   vfs_littlefs_lseek(void* ctx, int fd, off_t offset, int mode);
 static int     vfs_littlefs_stat(void* ctx, const char * path, struct stat * st);
@@ -173,10 +171,8 @@ esp_err_t esp_vfs_littlefs_register(const esp_vfs_littlefs_conf_t * conf)
     const esp_vfs_t vfs = {
         .flags       = ESP_VFS_FLAG_CONTEXT_PTR,
         .write_p     = &vfs_littlefs_write,
-        .pwrite_p    = &vfs_littlefs_pwrite,
         .lseek_p     = &vfs_littlefs_lseek,
         .read_p      = &vfs_littlefs_read,
-        .pread_p     = &vfs_littlefs_pread,
         .open_p      = &vfs_littlefs_open,
         .close_p     = &vfs_littlefs_close,
 #ifndef CONFIG_LITTLEFS_USE_ONLY_HASH
@@ -990,120 +986,6 @@ static ssize_t vfs_littlefs_read(void* ctx, int fd, void * dst, size_t size) {
     return res;
 }
 
-static ssize_t vfs_littlefs_pwrite(void *ctx, int fd, const void *src, size_t size, off_t offset)
-{
-    esp_littlefs_t *efs = (esp_littlefs_t *)ctx;
-    ssize_t res, save_res;
-    vfs_littlefs_file_t *file = NULL;
-
-    sem_take(efs);
-    if ((uint32_t)fd > efs->cache_size)
-    {
-        sem_give(efs);
-        ESP_LOGE(TAG, "FD %d must be <%d.", fd, efs->cache_size);
-        return LFS_ERR_BADF;
-    }
-    file = efs->cache[fd];
-
-    off_t old_offset = lfs_file_seek(efs->fs, &file->file, 0, SEEK_CUR);
-    if (old_offset < (off_t)0)
-    {
-        res = old_offset;
-        goto exit;
-    }
-
-    /* Set to wanted position.  */
-    res = lfs_file_seek(efs->fs, &file->file, offset, SEEK_SET);
-    if (res < (off_t)0)
-        goto exit;
-
-    /* Write out the data.  */
-    res = lfs_file_write(efs->fs, &file->file, src, size);
-
-    /* Now we have to restore the position.  If this fails we have to
-     return this as an error. But if the writing also failed we
-     return writing error.  */
-    save_res = lfs_file_seek(efs->fs, &file->file, old_offset, SEEK_SET);
-    if (res >= (ssize_t)0 && save_res < (off_t)0)
-    {
-            res = save_res;
-    }
-    sem_give(efs);
-
-exit:
-    if (res < 0)
-    {
-        errno = -res;
-#ifndef CONFIG_LITTLEFS_USE_ONLY_HASH
-        ESP_LOGV(TAG, "Failed to write FD %d; path \"%s\". Error %s (%d)",
-                fd, file->path, esp_littlefs_errno(res), res);
-#else
-        ESP_LOGV(TAG, "Failed to write FD %d. Error %s (%d)",
-                fd, esp_littlefs_errno(res), res);
-#endif
-        return -1;
-    }
-
-    return res;
-}
-
-static ssize_t vfs_littlefs_pread(void *ctx, int fd, void *dst, size_t size, off_t offset)
-{
-    esp_littlefs_t *efs = (esp_littlefs_t *)ctx;
-    ssize_t res, save_res;
-    vfs_littlefs_file_t *file = NULL;
-
-    sem_take(efs);
-    if ((uint32_t)fd > efs->cache_size)
-    {
-        sem_give(efs);
-        ESP_LOGE(TAG, "FD %d must be <%d.", fd, efs->cache_size);
-        return LFS_ERR_BADF;
-    }
-    file = efs->cache[fd];
-
-    off_t old_offset = lfs_file_seek(efs->fs, &file->file, 0, SEEK_CUR);
-    if (old_offset < (off_t)0)
-    {
-        res = old_offset;
-        goto exit;
-    }
-
-    /* Set to wanted position.  */
-    res = lfs_file_seek(efs->fs, &file->file, offset, SEEK_SET);
-    if (res < (off_t)0)
-        goto exit;
-
-    /* Read the data.  */
-    res = lfs_file_read(efs->fs, &file->file, dst, size);
-
-    /* Now we have to restore the position.  If this fails we have to
-     return this as an error. But if the reading also failed we
-     return reading error.  */
-    save_res = lfs_file_seek(efs->fs, &file->file, old_offset, SEEK_SET);
-    if (res >= (ssize_t)0 && save_res < (off_t)0)
-    {
-            res = save_res;
-    }
-    sem_give(efs);
-
-exit:
-    if (res < 0)
-    {
-        errno = -res;
-#ifndef CONFIG_LITTLEFS_USE_ONLY_HASH
-        ESP_LOGV(TAG, "Failed to read file \"%s\". Error %s (%d)",
-                 file->path, esp_littlefs_errno(res), res);
-#else
-        ESP_LOGV(TAG, "Failed to read FD %d. Error %s (%d)",
-                 fd, esp_littlefs_errno(res), res);
-#endif
-        return -1;
-    }
-
-    return res;
-}
-
 static int vfs_littlefs_close(void* ctx, int fd) {
     // TODO update mtime on close? SPIFFS doesn't do this
     esp_littlefs_t * efs = (esp_littlefs_t *)ctx;