X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Kernel%2Fvfs%2Fmount.c;h=1773218a3908ab4a474cbc17c3788607cd3fbfcb;hb=f0ffa8c904a7a99e115e926b4bf59d9749e86334;hp=0c07bcb88eb75defbe7553e31b958f12a95ba027;hpb=dea6bcf35a3f52396724d74e47f71cb3afade37c;p=tpg%2Facess2.git diff --git a/Kernel/vfs/mount.c b/Kernel/vfs/mount.c index 0c07bcb8..1773218a 100644 --- a/Kernel/vfs/mount.c +++ b/Kernel/vfs/mount.c @@ -11,13 +11,16 @@ extern int giVFS_MountFileID; extern char *gsVFS_MountFile; // === PROTOTYPES === - int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options); +#if 0 + int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options); +#endif void VFS_UpdateMountFile(void); // === GLOBALS === - int glVFS_MountList = 0; +tMutex glVFS_MountList; tVFS_Mount *gVFS_Mounts; tVFS_Mount *gVFS_RootMount = NULL; +Uint32 giVFS_NextMountIdent = 1; // === CODE === /** @@ -32,7 +35,7 @@ tVFS_Mount *gVFS_RootMount = NULL; * \a Filesystem. The options in the string \a Options is passed to the * driver's mount. */ -int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options) +int VFS_Mount(const char *Device, const char *MountPoint, const char *Filesystem, const char *Options) { tVFS_Mount *mnt; tVFS_Driver *fs; @@ -77,12 +80,20 @@ int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options) free(mnt); return -2; } + + mnt->Identifier = giVFS_NextMountIdent++; + #if 0 + // Ensure identifiers don't repeat + // - Only a problem if there have been 4 billion mounts + while( giVFS_NextMountIdent == 0 || VFS_GetMountByIdent(giVFS_NextMountIdent) ) + giVFS_NextMountIdent ++; + #endif // Set root if(!gVFS_RootMount) gVFS_RootMount = mnt; // Add to mount list - LOCK( &glVFS_MountList ); + Mutex_Acquire( &glVFS_MountList ); { tVFS_Mount *tmp; mnt->Next = NULL; @@ -94,7 +105,7 @@ int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options) gVFS_Mounts = mnt; } } - RELEASE( &glVFS_MountList ); + Mutex_Release( &glVFS_MountList ); Log_Log("VFS", "Mounted '%s' to '%s' ('%s')", Device, MountPoint, Filesystem); @@ -103,6 +114,20 @@ int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options) return 0; } +/** + * \brief Gets a mount point given the identifier + */ +tVFS_Mount *VFS_GetMountByIdent(Uint32 MountID) +{ + tVFS_Mount *mnt; + for(mnt = gVFS_Mounts; mnt; mnt = mnt->Next) + { + if(mnt->Identifier == MountID) + return mnt; + } + return NULL; +} + /** * \brief Updates the mount file buffer *