From 00f24d0160b5ada315a6338c2ac6062deb2880ed Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 25 Sep 2009 20:18:34 +0800 Subject: [PATCH] Changed tVFS_Node->close on a mount root to be a no-op by convention and added tVFS_Driver->Unmount to replace it --- Kernel/include/vfs.h | 1 + Kernel/vfs/fs/devfs.c | 2 +- Kernel/vfs/fs/fat.c | 22 ++++++++++------------ Kernel/vfs/fs/root.c | 4 +++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Kernel/include/vfs.h b/Kernel/include/vfs.h index 12cc8a41..209889cb 100644 --- a/Kernel/include/vfs.h +++ b/Kernel/include/vfs.h @@ -80,6 +80,7 @@ typedef struct sVFS_Driver { char *Name; Uint Flags; tVFS_Node *(*InitDevice)(char *Device, char *Options); + void (*Unmount)(tVFS_Node *Node); struct sVFS_Driver *Next; } tVFS_Driver; diff --git a/Kernel/vfs/fs/devfs.c b/Kernel/vfs/fs/devfs.c index 25be4907..25585095 100644 --- a/Kernel/vfs/fs/devfs.c +++ b/Kernel/vfs/fs/devfs.c @@ -15,7 +15,7 @@ tVFS_Node *DevFS_FindDir(tVFS_Node *Node, char *Name); // === GLOBALS === tVFS_Driver gDevFS_Info = { - "devfs", 0, DevFS_InitDevice, NULL + "devfs", 0, DevFS_InitDevice, NULL, NULL }; tVFS_Node gDevFS_RootNode = { .NumACLs = 1, diff --git a/Kernel/vfs/fs/fat.c b/Kernel/vfs/fs/fat.c index c4f66713..8cfeca44 100644 --- a/Kernel/vfs/fs/fat.c +++ b/Kernel/vfs/fs/fat.c @@ -39,7 +39,7 @@ typedef struct s_lfncache { // === PROTOTYPES === int FAT_Install(char **Arguments); tVFS_Node *FAT_InitDevice(char *device, char *options); -void FAT_CloseDevice(tVFS_Node *node); +void FAT_Unmount(tVFS_Node *Node); Uint64 FAT_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer); Uint64 FAT_Write(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer); char *FAT_ReadDir(tVFS_Node *dirNode, int dirpos); @@ -59,7 +59,7 @@ Uint32 *fat_cache[8]; t_lfncache *fat_lfncache; #endif tVFS_Driver gFAT_FSInfo = { - "fat", 0, FAT_InitDevice, NULL + "fat", 0, FAT_InitDevice, FAT_Unmount, NULL }; // === CODE === @@ -244,26 +244,24 @@ tVFS_Node *FAT_InitDevice(char *Device, char *options) node->FindDir = FAT_FindDir; node->Relink = FAT_Relink; node->MkNod = FAT_Mknod; - node->Close = FAT_CloseDevice; + //node->Close = FAT_CloseDevice; giFAT_PartCount ++; return node; } /** - * \fn void FAT_CloseDevice(tVFS_Node *node) + * \fn void FAT_Unmount(tVFS_Node *Node) * \brief Closes a mount and marks it as free */ -void FAT_CloseDevice(tVFS_Node *node) +void FAT_Unmount(tVFS_Node *Node) { - node->ReferenceCount --; - - if(node->ReferenceCount > 0) return; - // Close Disk Handle - VFS_Close( gFAT_Disks[node->ImplInt].fileHandle ); - Inode_ClearCache(gFAT_Disks[node->ImplInt].inodeHandle); - gFAT_Disks[node->ImplInt].fileHandle = -2; + VFS_Close( gFAT_Disks[Node->ImplInt].fileHandle ); + // Clear Node Cache + Inode_ClearCache(gFAT_Disks[Node->ImplInt].inodeHandle); + // Mark as unused + gFAT_Disks[Node->ImplInt].fileHandle = -2; return; } diff --git a/Kernel/vfs/fs/root.c b/Kernel/vfs/fs/root.c index e035fd7b..4a81715f 100644 --- a/Kernel/vfs/fs/root.c +++ b/Kernel/vfs/fs/root.c @@ -19,7 +19,9 @@ tRamFS_File *Root_int_AllocFile(); // === GLOBALS === tVFS_Driver gRootFS_Info = { - "rootfs", 0, Root_InitDevice, + "rootfs", 0, + Root_InitDevice, + NULL, // Unmount NULL }; tRamFS_File RootFS_Files[MAX_FILES]; -- 2.20.1