mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
- Kill off ramdrv, it is deprecated since a long time ago.
See issue #3422 for more details. svn path=/trunk/; revision=37739
This commit is contained in:
parent
67ac3637f8
commit
c47ab26e82
17 changed files with 0 additions and 1721 deletions
|
@ -7,8 +7,4 @@
|
||||||
<directory name="green">
|
<directory name="green">
|
||||||
<xi:include href="green/green.rbuild" />
|
<xi:include href="green/green.rbuild" />
|
||||||
</directory>
|
</directory>
|
||||||
|
|
||||||
<directory name="ramdrv">
|
|
||||||
<xi:include href="ramdrv/ramdrv.rbuild" />
|
|
||||||
</directory>
|
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -1,203 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS kernel
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 1992, Linus Torvalds.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* These have to be done with inline assembly: that way the bit-setting
|
|
||||||
* is guaranteed to be atomic. All bit operations return 0 if the bit
|
|
||||||
* was cleared before the operation and != 0 if it was not.
|
|
||||||
*
|
|
||||||
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __SMP__
|
|
||||||
#define LOCK_PREFIX "lock ; "
|
|
||||||
#else
|
|
||||||
#define LOCK_PREFIX ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function prototypes to keep gcc -Wall happy
|
|
||||||
*/
|
|
||||||
extern void set_bit(int nr, volatile void * addr);
|
|
||||||
extern void clear_bit(int nr, volatile void * addr);
|
|
||||||
extern void change_bit(int nr, volatile void * addr);
|
|
||||||
extern int test_and_set_bit(int nr, volatile void * addr);
|
|
||||||
extern int test_and_clear_bit(int nr, volatile void * addr);
|
|
||||||
extern int test_and_change_bit(int nr, volatile void * addr);
|
|
||||||
extern int __constant_test_bit(int nr, const volatile void * addr);
|
|
||||||
extern int __test_bit(int nr, volatile void * addr);
|
|
||||||
extern int find_first_zero_bit(void * addr, unsigned size);
|
|
||||||
extern int find_next_zero_bit (void * addr, int size, int offset);
|
|
||||||
extern unsigned long ffz(unsigned long word);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some hacks to defeat gcc over-optimizations..
|
|
||||||
*/
|
|
||||||
struct __dummy { unsigned long a[100]; };
|
|
||||||
#define ADDR (*(volatile struct __dummy *) addr)
|
|
||||||
#define CONST_ADDR (*(volatile const struct __dummy *) addr)
|
|
||||||
|
|
||||||
void set_bit(int nr, volatile void * addr)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__( LOCK_PREFIX
|
|
||||||
"btsl %1,%0"
|
|
||||||
:"=m" (ADDR)
|
|
||||||
:"Ir" (nr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_bit(int nr, volatile void * addr)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__( LOCK_PREFIX
|
|
||||||
"btrl %1,%0"
|
|
||||||
:"=m" (ADDR)
|
|
||||||
:"Ir" (nr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void change_bit(int nr, volatile void * addr)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__( LOCK_PREFIX
|
|
||||||
"btcl %1,%0"
|
|
||||||
:"=m" (ADDR)
|
|
||||||
:"Ir" (nr));
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_and_set_bit(int nr, volatile void * addr)
|
|
||||||
{
|
|
||||||
int oldbit;
|
|
||||||
|
|
||||||
__asm__ __volatile__( LOCK_PREFIX
|
|
||||||
"btsl %2,%1\n\tsbbl %0,%0"
|
|
||||||
:"=r" (oldbit),"=m" (ADDR)
|
|
||||||
:"Ir" (nr));
|
|
||||||
return oldbit;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_and_clear_bit(int nr, volatile void * addr)
|
|
||||||
{
|
|
||||||
int oldbit;
|
|
||||||
|
|
||||||
__asm__ __volatile__( LOCK_PREFIX
|
|
||||||
"btrl %2,%1\n\tsbbl %0,%0"
|
|
||||||
:"=r" (oldbit),"=m" (ADDR)
|
|
||||||
:"Ir" (nr));
|
|
||||||
return oldbit;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_and_change_bit(int nr, volatile void * addr)
|
|
||||||
{
|
|
||||||
int oldbit;
|
|
||||||
|
|
||||||
__asm__ __volatile__( LOCK_PREFIX
|
|
||||||
"btcl %2,%1\n\tsbbl %0,%0"
|
|
||||||
:"=r" (oldbit),"=m" (ADDR)
|
|
||||||
:"Ir" (nr));
|
|
||||||
return oldbit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine doesn't need to be atomic.
|
|
||||||
*/
|
|
||||||
int __constant_test_bit(int nr, const volatile void * addr)
|
|
||||||
{
|
|
||||||
return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_bit(int nr, volatile void * addr)
|
|
||||||
{
|
|
||||||
int oldbit;
|
|
||||||
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"btl %2,%1\n\tsbbl %0,%0"
|
|
||||||
:"=r" (oldbit)
|
|
||||||
:"m" (ADDR),"Ir" (nr));
|
|
||||||
return oldbit;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define test_bit(nr,addr) \
|
|
||||||
(__builtin_constant_p(nr) ? \
|
|
||||||
__constant_test_bit((nr),(addr)) : \
|
|
||||||
__test_bit((nr),(addr)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find-bit routines..
|
|
||||||
*/
|
|
||||||
int find_first_zero_bit(void * addr, unsigned size)
|
|
||||||
{
|
|
||||||
int d0, d1, d2;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
if (!size)
|
|
||||||
return 0;
|
|
||||||
__asm__("cld\n\t"
|
|
||||||
"movl $-1,%%eax\n\t"
|
|
||||||
"xorl %%edx,%%edx\n\t"
|
|
||||||
"repe; scasl\n\t"
|
|
||||||
"je 1f\n\t"
|
|
||||||
"xorl -4(%%edi),%%eax\n\t"
|
|
||||||
"subl $4,%%edi\n\t"
|
|
||||||
"bsfl %%eax,%%edx\n"
|
|
||||||
"1:\tsubl %%ebx,%%edi\n\t"
|
|
||||||
"shll $3,%%edi\n\t"
|
|
||||||
"addl %%edi,%%edx"
|
|
||||||
:"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
|
|
||||||
:"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int find_next_zero_bit (void * addr, int size, int offset)
|
|
||||||
{
|
|
||||||
unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
|
|
||||||
int set = 0, bit = offset & 31, res;
|
|
||||||
|
|
||||||
if (bit) {
|
|
||||||
/*
|
|
||||||
* Look for zero in first byte
|
|
||||||
*/
|
|
||||||
__asm__("bsfl %1,%0\n\t"
|
|
||||||
"jne 1f\n\t"
|
|
||||||
"movl $32, %0\n"
|
|
||||||
"1:"
|
|
||||||
: "=r" (set)
|
|
||||||
: "r" (~(*p >> bit)));
|
|
||||||
if (set < (32 - bit))
|
|
||||||
return set + offset;
|
|
||||||
set = 32 - bit;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* No zero yet, search remaining full bytes for a zero
|
|
||||||
*/
|
|
||||||
res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr));
|
|
||||||
return (offset + set + res);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ffz = Find First Zero in word. Undefined if no zero exists,
|
|
||||||
* so code should check against ~0UL first..
|
|
||||||
*/
|
|
||||||
unsigned long ffz(unsigned long word)
|
|
||||||
{
|
|
||||||
__asm__("bsfl %1,%0"
|
|
||||||
:"=r" (word)
|
|
||||||
:"r" (~word));
|
|
||||||
return word;
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
#ifndef _I386_BITOPS_H
|
|
||||||
#define _I386_BITOPS_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 1992, Linus Torvalds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These have to be done with inline assembly: that way the bit-setting
|
|
||||||
* is guaranteed to be atomic. All bit operations return 0 if the bit
|
|
||||||
* was cleared before the operation and != 0 if it was not.
|
|
||||||
*
|
|
||||||
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function prototypes to keep gcc -Wall happy
|
|
||||||
*/
|
|
||||||
extern void set_bit(int nr, volatile void * addr);
|
|
||||||
extern void clear_bit(int nr, volatile void * addr);
|
|
||||||
extern void change_bit(int nr, volatile void * addr);
|
|
||||||
extern int test_and_set_bit(int nr, volatile void * addr);
|
|
||||||
extern int test_and_clear_bit(int nr, volatile void * addr);
|
|
||||||
extern int test_and_change_bit(int nr, volatile void * addr);
|
|
||||||
extern int test_bit(int nr, volatile void * addr);
|
|
||||||
extern int find_first_zero_bit(void * addr, unsigned size);
|
|
||||||
extern int find_next_zero_bit (void * addr, int size, int offset);
|
|
||||||
extern unsigned long ffz(unsigned long word);
|
|
||||||
|
|
||||||
#endif /* _I386_BITOPS_H */
|
|
|
@ -1,109 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/minix.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
|
|
||||||
//#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix.h"
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
|
||||||
struct minix_inode* inode,
|
|
||||||
ULONG FileOffset)
|
|
||||||
{
|
|
||||||
int block;
|
|
||||||
PVOID BaseAddress;
|
|
||||||
ULONG blk;
|
|
||||||
|
|
||||||
blk = FileOffset / BLOCKSIZE;
|
|
||||||
|
|
||||||
DPRINT("MinixGetBlock(inode %x, blk %d)\n",inode,blk);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The first few blocks are available in the inode
|
|
||||||
*/
|
|
||||||
if (blk < 7)
|
|
||||||
{
|
|
||||||
block = inode->i_zone[blk];
|
|
||||||
return(block);
|
|
||||||
}
|
|
||||||
blk = blk - 7;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve a single-indirect block
|
|
||||||
*/
|
|
||||||
if (blk < 512)
|
|
||||||
{
|
|
||||||
block = inode->i_zone[7];
|
|
||||||
|
|
||||||
BaseAddress = ExAllocatePool(NonPagedPool, 512);
|
|
||||||
|
|
||||||
MinixReadSector(DeviceObject,
|
|
||||||
block,
|
|
||||||
BaseAddress);
|
|
||||||
|
|
||||||
block = ((PUSHORT)(BaseAddress))[blk];
|
|
||||||
|
|
||||||
ExFreePool(BaseAddress);
|
|
||||||
|
|
||||||
return(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get a double indirect block
|
|
||||||
*/
|
|
||||||
blk = blk - 512;
|
|
||||||
block = inode->i_zone[8];
|
|
||||||
|
|
||||||
BaseAddress = ExAllocatePool(NonPagedPool, 512);
|
|
||||||
|
|
||||||
MinixReadSector(DeviceObject,
|
|
||||||
block,
|
|
||||||
BaseAddress);
|
|
||||||
|
|
||||||
block = ((PUSHORT)BaseAddress)[(blk>>9)&511];
|
|
||||||
|
|
||||||
ExFreePool(BaseAddress);
|
|
||||||
|
|
||||||
|
|
||||||
BaseAddress = ExAllocatePool(NonPagedPool, 512);
|
|
||||||
|
|
||||||
MinixReadSector(DeviceObject,
|
|
||||||
block,
|
|
||||||
BaseAddress);
|
|
||||||
|
|
||||||
block = ((PUSHORT)BaseAddress)[blk&512];
|
|
||||||
|
|
||||||
ExFreePool(BaseAddress);
|
|
||||||
|
|
||||||
return(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
|
||||||
struct minix_inode* inode,
|
|
||||||
ULONG FileOffset,
|
|
||||||
PULONG DiskOffset)
|
|
||||||
{
|
|
||||||
unsigned int block;
|
|
||||||
|
|
||||||
DPRINT("MinixReadBlock()\n");
|
|
||||||
|
|
||||||
block = MinixGetBlock(DeviceObject, DeviceExt,inode, FileOffset);
|
|
||||||
|
|
||||||
(*DiskOffset) = block * BLOCKSIZE;
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
|
@ -1,154 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/minix.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix.h"
|
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
|
||||||
|
|
||||||
BOOLEAN MinixReadPage(PDEVICE_OBJECT DeviceObject,
|
|
||||||
ULONG Offset,
|
|
||||||
PVOID Buffer)
|
|
||||||
{
|
|
||||||
ULONG i;
|
|
||||||
BOOLEAN Result;
|
|
||||||
|
|
||||||
for (i=0; i<4; i++)
|
|
||||||
{
|
|
||||||
Result = MinixReadSector(DeviceObject,
|
|
||||||
(Offset + (i * PAGE_SIZE)) / BLOCKSIZE,
|
|
||||||
(Buffer + (i * PAGE_SIZE)));
|
|
||||||
if (!Result)
|
|
||||||
{
|
|
||||||
return(Result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
|
|
||||||
IN ULONG DiskSector,
|
|
||||||
IN PVOID Buffer)
|
|
||||||
{
|
|
||||||
LARGE_INTEGER sectorNumber;
|
|
||||||
PIRP irp;
|
|
||||||
IO_STATUS_BLOCK ioStatus;
|
|
||||||
KEVENT event;
|
|
||||||
NTSTATUS status;
|
|
||||||
ULONG sectorSize;
|
|
||||||
PULONG mbr;
|
|
||||||
|
|
||||||
DPRINT("MinixReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
|
||||||
pDeviceObject,DiskSector,Buffer);
|
|
||||||
|
|
||||||
sectorNumber.u.HighPart = 0;
|
|
||||||
sectorNumber.u.LowPart = DiskSector * BLOCKSIZE;
|
|
||||||
|
|
||||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
|
||||||
|
|
||||||
sectorSize = BLOCKSIZE;
|
|
||||||
|
|
||||||
mbr = ExAllocatePool(NonPagedPool, sectorSize);
|
|
||||||
|
|
||||||
if (!mbr) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
|
||||||
pDeviceObject,
|
|
||||||
mbr,
|
|
||||||
sectorSize,
|
|
||||||
§orNumber,
|
|
||||||
&event,
|
|
||||||
&ioStatus );
|
|
||||||
|
|
||||||
if (!irp) {
|
|
||||||
ExFreePool(mbr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = IoCallDriver(pDeviceObject,
|
|
||||||
irp);
|
|
||||||
|
|
||||||
if (status == STATUS_PENDING) {
|
|
||||||
KeWaitForSingleObject(&event,
|
|
||||||
Suspended,
|
|
||||||
KernelMode,
|
|
||||||
FALSE,
|
|
||||||
NULL);
|
|
||||||
status = ioStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(status)) {
|
|
||||||
ExFreePool(mbr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlCopyMemory(Buffer,mbr,sectorSize);
|
|
||||||
|
|
||||||
ExFreePool(mbr);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN MinixWriteSector(IN PDEVICE_OBJECT pDeviceObject,
|
|
||||||
IN ULONG DiskSector,
|
|
||||||
IN PVOID Buffer)
|
|
||||||
{
|
|
||||||
LARGE_INTEGER sectorNumber;
|
|
||||||
PIRP irp;
|
|
||||||
IO_STATUS_BLOCK ioStatus;
|
|
||||||
KEVENT event;
|
|
||||||
NTSTATUS status;
|
|
||||||
ULONG sectorSize;
|
|
||||||
|
|
||||||
DPRINT("MinixWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
|
||||||
pDeviceObject,DiskSector,Buffer);
|
|
||||||
|
|
||||||
sectorNumber.u.HighPart = 0;
|
|
||||||
sectorNumber.u.LowPart = DiskSector * BLOCKSIZE;
|
|
||||||
|
|
||||||
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
|
||||||
|
|
||||||
sectorSize = BLOCKSIZE;
|
|
||||||
|
|
||||||
irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
|
|
||||||
pDeviceObject,
|
|
||||||
Buffer,
|
|
||||||
sectorSize,
|
|
||||||
§orNumber,
|
|
||||||
&event,
|
|
||||||
&ioStatus );
|
|
||||||
|
|
||||||
|
|
||||||
status = IoCallDriver(pDeviceObject,
|
|
||||||
irp);
|
|
||||||
|
|
||||||
if (status == STATUS_PENDING) {
|
|
||||||
KeWaitForSingleObject(&event,
|
|
||||||
Suspended,
|
|
||||||
KernelMode,
|
|
||||||
FALSE,
|
|
||||||
NULL);
|
|
||||||
status = ioStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(status)) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/cache.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
#include <ntifs.h>
|
|
||||||
|
|
||||||
//#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix.h"
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
NTSTATUS MinixRequestCacheBlock(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PBCB Bcb,
|
|
||||||
ULONG FileOffset,
|
|
||||||
PVOID* BaseAddress,
|
|
||||||
PCACHE_SEGMENT* CacheSeg)
|
|
||||||
{
|
|
||||||
BOOLEAN UptoDate;
|
|
||||||
|
|
||||||
CcRosRequestCacheSegment(Bcb,
|
|
||||||
FileOffset,
|
|
||||||
BaseAddress,
|
|
||||||
&UptoDate,
|
|
||||||
CacheSeg);
|
|
||||||
if (!UptoDate)
|
|
||||||
{
|
|
||||||
MinixReadPage(DeviceObject,
|
|
||||||
PAGE_ROUND_DOWN(FileOffset),
|
|
||||||
BaseAddress);
|
|
||||||
}
|
|
||||||
BaseAddress = BaseAddress + (FileOffset % PAGE_SIZE);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,234 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/minix.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
//#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix.h"
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
BOOLEAN MinixCompareUnicodeStringToAnsi(PCH AnsiStr,
|
|
||||||
PWCHAR UnicodeStr,
|
|
||||||
ULONG MaxLen)
|
|
||||||
{
|
|
||||||
unsigned int i = 0;
|
|
||||||
|
|
||||||
while (i<MaxLen)
|
|
||||||
{
|
|
||||||
if ((*AnsiStr)!=(*UnicodeStr))
|
|
||||||
{
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
if ((*AnsiStr)==0 && (*UnicodeStr)==0)
|
|
||||||
{
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
AnsiStr++;
|
|
||||||
UnicodeStr++;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ENTRIES_PER_BLOCK (BLOCKSIZE / MINIX_DIR_ENTRY_SIZE)
|
|
||||||
|
|
||||||
ULONG MinixDirLookup(PMINIX_DEVICE_EXTENSION DeviceExt,
|
|
||||||
PDEVICE_OBJECT DeviceObject,
|
|
||||||
struct minix_inode* dir,
|
|
||||||
PWCHAR Name)
|
|
||||||
{
|
|
||||||
struct minix_dir_entry* current_entry = NULL;
|
|
||||||
unsigned int offset;
|
|
||||||
unsigned int i;
|
|
||||||
unsigned int inode;
|
|
||||||
PVOID Block;
|
|
||||||
ULONG DiskOffset;
|
|
||||||
|
|
||||||
DPRINT("MinixDirLookup(DeviceExt %x, dir %x, Name %S)\n",DeviceExt,dir,
|
|
||||||
Name);
|
|
||||||
|
|
||||||
Block = ExAllocatePool(NonPagedPool, 512);
|
|
||||||
|
|
||||||
for (i=0;i<(dir->i_size/MINIX_DIR_ENTRY_SIZE);i++)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
offset = i*MINIX_DIR_ENTRY_SIZE;
|
|
||||||
if ((offset%BLOCKSIZE)==0)
|
|
||||||
{
|
|
||||||
MinixReadBlock(DeviceObject,
|
|
||||||
DeviceExt,
|
|
||||||
dir,
|
|
||||||
offset/BLOCKSIZE,
|
|
||||||
&DiskOffset);
|
|
||||||
MinixReadSector(DeviceObject,
|
|
||||||
DiskOffset,
|
|
||||||
Block);
|
|
||||||
}
|
|
||||||
current_entry = (struct minix_dir_entry *)
|
|
||||||
(Block+offset%BLOCKSIZE);
|
|
||||||
DPRINT("Inode %x Name %.30s\n",current_entry->inode,
|
|
||||||
current_entry->name);
|
|
||||||
if (MinixCompareUnicodeStringToAnsi(current_entry->name,
|
|
||||||
Name,30))
|
|
||||||
{
|
|
||||||
inode = current_entry->inode;
|
|
||||||
ExFreePool(Block);
|
|
||||||
DPRINT("MinixDirLookup() = %d\n",inode);
|
|
||||||
return(inode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CHECKPOINT;
|
|
||||||
ExFreePool(Block);
|
|
||||||
DPRINT("MinixDirLookup() = %d\n",0);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
PFILE_OBJECT FileObject,
|
|
||||||
PMINIX_FSCONTEXT result,
|
|
||||||
PULONG Information)
|
|
||||||
{
|
|
||||||
PWSTR current;
|
|
||||||
PWSTR next;
|
|
||||||
PWSTR string;
|
|
||||||
struct minix_inode current_dir;
|
|
||||||
unsigned int current_ino;
|
|
||||||
|
|
||||||
string = ExAllocatePool(NonPagedPool,
|
|
||||||
2*(wcslen(FileObject->FileName.Buffer)+1));
|
|
||||||
wcscpy(string, FileObject->FileName.Buffer);
|
|
||||||
|
|
||||||
DbgPrint("MinixOpen(DeviceObject %x, DeviceName %S, result %x)\n",
|
|
||||||
DeviceObject,string,result);
|
|
||||||
|
|
||||||
|
|
||||||
next = &string[0];
|
|
||||||
current = next+1;
|
|
||||||
|
|
||||||
current_ino = MINIX_ROOT_INO;
|
|
||||||
|
|
||||||
while (next != NULL && current_ino != 0)
|
|
||||||
{
|
|
||||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
|
||||||
|
|
||||||
DPRINT("current %S next %x\n",current,next);
|
|
||||||
|
|
||||||
*next = '\\';
|
|
||||||
current = next+1;
|
|
||||||
next = wcschr(next+1,'\\');
|
|
||||||
if (next!=NULL)
|
|
||||||
{
|
|
||||||
*next=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
current_ino = MinixDirLookup(DeviceExt,
|
|
||||||
DeviceObject,
|
|
||||||
¤t_dir,
|
|
||||||
current);
|
|
||||||
}
|
|
||||||
if (next == NULL && current_ino != 0)
|
|
||||||
{
|
|
||||||
MinixReadInode(DeviceObject,DeviceExt,current_ino,¤t_dir);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(*Information) = FILE_DOES_NOT_EXIST;
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ExAllocatePool(NonPagedPool, sizeof(MINIX_FSCONTEXT));
|
|
||||||
memcpy(&result->inode,¤t_dir,sizeof(struct minix_inode));
|
|
||||||
|
|
||||||
DPRINT("MinxOpen() = STATUS_SUCCESS\n",0);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
MinixClose(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
|
||||||
|
|
||||||
DPRINT("MinixClose(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
|
||||||
|
|
||||||
ExFreePool(FileObject->FsContext);
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
MinixDirectoryControl(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
// PFILE_OBJECT FileObject = Stack->FileObject;
|
|
||||||
|
|
||||||
if (Stack->MinorFunction != IRP_MN_QUERY_DIRECTORY)
|
|
||||||
{
|
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
MinixCreate(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PMINIX_FSCONTEXT result;
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt;
|
|
||||||
|
|
||||||
DPRINT("MinixCreate(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
|
||||||
DPRINT("Opening file %x %S\n",FileObject->FileName.Buffer,
|
|
||||||
FileObject->FileName.Buffer);
|
|
||||||
DPRINT("FileObject->FileName.Buffer %x\n",
|
|
||||||
FileObject->FileName.Buffer);
|
|
||||||
|
|
||||||
DeviceExt = (MINIX_DEVICE_EXTENSION *)DeviceObject->DeviceExtension;
|
|
||||||
result = ExAllocatePool(NonPagedPool,sizeof(struct minix_inode));
|
|
||||||
DPRINT("result %x\n",result);
|
|
||||||
Status = MinixOpen(DeviceExt->AttachedDevice,
|
|
||||||
DeviceExt,
|
|
||||||
FileObject,
|
|
||||||
result,
|
|
||||||
&Irp->IoStatus.Information);
|
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
FileObject->FsContext = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
|
|
||||||
DPRINT("Finished MinixCreate()\n");
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,136 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/minix.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "bitops.h"
|
|
||||||
#include <ntifs.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix.h"
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
NTSTATUS MinixDeleteInode(PDEVICE_OBJECT Volume,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
ULONG ino)
|
|
||||||
{
|
|
||||||
PULONG Buffer;
|
|
||||||
ULONG off;
|
|
||||||
|
|
||||||
Buffer = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
|
||||||
MinixReadSector(Volume, (ino / 8192)+2, (PVOID)Buffer);
|
|
||||||
off = ino % 8192;
|
|
||||||
clear_bit(off%32,&Buffer[off/32]);
|
|
||||||
MinixWriteSector(Volume, (ino / 8192)+2, (PVOID)Buffer);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG MinixAllocateInode(PDEVICE_OBJECT Volume,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt)
|
|
||||||
{
|
|
||||||
ULONG i;
|
|
||||||
PULONG Buffer;
|
|
||||||
ULONG ino;
|
|
||||||
|
|
||||||
Buffer = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
|
||||||
for (i=0; i<DeviceExt->sb->s_imap_blocks; i++)
|
|
||||||
{
|
|
||||||
MinixReadSector(Volume,i + 2,Buffer);
|
|
||||||
ino = find_first_zero_bit(Buffer,8192);
|
|
||||||
if (ino < 8192)
|
|
||||||
{
|
|
||||||
set_bit(ino%32,&Buffer[32]);
|
|
||||||
MinixWriteSector(Volume,i + 2,Buffer);
|
|
||||||
ExFreePool(Buffer);
|
|
||||||
return(ino + (i*8192));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ExFreePool(Buffer);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG MinixNewInode(PDEVICE_OBJECT Volume,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
struct minix_inode* new_inode)
|
|
||||||
{
|
|
||||||
ULONG ino;
|
|
||||||
|
|
||||||
ino = MinixAllocateInode(Volume,DeviceExt);
|
|
||||||
if (ino == 0)
|
|
||||||
{
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
MinixWriteInode(Volume,DeviceExt,ino,new_inode);
|
|
||||||
return(ino);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixWriteInode(PDEVICE_OBJECT Volume,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
ULONG ino,
|
|
||||||
struct minix_inode* result)
|
|
||||||
{
|
|
||||||
int block;
|
|
||||||
char* buffer;
|
|
||||||
struct minix_inode* inodes;
|
|
||||||
|
|
||||||
DPRINT("MinixWriteInode(ino %x, result %x)\n",ino,result);
|
|
||||||
|
|
||||||
buffer = ExAllocatePool(NonPagedPool,1024);
|
|
||||||
inodes = (struct minix_inode *)buffer;
|
|
||||||
|
|
||||||
block = 2 + DeviceExt->sb->s_imap_blocks + DeviceExt->sb->s_zmap_blocks
|
|
||||||
+ ((ino-1) / MINIX_INODES_PER_BLOCK);
|
|
||||||
MinixReadSector(Volume,block,buffer);
|
|
||||||
memcpy(&inodes[(ino-1)%MINIX_INODES_PER_BLOCK],result,
|
|
||||||
sizeof(struct minix_inode));
|
|
||||||
MinixWriteSector(Volume,block,buffer);
|
|
||||||
|
|
||||||
ExFreePool(buffer);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
ULONG ino,
|
|
||||||
struct minix_inode* result)
|
|
||||||
{
|
|
||||||
int block;
|
|
||||||
struct minix_inode* inodes;
|
|
||||||
PVOID BaseAddress;
|
|
||||||
|
|
||||||
DPRINT("MinixReadInode(ino %x, result %x)\n",ino,result);
|
|
||||||
|
|
||||||
block = 2 + DeviceExt->sb->s_imap_blocks + DeviceExt->sb->s_zmap_blocks
|
|
||||||
+ ((ino-1) / MINIX_INODES_PER_BLOCK);
|
|
||||||
DPRINT("Reading block %x offset %x\n",block,block*BLOCKSIZE);
|
|
||||||
DPRINT("Index %x\n",(ino-1)%MINIX_INODES_PER_BLOCK);
|
|
||||||
|
|
||||||
BaseAddress = ExAllocatePool(NonPagedPool, PAGE_SIZE);
|
|
||||||
|
|
||||||
MinixReadPage(DeviceObject,
|
|
||||||
block,
|
|
||||||
BaseAddress);
|
|
||||||
|
|
||||||
inodes = (struct minix_inode *)(BaseAddress + ((block % 4) * 512));
|
|
||||||
|
|
||||||
memcpy(result,
|
|
||||||
&inodes[(ino-1)%MINIX_INODES_PER_BLOCK],
|
|
||||||
sizeof(struct minix_inode));
|
|
||||||
DPRINT("result->i_uid %x\n",result->i_uid);
|
|
||||||
DPRINT("result->i_size %x\n",result->i_size);
|
|
||||||
|
|
||||||
ExFreePool(BaseAddress);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
#include <ntddk.h>
|
|
||||||
#include <ntifs.h>
|
|
||||||
|
|
||||||
#define MINIX_ROOT_INO 1
|
|
||||||
|
|
||||||
/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
|
|
||||||
#define MINIX_LINK_MAX 250
|
|
||||||
|
|
||||||
#define MINIX_I_MAP_SLOTS 8
|
|
||||||
#define MINIX_Z_MAP_SLOTS 64
|
|
||||||
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
|
|
||||||
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
|
|
||||||
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
|
|
||||||
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
|
|
||||||
#define MINIX_VALID_FS 0x0001 /* Clean fs. */
|
|
||||||
#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
|
|
||||||
|
|
||||||
#define MINIX_INODES_PER_BLOCK ((BLOCKSIZE)/(sizeof (struct minix_inode)))
|
|
||||||
#define MINIX2_INODES_PER_BLOCK ((BLOCKSIZE)/(sizeof (struct minix2_inode)))
|
|
||||||
|
|
||||||
#define MINIX_V1 0x0001 /* original minix fs */
|
|
||||||
#define MINIX_V2 0x0002 /* minix V2 fs */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the original minix inode layout on disk.
|
|
||||||
* Note the 8-bit gid and atime and ctime.
|
|
||||||
*/
|
|
||||||
struct minix_inode {
|
|
||||||
unsigned short int i_mode;
|
|
||||||
unsigned short int i_uid;
|
|
||||||
unsigned long i_size;
|
|
||||||
unsigned long i_time;
|
|
||||||
unsigned char i_gid;
|
|
||||||
unsigned char i_nlinks;
|
|
||||||
unsigned short int i_zone[9];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The new minix inode has all the time entries, as well as
|
|
||||||
* long block numbers and a third indirect block (7+1+1+1
|
|
||||||
* instead of 7+1+1). Also, some previously 8-bit values are
|
|
||||||
* now 16-bit. The inode is now 64 bytes instead of 32.
|
|
||||||
*/
|
|
||||||
struct minix2_inode {
|
|
||||||
unsigned short int i_mode;
|
|
||||||
unsigned short int i_nlinks;
|
|
||||||
unsigned short int i_uid;
|
|
||||||
unsigned short int i_gid;
|
|
||||||
unsigned long i_size;
|
|
||||||
unsigned long i_atime;
|
|
||||||
unsigned long i_mtime;
|
|
||||||
unsigned long i_ctime;
|
|
||||||
unsigned long i_zone[10];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* minix super-block data on disk
|
|
||||||
*/
|
|
||||||
struct minix_super_block {
|
|
||||||
unsigned short int s_ninodes;
|
|
||||||
unsigned short int s_nzones;
|
|
||||||
unsigned short int s_imap_blocks;
|
|
||||||
unsigned short int s_zmap_blocks;
|
|
||||||
unsigned short int s_firstdatazone;
|
|
||||||
unsigned short int s_log_zone_size;
|
|
||||||
unsigned long s_max_size;
|
|
||||||
unsigned short int s_magic;
|
|
||||||
unsigned short int s_state;
|
|
||||||
unsigned long s_zones;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct minix_dir_entry {
|
|
||||||
unsigned short int inode;
|
|
||||||
char name[0];
|
|
||||||
};
|
|
||||||
#define MINIX_DIR_ENTRY_SIZE (sizeof(struct minix_dir_entry)+30)
|
|
||||||
|
|
||||||
BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
|
|
||||||
IN ULONG DiskSector,
|
|
||||||
IN PVOID Buffer);
|
|
||||||
BOOLEAN MinixWriteSector(IN PDEVICE_OBJECT pDeviceObject,
|
|
||||||
IN ULONG DiskSector,
|
|
||||||
IN PVOID Buffer);
|
|
||||||
|
|
||||||
#define BLOCKSIZE (1024)
|
|
||||||
|
|
||||||
//extern PDRIVER_OBJECT DriverObject;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT AttachedDevice;
|
|
||||||
struct minix_inode root_inode;
|
|
||||||
char superblock_buf[BLOCKSIZE];
|
|
||||||
struct minix_super_block* sb;
|
|
||||||
PFILE_OBJECT FileObject;
|
|
||||||
} MINIX_DEVICE_EXTENSION, *PMINIX_DEVICE_EXTENSION;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
struct minix_inode inode;
|
|
||||||
} MINIX_FSCONTEXT, *PMINIX_FSCONTEXT;
|
|
||||||
|
|
||||||
NTSTATUS STDCALL MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
|
||||||
NTSTATUS STDCALL MinixClose(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
|
||||||
NTSTATUS STDCALL MinixWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
|
||||||
NTSTATUS STDCALL MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
|
||||||
NTSTATUS STDCALL MinixDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
|
||||||
|
|
||||||
ULONG MinixNewInode(PDEVICE_OBJECT Volume,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
struct minix_inode* new_inode);
|
|
||||||
NTSTATUS MinixWriteInode(PDEVICE_OBJECT Volume,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
ULONG ino,
|
|
||||||
struct minix_inode* result);
|
|
||||||
NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
ULONG ino,
|
|
||||||
struct minix_inode* result);
|
|
||||||
NTSTATUS MinixDeleteInode(PDEVICE_OBJECT Volume,
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
|
||||||
ULONG ino);
|
|
||||||
|
|
||||||
NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
|
||||||
struct minix_inode* inode,
|
|
||||||
ULONG FileOffset,
|
|
||||||
PULONG DiskOffset);
|
|
||||||
|
|
||||||
BOOLEAN MinixReadPage(PDEVICE_OBJECT DeviceObject,
|
|
||||||
ULONG Offset,
|
|
||||||
PVOID Buffer);
|
|
|
@ -1,7 +0,0 @@
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#define REACTOS_VERSION_DLL
|
|
||||||
#define REACTOS_STR_FILE_DESCRIPTION "Minix IFS Driver\0"
|
|
||||||
#define REACTOS_STR_INTERNAL_NAME "minix\0"
|
|
||||||
#define REACTOS_STR_ORIGINAL_FILENAME "minix.sys\0"
|
|
||||||
#include <reactos/version.rc>
|
|
|
@ -1,80 +0,0 @@
|
||||||
#define MINIX_ROOT_INO 1
|
|
||||||
|
|
||||||
/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
|
|
||||||
#define MINIX_LINK_MAX 250
|
|
||||||
|
|
||||||
#define MINIX_I_MAP_SLOTS 8
|
|
||||||
#define MINIX_Z_MAP_SLOTS 64
|
|
||||||
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
|
|
||||||
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
|
|
||||||
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
|
|
||||||
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
|
|
||||||
#define MINIX_VALID_FS 0x0001 /* Clean fs. */
|
|
||||||
#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
|
|
||||||
|
|
||||||
#define MINIX_INODES_PER_BLOCK ((BLOCKSIZE)/(sizeof (struct minix_inode)))
|
|
||||||
#define MINIX2_INODES_PER_BLOCK ((BLOCKSIZE)/(sizeof (struct minix2_inode)))
|
|
||||||
|
|
||||||
#define MINIX_V1 0x0001 /* original minix fs */
|
|
||||||
#define MINIX_V2 0x0002 /* minix V2 fs */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the original minix inode layout on disk.
|
|
||||||
* Note the 8-bit gid and atime and ctime.
|
|
||||||
*/
|
|
||||||
struct minix_inode {
|
|
||||||
unsigned short int i_mode;
|
|
||||||
unsigned short int i_uid;
|
|
||||||
unsigned long i_size;
|
|
||||||
unsigned long i_time;
|
|
||||||
unsigned char i_gid;
|
|
||||||
unsigned char i_nlinks;
|
|
||||||
unsigned short int i_zone[9];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The new minix inode has all the time entries, as well as
|
|
||||||
* long block numbers and a third indirect block (7+1+1+1
|
|
||||||
* instead of 7+1+1). Also, some previously 8-bit values are
|
|
||||||
* now 16-bit. The inode is now 64 bytes instead of 32.
|
|
||||||
*/
|
|
||||||
struct minix2_inode {
|
|
||||||
unsigned short int i_mode;
|
|
||||||
unsigned short int i_nlinks;
|
|
||||||
unsigned short int i_uid;
|
|
||||||
unsigned short int i_gid;
|
|
||||||
unsigned long i_size;
|
|
||||||
unsigned long i_atime;
|
|
||||||
unsigned long i_mtime;
|
|
||||||
unsigned long i_ctime;
|
|
||||||
unsigned long i_zone[10];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* minix super-block data on disk
|
|
||||||
*/
|
|
||||||
struct minix_super_block {
|
|
||||||
unsigned short int s_ninodes;
|
|
||||||
unsigned short int s_nzones;
|
|
||||||
unsigned short int s_imap_blocks;
|
|
||||||
unsigned short int s_zmap_blocks;
|
|
||||||
unsigned short int s_firstdatazone;
|
|
||||||
unsigned short int s_log_zone_size;
|
|
||||||
unsigned long s_max_size;
|
|
||||||
unsigned short int s_magic;
|
|
||||||
unsigned short int s_state;
|
|
||||||
unsigned long s_zones;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct minix_dir_entry {
|
|
||||||
unsigned short int inode;
|
|
||||||
char name[0];
|
|
||||||
};
|
|
||||||
#define MINIX_DIR_ENTRY_SIZE (sizeof(struct minix_dir_entry)+30)
|
|
||||||
|
|
||||||
BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
|
|
||||||
IN ULONG DiskSector,
|
|
||||||
IN UCHAR* Buffer);
|
|
||||||
|
|
||||||
#define BLOCKSIZE (1024)
|
|
|
@ -1,160 +0,0 @@
|
||||||
/*
|
|
||||||
* ReactOS kernel
|
|
||||||
* Copyright (C) 2000 David Welch <welch@cwcom.net>
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/minix.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
#include <ntifs.h>
|
|
||||||
|
|
||||||
//#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix.h"
|
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
|
||||||
|
|
||||||
static PDRIVER_OBJECT DriverObject;
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
VOID MinixMount(PDEVICE_OBJECT DeviceToMount)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt;
|
|
||||||
|
|
||||||
IoCreateDevice(DriverObject,
|
|
||||||
sizeof(MINIX_DEVICE_EXTENSION),
|
|
||||||
NULL,
|
|
||||||
FILE_DEVICE_FILE_SYSTEM,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
&DeviceObject);
|
|
||||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
|
||||||
DeviceExt = DeviceObject->DeviceExtension;
|
|
||||||
|
|
||||||
MinixReadSector(DeviceToMount,1,DeviceExt->superblock_buf);
|
|
||||||
DeviceExt->sb = (struct minix_super_block *)(DeviceExt->superblock_buf);
|
|
||||||
|
|
||||||
DeviceExt->StorageDevice = DeviceToMount;
|
|
||||||
DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject;
|
|
||||||
DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice;
|
|
||||||
DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED;
|
|
||||||
DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1;
|
|
||||||
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
|
|
||||||
|
|
||||||
DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
MinixFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
// PVPB vpb = Stack->Parameters.Mount.Vpb;
|
|
||||||
PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
|
|
||||||
NTSTATUS Status;
|
|
||||||
char* superblock_buf;
|
|
||||||
struct minix_super_block* sb;
|
|
||||||
|
|
||||||
DbgPrint("MinixFileSystemControl(DeviceObject %x, Irp %x)\n",DeviceObject,
|
|
||||||
Irp);
|
|
||||||
DPRINT("DeviceToMount %x\n",DeviceToMount);
|
|
||||||
|
|
||||||
superblock_buf = ExAllocatePool(NonPagedPool,BLOCKSIZE);
|
|
||||||
|
|
||||||
DPRINT("MinixReadSector %x\n",MinixReadSector);
|
|
||||||
MinixReadSector(DeviceToMount,1,superblock_buf);
|
|
||||||
sb = (struct minix_super_block *)superblock_buf;
|
|
||||||
DPRINT("Magic %x\n",sb->s_magic);
|
|
||||||
DPRINT("Imap blocks %x\n",sb->s_imap_blocks);
|
|
||||||
DPRINT("Zmap blocks %x\n",sb->s_zmap_blocks);
|
|
||||||
if (sb->s_magic==MINIX_SUPER_MAGIC2)
|
|
||||||
{
|
|
||||||
DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
|
|
||||||
MinixMount(DeviceToMount);
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("%s() = STATUS_UNRECOGNIZED_VOLUME\n",__FUNCTION__);
|
|
||||||
Status = STATUS_UNRECOGNIZED_VOLUME;
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|
||||||
PUNICODE_STRING RegistryPath)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Called by the system to initalize the driver
|
|
||||||
* ARGUMENTS:
|
|
||||||
* DriverObject = object describing this driver
|
|
||||||
* RegistryPath = path to our configuration entries
|
|
||||||
* RETURNS: Success or failure
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
NTSTATUS ret;
|
|
||||||
UNICODE_STRING DeviceName;
|
|
||||||
|
|
||||||
DbgPrint("Minix FSD 0.0.1\n");
|
|
||||||
|
|
||||||
DriverObject = _DriverObject;
|
|
||||||
|
|
||||||
RtlInitUnicodeString(&DeviceName,
|
|
||||||
L"\\Device\\Minix");
|
|
||||||
ret = IoCreateDevice(DriverObject,
|
|
||||||
0,
|
|
||||||
&DeviceName,
|
|
||||||
FILE_DEVICE_FILE_SYSTEM,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
&DeviceObject);
|
|
||||||
if (!NT_SUCCESS(ret))
|
|
||||||
{
|
|
||||||
return(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceObject->Flags = 0;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MinixClose;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = MinixCreate;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = MinixRead;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = MinixWrite;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
|
||||||
MinixFileSystemControl;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
|
||||||
MinixDirectoryControl;
|
|
||||||
DriverObject->DriverUnload = NULL;
|
|
||||||
|
|
||||||
IoRegisterFileSystem(DeviceObject);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: services/fs/minix/rw.c
|
|
||||||
* PURPOSE: Minix FSD
|
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
|
||||||
* UPDATE HISTORY:
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntddk.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ntos/minmax.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "minix.h"
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
MinixWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
DPRINT("MinixWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS MinixReadFilePage(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
|
||||||
PMINIX_FSCONTEXT FsContext,
|
|
||||||
ULONG Offset,
|
|
||||||
PVOID* Buffer)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
ULONG i;
|
|
||||||
ULONG DiskOffset;
|
|
||||||
|
|
||||||
*Buffer = ExAllocatePool(NonPagedPool, 4096);
|
|
||||||
|
|
||||||
for (i=0; i<4; i++)
|
|
||||||
{
|
|
||||||
Status = MinixReadBlock(DeviceObject,
|
|
||||||
DeviceExt,
|
|
||||||
&FsContext->inode,
|
|
||||||
Offset + (i * BLOCKSIZE),
|
|
||||||
&DiskOffset);
|
|
||||||
MinixReadSector(DeviceObject,
|
|
||||||
DiskOffset / BLOCKSIZE,
|
|
||||||
(*Buffer) + (i * BLOCKSIZE));
|
|
||||||
}
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
ULONG Length;
|
|
||||||
PVOID Buffer;
|
|
||||||
ULONG Offset;
|
|
||||||
ULONG CurrentOffset;
|
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
|
||||||
MINIX_DEVICE_EXTENSION* DeviceExt = DeviceObject->DeviceExtension;
|
|
||||||
PMINIX_FSCONTEXT FsContext = (PMINIX_FSCONTEXT)FileObject->FsContext;
|
|
||||||
unsigned int i;
|
|
||||||
PVOID DiskBuffer;
|
|
||||||
|
|
||||||
DPRINT("MinixRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
|
||||||
|
|
||||||
Length = Stack->Parameters.Read.Length;
|
|
||||||
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
|
||||||
Offset = Stack->Parameters.Read.ByteOffset.u.LowPart;
|
|
||||||
|
|
||||||
DPRINT("Length %d Buffer %x Offset %x\n",Length,Buffer,Offset);
|
|
||||||
|
|
||||||
CurrentOffset=Offset;
|
|
||||||
|
|
||||||
DPRINT("inode->i_size %d\n",inode->i_size);
|
|
||||||
|
|
||||||
if (Offset > FsContext->inode.i_size)
|
|
||||||
{
|
|
||||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
if ((Offset+Length) > FsContext->inode.i_size)
|
|
||||||
{
|
|
||||||
Length = FsContext->inode.i_size - Offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((Offset%PAGE_SIZE)!=0)
|
|
||||||
{
|
|
||||||
CurrentOffset = Offset - (Offset%PAGE_SIZE);
|
|
||||||
|
|
||||||
MinixReadFilePage(DeviceObject,
|
|
||||||
DeviceExt,
|
|
||||||
FsContext,
|
|
||||||
CurrentOffset,
|
|
||||||
&DiskBuffer);
|
|
||||||
|
|
||||||
memcpy(Buffer,
|
|
||||||
DiskBuffer+(Offset%PAGE_SIZE),
|
|
||||||
min(PAGE_SIZE - (Offset%PAGE_SIZE),Length));
|
|
||||||
|
|
||||||
ExFreePool(DiskBuffer);
|
|
||||||
|
|
||||||
DPRINT("(BLOCKSIZE - (Offset%BLOCKSIZE)) %d\n",
|
|
||||||
(BLOCKSIZE - (Offset%BLOCKSIZE)));
|
|
||||||
DPRINT("Length %d\n",Length);
|
|
||||||
CurrentOffset = CurrentOffset + PAGE_SIZE;
|
|
||||||
Buffer = Buffer + PAGE_SIZE - (Offset%PAGE_SIZE);
|
|
||||||
Length = Length - min(PAGE_SIZE - (Offset%PAGE_SIZE),Length);
|
|
||||||
DPRINT("CurrentOffset %d Buffer %x Length %d\n",CurrentOffset,Buffer,
|
|
||||||
Length);
|
|
||||||
}
|
|
||||||
for (i=0;i<(Length/PAGE_SIZE);i++)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
DPRINT("Length %d\n",Length);
|
|
||||||
|
|
||||||
MinixReadFilePage(DeviceObject,
|
|
||||||
DeviceExt,
|
|
||||||
FsContext,
|
|
||||||
CurrentOffset,
|
|
||||||
&DiskBuffer);
|
|
||||||
memcpy(Buffer, DiskBuffer, PAGE_SIZE);
|
|
||||||
|
|
||||||
ExFreePool(DiskBuffer);
|
|
||||||
|
|
||||||
CurrentOffset = CurrentOffset + PAGE_SIZE;
|
|
||||||
Buffer = Buffer + PAGE_SIZE;
|
|
||||||
}
|
|
||||||
if ((Length%PAGE_SIZE) > 0)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
DPRINT("Length %x Buffer %x\n",(Length%PAGE_SIZE),Buffer);
|
|
||||||
|
|
||||||
MinixReadFilePage(DeviceObject,
|
|
||||||
DeviceExt,
|
|
||||||
FsContext,
|
|
||||||
CurrentOffset,
|
|
||||||
&DiskBuffer);
|
|
||||||
|
|
||||||
memcpy(Buffer, DiskBuffer, (Length%PAGE_SIZE));
|
|
||||||
|
|
||||||
ExFreePool(DiskBuffer);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
|
||||||
Irp->IoStatus.Information = Length;
|
|
||||||
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
|
@ -1,242 +0,0 @@
|
||||||
#include <ntddk.h>
|
|
||||||
#include <ntdddisk.h>
|
|
||||||
#include "ramdrv.h"
|
|
||||||
#include <debug.h>
|
|
||||||
#include "bzlib.h"
|
|
||||||
|
|
||||||
static NTSTATUS STDCALL RamdrvDispatchDeviceControl(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
{
|
|
||||||
PIO_STACK_LOCATION IrpStack;
|
|
||||||
ULONG ControlCode, InputLength, OutputLength;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("RamdrvDispatchDeviceControl\n");
|
|
||||||
|
|
||||||
IrpStack = IoGetCurrentIrpStackLocation(Irp);
|
|
||||||
ControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
|
|
||||||
InputLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
|
|
||||||
OutputLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
|
|
||||||
|
|
||||||
switch (ControlCode)
|
|
||||||
{
|
|
||||||
case IOCTL_DISK_GET_DRIVE_GEOMETRY:
|
|
||||||
if (OutputLength < sizeof(DISK_GEOMETRY))
|
|
||||||
{
|
|
||||||
Status = STATUS_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PDISK_GEOMETRY Geometry = Irp->AssociatedIrp.SystemBuffer;
|
|
||||||
Geometry->MediaType = F3_1Pt44_512;
|
|
||||||
Geometry->Cylinders.QuadPart = 80;
|
|
||||||
Geometry->TracksPerCylinder = 2 * 18;
|
|
||||||
Geometry->SectorsPerTrack = 18;
|
|
||||||
Geometry->BytesPerSector = 512;
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Status = STATUS_INVALID_DEVICE_REQUEST;
|
|
||||||
}
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
IoCompleteRequest(Irp, NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS STDCALL RamdrvDispatchReadWrite(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
{
|
|
||||||
PRAMDRV_DEVICE_EXTENSION devext = (PRAMDRV_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
|
||||||
PIO_STACK_LOCATION Stk = IoGetCurrentIrpStackLocation( Irp );
|
|
||||||
|
|
||||||
if( Stk->Parameters.Read.ByteOffset.u.HighPart ||
|
|
||||||
Stk->Parameters.Read.ByteOffset.u.LowPart >= devext->Size )
|
|
||||||
{
|
|
||||||
Irp->IoStatus.Status = STATUS_END_OF_FILE;
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
IoCompleteRequest( Irp, 0 );
|
|
||||||
return STATUS_END_OF_FILE;
|
|
||||||
}
|
|
||||||
if( (Stk->Parameters.Read.ByteOffset.u.LowPart + Stk->Parameters.Read.Length) > devext->Size )
|
|
||||||
Stk->Parameters.Read.Length = devext->Size - Stk->Parameters.Read.ByteOffset.u.LowPart;
|
|
||||||
if( Stk->MajorFunction == IRP_MJ_READ )
|
|
||||||
RtlCopyMemory( MmGetSystemAddressForMdl( Irp->MdlAddress ),
|
|
||||||
(PVOID)((ULONG_PTR)devext->Buffer + Stk->Parameters.Read.ByteOffset.u.LowPart),
|
|
||||||
Stk->Parameters.Read.Length );
|
|
||||||
else RtlCopyMemory( (PVOID)((ULONG_PTR)devext->Buffer + Stk->Parameters.Read.ByteOffset.u.LowPart),
|
|
||||||
MmGetSystemAddressForMdl( Irp->MdlAddress ),
|
|
||||||
Stk->Parameters.Read.Length );
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
|
||||||
Irp->IoStatus.Information = Stk->Parameters.Read.Length;
|
|
||||||
IoCompleteRequest( Irp, 0 );
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS STDCALL RamdrvDispatchOpenClose(PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
{
|
|
||||||
DPRINT("RamdrvDispatchOpenClose\n");
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
|
||||||
IN PUNICODE_STRING RegistryPath)
|
|
||||||
{
|
|
||||||
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\Ramdisk");
|
|
||||||
NTSTATUS Status;
|
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
PRAMDRV_DEVICE_EXTENSION devext;
|
|
||||||
UNICODE_STRING LinkName = RTL_CONSTANT_STRING(L"\\??\\Z:");
|
|
||||||
UNICODE_STRING ImageName = RTL_CONSTANT_STRING(L"\\Device\\Floppy0\\ramdisk.bz2");
|
|
||||||
HANDLE file;
|
|
||||||
OBJECT_ATTRIBUTES objattr;
|
|
||||||
IO_STATUS_BLOCK iosb;
|
|
||||||
LARGE_INTEGER allocsize;
|
|
||||||
HANDLE event;
|
|
||||||
void *tbuff;
|
|
||||||
unsigned int dstlen = 1024 * 1440;
|
|
||||||
FILE_STANDARD_INFORMATION finfo;
|
|
||||||
ULONG err;
|
|
||||||
|
|
||||||
DPRINT("Ramdisk driver\n");
|
|
||||||
|
|
||||||
/* Export other driver entry points... */
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = RamdrvDispatchOpenClose;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = RamdrvDispatchOpenClose;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = RamdrvDispatchReadWrite;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = RamdrvDispatchReadWrite;
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = RamdrvDispatchDeviceControl;
|
|
||||||
|
|
||||||
|
|
||||||
// create device and symbolic link
|
|
||||||
Status = IoCreateDevice( DriverObject,
|
|
||||||
sizeof( RAMDRV_DEVICE_EXTENSION ),
|
|
||||||
&DeviceName,
|
|
||||||
FILE_DEVICE_DISK,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
&DeviceObject );
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
|
||||||
return Status;
|
|
||||||
DeviceObject->Flags |= DO_DIRECT_IO;
|
|
||||||
devext = (PRAMDRV_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
|
||||||
devext->Size = 1440 * 1024;
|
|
||||||
devext->Buffer = ExAllocatePool( PagedPool, devext->Size );
|
|
||||||
if( !devext->Buffer )
|
|
||||||
{
|
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
goto cleandevice;
|
|
||||||
}
|
|
||||||
IoCreateSymbolicLink( &LinkName, &DeviceName );
|
|
||||||
|
|
||||||
InitializeObjectAttributes( &objattr,
|
|
||||||
&ImageName,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0 );
|
|
||||||
allocsize.u.LowPart = allocsize.u.HighPart = 0;
|
|
||||||
|
|
||||||
Status = ZwOpenFile( &file,
|
|
||||||
GENERIC_READ,
|
|
||||||
&objattr,
|
|
||||||
&iosb,
|
|
||||||
FILE_SHARE_READ,
|
|
||||||
FILE_NO_INTERMEDIATE_BUFFERING );
|
|
||||||
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
|
||||||
{
|
|
||||||
DPRINT( "Failed to open floppy\n" );
|
|
||||||
goto cleanbuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeObjectAttributes( &objattr,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0 );
|
|
||||||
Status = ZwCreateEvent( &event,
|
|
||||||
0,
|
|
||||||
&objattr,
|
|
||||||
NotificationEvent,
|
|
||||||
FALSE );
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
|
||||||
{
|
|
||||||
DPRINT( "Failed to create event\n" );
|
|
||||||
goto cleanfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = ZwQueryInformationFile( file,
|
|
||||||
&iosb,
|
|
||||||
&finfo,
|
|
||||||
sizeof( finfo ),
|
|
||||||
FileStandardInformation );
|
|
||||||
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
|
||||||
{
|
|
||||||
DPRINT1( "Failed to query file information\n" );
|
|
||||||
goto cleanevent;
|
|
||||||
}
|
|
||||||
tbuff = ExAllocatePool( PagedPool, finfo.EndOfFile.u.LowPart );
|
|
||||||
if( !tbuff )
|
|
||||||
{
|
|
||||||
DPRINT1( "Failed to allocate buffer of size %d\n", finfo.EndOfFile.u.LowPart );
|
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
goto cleanevent;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = ZwReadFile( file,
|
|
||||||
event,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
&iosb,
|
|
||||||
tbuff,
|
|
||||||
finfo.EndOfFile.u.LowPart,
|
|
||||||
&allocsize,
|
|
||||||
0 );
|
|
||||||
|
|
||||||
if( !NT_SUCCESS( Status ) )
|
|
||||||
{
|
|
||||||
DPRINT( "Failed to read floppy\n" );
|
|
||||||
goto cleantbuff;
|
|
||||||
}
|
|
||||||
Status = ZwWaitForSingleObject( event, FALSE, 0 );
|
|
||||||
if( Status != STATUS_WAIT_0 || !NT_SUCCESS( iosb.Status ) )
|
|
||||||
{
|
|
||||||
DPRINT( "Failed to read floppy\n" );
|
|
||||||
goto cleantbuff;
|
|
||||||
}
|
|
||||||
DPRINT( "RAMDRV: Read in %d bytes, decompressing now\n", iosb.Information );
|
|
||||||
err = BZ2_bzBuffToBuffDecompress( devext->Buffer,
|
|
||||||
&dstlen,
|
|
||||||
tbuff,
|
|
||||||
iosb.Information,
|
|
||||||
1,
|
|
||||||
0 );
|
|
||||||
if( err == 0 )
|
|
||||||
{
|
|
||||||
DPRINT( "RAMDRV: Image Decompressed\n");
|
|
||||||
}
|
|
||||||
else DbgPrint( "RAMDRV: Failed to decomparess image, error: %d\n", err );
|
|
||||||
ExFreePool( tbuff );
|
|
||||||
ZwClose( file );
|
|
||||||
ZwClose( event );
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
|
|
||||||
cleantbuff:
|
|
||||||
ExFreePool( tbuff );
|
|
||||||
cleanevent:
|
|
||||||
ZwClose( event );
|
|
||||||
cleanfile:
|
|
||||||
ZwClose( file );
|
|
||||||
cleanbuffer:
|
|
||||||
ExFreePool( devext->Buffer );
|
|
||||||
|
|
||||||
cleandevice:
|
|
||||||
IoDeleteDevice( DeviceObject );
|
|
||||||
for(;;);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
typedef struct _RAMDRV_DEVICE_EXTENSION {
|
|
||||||
void *Buffer;
|
|
||||||
unsigned long Size;
|
|
||||||
} RAMDRV_DEVICE_EXTENSION, *PRAMDRV_DEVICE_EXTENSION;
|
|
||||||
|
|
||||||
NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
|
||||||
IN PUNICODE_STRING RegistryPath);
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<module name="ramdrv" type="kernelmodedriver">
|
|
||||||
<include base="ramdrv">.</include>
|
|
||||||
<include base="bzip2">.</include>
|
|
||||||
<library>ntoskrnl</library>
|
|
||||||
<library>hal</library>
|
|
||||||
<library>bzip2</library>
|
|
||||||
<file>ramdrv.c</file>
|
|
||||||
<file>ramdrv.rc</file>
|
|
||||||
</module>
|
|
|
@ -1,5 +0,0 @@
|
||||||
#define REACTOS_VERSION_DLL
|
|
||||||
#define REACTOS_STR_FILE_DESCRIPTION "RAM Disk Device Driver\0"
|
|
||||||
#define REACTOS_STR_INTERNAL_NAME "ramdrv\0"
|
|
||||||
#define REACTOS_STR_ORIGINAL_FILENAME "ramdrv.sys\0"
|
|
||||||
#include <reactos/version.rc>
|
|
Loading…
Reference in a new issue