Kernel - Added .Detect method to VFS drivers
[tpg/acess2.git] / KernelLand / Modules / Filesystems / FAT / fat.c
index ab91fcb..f7ebafe 100644 (file)
@@ -27,6 +27,7 @@
 // === PROTOTYPES ===\r
 // --- Driver Core\r
  int   FAT_Install(char **Arguments);\r
+ int   FAT_Detect(int FD);\r
 tVFS_Node      *FAT_InitDevice(const char *device, const char **options);\r
 void   FAT_Unmount(tVFS_Node *Node);\r
 // --- Helpers\r
@@ -46,7 +47,13 @@ void FAT_CloseFile(tVFS_Node *node);
 MODULE_DEFINE(0, VER2(0,80) /*v0.80*/, VFAT, FAT_Install, NULL, NULL);\r
 tFAT_VolInfo   gFAT_Disks[8];\r
  int   giFAT_PartCount = 0;\r
-tVFS_Driver    gFAT_FSInfo = {"fat", 0, FAT_InitDevice, FAT_Unmount, FAT_GetNodeFromINode, NULL};\r
+tVFS_Driver    gFAT_FSInfo = {\r
+       .Name = "fat",\r
+       .Detect = FAT_Detect,\r
+       .InitDevice = FAT_InitDevice,\r
+       .Unmount = FAT_Unmount,\r
+       .GetNodeFromINode = FAT_GetNodeFromINode\r
+};\r
 tVFS_NodeType  gFAT_DirType = {\r
        .TypeName = "FAT-Dir",\r
        .ReadDir = FAT_ReadDir,\r
@@ -78,6 +85,22 @@ int FAT_Install(char **Arguments)
        return MODULE_ERR_OK;\r
 }\r
 \r
+/**\r
+ * \brief Detect if a file is a FAT device\r
+ */\r
+int FAT_Detect(int FD)\r
+{\r
+       fat_bootsect bs;\r
+       \r
+       if( VFS_ReadAt(FD, 0, 512, &bs) != 512) {\r
+               return 0;\r
+       }\r
+\r
+       if(bs.bps == 0 || bs.spc == 0)\r
+               return 0;\r
+       \r
+       return 1;\r
+}\r
 /**\r
  * \brief Reads the boot sector of a disk and prepares the structures for it\r
  */\r

UCC git Repository :: git.ucc.asn.au