casaroli commented on code in PR #21391:
URL: https://github.com/apache/nuttx/pull/21391#discussion_r4453585281


##########
fs/fat/fs_fat32.c:
##########
@@ -163,10 +185,17 @@ const struct mountpt_operations g_fat_operations =
   fat_unbind,        /* unbind */
   fat_statfs,        /* statfs */
 
+#ifdef CONFIG_FS_FAT_READONLY
+  NULL,              /* unlink */

Review Comment:
   With these NULL entries, rm, mkdir, rmdir and mv on a read-only FAT fail 
with ENOSYS (the VFS returns -ENOSYS for a NULL op); tested on sim:nsh. POSIX 
asks for EROFS on a read-only file system.
   
   Fix: keep small stubs for unlink, mkdir, rmdir and rename that return -EROFS.



##########
fs/fat/fs_fat32.c:
##########
@@ -140,16 +150,28 @@ const struct mountpt_operations g_fat_operations =
   fat_open,          /* open */
   fat_close,         /* close */
   fat_read,          /* read */
+#ifdef CONFIG_FS_FAT_READONLY
+  NULL,              /* write */
+#else
   fat_write,         /* write */
+#endif
   fat_seek,          /* seek */
   fat_ioctl,         /* ioctl */
   NULL,              /* mmap */
+#ifdef CONFIG_FS_FAT_READONLY
+  NULL,              /* truncate */
+#else
   fat_truncate,      /* truncate */
+#endif
   NULL,              /* poll */
   NULL,              /* readv */
   NULL,              /* writev */
 
+#ifdef CONFIG_FS_FAT_READONLY
+  NULL,              /* sync */

Review Comment:
   With sync NULL, fsync() on a FAT file opened read-only now fails with EINVAL 
(fs/vfs/fs_fsync.c returns -EINVAL for a mountpoint without sync); without the 
option it returns OK.
   
   Fix: keep a sync stub that returns OK when CONFIG_FS_FAT_READONLY is set.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to