* \}
*/
+ /**
+ * \name Node State
+ * \brief Stores the misc information about the node
+ * \{
+ */
int ReferenceCount; //!< Number of times the node is used
Uint64 Size; //!< File Size
Uint32 Flags; //!< File Flags
+ /**
+ * \}
+ */
/**
* \name Times
* \param Node Pointer to this node
* \param OldName Name of the item to move/delete
* \param NewName New name (or NULL if unlinking is wanted)
- * \return Boolean Success
+ * \return Zero on Success, non-zero on error (see errno.h)
*/
int (*Relink)(struct sVFS_Node *Node, char *OldName, char *NewName);
return length;\r
}\r
\r
+ #if 0\r
+ if( FAT_int_GetAddress(Node, offset, &addr) )\r
+ {\r
+ Log_Warning("FAT", "Offset is past end of cluster chain mark");\r
+ LEAVE('i', 0);\r
+ return 0;\r
+ }\r
+ #endif\r
+ \r
preSkip = offset / bpc;\r
\r
//Skip previous clusters\r
for(i=preSkip;i--;) {\r
cluster = FAT_int_GetFatValue(disk, cluster);\r
if(cluster == -1) {\r
- Warning("FAT_Read - Offset is past end of cluster chain mark");\r
+ Log_Warning("FAT", "Offset is past end of cluster chain mark");\r
LEAVE('i', 0);\r
return 0;\r
}\r
}\r
\r
#if USE_LFN\r
+// I should probably more tightly associate the LFN cache with the node\r
+// somehow, maybe by adding a field to tVFS_Node before locking it\r
+// Maybe .Cache or something like that (something that is free'd by the\r
+// Inode_UncacheNode function)\r
+ \r
/**\r
* \fn char *FAT_int_GetLFN(tVFS_Node *node)\r
* \brief Return pointer to LFN cache entry\r
}\r
\r
//Check if the files are free\r
- if(fileinfo[i&0xF].name[0] == '\0') break; //Free and last\r
+ if(fileinfo[i&0xF].name[0] == '\0') break; // Free and last\r
if(fileinfo[i&0xF].name[0] == '\xE5') continue; //Free\r
\r
\r
{\r
tVFS_Node *child;\r
fat_filetable ft = {0};\r
- Uint32 cluster;\r
- int ofs;\r
+ int ret;\r
\r
child = FAT_FindDir(Node, OldName);\r
- if(!child) return 0;\r
+ if(!child) return ENOTFOUND;\r
\r
// Delete?\r
if( NewName == NULL )\r
{\r
child->ImplInt |= FAT_FLAG_DELETE; // Mark for deletion on close\r
- cluster = Node->Inode & 0xFFFFFFFF;\r
- ofs = child->ImplInt & 0xFFFF;\r
+ \r
+ // Delete from the directory\r
ft.name[0] = '\xE9';\r
+ FAT_int_WriteDirEntry(Node, child->ImplInt & 0xFFFF, &ft);\r
+ \r
+ // Return success\r
+ ret = EOK;\r
}\r
// Rename\r
else\r
{\r
+ Log_Warning("FAT", "Renaming no yet supported %p ('%s' => '%s')",\r
+ Node, OldName, NewName);\r
+ ret = ENOTIMPL;\r
}\r
\r
- return 0;\r
+ // Close child\r
+ child->Close( child );\r
+ return ret;\r
}\r
\r
/**\r
tFAT_VolInfo *disk = Node->ImplPtr;\r
if(Node == NULL) return ;\r
\r
- if( Node->ImplInt & FAT_FLAG_DIRTY ) {\r
- #if 0\r
- // Write back\r
- FAT_int_UpdateDirEntry(\r
- Node->Inode >> 32, Node->ImplInt & 0xFFFF,\r
- Node\r
- );\r
- #endif\r
+ // Update the node if it's dirty (don't bother if it's marked for\r
+ // deletion)\r
+ if( Node->ImplInt & FAT_FLAG_DIRTY && !(Node->ImplInt & FAT_FLAG_DELETE) )\r
+ {\r
+ tFAT_VolInfo buf[16];\r
+ tFAT_VolInfo *ft = &buf[ (Node->ImplInt & 0xFFFF) % 16 ];\r
+ \r
+ FAT_int_ReadDirSector(Node, (Node->ImplInt & 0xFFFF)/16, buf);\r
+ ft->size = Node->Size;\r
+ // TODO: update adate, mtime, mdate\r
+ FAT_int_WriteDirEntry(Node, Node->ImplInt & 0xFFFF, ft);\r
+ \r
+ Node->ImplInt &= ~FAT_FLAG_DIRTY;\r
}\r
\r
+ // TODO: Make this more thread safe somehow, probably by moving the\r
+ // Inode_UncacheNode higher up and saving the cluster value somewhere\r
if( Node->ReferenceCount == 1 )\r
{\r
// Delete LFN Cache\r