git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
2c6ec28
)
Modules/NTFS - Added _Read, working on _Close cleanup
author
John Hodge
<
[email protected]
>
Tue, 25 Jun 2013 01:01:36 +0000
(09:01 +0800)
committer
John Hodge
<
[email protected]
>
Tue, 25 Jun 2013 01:01:36 +0000
(09:01 +0800)
KernelLand/Modules/Filesystems/NTFS/Makefile
patch
|
blob
|
history
KernelLand/Modules/Filesystems/NTFS/common.h
patch
|
blob
|
history
KernelLand/Modules/Filesystems/NTFS/dir.c
patch
|
blob
|
history
KernelLand/Modules/Filesystems/NTFS/io.c
[new file with mode: 0644]
patch
|
blob
KernelLand/Modules/Filesystems/NTFS/main.c
patch
|
blob
|
history
diff --git
a/KernelLand/Modules/Filesystems/NTFS/Makefile
b/KernelLand/Modules/Filesystems/NTFS/Makefile
index
22c1677
..
9c79f72
100644
(file)
--- a/
KernelLand/Modules/Filesystems/NTFS/Makefile
+++ b/
KernelLand/Modules/Filesystems/NTFS/Makefile
@@
-1,7
+1,7
@@
#
#
#
#
-OBJ = main.o dir.o
+OBJ = main.o dir.o
io.o
NAME = NTFS
-include ../Makefile.tpl
NAME = NTFS
-include ../Makefile.tpl
diff --git
a/KernelLand/Modules/Filesystems/NTFS/common.h
b/KernelLand/Modules/Filesystems/NTFS/common.h
index
80e5bbe
..
e8dbe7d
100644
(file)
--- a/
KernelLand/Modules/Filesystems/NTFS/common.h
+++ b/
KernelLand/Modules/Filesystems/NTFS/common.h
@@
-85,14
+85,19
@@
struct sNTFS_Attrib
extern tVFS_NodeType gNTFS_DirType;
extern tVFS_NodeType gNTFS_FileType;
extern tVFS_NodeType gNTFS_DirType;
extern tVFS_NodeType gNTFS_FileType;
+extern void NTFS_Close(tVFS_Node *Node);
+extern void NTFS_FreeNode(tVFS_Node *Node);
extern int NTFS_int_ApplyUpdateSequence(void *Buf, size_t BufLen, const Uint16 *Sequence, size_t NumEntries);
// -- MFT Access / Manipulation
extern tNTFS_FILE_Header *NTFS_GetMFT(tNTFS_Disk *Disk, Uint32 MFTEntry);
extern void NTFS_ReleaseMFT(tNTFS_Disk *Disk, Uint32 MFTEntry, tNTFS_FILE_Header *Entry);
extern tNTFS_Attrib *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const char *Name, int DesIdx);
extern int NTFS_int_ApplyUpdateSequence(void *Buf, size_t BufLen, const Uint16 *Sequence, size_t NumEntries);
// -- MFT Access / Manipulation
extern tNTFS_FILE_Header *NTFS_GetMFT(tNTFS_Disk *Disk, Uint32 MFTEntry);
extern void NTFS_ReleaseMFT(tNTFS_Disk *Disk, Uint32 MFTEntry, tNTFS_FILE_Header *Entry);
extern tNTFS_Attrib *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const char *Name, int DesIdx);
+extern void NTFS_FreeAttrib(tNTFS_Attrib *Attrib);
extern size_t NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer);
// -- dir.c
extern int NTFS_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]);
extern tVFS_Node *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags);
extern size_t NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer);
// -- dir.c
extern int NTFS_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]);
extern tVFS_Node *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags);
+// -- io.c
+extern size_t NTFS_ReadFile(tVFS_Node *Node, Uint64 Offset, size_t Length, void *Buffer, Uint Flags);
#endif
#endif
diff --git
a/KernelLand/Modules/Filesystems/NTFS/dir.c
b/KernelLand/Modules/Filesystems/NTFS/dir.c
index
617d7db
..
dc5fb7c
100644
(file)
--- a/
KernelLand/Modules/Filesystems/NTFS/dir.c
+++ b/
KernelLand/Modules/Filesystems/NTFS/dir.c
@@
-319,8
+319,19
@@
tVFS_Node *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags)
if( len == 0 )
break;
tNTFS_IndexHeader *hdr = (void*)buf;
if( len == 0 )
break;
tNTFS_IndexHeader *hdr = (void*)buf;
+
+ if( memcmp(&hdr->Magic, "INDX", 4) != 0 ) {
+ Log_Notice("NTFS", "FindDir %p:%X:%x index magic bad %08x",
+ disk, Node->Inode, ofs / unit_len, hdr->Magic);
+ break;
+ }
// Apply update sequence
// Apply update sequence
- ASSERT(hdr->UpdateSequenceOfs + 2*hdr->UpdateSequenceSize <= len);
+ if(hdr->UpdateSequenceOfs + 2*hdr->UpdateSequenceSize > len) {
+ Log_Notice("NTFS", "FindDir %p:%X:%x index update sequence out of buffer (%x+%x>%x)",
+ disk, Node->Inode, ofs / unit_len,
+ hdr->UpdateSequenceOfs, 2*hdr->UpdateSequenceSize, len);
+ break;
+ }
NTFS_int_ApplyUpdateSequence(buf,len, (void*)(buf+hdr->UpdateSequenceOfs), hdr->UpdateSequenceSize);
// Search
//mftent = NTFS_BTreeSearch(len, (void*)buf, NTFS_BTreeSearch_CmpI30, name16len*2, name16);
NTFS_int_ApplyUpdateSequence(buf,len, (void*)(buf+hdr->UpdateSequenceOfs), hdr->UpdateSequenceSize);
// Search
//mftent = NTFS_BTreeSearch(len, (void*)buf, NTFS_BTreeSearch_CmpI30, name16len*2, name16);
@@
-330,7
+341,7
@@
tVFS_Node *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags)
);
}
);
}
- if( !mftent ) {
+ if( !mftent
|| (mftent & (1ULL << 63))
) {
LEAVE('n');
return NULL;
}
LEAVE('n');
return NULL;
}
diff --git a/KernelLand/Modules/Filesystems/NTFS/io.c
b/KernelLand/Modules/Filesystems/NTFS/io.c
new file mode 100644
(file)
index 0000000..
d0f7088
--- /dev/null
+++ b/
KernelLand/Modules/Filesystems/NTFS/io.c
@@ -0,0
+1,21
@@
+/*
+ * Acess2 - NTFS Driver
+ * - By John Hodge (thePowersGang)
+ * This file is published under the terms of the Acess licence. See the
+ * file COPYING for details.
+ *
+ * io.c
+ * - File Read/Write
+ */
+#define DEBUG 1
+#include "common.h"
+
+// == CODE ===
+size_t NTFS_ReadFile(tVFS_Node *Node, Uint64 Offset, size_t Length, void *Buffer, Uint Flags)
+{
+ tNTFS_File *File = (void*)Node;
+
+ return NTFS_ReadAttribData(File->Data, Offset, Length, Buffer);
+}
+
+
diff --git
a/KernelLand/Modules/Filesystems/NTFS/main.c
b/KernelLand/Modules/Filesystems/NTFS/main.c
index
8d6a724
..
4586e12
100644
(file)
--- a/
KernelLand/Modules/Filesystems/NTFS/main.c
+++ b/
KernelLand/Modules/Filesystems/NTFS/main.c
@@
-40,11
+40,12
@@
tVFS_NodeType gNTFS_DirType = {
.TypeName = "NTFS-Dir",
.ReadDir = NTFS_ReadDir,
.FindDir = NTFS_FindDir,
.TypeName = "NTFS-Dir",
.ReadDir = NTFS_ReadDir,
.FindDir = NTFS_FindDir,
- .Close = N
ULL
+ .Close = N
TFS_Close
};
tVFS_NodeType gNTFS_FileType = {
.TypeName = "NTFS-File",
};
tVFS_NodeType gNTFS_FileType = {
.TypeName = "NTFS-File",
- .Close = NULL
+ .Read = NTFS_ReadFile,
+ .Close = NTFS_Close
};
tNTFS_Disk gNTFS_Disks;
};
tNTFS_Disk gNTFS_Disks;
@@
-177,6
+178,25
@@
void NTFS_Unmount(tVFS_Node *Node)
free(Disk);
}
free(Disk);
}
+void NTFS_Close(tVFS_Node *Node)
+{
+ tNTFS_Disk *Disk = Node->ImplPtr;
+ Inode_UncacheNode(Disk->InodeCache, Node->Inode);
+}
+
+void NTFS_FreeNode(tVFS_Node *Node)
+{
+ if( Node->Type == &gNTFS_DirType ) {
+ tNTFS_Directory *Dir = (void*)Node;
+ NTFS_FreeAttrib(Dir->I30Root);
+ NTFS_FreeAttrib(Dir->I30Allocation);
+ }
+ else {
+ tNTFS_File *File = (void*)Node;
+ NTFS_FreeAttrib(File->Data);
+ }
+}
+
int NTFS_int_ApplyUpdateSequence(void *Buffer, size_t BufLen, const Uint16 *Sequence, size_t NumEntries)
{
Uint16 cksum = Sequence[0];
int NTFS_int_ApplyUpdateSequence(void *Buffer, size_t BufLen, const Uint16 *Sequence, size_t NumEntries)
{
Uint16 cksum = Sequence[0];
@@
-387,6
+407,12
@@
tNTFS_Attrib *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const
return NULL;
}
return NULL;
}
+void NTFS_FreeAttrib(tNTFS_Attrib *Attrib)
+{
+ if( Attrib )
+ free(Attrib);
+}
+
size_t NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer)
{
if( !Attrib )
size_t NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer)
{
if( !Attrib )
@@
-465,17
+491,13
@@
void NTFS_DumpEntry(tNTFS_Disk *Disk, Uint32 Entry)
tNTFS_FILE_Attrib *attr;
int i;
tNTFS_FILE_Attrib *attr;
int i;
- tNTFS_FILE_Header *hdr = malloc( Disk->MFTRecSize );
+
+ tNTFS_FILE_Header *hdr = NTFS_GetMFT(Disk, Entry);
if(!hdr) {
Log_Warning("FS_NTFS", "malloc() fail!");
return ;
}
if(!hdr) {
Log_Warning("FS_NTFS", "malloc() fail!");
return ;
}
- VFS_ReadAt( Disk->FD,
- Disk->MFTBase * Disk->ClusterSize + Entry * Disk->MFTRecSize,
- Disk->MFTRecSize,
- hdr);
-
Log_Debug("FS_NTFS", "MFT Entry #%i", Entry);
Log_Debug("FS_NTFS", "- Magic = 0x%08x (%4C)", hdr->Magic, &hdr->Magic);
Log_Debug("FS_NTFS", "- UpdateSequenceOfs = 0x%x", hdr->UpdateSequenceOfs);
Log_Debug("FS_NTFS", "MFT Entry #%i", Entry);
Log_Debug("FS_NTFS", "- Magic = 0x%08x (%4C)", hdr->Magic, &hdr->Magic);
Log_Debug("FS_NTFS", "- UpdateSequenceOfs = 0x%x", hdr->UpdateSequenceOfs);
@@
-536,5
+558,5
@@
void NTFS_DumpEntry(tNTFS_Disk *Disk, Uint32 Entry)
attr = (void*)( (tVAddr)attr + attr->Size );
}
attr = (void*)( (tVAddr)attr + attr->Size );
}
-
free(
hdr);
+
NTFS_ReleaseMFT(Disk, Entry,
hdr);
}
}
UCC
git Repository :: git.ucc.asn.au