我想实现一个非常简单的虚拟文件系统( VFS ),它支持一些基本的文件系统操作,如fwrite、fopen、fput等。VFS是一些具体操作系统(如Windows、Linux等)之上的抽象层。
FILE VFS_File_Open( const unsigned char* strFile, int flags );现在,我想知道如何在这个接口的实际实现中区分与之交谈的文件系统。在C中是否有告诉我应用程序在哪个操作系统上运行的东西,以便我可以这样做:
FILE VFS_File_Open( const unsigned char strFile, int flags )
{
int OS = getOSID();
if (0S == 1)
//implement here the system calls required to open a file on a WIN OS
else if (OS == 2)
//implement here the system calls required to open a file on a Linux OS
etc
}编辑:
现在,我想知道是否有人知道在哪里可以找到用于Windows的文件操作的系统调用?很容易在Linux上找到它们,但是我很难在windows中找到类似的东西,例如,我会对系统调用来打开文件、编写文件等感兴趣。
另一个注意事项:Cstdio.h提供了一些站立IO操作,如
FILE * fopen (const char *filename, const char *opentype)换句话说,我不必在我的VFS中重新实现fopen例程,因为Gnu C库关心它处理的是什么操作系统,对吗?我只需要实现stdio库不支持的功能,例如创建目录,这些目录因文件系统而异吗?
谢谢
https://stackoverflow.com/questions/1361560
复制相似问题