2 * Acess Micro - VFS Server version 1
10 extern int giVFS_MountFileID;
11 extern char *gsVFS_MountFile;
14 int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *ArgString);
15 void VFS_UpdateMountFile();
18 int glVFS_MountList = 0;
19 tVFS_Mount *gVFS_Mounts;
20 tVFS_Mount *gVFS_RootMount = NULL;
24 * \fn int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *ArgString)
25 * \brief Mount a device
26 * \param Device Device string to mount
27 * \param MountPoint Destination for the mount
28 * \param Filesystem Filesystem to use for the mount
29 * \param ArgString Options to be passed to the filesystem
30 * \return -1 on Invalid FS, -2 on No Mem, 0 on success
32 int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *ArgString)
36 int deviceLen = strlen(Device);
37 int mountLen = strlen(MountPoint);
38 int argLen = strlen(ArgString);
41 fs = VFS_GetFSByName(Filesystem);
43 Warning("VFS_Mount - Unknown FS Type '%s'", Filesystem);
47 // Create mount information
48 mnt = malloc( sizeof(tVFS_Mount)+deviceLen+1+mountLen+1+argLen+1 );
53 // HACK: Forces VFS_ParsePath to fall back on root
54 if(mountLen == 1 && MountPoint[0] == '/')
55 mnt->MountPointLen = 0;
57 mnt->MountPointLen = mountLen;
62 mnt->Device = &mnt->StrData[0];
63 memcpy( mnt->Device, Device, deviceLen+1 );
65 mnt->MountPoint = &mnt->StrData[deviceLen+1];
66 memcpy( mnt->MountPoint, MountPoint, mountLen+1 );
68 mnt->Options = &mnt->StrData[deviceLen+1+mountLen+1];
69 memcpy( mnt->Options, ArgString, argLen+1 );
72 mnt->RootNode = fs->InitDevice(Device, NULL); //&ArgString);
79 if(!gVFS_RootMount) gVFS_RootMount = mnt;
82 LOCK( &glVFS_MountList );
87 for( tmp = gVFS_Mounts; tmp->Next; tmp = tmp->Next );
94 RELEASE( &glVFS_MountList );
96 Log("VFS_Mount: Mounted '%s' to '%s' ('%s')", Device, MountPoint, Filesystem);
98 VFS_UpdateMountFile();
104 * \fn void VFS_UpdateMountFile()
105 * \brief Updates the mount file buffer
107 void VFS_UpdateMountFile()
114 // <device>\t<location>\t<type>\t<options>\n
116 for(mnt = gVFS_Mounts; mnt; mnt = mnt->Next)
118 len += 4 + strlen(mnt->Device) + strlen(mnt->MountPoint)
119 + strlen(mnt->Filesystem->Name) + strlen(mnt->Options);
122 buf = malloc( len + 1 );
124 for(mnt = gVFS_Mounts; mnt; mnt = mnt->Next)
126 strcpy( &buf[len], mnt->Device );
127 len += strlen(mnt->Device);
130 strcpy( &buf[len], mnt->MountPoint );
131 len += strlen(mnt->MountPoint);
134 strcpy( &buf[len], mnt->Filesystem->Name );
135 len += strlen(mnt->Filesystem->Name);
138 strcpy( &buf[len], mnt->Options );
139 len += strlen(mnt->Options);
144 SysFS_UpdateFile( giVFS_MountFileID, buf, len );
145 if( gsVFS_MountFile ) free( gsVFS_MountFile );
146 gsVFS_MountFile = buf;