]> granicus.if.org Git - esp-idf/commitdiff
vfs: Add ioctl() to filesystem set
authorAngus Gratton <angus@espressif.com>
Tue, 3 Oct 2017 22:24:40 +0000 (09:24 +1100)
committerAngus Gratton <gus@projectgus.com>
Mon, 16 Oct 2017 01:45:49 +0000 (09:45 +0800)
components/vfs/include/esp_vfs.h
components/vfs/vfs.c

index 6ced2ce2b84130070bf98295a79ac45cfc060b8b..fcd2e66bbbaee97dbe0c14e201620363565b97e4 100644 (file)
@@ -145,6 +145,10 @@ typedef struct
         int (*fcntl_p)(void* ctx, int fd, int cmd, va_list args);
         int (*fcntl)(int fd, int cmd, va_list args);
     };
+    union {
+        int (*ioctl_p)(void* ctx, int fd, int cmd, va_list args);
+        int (*ioctl)(int fd, int cmd, va_list args);
+    };
 } esp_vfs_t;
 
 
index f07bf7c37a13c8f2accfd98c3576297642121aed..c307fdef1171a9848d3dd4eab889761b778ad81b 100644 (file)
@@ -489,3 +489,20 @@ int fcntl(int fd, int cmd, ...)
     va_end(args);
     return ret;
 }
+
+int ioctl(int fd, int cmd, ...)
+{
+    const vfs_entry_t* vfs = get_vfs_for_fd(fd);
+    struct _reent* r = __getreent();
+    if (vfs == NULL) {
+        __errno_r(r) = EBADF;
+        return -1;
+    }
+    int local_fd = translate_fd(vfs, fd);
+    int ret;
+    va_list args;
+    va_start(args, cmd);
+    CHECK_AND_CALL(ret, r, vfs, ioctl, local_fd, cmd, args);
+    va_end(args);
+    return ret;
+}