2003-07-17 Casper S. Hornstrup <chorns@users.sourceforge.net>

* drivers/fs/ntfs/notes.txt: New file.
	* drivers/fs/ntfs/close.c: Ditto.
	* drivers/fs/ntfs/rw.c: Ditto.
	* drivers/fs/ntfs/attrib.c: Change Cdfs prefix to Ntfs.
	* drivers/fs/ntfs/fcb.c: Ditto.
	* drivers/fs/ntfs/finfo.c: Ditto.
	* drivers/fs/ntfs/fsctl.c: Ditto.
	* drivers/fs/ntfs/volinfo.c: Ditto.
	* drivers/fs/ntfs/ntfs.c (DriverEntry): Set remaining dispatch functions.
	* drivers/fs/ntfs/ntfs.h: Change Cdfs prefix to Ntfs.
	(NTFS_RECORD_HEADER, FILE_RECORD_HEADER): Document fields.
	* drivers/fs/ntfs/makefile (TARGET_OBJECTS): Add close.o rw.o.

svn path=/trunk/; revision=5150
This commit is contained in:
Casper Hornstrup 2003-07-17 13:31:39 +00:00
parent 7359af43d8
commit cb35a5b425
12 changed files with 419 additions and 82 deletions

View file

@ -1,3 +1,18 @@
2003-07-17 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/fs/ntfs/notes.txt: New file.
* drivers/fs/ntfs/close.c: Ditto.
* drivers/fs/ntfs/rw.c: Ditto.
* drivers/fs/ntfs/attrib.c: Change Cdfs prefix to Ntfs.
* drivers/fs/ntfs/fcb.c: Ditto.
* drivers/fs/ntfs/finfo.c: Ditto.
* drivers/fs/ntfs/fsctl.c: Ditto.
* drivers/fs/ntfs/volinfo.c: Ditto.
* drivers/fs/ntfs/ntfs.c (DriverEntry): Set remaining dispatch functions.
* drivers/fs/ntfs/ntfs.h: Change Cdfs prefix to Ntfs.
(NTFS_RECORD_HEADER, FILE_RECORD_HEADER): Document fields.
* drivers/fs/ntfs/makefile (TARGET_OBJECTS): Add close.o rw.o.
2003-07-17 Casper S. Hornstrup <chorns@users.sourceforge.net>
* INSTALL: Update installation instructions.

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: attrib.c,v 1.2 2003/01/17 18:51:13 ekohl Exp $
/* $Id: attrib.c,v 1.3 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -29,7 +29,7 @@
#include <ddk/ntddk.h>
#define NDEBUG
//#define NDEBUG
#include <debug.h>
#include "ntfs.h"

112
reactos/drivers/fs/ntfs/close.c Executable file
View file

@ -0,0 +1,112 @@
/*
* ReactOS kernel
* Copyright (C) 2002 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: close.c,v 1.1 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/fs/ntfs/close.c
* PURPOSE: NTFS filesystem driver
* PROGRAMMER: Art Yerkes
* UPDATE HISTORY:
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
//#define NDEBUG
#include <debug.h>
#include "ntfs.h"
/* FUNCTIONS ****************************************************************/
static NTSTATUS
NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject)
/*
* FUNCTION: Closes a file
*/
{
PCCB Ccb;
DPRINT("NtfsCloseFile(DeviceExt %x, FileObject %x)\n",
DeviceExt,
FileObject);
Ccb = (PCCB)(FileObject->FsContext2);
DPRINT("Ccb %x\n", Ccb);
if (Ccb == NULL)
{
return(STATUS_SUCCESS);
}
FileObject->FsContext2 = NULL;
if (FileObject->FileName.Buffer)
{
// This a FO, that was created outside from FSD.
// Some FO's are created with IoCreateStreamFileObject() insid from FSD.
// This FO's don't have a FileName.
NtfsReleaseFCB(DeviceExt, FileObject->FsContext);
}
if (Ccb->DirectorySearchPattern)
{
ExFreePool(Ccb->DirectorySearchPattern);
}
ExFreePool(Ccb);
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
NtfsClose(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PDEVICE_EXTENSION DeviceExtension;
PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject;
NTSTATUS Status;
DPRINT("NtfsClose() called\n");
if (DeviceObject == NtfsGlobalData->DeviceObject)
{
DPRINT("Closing file system\n");
Status = STATUS_SUCCESS;
goto ByeBye;
}
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
DeviceExtension = DeviceObject->DeviceExtension;
Status = NtfsCloseFile(DeviceExtension,FileObject);
ByeBye:
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: fcb.c,v 1.6 2003/06/07 11:34:35 chorns Exp $
/* $Id: fcb.c,v 1.7 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -29,7 +29,7 @@
#include <ddk/ntddk.h>
#define NDEBUG
//#define NDEBUG
#include <debug.h>
#include "ntfs.h"
@ -327,7 +327,7 @@ NtfsGetDirEntryName(PDEVICE_EXTENSION DeviceExt,
}
else
{
CdfsSwapString(Name, Record->FileId, Record->FileIdLength);
NtfsSwapString(Name, Record->FileId, Record->FileIdLength);
}
}
@ -353,7 +353,7 @@ NtfsMakeFCBFromDirEntry(PVCB Vcb,
}
wcscpy(pathName, DirectoryFCB->PathName);
if (!CdfsFCBIsRoot(DirectoryFCB))
if (!NtfsFCBIsRoot(DirectoryFCB))
{
wcscat(pathName, L"\\");
}
@ -366,11 +366,11 @@ NtfsMakeFCBFromDirEntry(PVCB Vcb,
{
WCHAR entryName[MAX_PATH];
CdfsGetDirEntryName(Vcb, Record, entryName);
NtfsGetDirEntryName(Vcb, Record, entryName);
wcscat(pathName, entryName);
}
rcFCB = CdfsCreateFCB(pathName);
rcFCB = NtfsCreateFCB(pathName);
memcpy(&rcFCB->Entry, Record, sizeof(DIR_RECORD));
Size = rcFCB->Entry.DataLengthL;
@ -379,9 +379,9 @@ NtfsMakeFCBFromDirEntry(PVCB Vcb,
rcFCB->RFCB.ValidDataLength.QuadPart = Size;
rcFCB->RFCB.AllocationSize.QuadPart = ROUND_UP(Size, BLOCKSIZE);
// DPRINT1("%S %d %d\n", longName, Size, (ULONG)rcFCB->RFCB.AllocationSize.QuadPart);
CdfsFCBInitializeCache(Vcb, rcFCB);
NtfsFCBInitializeCache(Vcb, rcFCB);
rcFCB->RefCount++;
CdfsAddFCBToTable(Vcb, rcFCB);
NtfsAddFCBToTable(Vcb, rcFCB);
*fileFCB = rcFCB;
return(STATUS_SUCCESS);
@ -424,19 +424,19 @@ NtfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb,
Fcb->Flags |= FCB_CACHE_INITIALIZED;
}
DPRINT("file open: fcb:%x file size: %d\n", Fcb, Fcb->Entry.DataLengthL);
//DPRINT("file open: fcb:%x file size: %d\n", Fcb, Fcb->Entry.DataLengthL);
return(STATUS_SUCCESS);
}
#if 0
NTSTATUS
NtfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
PFCB DirectoryFcb,
PWSTR FileToFind,
PFCB *FoundFCB)
{
#if 0
WCHAR TempName[2];
WCHAR Name[256];
PVOID Block;
@ -454,7 +454,7 @@ NtfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
assert(DirectoryFcb);
assert(FileToFind);
DPRINT("CdfsDirFindFile(VCB:%08x, dirFCB:%08x, File:%S)\n",
DPRINT("NtfsDirFindFile(VCB:%08x, dirFCB:%08x, File:%S)\n",
DeviceExt,
DirectoryFcb,
FileToFind);
@ -492,13 +492,13 @@ NtfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
DPRINT("RecordLength %u ExtAttrRecordLength %u NameLength %u\n",
Record->RecordLength, Record->ExtAttrRecordLength, Record->FileIdLength);
CdfsGetDirEntryName(DeviceExt, Record, Name);
NtfsGetDirEntryName(DeviceExt, Record, Name);
DPRINT("Name '%S'\n", Name);
if (wstrcmpjoki(Name, FileToFind))
{
DPRINT("Match found, %S\n", Name);
Status = CdfsMakeFCBFromDirEntry(DeviceExt,
Status = NtfsMakeFCBFromDirEntry(DeviceExt,
DirectoryFcb,
Name,
Record,
@ -536,10 +536,10 @@ NtfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
}
CcUnpinData(Context);
#endif
return(STATUS_OBJECT_NAME_NOT_FOUND);
}
#endif
NTSTATUS
NtfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
@ -561,11 +561,11 @@ NtfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
pFileName);
/* Dummy code */
FCB = NtfsOpenRootFCB(Vcb);
*pFCB = FCB;
*pParentFCB = NULL;
// FCB = NtfsOpenRootFCB(Vcb);
// *pFCB = FCB;
// *pParentFCB = NULL;
#if 0
#if 1
/* Trivial case, open of the root directory on volume */
if (pFileName [0] == L'\0' || wcscmp(pFileName, L"\\") == 0)
{
@ -581,15 +581,15 @@ NtfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
{
currentElement = pFileName + 1;
wcscpy (pathName, L"\\");
FCB = CdfsOpenRootFCB (Vcb);
FCB = NtfsOpenRootFCB (Vcb);
}
parentFCB = NULL;
/* Parse filename and check each path element for existance and access */
while (CdfsGetNextPathElement(currentElement) != 0)
while (NtfsGetNextPathElement(currentElement) != 0)
{
/* Skip blank directory levels */
if ((CdfsGetNextPathElement(currentElement) - currentElement) == 0)
if ((NtfsGetNextPathElement(currentElement) - currentElement) == 0)
{
currentElement++;
continue;
@ -601,16 +601,16 @@ NtfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
/* Descend to next directory level */
if (parentFCB)
{
CdfsReleaseFCB(Vcb, parentFCB);
NtfsReleaseFCB(Vcb, parentFCB);
parentFCB = NULL;
}
/* fail if element in FCB is not a directory */
if (!CdfsFCBIsDirectory(FCB))
if (!NtfsFCBIsDirectory(FCB))
{
DPRINT("Element in requested path is not a directory\n");
CdfsReleaseFCB(Vcb, FCB);
NtfsReleaseFCB(Vcb, FCB);
FCB = 0;
*pParentFCB = NULL;
*pFCB = NULL;
@ -620,26 +620,26 @@ NtfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
parentFCB = FCB;
/* Extract next directory level into dirName */
CdfsWSubString(pathName,
NtfsWSubString(pathName,
pFileName,
CdfsGetNextPathElement(currentElement) - pFileName);
NtfsGetNextPathElement(currentElement) - pFileName);
DPRINT(" pathName:%S\n", pathName);
FCB = CdfsGrabFCBFromTable(Vcb, pathName);
FCB = NtfsGrabFCBFromTable(Vcb, pathName);
if (FCB == NULL)
{
CdfsWSubString(elementName,
NtfsWSubString(elementName,
currentElement,
CdfsGetNextPathElement(currentElement) - currentElement);
NtfsGetNextPathElement(currentElement) - currentElement);
DPRINT(" elementName:%S\n", elementName);
Status = CdfsDirFindFile(Vcb, parentFCB, elementName, &FCB);
Status = NtfsDirFindFile(Vcb, parentFCB, elementName, &FCB);
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
{
*pParentFCB = parentFCB;
*pFCB = NULL;
currentElement = CdfsGetNextPathElement(currentElement);
if (*currentElement == L'\0' || CdfsGetNextPathElement(currentElement + 1) == 0)
currentElement = NtfsGetNextPathElement(currentElement);
if (*currentElement == L'\0' || NtfsGetNextPathElement(currentElement + 1) == 0)
{
return(STATUS_OBJECT_NAME_NOT_FOUND);
}
@ -650,14 +650,14 @@ NtfsGetFCBForFile(PDEVICE_EXTENSION Vcb,
}
else if (!NT_SUCCESS(Status))
{
CdfsReleaseFCB(Vcb, parentFCB);
NtfsReleaseFCB(Vcb, parentFCB);
*pParentFCB = NULL;
*pFCB = NULL;
return(Status);
}
}
currentElement = CdfsGetNextPathElement(currentElement);
currentElement = NtfsGetNextPathElement(currentElement);
}
*pParentFCB = parentFCB;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: finfo.c,v 1.1 2002/06/25 22:23:05 ekohl Exp $
/* $Id: finfo.c,v 1.2 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -140,16 +140,16 @@ NtfsGetNameInformation(PFILE_OBJECT FileObject,
assert(NameInfo != NULL);
assert(Fcb != NULL);
// NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
NameLength = 2;
NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
// NameLength = 2;
if (*BufferLength < sizeof(FILE_NAME_INFORMATION) + NameLength)
return(STATUS_BUFFER_OVERFLOW);
NameInfo->FileNameLength = NameLength;
// memcpy(NameInfo->FileName,
// Fcb->PathName,
// NameLength + sizeof(WCHAR));
wcscpy(NameInfo->FileName, L"\\");
memcpy(NameInfo->FileName,
Fcb->PathName,
NameLength + sizeof(WCHAR));
// wcscpy(NameInfo->FileName, L"\\");
*BufferLength -=
(sizeof(FILE_NAME_INFORMATION) + NameLength + sizeof(WCHAR));

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: fsctl.c,v 1.6 2003/06/07 11:34:36 chorns Exp $
/* $Id: fsctl.c,v 1.7 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -29,7 +29,7 @@
#include <ddk/ntddk.h>
#define NDEBUG
//#define NDEBUG
#include <debug.h>
#include "ntfs.h"

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.3 2003/04/05 09:37:42 chorns Exp $
# $Id: makefile,v 1.4 2003/07/17 13:31:39 chorns Exp $
PATH_TO_TOP = ../../..
@ -9,7 +9,7 @@ TARGET_TYPE = driver
TARGET_NAME = ntfs
TARGET_OBJECTS = $(TARGET_NAME).o attrib.o blockdev.o create.o dirctl.o \
fcb.o finfo.o fsctl.o mft.o volinfo.o
fcb.o finfo.o fsctl.o mft.o volinfo.o close.o rw.o
include $(PATH_TO_TOP)/rules.mak

View file

@ -0,0 +1,5 @@
These are notes about the NT filesystem
More documentation is available at:
http://linux-ntfs.sourceforge.net/ntfs/index.html

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: ntfs.c,v 1.2 2002/08/20 20:37:06 hyperion Exp $
/* $Id: ntfs.c,v 1.3 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -29,7 +29,7 @@
#include <ddk/ntddk.h>
#define NDEBUG
//#define NDEBUG
#include <debug.h>
#include "ntfs.h"
@ -80,20 +80,20 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
/* Initialize driver data */
DeviceObject->Flags = DO_DIRECT_IO;
// DriverObject->MajorFunction[IRP_MJ_CLOSE] = NtfsClose;
DriverObject->MajorFunction[IRP_MJ_CREATE] = NtfsCreate;
// DriverObject->MajorFunction[IRP_MJ_READ] = NtfsRead;
// DriverObject->MajorFunction[IRP_MJ_WRITE] = NtfsWrite;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH) NtfsClose;
DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH) NtfsCreate;
DriverObject->MajorFunction[IRP_MJ_READ] = (PDRIVER_DISPATCH) NtfsRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = (PDRIVER_DISPATCH) NtfsWrite;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
NtfsFileSystemControl;
(PDRIVER_DISPATCH) NtfsFileSystemControl;
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
NtfsDirectoryControl;
(PDRIVER_DISPATCH) NtfsDirectoryControl;
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
NtfsQueryInformation;
// DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
// NtfsQueryVolumeInformation;
// DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
// NtfsSetVolumeInformation;
(PDRIVER_DISPATCH) NtfsQueryInformation;
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
(PDRIVER_DISPATCH) NtfsQueryVolumeInformation;
DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
(PDRIVER_DISPATCH) NtfsSetVolumeInformation;
DriverObject->DriverUnload = NULL;

View file

@ -152,25 +152,34 @@ typedef enum
typedef struct
{
ULONG Type;
USHORT UsnOffset;
USHORT UsnSize;
ULONGLONG Usn;
ULONG Type; /* Magic number 'FILE' */
USHORT UsnOffset; /* Offset to the update sequence */
USHORT UsnSize; /* Size in words of Update Sequence Number & Array (S) */
ULONGLONG Lsn; /* $LogFile Sequence Number (LSN) */
} NTFS_RECORD_HEADER, *PNTFS_RECORD_HEADER;
typedef struct
{
NTFS_RECORD_HEADER Ntfs;
USHORT SequenceNumber;
USHORT LinkCount;
USHORT AttributeOffset;
USHORT Flags;
ULONG BytesInUse;
ULONG BytesAllocated;
ULONGLONG BaseFileRecord;
USHORT NextAttributeNumber;
USHORT SequenceNumber; /* Sequence number */
USHORT LinkCount; /* Hard link count */
USHORT AttributeOffset; /* Offset to the first Attribute */
USHORT Flags; /* Flags */
ULONG BytesInUse; /* Real size of the FILE record */
ULONG BytesAllocated; /* Allocated size of the FILE record */
ULONGLONG BaseFileRecord; /* File reference to the base FILE record */
USHORT NextAttributeNumber; /* Next Attribute Id */
USHORT Pading; /* Align to 4 byte boundary (XP) */
ULONG MFTRecordNumber; /* Number of this MFT Record (XP) */
} FILE_RECORD_HEADER, *PFILE_RECORD_HEADER;
/* Flags in FILE_RECORD_HEADER */
#define FRH_IN_USE 0x01 /* Record is in use */
#define FRH_DIRECTORY 0x02 /* Record is a directory */
#define FRH_UNKNOWN1 0x04 /* Don't know */
#define FRH_UNKNOWN2 0x08 /* Don't know */
typedef struct
{
ATTRIBUTE_TYPE AttributeType;
@ -299,13 +308,11 @@ NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
IN OUT PVOID OutputBuffer,
IN OUT PULONG OutputBufferSize);
#if 0
/* close.c */
NTSTATUS STDCALL
CdfsClose(PDEVICE_OBJECT DeviceObject,
NtfsClose(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
#endif
/* create.c */
@ -320,7 +327,6 @@ NTSTATUS STDCALL
NtfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
/* fcb.c */
PFCB
@ -411,17 +417,17 @@ CdfsDateTimeToFileTime(PFCB Fcb,
VOID
CdfsFileFlagsToAttributes(PFCB Fcb,
PULONG FileAttributes);
#endif
/* rw.c */
NTSTATUS STDCALL
CdfsRead(PDEVICE_OBJECT DeviceObject,
NtfsRead(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
NTSTATUS STDCALL
CdfsWrite(PDEVICE_OBJECT DeviceObject,
NtfsWrite(PDEVICE_OBJECT DeviceObject,
PIRP Irp);
#endif
/* volinfo.c */

199
reactos/drivers/fs/ntfs/rw.c Executable file
View file

@ -0,0 +1,199 @@
/*
* ReactOS kernel
* Copyright (C) 2002 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: rw.c,v 1.1 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/fs/cdfs/rw.c
* PURPOSE: CDROM (ISO 9660) filesystem driver
* PROGRAMMER: Art Yerkes
* UPDATE HISTORY:
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <ntos/minmax.h>
//#define NDEBUG
#include <debug.h>
#include "ntfs.h"
/* GLOBALS *******************************************************************/
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
/* FUNCTIONS ****************************************************************/
static NTSTATUS
NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject,
PUCHAR Buffer,
ULONG Length,
ULONG ReadOffset,
ULONG IrpFlags,
PULONG LengthRead)
/*
* FUNCTION: Reads data from a file
*/
{
#if 0
NTSTATUS Status = STATUS_SUCCESS;
PUCHAR TempBuffer;
ULONG TempLength;
PCCB Ccb;
PFCB Fcb;
DPRINT("CdfsReadFile(ReadOffset %lu Length %lu)\n", ReadOffset, Length);
*LengthRead = 0;
if (Length == 0)
return(STATUS_SUCCESS);
Ccb = (PCCB)FileObject->FsContext2;
Fcb = (PFCB)FileObject->FsContext;
if (ReadOffset >= Fcb->Entry.DataLengthL)
return(STATUS_END_OF_FILE);
DPRINT("Reading %d bytes at %d\n", Length, ReadOffset);
if (!(IrpFlags & (IRP_NOCACHE|IRP_PAGING_IO)))
{
LARGE_INTEGER FileOffset;
IO_STATUS_BLOCK IoStatus;
if (ReadOffset + Length > Fcb->Entry.DataLengthL)
Length = Fcb->Entry.DataLengthL - ReadOffset;
if (FileObject->PrivateCacheMap == NULL)
{
CcRosInitializeFileCache(FileObject, PAGE_SIZE);
}
FileOffset.QuadPart = (LONGLONG)ReadOffset;
CcCopyRead(FileObject,
&FileOffset,
Length,
TRUE,
Buffer,
&IoStatus);
*LengthRead = IoStatus.Information;
return(IoStatus.Status);
}
if ((ReadOffset % BLOCKSIZE) != 0 || (Length % BLOCKSIZE) != 0)
{
return STATUS_INVALID_PARAMETER;
}
if (ReadOffset + Length > ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE))
Length = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE) - ReadOffset;
Status = CdfsReadSectors(DeviceExt->StorageDevice,
Fcb->Entry.ExtentLocationL + (ReadOffset / BLOCKSIZE),
Length / BLOCKSIZE,
Buffer);
if (NT_SUCCESS(Status))
{
*LengthRead = Length;
if (Length + ReadOffset > Fcb->Entry.DataLengthL)
{
memset(Buffer + Fcb->Entry.DataLengthL - ReadOffset,
0, Length + ReadOffset - Fcb->Entry.DataLengthL);
}
}
return(Status);
#else
*LengthRead = 0;
return STATUS_END_OF_FILE;
#endif
}
NTSTATUS STDCALL
NtfsRead(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PDEVICE_EXTENSION DeviceExt;
PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject;
PVOID Buffer;
ULONG ReadLength;
LARGE_INTEGER ReadOffset;
ULONG ReturnedReadLength = 0;
NTSTATUS Status = STATUS_SUCCESS;
DPRINT("NtfsRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
DeviceExt = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
ReadLength = Stack->Parameters.Read.Length;
ReadOffset = Stack->Parameters.Read.ByteOffset;
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Status = NtfsReadFile(DeviceExt,
FileObject,
Buffer,
ReadLength,
ReadOffset.u.LowPart,
Irp->Flags,
&ReturnedReadLength);
ByeBye:
if (NT_SUCCESS(Status))
{
if (FileObject->Flags & FO_SYNCHRONOUS_IO)
{
FileObject->CurrentByteOffset.QuadPart =
ReadOffset.QuadPart + ReturnedReadLength;
}
Irp->IoStatus.Information = ReturnedReadLength;
}
else
{
Irp->IoStatus.Information = 0;
}
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp,IO_NO_INCREMENT);
return(Status);
}
NTSTATUS STDCALL
NtfsWrite(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
DPRINT("NtfwWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0;
return(STATUS_NOT_SUPPORTED);
}
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: volinfo.c,v 1.1 2002/06/25 22:23:06 ekohl Exp $
/* $Id: volinfo.c,v 1.2 2003/07/17 13:31:39 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -29,7 +29,7 @@
#include <ddk/ntddk.h>
#define NDEBUG
//#define NDEBUG
#include <debug.h>
#include "ntfs.h"