Cleaning up timer code, implementing cursor in vesa
[tpg/acess2.git] / Modules / Filesystems / NTFS / main.c
1 /*
2  * Acess2 - NTFS Driver
3  * By John Hodge (thePowersGang)
4  * This file is published under the terms of the Acess licence. See the
5  * file COPYING for details.
6  *
7  * main.c - Driver core
8  */
9 #define DEBUG   1
10 #define VERBOSE 0
11 #include <acess.h>
12 #include <vfs.h>
13 #include "common.h"
14 #include <modules.h>
15
16 // === PROTOTYPES ===
17  int    NTFS_Install(char **Arguments);
18 tVFS_Node       *NTFS_InitDevice(char *Devices, char **Options);
19 void    NTFS_Unmount(tVFS_Node *Node);
20
21 // === GLOBALS ===
22 MODULE_DEFINE(0, 0x0A /*v0.1*/, FS_NTFS, NTFS_Install, NULL);
23 tVFS_Driver     gNTFS_FSInfo = {"ntfs", 0, NTFS_InitDevice, NTFS_Unmount, NULL};
24
25 tNTFS_Disk      gNTFS_Disks;
26
27 // === CODE ===
28 /**
29  * \brief Installs the NTFS driver
30  */
31 int NTFS_Install(char **Arguments)
32 {
33         VFS_AddDriver( &gNTFS_FSInfo );
34         return 1;
35 }
36
37 /**
38  * \brief Mount a NTFS volume
39  */
40 tVFS_Node *NTFS_InitDevice(char *Device, char **Options)
41 {
42         tNTFS_Disk      *disk;
43         tNTFS_BootSector        bs;
44         
45         disk = malloc( sizeof(tNTFS_Disk) );
46         
47         disk->FD = VFS_Open(Device, VFS_OPENFLAG_READ);
48         if(!disk->FD) {
49                 free(disk);
50                 return NULL;
51         }
52         
53         VFS_ReadAt(disk->FD, 0, 512, &bs);
54         
55         disk->ClusterSize = bs.BytesPerSector * bs.SectorsPerCluster;
56         Log_Debug("NTFS", "Cluster Size = %i KiB", disk->ClusterSize/1024);
57         disk->MFTBase = bs.MFTStart;
58         Log_Debug("NTFS", "MFT Base = %i", disk->MFTBase);
59         
60         disk->RootNode.Inode = 5;       // MFT Ent #5 is filesystem root
61         disk->RootNode.ImplPtr = disk;
62         
63         disk->RootNode.UID = 0;
64         disk->RootNode.GID = 0;
65         
66         disk->RootNode.NumACLs = 1;
67         disk->RootNode.ACLs = &gVFS_ACL_EveryoneRX;
68         
69         disk->RootNode.ReadDir = NTFS_ReadDir;
70         disk->RootNode.FindDir = NTFS_FindDir;
71         disk->RootNode.MkNod = NULL;
72         disk->RootNode.Link = NULL;
73         disk->RootNode.Relink = NULL;
74         disk->RootNode.Close = NULL;
75         
76         return &disk->RootNode;
77 }
78
79 /**
80  * \brief Unmount an NTFS Disk
81  */
82 void NTFS_Unmount(tVFS_Node *Node)
83 {
84         
85 }

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