3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * PROJECT: ReactOS kernel
21 * FILE: services/fs/minix/minix.c
23 * PROGRAMMER: David Welch (welch@mcmail.com)
27 /* INCLUDES *****************************************************************/
37 /* GLOBALS *******************************************************************/
39 static PDRIVER_OBJECT DriverObject
;
41 /* FUNCTIONS ****************************************************************/
43 VOID
MinixMount(PDEVICE_OBJECT DeviceToMount
)
45 PDEVICE_OBJECT DeviceObject
;
46 MINIX_DEVICE_EXTENSION
* DeviceExt
;
48 IoCreateDevice(DriverObject
,
49 sizeof(MINIX_DEVICE_EXTENSION
),
51 FILE_DEVICE_FILE_SYSTEM
,
55 DeviceObject
->Flags
= DeviceObject
->Flags
| DO_DIRECT_IO
;
56 DeviceExt
= DeviceObject
->DeviceExtension
;
58 MinixReadSector(DeviceToMount
,1,DeviceExt
->superblock_buf
);
59 DeviceExt
->sb
= (struct minix_super_block
*)(DeviceExt
->superblock_buf
);
61 DeviceExt
->StorageDevice
= DeviceToMount
;
62 DeviceExt
->StorageDevice
->Vpb
->DeviceObject
= DeviceObject
;
63 DeviceExt
->StorageDevice
->Vpb
->RealDevice
= DeviceExt
->StorageDevice
;
64 DeviceExt
->StorageDevice
->Vpb
->Flags
|= VPB_MOUNTED
;
65 DeviceObject
->StackSize
= DeviceExt
->StorageDevice
->StackSize
+ 1;
66 DeviceObject
->Flags
&= ~DO_DEVICE_INITIALIZING
;
68 DeviceExt
->FileObject
= IoCreateStreamFileObject(NULL
, DeviceObject
);
72 MinixFileSystemControl(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
74 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
75 // PVPB vpb = Stack->Parameters.Mount.Vpb;
76 PDEVICE_OBJECT DeviceToMount
= Stack
->Parameters
.Mount
.DeviceObject
;
79 struct minix_super_block
* sb
;
81 DbgPrint("MinixFileSystemControl(DeviceObject %x, Irp %x)\n",DeviceObject
,
83 DPRINT("DeviceToMount %x\n",DeviceToMount
);
85 superblock_buf
= ExAllocatePool(NonPagedPool
,BLOCKSIZE
);
87 DPRINT("MinixReadSector %x\n",MinixReadSector
);
88 MinixReadSector(DeviceToMount
,1,superblock_buf
);
89 sb
= (struct minix_super_block
*)superblock_buf
;
90 DPRINT("Magic %x\n",sb
->s_magic
);
91 DPRINT("Imap blocks %x\n",sb
->s_imap_blocks
);
92 DPRINT("Zmap blocks %x\n",sb
->s_zmap_blocks
);
93 if (sb
->s_magic
==MINIX_SUPER_MAGIC2
)
95 DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__
);
96 MinixMount(DeviceToMount
);
97 Status
= STATUS_SUCCESS
;
101 DPRINT("%s() = STATUS_UNRECOGNIZED_VOLUME\n",__FUNCTION__
);
102 Status
= STATUS_UNRECOGNIZED_VOLUME
;
105 Irp
->IoStatus
.Status
= Status
;
106 Irp
->IoStatus
.Information
= 0;
108 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
113 DriverEntry(PDRIVER_OBJECT _DriverObject
,
114 PUNICODE_STRING RegistryPath
)
116 * FUNCTION: Called by the system to initalize the driver
118 * DriverObject = object describing this driver
119 * RegistryPath = path to our configuration entries
120 * RETURNS: Success or failure
123 PDEVICE_OBJECT DeviceObject
;
125 UNICODE_STRING DeviceName
;
127 DbgPrint("Minix FSD 0.0.1\n");
129 DriverObject
= _DriverObject
;
131 RtlInitUnicodeString(&DeviceName
,
133 ret
= IoCreateDevice(DriverObject
,
136 FILE_DEVICE_FILE_SYSTEM
,
140 if (!NT_SUCCESS(ret
))
145 DeviceObject
->Flags
= 0;
146 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = MinixClose
;
147 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = MinixCreate
;
148 DriverObject
->MajorFunction
[IRP_MJ_READ
] = MinixRead
;
149 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = MinixWrite
;
150 DriverObject
->MajorFunction
[IRP_MJ_FILE_SYSTEM_CONTROL
] =
151 MinixFileSystemControl
;
152 DriverObject
->MajorFunction
[IRP_MJ_DIRECTORY_CONTROL
] =
153 MinixDirectoryControl
;
154 DriverObject
->DriverUnload
= NULL
;
156 IoRegisterFileSystem(DeviceObject
);
158 return(STATUS_SUCCESS
);