]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
security: remove truncate fallback, return ENOSYS for no backend (Fase 3)
authorTulio A M Mendes <[email protected]>
Tue, 26 May 2026 05:19:40 +0000 (02:19 -0300)
committerTulio A M Mendes <[email protected]>
Wed, 3 Jun 2026 05:52:27 +0000 (02:52 -0300)
src/kernel/fs.c

index 9bd62a8096be1d9728ef76fa7bd427d902924a09..94f63019571126e81fb31dd3d1a014ff085ae5c4 100644 (file)
@@ -610,9 +610,8 @@ int vfs_truncate(const char* path, uint32_t length) {
     if (node->flags != FS_FILE) return -EISDIR;
     if (node->i_ops && node->i_ops->truncate)
         return node->i_ops->truncate(node, length);
-    /* A14: fallback for FS that don't support truncate - just update length */
-    node->length = length;
-    return 0;
+    /* No truncate backend - return ENOSYS instead of silent fallback */
+    return -ENOSYS;
 }
 
 /* A14: Helper for ftruncate - truncate by node instead of path */
@@ -621,9 +620,8 @@ int vfs_truncate_node(fs_node_t* node, uint32_t length) {
     if (node->flags != FS_FILE) return -EINVAL;
     if (node->i_ops && node->i_ops->truncate)
         return node->i_ops->truncate(node, length);
-    /* Fallback for FS that don't support truncate */
-    node->length = length;
-    return 0;
+    /* No truncate backend - return ENOSYS instead of silent fallback */
+    return -ENOSYS;
 }
 
 /* A07: Helper to check parent directory permissions for mutations */