Index: /trunk/include/iprt/fsvfs.h
===================================================================
--- /trunk/include/iprt/fsvfs.h	(revision 66697)
+++ /trunk/include/iprt/fsvfs.h	(revision 66698)
@@ -114,4 +114,5 @@
  * @param   hVfsFile            The image.  Will be grown to 1.44MB if
  *                              necessary.
+ * @param   fQuick              Whether to quick format the floppy or not.
  */
 RTDECL(int) RTFsFatVolFormat144(RTVFSFILE hVfsFile, bool fQuick);
Index: /trunk/src/VBox/Runtime/common/filesystem/fatvfs.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/filesystem/fatvfs.cpp	(revision 66697)
+++ /trunk/src/VBox/Runtime/common/filesystem/fatvfs.cpp	(revision 66698)
@@ -1749,6 +1749,10 @@
 {
     PRTFSFATFILE pThis = (PRTFSFATFILE)pvThis;
+    PRTFSFATVOL  pVol  = pThis->Core.pVol;
     AssertReturn(pSgBuf->cSegs != 0, VERR_INTERNAL_ERROR_3);
     RT_NOREF(fBlocking);
+
+    if (pVol->fReadOnly)
+        return VERR_WRITE_PROTECT;
 
     if (off == -1)
@@ -1790,8 +1794,8 @@
 
         /* Figure the disk offset. */
-        uint64_t offDisk = rtFsFatChain_FileOffsetToDiskOff(&pThis->Core.Clusters, (uint32_t)off, pThis->Core.pVol);
+        uint64_t offDisk = rtFsFatChain_FileOffsetToDiskOff(&pThis->Core.Clusters, (uint32_t)off, pVol);
         if (offDisk != UINT64_MAX)
         {
-            rc = RTVfsFileWriteAt(pThis->Core.pVol->hVfsBacking, offDisk, pbSrc, cbToWrite, NULL);
+            rc = RTVfsFileWriteAt(pVol->hVfsBacking, offDisk, pbSrc, cbToWrite, NULL);
             if (RT_SUCCESS(rc))
             {
@@ -2650,4 +2654,11 @@
                                         uint32_t *poffEntryInDir, uint32_t *pcFreeTail)
 {
+    /* First try make gcc happy. */
+    *pcFreeTail     = 0;
+    *poffEntryInDir = UINT32_MAX;
+
+    /*
+     * Scan the whole directory, buffer by buffer.
+     */
     uint32_t            offStartFreeEntries = UINT32_MAX;
     uint32_t            cFreeEntries        = 0;
@@ -2713,7 +2724,5 @@
         rtFsFatDir_ReleaseBufferAfterReading(pThis, uBufferLock);
     }
-
-    *pcFreeTail     = cFreeEntries;
-    *poffEntryInDir = UINT32_MAX;
+    *pcFreeTail = cFreeEntries;
     return VERR_DISK_FULL;
 }
@@ -2849,4 +2858,6 @@
     PRTFSFATVOL pVol = pThis->Core.pVol;
     *poffEntryInDir = UINT32_MAX;
+    if (pVol->fReadOnly)
+        return VERR_WRITE_PROTECT;
 
     /*
