feat: (iso9660) rock ridge extension
[lunaix-os.git] / lunaix-os / kernel / fs / pcache.c
index 317e491a336284268a6f827ae82d7aec1841e4ae..a6c4c31d34993b9ba9b8da91a195f51b886ad655 100644 (file)
@@ -115,6 +115,7 @@ pcache_write(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos)
 
         pcache_set_dirty(pcache, pg);
 
+        pg->len = pg_off + wr_bytes;
         buf_off += wr_bytes;
         fpos += wr_bytes;
     }
@@ -146,8 +147,13 @@ pcache_read(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos)
             } else if (errno < 0) {
                 break;
             }
+            pg->len = errno;
         }
-        uint32_t rd_bytes = MIN(PG_SIZE - pg_off, len - buf_off);
+        uint32_t rd_bytes = MIN(pg->len - pg_off, len - buf_off);
+
+        if (!rd_bytes)
+            break;
+
         memcpy((data + buf_off), pg->pg + pg_off, rd_bytes);
 
         buf_off += rd_bytes;