Kernel - Slight reworks to timer code
[tpg/acess2.git] / Kernel / vfs / mount.c
index 6c0929e..1773218 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * Acess Micro - VFS Server version 1
  */
-#include <common.h>
+#include <acess.h>
 #include <vfs.h>
 #include <vfs_int.h>
 #include <fs_sysfs.h>
@@ -11,25 +11,31 @@ extern int  giVFS_MountFileID;
 extern char    *gsVFS_MountFile;
 
 // === PROTOTYPES ===
- int   VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *ArgString);
-void   VFS_UpdateMountFile();
+#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 ===
 /**
- * \fn int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options)
  * \brief Mount a device
  * \param Device       Device string to mount
  * \param MountPoint   Destination for the mount
  * \param Filesystem   Filesystem to use for the mount
  * \param Options              Options to be passed to the filesystem
  * \return -1 on Invalid FS, -2 on No Mem, 0 on success
+ * 
+ * Mounts the filesystem on \a Device at \a MountPoint using the driver
+ * \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;
@@ -40,7 +46,7 @@ int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options)
        // Get the filesystem
        fs = VFS_GetFSByName(Filesystem);
        if(!fs) {
-               Warning("VFS_Mount - Unknown FS Type '%s'", Filesystem);
+               Log_Warning("VFS", "VFS_Mount - Unknown FS Type '%s'", Filesystem);
                return -1;
        }
        
@@ -74,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;
@@ -91,9 +105,9 @@ int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options)
                        gVFS_Mounts = mnt;
                }
        }
-       RELEASE( &glVFS_MountList );
+       Mutex_Release( &glVFS_MountList );
        
-       Log("VFS_Mount: Mounted '%s' to '%s' ('%s')", Device, MountPoint, Filesystem);
+       Log_Log("VFS", "Mounted '%s' to '%s' ('%s')", Device, MountPoint, Filesystem);
        
        VFS_UpdateMountFile();
        
@@ -101,10 +115,25 @@ int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options)
 }
 
 /**
- * \fn void VFS_UpdateMountFile()
+ * \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
+ * 
+ * Updates the ProcFS mounts file buffer to match the current mounts list.
  */
-void VFS_UpdateMountFile()
+void VFS_UpdateMountFile(void)
 {
         int    len = 0;
        char    *buf;

UCC git Repository :: git.ucc.asn.au