mirror of
https://github.com/reactos/reactos.git
synced 2025-07-25 23:24:01 +00:00
[FREELDR] fs.c: Move the filesystem mount routines list into a table (#7385)
This allows to make the code better extendable: adding a new FS mount routine into the table, instead of duplicating also a whole `if (!FileFuncTable) ...` check. Later, this table will be made dynamic, so that new filesystems could be dynamically registered at runtime, and a filesystem could be forced to be mounted by the user (using a specific syntax).
This commit is contained in:
parent
3a7fe56a5d
commit
29a0ff73e6
1 changed files with 28 additions and 20 deletions
|
@ -51,6 +51,27 @@ typedef struct tagDEVICE
|
||||||
static FILEDATA FileData[MAX_FDS];
|
static FILEDATA FileData[MAX_FDS];
|
||||||
static LIST_ENTRY DeviceListHead;
|
static LIST_ENTRY DeviceListHead;
|
||||||
|
|
||||||
|
typedef const DEVVTBL* (*PFS_MOUNT)(ULONG DeviceId);
|
||||||
|
|
||||||
|
PFS_MOUNT FileSystems[] =
|
||||||
|
{
|
||||||
|
#ifndef _M_ARM
|
||||||
|
IsoMount,
|
||||||
|
#endif
|
||||||
|
FatMount,
|
||||||
|
BtrFsMount,
|
||||||
|
#ifndef _M_ARM
|
||||||
|
NtfsMount,
|
||||||
|
Ext2Mount,
|
||||||
|
#endif
|
||||||
|
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||||
|
#ifndef UEFIBOOT
|
||||||
|
PxeMount,
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* ARC FUNCTIONS **************************************************************/
|
/* ARC FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
|
@ -146,28 +167,15 @@ ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to detect the file system */
|
/* Try to detect the file system */
|
||||||
#ifndef _M_ARM
|
for (ULONG fs = 0; fs < _countof(FileSystems); ++fs)
|
||||||
FileData[DeviceId].FileFuncTable = IsoMount(DeviceId);
|
{
|
||||||
if (!FileData[DeviceId].FileFuncTable)
|
FileData[DeviceId].FileFuncTable = FileSystems[fs](DeviceId);
|
||||||
#endif
|
if (FileData[DeviceId].FileFuncTable)
|
||||||
FileData[DeviceId].FileFuncTable = FatMount(DeviceId);
|
break;
|
||||||
if (!FileData[DeviceId].FileFuncTable)
|
}
|
||||||
FileData[DeviceId].FileFuncTable = BtrFsMount(DeviceId);
|
|
||||||
#ifndef _M_ARM
|
|
||||||
if (!FileData[DeviceId].FileFuncTable)
|
|
||||||
FileData[DeviceId].FileFuncTable = NtfsMount(DeviceId);
|
|
||||||
if (!FileData[DeviceId].FileFuncTable)
|
|
||||||
FileData[DeviceId].FileFuncTable = Ext2Mount(DeviceId);
|
|
||||||
#endif
|
|
||||||
#if defined(_M_IX86) || defined(_M_AMD64)
|
|
||||||
#ifndef UEFIBOOT
|
|
||||||
if (!FileData[DeviceId].FileFuncTable)
|
|
||||||
FileData[DeviceId].FileFuncTable = PxeMount(DeviceId);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
if (!FileData[DeviceId].FileFuncTable)
|
if (!FileData[DeviceId].FileFuncTable)
|
||||||
{
|
{
|
||||||
/* Error, unable to detect file system */
|
/* Error, unable to detect the file system */
|
||||||
pDevice->FuncTable->Close(DeviceId);
|
pDevice->FuncTable->Close(DeviceId);
|
||||||
FileData[DeviceId].FuncTable = NULL;
|
FileData[DeviceId].FuncTable = NULL;
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue