michallenc commented on code in PR #10602:
URL: https://github.com/apache/nuttx/pull/10602#discussion_r1350309565


##########
include/nuttx/fs/fs.h:
##########
@@ -425,6 +425,55 @@ struct inode
 
 #define FSNODE_SIZE(n) (sizeof(struct inode) + (n))
 
+/* Definitions for custom stream operations with fopencookie. The
+ * implementation is as defined in Standard C library (libc). The only
+ * difference is that we use off_t instead of off64_t. This means
+ * off_t is int64_t if CONFIG_FS_LARGEFILE is defined and int32_t if not.
+ */
+
+typedef ssize_t cookie_read_function_t(void *cookie, char *buf, size_t size);
+typedef ssize_t cookie_write_function_t(void *cookie, const char *buf,
+                                        size_t size);
+typedef off_t cookie_seek_function_t(void *cookie, off_t *offset,
+                                     int whence);
+typedef int cookie_close_function_t(void *cookie);
+
+typedef struct
+{
+  FAR cookie_read_function_t *read;
+  FAR cookie_write_function_t *write;
+  FAR cookie_seek_function_t *seek;
+  FAR cookie_close_function_t *close;
+} cookie_io_functions_t;
+
+struct cookie_s
+{
+  FAR void *cookie;                /* Pointer to the caller's cookie struct */
+  cookie_io_functions_t cookie_io; /* Programmer-defined hook functions */
+};
+
+/* Definition of internal callbacks for read/write/seek/close operations.
+ * These are needed to ensure custom callbacks from fopencookie are called
+ * from user address space and not from kernel address space. These callbacks
+ * are either routed to fopencookie related callbacks or to internal
+ * read/write/seek/close operations defined in file system (thus in kernel
+ * address space)
+ */
+
+typedef ssize_t read_internal_cb_t(FAR void *s, char *buf, size_t size);
+typedef ssize_t write_internal_cb_t(FAR void *s, const char *buf,
+                                    size_t size);
+typedef off_t seek_internal_cb_t(FAR void *s, off_t offset, int whence);
+typedef int close_internal_cb_t(FAR void *s);
+
+typedef struct
+{
+  FAR read_internal_cb_t *read;
+  FAR write_internal_cb_t *write;
+  FAR seek_internal_cb_t *seek;
+  FAR close_internal_cb_t *close;
+} io_callbacks_t;

Review Comment:
   Removed



##########
include/nuttx/fs/fs.h:
##########
@@ -497,6 +546,8 @@ struct file_struct
   FAR struct file_struct *fs_next;      /* Pointer to next file stream */
   rmutex_t                fs_lock;      /* Recursive lock */
   int                     fs_fd;        /* File descriptor associated with 
stream */
+  FAR struct cookie_s     fs_cookie;    /* Cookie structure for fopencookie */
+  io_callbacks_t          fs_callbacks; /* Internal callbacks for IO call */

Review Comment:
   Removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to