*/
Uint Flags;
+ /**
+ * \brief Detect if a volume is accessible using this driver
+ * \return Boolean success (with higher numbers being higher priority)
+ *
+ * E.g. FAT would return 1 as it's the lowest common denominator while ext2 might return 2,
+ * because it can be embedded in a FAT volume (and is a more fully featured filesystem).
+ */
+ int (*Detect)(int FD);
+
/**
* \brief Callback to mount a device
*/
// === GLOBALS ===
tVFS_Driver gDevFS_Info = {
- "devfs", 0, DevFS_InitDevice, DevFS_Unmount, NULL
+ .Name = "devfs",
+ .InitDevice = DevFS_InitDevice,
+ .Unmount = DevFS_Unmount
};
tVFS_NodeType gDevFS_DirType = {
.TypeName = "DevFS-Dir",
// === GLOBALS ===
tVFS_Driver gRootFS_Info = {
- "rootfs", 0, Root_InitDevice, NULL, NULL
+ .Name = "rootfs",
+ .InitDevice = Root_InitDevice
};
tRamFS_File RootFS_Files[MAX_FILES];
tVFS_ACL RootFS_DirACLs[3] = {
int Ext2_Install(char **Arguments);\r
int Ext2_Cleanup(void);\r
// - Interface Functions\r
+ int Ext2_Detect(int FD);\r
tVFS_Node *Ext2_InitDevice(const char *Device, const char **Options);\r
void Ext2_Unmount(tVFS_Node *Node);\r
void Ext2_CloseFile(tVFS_Node *Node);\r
tExt2_Disk gExt2_disks[6];\r
int giExt2_count = 0;\r
tVFS_Driver gExt2_FSInfo = {\r
- "ext2", 0, Ext2_InitDevice, Ext2_Unmount, NULL\r
+ .Name = "ext2",\r
+ .Detect = Ext2_Detect,\r
+ .InitDevice = Ext2_InitDevice,\r
+ .Unmount = Ext2_Unmount,\r
+ .GetNodeFromINode = NULL\r
};\r
\r
// === CODE ===\r
return 0;\r
}\r
\r
+/**\r
+ * Detect if a volume is Ext2 formatted\r
+ */\r
+int Ext2_Detect(int FD)\r
+{\r
+ tExt2_SuperBlock sb;\r
+ size_t len;\r
+ \r
+ len = VFS_ReadAt(FD, 1024, 1024, &sb);\r
+\r
+ if( len != 1024 ) {\r
+ Log_Debug("Ext2", "_Detect: Read failed? (0x%x != 1024)", len);\r
+ return 0;\r
+ }\r
+ \r
+ switch(sb.s_magic)\r
+ {\r
+ case 0xEF53:\r
+ return 2;\r
+ default:\r
+ Log_Debug("Ext2", "_Detect: s_magic = 0x%x", sb.s_magic);\r
+ return 0;\r
+ }\r
+}\r
+\r
/**\r
\brief Initializes a device to be read by by the driver\r
\param Device String - Device to read from\r
// === 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
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
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
// === GLOBALS ===
MODULE_DEFINE(0, 0x0A /*v0.1*/, FS_NTFS, NTFS_Install, NULL);
-tVFS_Driver gNTFS_FSInfo = {"ntfs", 0, NTFS_InitDevice, NTFS_Unmount, NULL};
+tVFS_Driver gNTFS_FSInfo = {
+ .Name = "ntfs",
+ .InitDevice = NTFS_InitDevice,
+ .Unmount = NTFS_Unmount,
+ .GetNodeFromINode = NULL
+};
tVFS_NodeType gNTFS_DirType = {
.TypeName = "NTFS-File",
.ReadDir = NTFS_ReadDir,