X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FFilesystems%2FExt2%2Fext2.c;h=971ef28ed538e185dc73c63c83289dce872727b4;hb=891868f0b4d64eb274b5810ac0c4f0a53d104114;hp=f40689e0ecf9696261f6ff72f48f4aa560eb6c5b;hpb=11dbd684e9a3d907d43d71a3145205f1a86992fb;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/Ext2/ext2.c b/KernelLand/Modules/Filesystems/Ext2/ext2.c index f40689e0..971ef28e 100644 --- a/KernelLand/Modules/Filesystems/Ext2/ext2.c +++ b/KernelLand/Modules/Filesystems/Ext2/ext2.c @@ -17,6 +17,7 @@ extern tVFS_NodeType gExt2_DirType; int Ext2_Install(char **Arguments); int Ext2_Cleanup(void); // - Interface Functions + int Ext2_Detect(int FD); tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options); void Ext2_Unmount(tVFS_Node *Node); void Ext2_CloseFile(tVFS_Node *Node); @@ -31,7 +32,11 @@ MODULE_DEFINE(0, VERSION, FS_Ext2, Ext2_Install, Ext2_Cleanup); tExt2_Disk gExt2_disks[6]; int giExt2_count = 0; tVFS_Driver gExt2_FSInfo = { - "ext2", 0, Ext2_InitDevice, Ext2_Unmount, NULL + .Name = "ext2", + .Detect = Ext2_Detect, + .InitDevice = Ext2_InitDevice, + .Unmount = Ext2_Unmount, + .GetNodeFromINode = NULL }; // === CODE === @@ -53,6 +58,31 @@ int Ext2_Cleanup(void) return 0; } +/** + * Detect if a volume is Ext2 formatted + */ +int Ext2_Detect(int FD) +{ + tExt2_SuperBlock sb; + size_t len; + + len = VFS_ReadAt(FD, 1024, 1024, &sb); + + if( len != 1024 ) { + Log_Debug("Ext2", "_Detect: Read failed? (0x%x != 1024)", len); + return 0; + } + + switch(sb.s_magic) + { + case 0xEF53: + return 2; + default: + Log_Debug("Ext2", "_Detect: s_magic = 0x%x", sb.s_magic); + return 0; + } +} + /** \brief Initializes a device to be read by by the driver \param Device String - Device to read from