2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: services/fs/minix/minix.c
6 * PROGRAMMER: David Welch (welch@mcmail.com)
10 /* INCLUDES *****************************************************************/
12 #include <ddk/ntddk.h>
19 /* FUNCTIONS ****************************************************************/
21 static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
22 PMINIX_DEVICE_EXTENSION DeviceExt,
23 struct minix_inode* inode,
30 blk = FileOffset / BLOCKSIZE;
32 DPRINT("MinixGetBlock(inode %x, blk %d)\n",inode,blk);
35 * The first few blocks are available in the inode
39 block = inode->i_zone[blk];
45 * Retrieve a single-indirect block
49 block = inode->i_zone[7];
51 BaseAddress = ExAllocatePool(NonPagedPool, 512);
53 MinixReadSector(DeviceObject,
57 block = ((PUSHORT)(BaseAddress))[blk];
59 ExFreePool(BaseAddress);
65 * Get a double indirect block
68 block = inode->i_zone[8];
70 BaseAddress = ExAllocatePool(NonPagedPool, 512);
72 MinixReadSector(DeviceObject,
76 block = ((PUSHORT)BaseAddress)[(blk>>9)&511];
78 ExFreePool(BaseAddress);
81 BaseAddress = ExAllocatePool(NonPagedPool, 512);
83 MinixReadSector(DeviceObject,
87 block = ((PUSHORT)BaseAddress)[blk&512];
89 ExFreePool(BaseAddress);
94 NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
95 PMINIX_DEVICE_EXTENSION DeviceExt,
96 struct minix_inode* inode,
102 DPRINT("MinixReadBlock()\n");
104 block = MinixGetBlock(DeviceObject, DeviceExt,inode, FileOffset);
106 (*DiskOffset) = block * BLOCKSIZE;
108 return(STATUS_SUCCESS);