Trying to fix the string corruption bug, working on NTFS driver
[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 "common.h"
12 #include <modules.h>
13
14 // === PROTOTYPES ===
15  int    NTFS_Install(char **Arguments);
16 tVFS_Node       *NTFS_InitDevice(char *Devices, char **Options);
17 void    NTFS_Unmount(tVFS_Node *Node);
18
19 // === GLOBALS ===
20 MODULE_DEFINE(0, 0x0A /*v0.1*/, FS_NTFS, NTFS_Install, NULL);
21 tVFS_Driver     gNTFS_FSInfo = {"ntfs", 0, NTFS_InitDevice, NTFS_Unmount, NULL};
22
23 tNTFS_Disk      gNTFS_Disks;
24
25 // === CODE ===
26 /**
27  * \brief Installs the NTFS driver
28  */
29 int NTFS_Install(char **Arguments)
30 {
31         VFS_AddDriver( &gNTFS_FSInfo );
32         return 1;
33 }
34
35 /**
36  * \brief Mount a NTFS volume
37  */
38 tVFS_Node *NTFS_InitDevice(char *Device, char **Options)
39 {
40         tNTFS_Disk      *disk;
41         tNTFS_BootSector        bs;
42         
43         disk = malloc( sizeof(tNTFS_Disk) );
44         
45         disk->FD = VFS_Open(Device, VFS_OPENFLAG_READ);
46         if(!disk->FD) {
47                 free(disk);
48                 return NULL;
49         }
50         
51         VFS_ReadAt(disk->FD, 0, 512, &bs);
52         
53         disk->ClusterSize = bs.BytesPerSector * bs.SectorsPerCluster;
54         Log_Debug("NTFS", "Cluster Size = %i KiB", disk->ClusterSize/1024);
55         disk->MFTBase = bs.MFTStart;
56         Log_Debug("NTFS", "MFT Base = %i", disk->MFTBase);
57         
58         disk->RootNode.Inode = 5;       // MFT Ent #5 is '.'
59         disk->RootNode.ImplPtr = disk;
60         
61         disk->RootNode.UID = 0;
62         disk->RootNode.GID = 0;
63         
64         disk->RootNode.NumACLs = 1;
65         disk->RootNode.ACLs = &gVFS_ACL_EveryoneRX;
66         
67         disk->RootNode.ReadDir = NTFS_ReadDir;
68         disk->RootNode.FindDir = NTFS_FindDir;
69         disk->RootNode.MkNod = NULL;
70         disk->RootNode.Link = NULL;
71         disk->RootNode.Relink = NULL;
72         disk->RootNode.Close = NULL;
73         
74         return &disk->RootNode;
75 }
76
77 /**
78  * \brief Unmount an NTFS Disk
79  */
80 void NTFS_Unmount(tVFS_Node *Node)
81 {
82         
83 }

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