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


##########
include/nuttx/fs/fs.h:
##########
@@ -426,6 +426,31 @@ 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.
+ *
+ * These callbacks can either lead to custom functions if fopencookie is used
+ * or to standard file system functions if not.
+ */
+
+typedef CODE ssize_t cookie_read_function_t(void *cookie, char *buf,
+                                            size_t size);
+typedef CODE ssize_t cookie_write_function_t(void *cookie, const char *buf,
+                                             size_t size);
+typedef CODE off_t cookie_seek_function_t(void *cookie, off_t *offset,
+                                     int whence);

Review Comment:
   done



##########
libs/libc/stdio/lib_libfflush.c:
##########
@@ -107,7 +107,9 @@ ssize_t lib_fflush_unlocked(FAR FILE *stream, bool bforce)
         {
           /* Perform the write */
 
-          bytes_written = _NX_WRITE(stream->fs_fd, src, nbuffer);
+          bytes_written = stream->fs_iofunc.write(stream->fs_cookie,
+                                                  (const char *)src,

Review Comment:
   done



##########
libs/libc/stdio/lib_libfread_unlocked.c:
##########
@@ -170,7 +170,9 @@ ssize_t lib_fread_unlocked(FAR void *ptr, size_t count, FAR 
FILE *stream)
 
                   if (remaining > buffer_available)
                     {
-                      bytes_read = _NX_READ(stream->fs_fd, dest, remaining);
+                      bytes_read = stream->fs_iofunc.read(stream->fs_cookie,
+                                                          (char *)dest,

Review Comment:
   done



##########
libs/libc/stdio/lib_ungetc.c:
##########
@@ -52,7 +53,7 @@ int ungetc(int c, FAR FILE *stream)
 
   /* Stream must be open for read access */
 
-  if ((stream->fs_fd < 0) || ((stream->fs_oflags & O_RDOK) == 0))
+  if ((fd < 0) || ((stream->fs_oflags & O_RDOK) == 0))

Review Comment:
   done



-- 
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