ReactOS 0.4.15-dev-7788-g1ad9096
ext2fs.h File Reference
#include <linux/module.h>
#include <ntdddisk.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <linux/ext2_fs.h>
#include <linux/ext3_fs.h>
#include <linux/ext3_fs_i.h>
#include <linux/ext4.h>
#include "common.h"
Include dependency graph for ext2fs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _EXT2_IDENTIFIER
 
struct  _EXT2_REAPER
 
struct  _EXT2_GLOBAL
 
struct  _EXT2_FCBVCB
 
struct  _EXT2_VCB
 
struct  _EXT2_FCB
 
struct  _EXT2_MCB
 
struct  _EXT2_CCB
 
struct  ext2_icb
 
struct  _EXT2_ALLOC_HEADER
 
struct  _FCB_LIST_ENTRY
 
struct  _EXT2_EXTENT
 
struct  _EXT2_FILLDIR_CONTEXT
 
struct  _EXT2_RW_CONTEXT
 

Macros

#define EXT2_DEBUG   0
 
#define EXT_DEBUG_BREAKPOINT   FALSE
 
#define DbgBreak()
 
#define EXT2FSD_VERSION   "0.69"
 
#define EXT2_UNLOAD   FALSE
 
#define EXT2_PRE_ALLOCATION_SUPPORT   TRUE
 
#define EXT2_MAX_NESTED_LINKS   (8)
 
#define EXT2_LINKLEN_IN_INODE   (60)
 
#define EXT2_BLOCK_TYPES   (0x04)
 
#define MAXIMUM_RECORD_LENGTH   (0x10000)
 
#define SECTOR_BITS   (Vcb->SectorBits)
 
#define SECTOR_SIZE   (Vcb->DiskGeometry.BytesPerSector)
 
#define DEFAULT_SECTOR_SIZE   (0x200)
 
#define SUPER_BLOCK_OFFSET   (0x400)
 
#define SUPER_BLOCK_SIZE   (0x400)
 
#define READ_AHEAD_GRANULARITY   (0x10000)
 
#define SUPER_BLOCK   (Vcb->SuperBlock)
 
#define INODE_SIZE   (Vcb->InodeSize)
 
#define BLOCK_SIZE   (Vcb->BlockSize)
 
#define BLOCK_BITS   (SUPER_BLOCK->s_log_block_size + 10)
 
#define GROUP_DESC_SIZE   (Vcb->sbi.s_desc_size)
 
#define INODES_COUNT   (Vcb->SuperBlock->s_inodes_count)
 
#define INODES_PER_GROUP   (SUPER_BLOCK->s_inodes_per_group)
 
#define BLOCKS_PER_GROUP   (SUPER_BLOCK->s_blocks_per_group)
 
#define TOTAL_BLOCKS   (ext3_blocks_count(SUPER_BLOCK))
 
#define EXT2_FIRST_DATA_BLOCK   (SUPER_BLOCK->s_first_data_block)
 
#define CEILING_ALIGNED(T, A, B)   (((A) + (B) - 1) & (~((T)(B) - 1)))
 
#define COCKLOFT_ALIGNED(T, A, B)   (((A) + (B)) & (~((T)(B) - 1)))
 
#define CL_ASSERT(cond)   do {switch('x') {case (cond): case 0: break;}} while (0)
 
#define DRIVER_NAME   "Ext2Fsd"
 
#define DEVICE_NAME   L"\\Ext2Fsd"
 
#define CDROM_NAME   L"\\Ext2CdFsd"
 
#define PARAMETERS_KEY   L"\\Parameters"
 
#define VOLUMES_KEY   L"\\Volumes"
 
#define READING_ONLY   L"Readonly"
 
#define WRITING_SUPPORT   L"WritingSupport"
 
#define CHECKING_BITMAP   L"CheckingBitmap"
 
#define EXT3_FORCEWRITING   L"Ext3ForceWriting"
 
#define CODEPAGE_NAME   L"CodePage"
 
#define HIDING_PREFIX   L"HidingPrefix"
 
#define HIDING_SUFFIX   L"HidingSuffix"
 
#define AUTO_MOUNT   L"AutoMount"
 
#define MOUNT_POINT   L"MountPoint"
 
#define UID   L"uid"
 
#define GID   L"gid"
 
#define EUID   L"euid"
 
#define EGID   L"egid"
 
#define DOS_DEVICE_NAME   L"\\DosDevices\\Ext2Fsd"
 
#define IsFlagOn(a, b)   ((BOOLEAN)(FlagOn(a,b) == b))
 
#define FlagOn(_F, _SF)   ((_F) & (_SF))
 
#define BooleanFlagOn(F, SF)   ((BOOLEAN)(((F) & (SF)) != 0))
 
#define SetFlag(_F, _SF)   ((_F) |= (_SF))
 
#define ClearFlag(_F, _SF)   ((_F) &= ~(_SF))
 
#define min(a, b)   (((a) < (b)) ? (a) : (b))
 
#define max(a, b)   (((a) > (b)) ? (a) : (b))
 
#define SetLongFlag(_F, _SF)   InterlockedOr(&(_F), (ULONG)(_SF))
 
#define ClearLongFlag(_F, _SF)   InterlockedAnd(&(_F), ~((ULONG)(_SF)))
 
#define Ext2RaiseStatus(IRPCONTEXT, STATUS)
 
#define Ext2NormalizeAndRaiseStatus(IRPCONTEXT, STATUS)
 
#define FILE_WRITE_TO_END_OF_FILE   0xffffffff
 
#define IsWritingToEof(Pos)
 
#define IsDirectory(Fcb)   IsMcbDirectory((Fcb)->Mcb)
 
#define IsSpecialFile(Fcb)   IsMcbSpecialFile((Fcb)->Mcb)
 
#define IsSymLink(Fcb)   IsMcbSymLink((Fcb)->Mcb)
 
#define IsInodeSymLink(I)   S_ISLNK((I)->i_mode)
 
#define IsRoot(Fcb)   IsMcbRoot((Fcb)->Mcb)
 
#define TAG_VPB   ' bpV'
 
#define VPB_SIZE   sizeof(VPB)
 
#define EXT2_DATA_MAGIC   'BD2E'
 
#define EXT2_INAME_MAGIC   'NI2E'
 
#define EXT2_FNAME_MAGIC   'NF2E'
 
#define EXT2_VNAME_MAGIC   'NV2E'
 
#define EXT2_DENTRY_MAGIC   'ED2E'
 
#define EXT2_DIRSP_MAGIC   'SD2E'
 
#define EXT2_SB_MAGIC   'BS2E'
 
#define EXT2_GD_MAGIC   'DG2E'
 
#define EXT2_FLIST_MAGIC   'LF2E'
 
#define EXT2_PARAM_MAGIC   'PP2E'
 
#define EXT2_RWC_MAGIC   'WR2E'
 
#define EXT2_FILE_SYSTEM   (FILE_SYSTEM)
 
#define EXT2_BUGCHK_BLOCK   (0x00010000)
 
#define EXT2_BUGCHK_CLEANUP   (0x00020000)
 
#define EXT2_BUGCHK_CLOSE   (0x00030000)
 
#define EXT2_BUGCHK_CMCB   (0x00040000)
 
#define EXT2_BUGCHK_CREATE   (0x00050000)
 
#define EXT2_BUGCHK_DEBUG   (0x00060000)
 
#define EXT2_BUGCHK_DEVCTL   (0x00070000)
 
#define EXT2_BUGCHK_DIRCTL   (0x00080000)
 
#define EXT2_BUGCHK_DISPATCH   (0x00090000)
 
#define EXT2_BUGCHK_EXCEPT   (0x000A0000)
 
#define EXT2_BUGCHK_EXT2   (0x000B0000)
 
#define EXT2_BUGCHK_FASTIO   (0x000C0000)
 
#define EXT2_BUGCHK_FILEINFO   (0x000D0000)
 
#define EXT2_BUGCHK_FLUSH   (0x000E0000)
 
#define EXT2_BUGCHK_FSCTL   (0x000F0000)
 
#define EXT2_BUGCHK_INIT   (0x00100000)
 
#define EXT2_BUGCHK_LOCK   (0x0011000)
 
#define EXT2_BUGCHK_MEMORY   (0x0012000)
 
#define EXT2_BUGCHK_MISC   (0x0013000)
 
#define EXT2_BUGCHK_READ   (0x00140000)
 
#define EXT2_BUGCHK_SHUTDOWN   (0x00150000)
 
#define EXT2_BUGCHK_VOLINFO   (0x00160000)
 
#define EXT2_BUGCHK_WRITE   (0x00170000)
 
#define EXT2_BUGCHK_LAST   (0x00170000)
 
#define Ext2BugCheck(A, B, C, D)   { KeBugCheckEx(EXT2_FILE_SYSTEM, A | __LINE__, B, C, D ); }
 
#define EXT2_SUPER_MAGIC   0xEF53
 
#define EXT2_MIN_BLOCK   1024
 
#define EXT2_MIN_FRAG   1024
 
#define EXT2_MAX_USER_BLKSIZE   65536
 
#define S_IFMT   0x0F000 /* 017 0000 */
 
#define S_IFSOCK   0x0C000 /* 014 0000 */
 
#define S_IFLNK   0x0A000 /* 012 0000 */
 
#define S_IFREG   0x08000 /* 010 0000 */
 
#define S_IFBLK   0x06000 /* 006 0000 */
 
#define S_IFDIR   0x04000 /* 004 0000 */
 
#define S_IFCHR   0x02000 /* 002 0000 */
 
#define S_IFIFO   0x01000 /* 001 0000 */
 
#define S_ISUID   0x00800 /* 000 4000 */
 
#define S_ISGID   0x00400 /* 000 2000 */
 
#define S_ISVTX   0x00200 /* 000 1000 */
 
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)
 
#define S_ISSOCK(m)   (((m) & S_IFMT) == S_IFSOCK)
 
#define S_ISLNK(m)   (((m) & S_IFMT) == S_IFLNK)
 
#define S_ISFIL(m)   (((m) & S_IFMT) == S_IFFIL)
 
#define S_ISBLK(m)   (((m) & S_IFMT) == S_IFBLK)
 
#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
 
#define S_ISCHR(m)   (((m) & S_IFMT) == S_IFCHR)
 
#define S_ISFIFO(m)   (((m) & S_IFMT) == S_IFIFO)
 
#define S_IPERMISSION_MASK   0x1FF /* */
 
#define S_IRWXU   0x1C0 /* 0 0700 */
 
#define S_IRWNU   0x180 /* 0 0600 */
 
#define S_IRUSR   0x100 /* 0 0400 */
 
#define S_IWUSR   0x080 /* 0 0200 */
 
#define S_IXUSR   0x040 /* 0 0100 */
 
#define S_IRWXG   0x038 /* 0 0070 */
 
#define S_IRWNG   0x030 /* 0 0060 */
 
#define S_IRGRP   0x020 /* 0 0040 */
 
#define S_IWGRP   0x010 /* 0 0020 */
 
#define S_IXGRP   0x008 /* 0 0010 */
 
#define S_IRWXO   0x007 /* 0 0007 */
 
#define S_IRWNO   0x006 /* 0 0006 */
 
#define S_IROTH   0x004 /* 0 0004 */
 
#define S_IWOTH   0x002 /* 0 0002 */
 
#define S_IXOTH   0x001 /* 0 0001 */
 
#define S_IRWXUGO   (S_IRWXU|S_IRWXG|S_IRWXO)
 
#define S_IALLUGO   (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
 
#define S_IRUGO   (S_IRUSR|S_IRGRP|S_IROTH)
 
#define S_IWUGO   (S_IWUSR|S_IWGRP|S_IWOTH)
 
#define S_IXUGO   (S_IXUSR|S_IXGRP|S_IXOTH)
 
#define S_IFATTR   (S_IRWNU|S_IRWNG|S_IRWNO)
 
#define S_ISREADABLE(m)   (((m) & S_IPERMISSION_MASK) == (S_IRUSR | S_IRGRP | S_IROTH))
 
#define S_ISWRITABLE(m)   (((m) & S_IPERMISSION_MASK) == (S_IWUSR | S_IWGRP | S_IWOTH))
 
#define Ext2SetReadable(m)   do {(m) = (m) | (S_IRUSR | S_IRGRP | S_IROTH);} while(0)
 
#define Ext2SetWritable(m)   do {(m) = (m) | (S_IWUSR | S_IWGRP | S_IWOTH);} while(0)
 
#define Ext2SetOwnerWritable(m)   do {(m) |= S_IWUSR;} while(0)
 
#define Ext2SetOwnerReadOnly(m)   do {(m) &= ~S_IWUSR;} while(0)
 
#define Ext2IsOwnerWritable(m)   (((m) & S_IWUSR) == S_IWUSR)
 
#define Ext2IsOwnerReadable(m)   (((m) & S_IRUSR) == S_IRUSR)
 
#define Ext2IsOwnerReadOnly(m)   (!(Ext2IsOwnerWritable(m)) && Ext2IsOwnerReadable(m))
 
#define Ext2IsGroupWritable(m)   (((m) & S_IWGRP) == S_IWGRP)
 
#define Ext2IsGroupReadable(m)   (((m) & S_IRGRP) == S_IRGRP)
 
#define Ext2IsGroupReadOnly(m)   (!(Ext2IsGroupWritable(m)) && Ext2IsGroupReadable(m))
 
#define Ext2IsOtherWritable(m)   (((m) & S_IWOTH) == S_IWOTH)
 
#define Ext2IsOtherReadable(m)   (((m) & S_IROTH) == S_IROTH)
 
#define Ext2IsOtherReadOnly(m)   (!(Ext2IsOtherWritable(m)) && Ext2IsOtherReadable(m))
 
#define Ext2SetReadOnly(m)   do {(m) &= ~(S_IWUSR | S_IWGRP | S_IWOTH);} while(0)
 
#define Ext2FileCanRead   (0x1)
 
#define Ext2FileCanWrite   (0x2)
 
#define Ext2FileCanExecute   (0x4)
 
#define NodeType(Ptr)   (*((EXT2_IDENTIFIER_TYPE *)(Ptr)))
 
#define EXT2_REAPER_FLAG_STOP   (1 << 0)
 
#define EXT2_UNLOAD_PENDING   0x00000001
 
#define EXT2_SUPPORT_WRITING   0x00000002
 
#define EXT3_FORCE_WRITING   0x00000004
 
#define EXT2_CHECKING_BITMAP   0x00000008
 
#define EXT2_AUTO_MOUNT   0x00000010
 
#define INC_MEM_COUNT(_i, _p, _s)   do { ASSERT(_p); Ext2TraceMemory(TRUE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)
 
#define DEC_MEM_COUNT(_i, _p, _s)   do { ASSERT(_p); Ext2TraceMemory(FALSE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)
 
#define INC_IRP_COUNT(IrpContext)   Ext2TraceIrpContext(TRUE, (IrpContext))
 
#define DEC_IRP_COUNT(IrpContext)   Ext2TraceIrpContext(FALSE, (IrpContext))
 
#define IsExt2FsDevice(DO)
 
#define VCB_INITIALIZED   0x00000001
 
#define VCB_VOLUME_LOCKED   0x00000002
 
#define VCB_MOUNTED   0x00000004
 
#define VCB_DISMOUNT_PENDING   0x00000008
 
#define VCB_NEW_VPB   0x00000010
 
#define VCB_BEING_CLOSED   0x00000020
 
#define VCB_USER_IDS   0x00000040 /* uid/gid specified by user */
 
#define VCB_USER_EIDS   0x00000080 /* euid/egid specified by user */
 
#define VCB_GD_LOADED   0x00000100 /* group desc loaded */
 
#define VCB_BEING_DROPPED   0x00002000
 
#define VCB_FORCE_WRITING   0x00004000
 
#define VCB_DEVICE_REMOVED   0x00008000
 
#define VCB_JOURNAL_RECOVER   0x00080000
 
#define VCB_ARRIVAL_NOTIFIED   0x00800000
 
#define VCB_RO_COMPAT_READ_ONLY   0x01000000
 
#define VCB_READ_ONLY   0x08000000
 
#define VCB_WRITE_PROTECTED   0x10000000
 
#define VCB_FLOPPY_DISK   0x20000000
 
#define VCB_REMOVAL_PREVENTED   0x40000000
 
#define VCB_REMOVABLE_MEDIA   0x80000000
 
#define IsVcbInited(Vcb)   (IsFlagOn((Vcb)->Flags, VCB_INITIALIZED))
 
#define IsMounted(Vcb)   (IsFlagOn((Vcb)->Flags, VCB_MOUNTED))
 
#define IsDispending(Vcb)   (IsFlagOn((Vcb)->Flags, VCB_DISMOUNT_PENDING))
 
#define IsVcbReadOnly(Vcb)
 
#define IsExt3ForceWrite()   (IsFlagOn(Ext2Global->Flags, EXT3_FORCE_WRITING))
 
#define IsVcbForceWrite(Vcb)   (IsFlagOn((Vcb)->Flags, VCB_FORCE_WRITING))
 
#define CanIWrite(Vcb)   (IsExt3ForceWrite() || (!IsVcbReadOnly(Vcb) && IsVcbForceWrite(Vcb)))
 
#define IsLazyWriter(Fcb)   ((Fcb)->LazyWriterThread == PsGetCurrentThread())
 
#define FCB_FROM_POOL   0x00000001
 
#define FCB_PAGE_FILE   0x00000002
 
#define FCB_FILE_MODIFIED   0x00000020
 
#define FCB_ALLOC_IN_CREATE   0x00000080
 
#define FCB_ALLOC_IN_WRITE   0x00000100
 
#define FCB_ALLOC_IN_SETINFO   0x00000200
 
#define FCB_DELETE_PENDING   0x80000000
 
#define MCB_FROM_POOL   0x00000001
 
#define MCB_VCB_LINK   0x00000002
 
#define MCB_ENTRY_TREE   0x00000004
 
#define MCB_FILE_DELETED   0x00000008
 
#define MCB_ZONE_INITED   0x20000000
 
#define MCB_TYPE_SPECIAL   0x40000000 /* unresolved symlink + device node */
 
#define MCB_TYPE_SYMLINK   0x80000000
 
#define IsMcbUsed(Mcb)   ((Mcb)->Refercount > 0)
 
#define IsMcbSymLink(Mcb)   IsFlagOn((Mcb)->Flags, MCB_TYPE_SYMLINK)
 
#define IsZoneInited(Mcb)   IsFlagOn((Mcb)->Flags, MCB_ZONE_INITED)
 
#define IsMcbSpecialFile(Mcb)   IsFlagOn((Mcb)->Flags, MCB_TYPE_SPECIAL)
 
#define IsMcbRoot(Mcb)   ((Mcb)->Inode.i_ino == EXT2_ROOT_INO)
 
#define IsMcbReadonly(Mcb)   IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_READONLY)
 
#define IsMcbDirectory(Mcb)   IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_DIRECTORY)
 
#define IsFileDeleted(Mcb)   IsFlagOn((Mcb)->Flags, MCB_FILE_DELETED)
 
#define IsLinkInvalid(Mcb)   (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target))
 
#define Ext2ReferXcb(_C)   InterlockedIncrement(_C)
 
#define Ext2DerefXcb(_C)   DEC_OBJ_CNT(_C)
 
#define Ext2ReferMcb(Mcb)   Ext2ReferXcb(&Mcb->Refercount)
 
#define Ext2DerefMcb(Mcb)   Ext2DerefXcb(&Mcb->Refercount)
 
#define CCB_FROM_POOL   0x00000001
 
#define CCB_VOLUME_DASD_PURGE   0x00000002
 
#define CCB_LAST_WRITE_UPDATED   0x00000004
 
#define CCB_OPEN_REPARSE_POINT   0x00000008
 
#define CCB_DELETE_ON_CLOSE   0x00000010
 
#define CCB_ALLOW_EXTENDED_DASD_IO   0x80000000
 
#define IRP_CONTEXT_FLAG_FROM_POOL   (0x00000001)
 
#define IRP_CONTEXT_FLAG_WAIT   (0x00000002)
 
#define IRP_CONTEXT_FLAG_WRITE_THROUGH   (0x00000004)
 
#define IRP_CONTEXT_FLAG_FLOPPY   (0x00000008)
 
#define IRP_CONTEXT_FLAG_DISABLE_POPUPS   (0x00000020)
 
#define IRP_CONTEXT_FLAG_DEFERRED   (0x00000040)
 
#define IRP_CONTEXT_FLAG_VERIFY_READ   (0x00000080)
 
#define IRP_CONTEXT_STACK_IO_CONTEXT   (0x00000100)
 
#define IRP_CONTEXT_FLAG_REQUEUED   (0x00000200)
 
#define IRP_CONTEXT_FLAG_USER_IO   (0x00000400)
 
#define IRP_CONTEXT_FLAG_DELAY_CLOSE   (0x00000800)
 
#define IRP_CONTEXT_FLAG_FILE_BUSY   (0x00001000)
 
#define Ext2CanIWait()   (!IrpContext || IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT))
 
#define FSCTL_GET_RETRIEVAL_POINTER_BASE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES   0x00800000
 
#define CanExt2Wait(IRP)   IoIsOperationSynchronous(Irp)
 
#define EXT2_LOOKUP_FLAG_MASK   (0xFF00000)
 
#define EXT2_LOOKUP_NOT_FOLLOW   (0x8000000)
 
#define DL_NVR   0
 
#define DL_VIT   0x00000001
 
#define DL_ERR   0x00000002
 
#define DL_DBG   0x00000004
 
#define DL_INF   0x00000008
 
#define DL_FUN   0x00000010
 
#define DL_LOW   0x00000020
 
#define DL_REN   0x00000040 /* renaming operation */
 
#define DL_RES   0x00000080 /* entry reference managment */
 
#define DL_BLK   0x00000100 /* data block allocation / free */
 
#define DL_CP   0x00000200 /* code pages (create, querydir) */
 
#define DL_EXT   0x00000400 /* mcb extents */
 
#define DL_MAP   0x00000800 /* retrieval points */
 
#define DL_JNL   0x00001000 /* dump journal operations */
 
#define DL_HTI   0x00002000 /* htree index */
 
#define DL_WRN   0x00004000 /* warning */
 
#define DL_BH   0x00008000 /* buffer head */
 
#define DL_PNP   0x00010000 /* pnp */
 
#define DL_IO   0x00020000 /* file i/o */
 
#define DL_DEFAULT   (DL_ERR|DL_VIT)
 
#define DEBUG(_DL, arg)   do {if ((_DL) & DL_ERR) DbgPrint arg;} while(0)
 
#define Ext2CompleteRequest(Irp, bPrint, PriorityBoost)    IoCompleteRequest(Irp, PriorityBoost)
 
#define Ext2GetCurrentProcessName()
 
#define ext3_error   ext3_warning
 
#define ext4_error   ext3_error
 
#define EXT2_RW_CONTEXT_WRITE   1
 

Typedefs

typedef struct ext3_super_block EXT2_SUPER_BLOCK
 
typedef struct ext3_super_blockPEXT2_SUPER_BLOCK
 
typedef struct ext3_inode EXT2_INODE
 
typedef struct ext3_inodePEXT2_INODE
 
typedef struct ext4_group_desc EXT2_GROUP_DESC
 
typedef struct ext4_group_descPEXT2_GROUP_DESC
 
typedef struct ext3_dir_entry EXT2_DIR_ENTRY
 
typedef struct ext3_dir_entryPEXT2_DIR_ENTRY
 
typedef struct ext3_dir_entry_2 EXT2_DIR_ENTRY2
 
typedef struct ext3_dir_entry_2PEXT2_DIR_ENTRY2
 
typedef IO_STACK_LOCATION EXTENDED_IO_STACK_LOCATION
 
typedef IO_STACK_LOCATIONPEXTENDED_IO_STACK_LOCATION
 
typedef enum _EXT2_IDENTIFIER_TYPE EXT2_IDENTIFIER_TYPE
 
typedef struct _EXT2_IDENTIFIER EXT2_IDENTIFIER
 
typedef struct _EXT2_IDENTIFIERPEXT2_IDENTIFIER
 
typedef struct _EXT2_MCB EXT2_MCB
 
typedef struct _EXT2_MCBPEXT2_MCB
 
typedef PVOID PBCB
 
typedef VOID(* EXT2_REAPER_RELEASE) (PVOID)
 
typedef struct _EXT2_REAPER EXT2_REAPER
 
typedef struct _EXT2_REAPERPEXT2_REAPER
 
typedef struct _EXT2_GLOBAL EXT2_GLOBAL
 
typedef struct _EXT2_GLOBALPEXT2_GLOBAL
 
typedef struct _EXT2_FCBVCB EXT2_FCBVCB
 
typedef struct _EXT2_FCBVCBPEXT2_FCBVCB
 
typedef struct _EXT2_VCB EXT2_VCB
 
typedef struct _EXT2_VCBPEXT2_VCB
 
typedef struct _EXT2_FCB EXT2_FCB
 
typedef struct _EXT2_FCBPEXT2_FCB
 
typedef struct _EXT2_CCB EXT2_CCB
 
typedef struct _EXT2_CCBPEXT2_CCB
 
typedef struct ext2_icb EXT2_IRP_CONTEXT
 
typedef struct ext2_icbPEXT2_IRP_CONTEXT
 
typedef struct _EXT2_ALLOC_HEADER EXT2_ALLOC_HEADER
 
typedef struct _EXT2_ALLOC_HEADERPEXT2_ALLOC_HEADER
 
typedef struct _FCB_LIST_ENTRY FCB_LIST_ENTRY
 
typedef struct _FCB_LIST_ENTRYPFCB_LIST_ENTRY
 
typedef struct _EXT2_EXTENT EXT2_EXTENT
 
typedef struct _EXT2_EXTENTPEXT2_EXTENT
 
typedef struct _EXT2_FILLDIR_CONTEXT EXT2_FILLDIR_CONTEXT
 
typedef struct _EXT2_FILLDIR_CONTEXTPEXT2_FILLDIR_CONTEXT
 
typedef int(* filldir_t) (void *, const char *, int, unsigned long, __u32, unsigned)
 
typedef struct _EXT2_RW_CONTEXT EXT2_RW_CONTEXT
 
typedef struct _EXT2_RW_CONTEXTPEXT2_RW_CONTEXT
 

Enumerations

enum  _EXT2_IDENTIFIER_TYPE {
  EXT2FGD = 0xE2FD0001 , EXT2VCB = 0xE2FD0002 , EXT2FCB = 0xE2FD0003 , EXT2CCB = 0xE2FD0004 ,
  EXT2ICX = 0xE2FD0005 , EXT2FSD = 0xE2FD0006 , EXT2MCB = 0xE2FD0007
}
 

Functions

__inline ULONG DEC_OBJ_CNT (PULONG _C)
 
__inline VOID Ext2TraceMemory (BOOLEAN _n, int _i, PVOID _p, LONG _s)
 
__inline VOID Ext2TraceIrpContext (BOOLEAN _n, PEXT2_IRP_CONTEXT IrpContext)
 
int Ext2CheckInodeAccess (PEXT2_VCB Vcb, struct inode *in, int attempt)
 
int Ext2CheckFileAccess (PEXT2_VCB Vcb, PEXT2_MCB Mcb, int attempt)
 
PMDL Ext2CreateMdl (IN PVOID Buffer, IN ULONG Length, IN LOCK_OPERATION Operation)
 
VOID Ext2DestroyMdl (IN PMDL Mdl)
 
NTSTATUS Ext2LockUserBuffer (IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
 
PVOID Ext2GetUserBuffer (IN PIRP Irp)
 
NTSTATUS Ext2ReadWriteBlocks (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_EXTENT Extent, IN ULONG Length)
 
NTSTATUS Ext2ReadSync (IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Length, OUT PVOID Buffer, IN BOOLEAN bVerify)
 
NTSTATUS Ext2ReadDisk (IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
 
NTSTATUS Ext2DiskIoControl (IN PDEVICE_OBJECT DeviceOjbect, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
 
VOID Ext2MediaEjectControl (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bPrevent)
 
NTSTATUS Ext2DiskShutDown (PEXT2_VCB Vcb)
 
NTSTATUS Ext2Cleanup (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2Close (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2QueueCloseRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2DeQueueCloseRequest (IN PVOID Context)
 
BOOLEAN Ext2AcquireForLazyWrite (IN PVOID Context, IN BOOLEAN Wait)
 
VOID Ext2ReleaseFromLazyWrite (IN PVOID Context)
 
BOOLEAN Ext2AcquireForReadAhead (IN PVOID Context, IN BOOLEAN Wait)
 
VOID Ext2ReleaseFromReadAhead (IN PVOID Context)
 
BOOLEAN Ext2NoOpAcquire (IN PVOID Fcb, IN BOOLEAN Wait)
 
VOID Ext2NoOpRelease (IN PVOID Fcb)
 
BOOLEAN Ext2IsNameValid (PUNICODE_STRING FileName)
 
NTSTATUS Ext2FollowLink (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Parent, IN PEXT2_MCB Mcb, IN ULONG Linkdep)
 
NTSTATUS Ext2ScanDir (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Parent, IN PUNICODE_STRING FileName, OUT PULONG Inode, struct dentry **dentry)
 
BOOLEAN Ext2IsSpecialSystemFile (IN PUNICODE_STRING FileName, IN BOOLEAN bDirectory)
 
NTSTATUS Ext2LookupFile (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PUNICODE_STRING FullName, IN PEXT2_MCB Parent, OUT PEXT2_MCB *Ext2Mcb, IN ULONG Linkdep)
 
NTSTATUS Ext2CreateFile (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, OUT PBOOLEAN OpPostIrp)
 
NTSTATUS Ext2CreateVolume (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2Create (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2CreateInode (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB pParentFcb, IN ULONG Type, IN ULONG FileAttr, IN PUNICODE_STRING FileName)
 
NTSTATUS Ext2SupersedeOrOverWriteFile (IN PEXT2_IRP_CONTEXT IrpContext, IN PFILE_OBJECT FileObject, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PLARGE_INTEGER AllocationSize, IN ULONG Disposition)
 
VOID __cdecl Ext2Printf (PCHAR DebugMessage,...)
 
ULONG Ext2GetProcessNameOffset (VOID)
 
VOID Ext2DbgPrintCall (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID Ext2DbgPrintComplete (IN PIRP Irp, IN BOOLEAN bPrint)
 
PUCHAR Ext2NtStatusToString (IN NTSTATUS Status)
 
PVOID Ext2AllocatePool (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
 
VOID Ext2FreePool (IN PVOID P, IN ULONG Tag)
 
NTSTATUS Ext2ProcessGlobalProperty (IN PDEVICE_OBJECT DeviceObject, IN PEXT2_VOLUME_PROPERTY3 Property, IN ULONG Length)
 
NTSTATUS Ext2ProcessVolumeProperty (IN PEXT2_VCB Vcb, IN PEXT2_VOLUME_PROPERTY3 Property, IN ULONG Length)
 
NTSTATUS Ext2ProcessUserProperty (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VOLUME_PROPERTY3 Property, IN ULONG Length)
 
NTSTATUS Ex2ProcessUserPerfStat (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_QUERY_PERFSTAT QueryPerf, IN ULONG Length)
 
NTSTATUS Ex2ProcessMountPoint (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_MOUNT_POINT MountPoint, IN ULONG Length)
 
NTSTATUS Ext2DeviceControlNormal (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2PrepareToUnload (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2DeviceControl (IN PEXT2_IRP_CONTEXT IrpContext)
 
ULONG Ext2GetInfoLength (IN FILE_INFORMATION_CLASS FileInformationClass)
 
NTSTATUS Ext2ProcessEntry (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG in, IN PVOID Buffer, IN ULONG UsedLength, IN ULONG Length, IN ULONG FileIndex, IN PUNICODE_STRING pName, OUT PULONG EntrySize, IN BOOLEAN Single)
 
BOOLEAN Ext2IsWearingCloak (IN PEXT2_VCB Vcb, IN POEM_STRING OeName)
 
NTSTATUS Ext2QueryDirectory (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2NotifyChangeDirectory (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2NotifyReportChange (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Filter, IN ULONG Action)
 
NTSTATUS Ext2DirectoryControl (IN PEXT2_IRP_CONTEXT IrpContext)
 
BOOLEAN Ext2IsDirectoryEmpty (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
 
VOID Ext2OplockComplete (IN PVOID Context, IN PIRP Irp)
 
VOID Ext2LockIrp (IN PVOID Context, IN PIRP Irp)
 
NTSTATUS Ext2QueueRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2DeQueueRequest (IN PVOID Context)
 
NTSTATUS Ext2DispatchRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2BuildRequest (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS Ext2QueryEa (IN PEXT2_IRP_CONTEXT IrpContext)
 
BOOLEAN Ext2IsEaNameValid (IN OEM_STRING Name)
 
NTSTATUS Ext2SetEa (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2ExceptionFilter (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
 
NTSTATUS Ext2ExceptionHandler (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2MapExtent (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN Alloc, OUT PULONG Block, OUT PULONG Number)
 
NTSTATUS Ext2ExpandExtent (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Start, ULONG End, PLARGE_INTEGER Size)
 
NTSTATUS Ext2TruncateExtent (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
 
static ext3_fsblk_t ext3_blocks_count (struct ext3_super_block *es)
 
static ext3_fsblk_t ext3_r_blocks_count (struct ext3_super_block *es)
 
static ext3_fsblk_t ext3_free_blocks_count (struct ext3_super_block *es)
 
static void ext3_blocks_count_set (struct ext3_super_block *es, ext3_fsblk_t blk)
 
static void ext3_free_blocks_count_set (struct ext3_super_block *es, ext3_fsblk_t blk)
 
static void ext3_r_blocks_count_set (struct ext3_super_block *es, ext3_fsblk_t blk)
 
blkcnt_t ext3_inode_blocks (struct ext3_inode *raw_inode, struct inode *inode)
 
int ext3_inode_blocks_set (struct ext3_inode *raw_inode, struct inode *inode)
 
ext4_fsblk_t ext4_block_bitmap (struct super_block *sb, struct ext4_group_desc *bg)
 
ext4_fsblk_t ext4_inode_bitmap (struct super_block *sb, struct ext4_group_desc *bg)
 
ext4_fsblk_t ext4_inode_table (struct super_block *sb, struct ext4_group_desc *bg)
 
__u32 ext4_free_blks_count (struct super_block *sb, struct ext4_group_desc *bg)
 
__u32 ext4_free_inodes_count (struct super_block *sb, struct ext4_group_desc *bg)
 
__u32 ext4_used_dirs_count (struct super_block *sb, struct ext4_group_desc *bg)
 
__u32 ext4_itable_unused_count (struct super_block *sb, struct ext4_group_desc *bg)
 
void ext4_block_bitmap_set (struct super_block *sb, struct ext4_group_desc *bg, ext4_fsblk_t blk)
 
void ext4_inode_bitmap_set (struct super_block *sb, struct ext4_group_desc *bg, ext4_fsblk_t blk)
 
void ext4_inode_table_set (struct super_block *sb, struct ext4_group_desc *bg, ext4_fsblk_t blk)
 
void ext4_free_blks_set (struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
 
void ext4_free_inodes_set (struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
 
void ext4_used_dirs_set (struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
 
void ext4_itable_unused_set (struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
 
int ext3_bg_has_super (struct super_block *sb, ext3_group_t group)
 
unsigned long ext4_bg_num_gdb (struct super_block *sb, ext4_group_t group)
 
unsigned ext4_init_inode_bitmap (struct super_block *sb, struct buffer_head *bh, ext4_group_t block_group, struct ext4_group_desc *gdp)
 
unsigned ext4_init_block_bitmap (struct super_block *sb, struct buffer_head *bh, ext4_group_t block_group, struct ext4_group_desc *gdp)
 
struct ext4_group_descext4_get_group_desc (struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
 
ext4_fsblk_t ext4_count_free_blocks (struct super_block *sb)
 
unsigned long ext4_count_free_inodes (struct super_block *sb)
 
int ext4_check_descriptors (struct super_block *sb)
 
NTSTATUS Ext2LoadSuper (IN PEXT2_VCB Vcb, IN BOOLEAN bVerify, OUT PEXT2_SUPER_BLOCK *Sb)
 
BOOLEAN Ext2SaveSuper (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
 
BOOLEAN Ext2RefreshSuper (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
 
BOOLEAN Ext2LoadGroupBH (IN PEXT2_VCB Vcb)
 
BOOLEAN Ext2LoadGroup (IN PEXT2_VCB Vcb)
 
VOID Ext2DropGroupBH (IN PEXT2_VCB Vcb)
 
VOID Ext2PutGroup (IN PEXT2_VCB Vcb)
 
VOID Ext2DropBH (IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2FlushVcb (IN PEXT2_VCB Vcb)
 
BOOLEAN Ext2SaveGroup (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
 
BOOLEAN Ext2RefreshGroup (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
 
BOOLEAN Ext2GetInodeLba (IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
 
BOOLEAN Ext2LoadInode (IN PEXT2_VCB Vcb, IN struct inode *Inode)
 
BOOLEAN Ext2ClearInode (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG inode)
 
BOOLEAN Ext2SaveInode (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
 
BOOLEAN Ext2LoadInodeXattr (IN PEXT2_VCB Vcb, IN struct inode *Inode, IN PEXT2_INODE InodeXattr)
 
BOOLEAN Ext2SaveInodeXattr (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode, IN PEXT2_INODE InodeXattr)
 
BOOLEAN Ext2LoadBlock (IN PEXT2_VCB Vcb, IN ULONG dwBlk, IN PVOID Buffer)
 
BOOLEAN Ext2SaveBlock (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG dwBlk, IN PVOID Buf)
 
BOOLEAN Ext2LoadBuffer (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
 
BOOLEAN Ext2ZeroBuffer (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG Offset, IN ULONG Size)
 
BOOLEAN Ext2SaveBuffer (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
 
NTSTATUS Ext2GetBlock (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Base, IN ULONG Layer, IN ULONG Start, IN ULONG SizeArray, IN PULONG BlockArray, IN BOOLEAN bAlloc, IN OUT PULONG Hint, OUT PULONG Block, OUT PULONG Number)
 
NTSTATUS Ext2BlockMap (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
 
VOID Ext2UpdateVcbStat (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2NewBlock (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG GroupHint, IN ULONG BlockHint, OUT PULONG Block, IN OUT PULONG Number)
 
NTSTATUS Ext2FreeBlock (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Block, IN ULONG Number)
 
NTSTATUS Ext2NewInode (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG GroupHint, IN ULONG Type, OUT PULONG Inode)
 
NTSTATUS Ext2UpdateGroupDirStat (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
 
NTSTATUS Ext2FreeInode (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Inode, IN ULONG Type)
 
NTSTATUS Ext2AddEntry (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN struct inode *Inode, IN PUNICODE_STRING FileName, OUT struct dentry **dentry)
 
NTSTATUS Ext2SetFileType (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN PEXT2_MCB Mcb, IN umode_t mode)
 
NTSTATUS Ext2RemoveEntry (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN PEXT2_MCB Mcb)
 
NTSTATUS Ext2SetParentEntry (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN ULONG OldParent, IN ULONG NewParent)
 
NTSTATUS Ext2TruncateBlock (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Base, IN ULONG Start, IN ULONG Layer, IN ULONG SizeArray, IN PULONG BlockArray, IN PULONG Extra)
 
struct ext3_dir_entry_2ext3_next_entry (struct ext3_dir_entry_2 *p)
 
int ext3_check_dir_entry (const char *function, struct inode *dir, struct ext3_dir_entry_2 *de, struct buffer_head *bh, unsigned long offset)
 
loff_t ext3_max_size (int blkbits, int has_huge_files)
 
loff_t ext3_max_bitmap_size (int bits, int has_huge_files)
 
__le16 ext4_group_desc_csum (struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
 
int ext4_group_desc_csum_verify (struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
 
ext3_fsblk_t descriptor_loc (struct super_block *sb, ext3_fsblk_t logical_sb_block, unsigned int nr)
 
FAST_IO_POSSIBLE Ext2IsFastIoPossible (IN PEXT2_FCB Fcb)
 
BOOLEAN Ext2FastIoCheckIfPossible (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoRead (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoWrite (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoQueryBasicInfo (IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoQueryStandardInfo (IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoLock (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN PEPROCESS Process, IN ULONG Key, IN BOOLEAN FailImmediately, IN BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoUnlockSingle (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN PEPROCESS Process, IN ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoUnlockAll (IN PFILE_OBJECT FileObject, IN PEPROCESS Process, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoUnlockAllByKey (IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN Ext2FastIoQueryNetworkOpenInfo (IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_NETWORK_OPEN_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
VOID Ext2AcquireForCreateSection (IN PFILE_OBJECT FileObject)
 
VOID Ext2ReleaseForCreateSection (IN PFILE_OBJECT FileObject)
 
NTSTATUS Ext2AcquireFileForModWrite (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER EndingOffset, OUT PERESOURCE *ResourceToRelease, IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS Ext2ReleaseFileForModWrite (IN PFILE_OBJECT FileObject, IN PERESOURCE ResourceToRelease, IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS Ext2AcquireFileForCcFlush (IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS Ext2ReleaseFileForCcFlush (IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS Ext2PreAcquireForCreateSection (IN PFS_FILTER_CALLBACK_DATA cd, OUT PVOID *cc)
 
NTSTATUS Ext2QueryFileInformation (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2SetFileInformation (IN PEXT2_IRP_CONTEXT IrpContext)
 
ULONG Ext2TotalBlocks (PEXT2_VCB Vcb, PLARGE_INTEGER Size, PULONG pMeta)
 
NTSTATUS Ext2ExpandFile (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
 
NTSTATUS Ext2TruncateFile (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER AllocationSize)
 
NTSTATUS Ext2IsFileRemovable (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
 
NTSTATUS Ext2SetDispositionInfo (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb, BOOLEAN bDelete)
 
NTSTATUS Ext2SetRenameInfo (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
 
NTSTATUS Ext2SetLinkInfo (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
 
ULONG Ext2InodeType (PEXT2_MCB Mcb)
 
NTSTATUS Ext2DeleteFile (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_MCB Mcb)
 
NTSTATUS Ext2FlushFiles (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
 
NTSTATUS Ext2FlushVolume (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
 
NTSTATUS Ext2FlushFile (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
 
NTSTATUS Ext2Flush (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2ReadSymlink (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesRead)
 
NTSTATUS Ext2WriteSymlink (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesWritten)
 
NTSTATUS Ext2TruncateSymlink (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Size)
 
VOID Ext2SetVpbFlag (IN PVPB Vpb, IN USHORT Flag)
 
VOID Ext2ClearVpbFlag (IN PVPB Vpb, IN USHORT Flag)
 
BOOLEAN Ext2CheckDismount (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bForce)
 
NTSTATUS Ext2PurgeVolume (IN PEXT2_VCB Vcb, IN BOOLEAN FlushBeforePurge)
 
NTSTATUS Ext2PurgeFile (IN PEXT2_FCB Fcb, IN BOOLEAN FlushBeforePurge)
 
BOOLEAN Ext2IsHandleCountZero (IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2LockVcb (IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject)
 
NTSTATUS Ext2LockVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2UnlockVcb (IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject)
 
NTSTATUS Ext2UnlockVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2AllowExtendedDasdIo (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2OplockRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2QueryExtentMappings (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PLARGE_INTEGER RequestVbn, OUT PLARGE_INTEGER *pMappedRuns)
 
NTSTATUS Ext2QueryRetrievalPointers (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2GetRetrievalPointers (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2GetRetrievalPointerBase (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2UserFsRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
BOOLEAN Ext2IsMediaWriteProtected (IN PEXT2_IRP_CONTEXT IrpContext, IN PDEVICE_OBJECT TargetDevice)
 
NTSTATUS Ext2MountVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2VerifyVcb (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2VerifyVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2IsVolumeMounted (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2DismountVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2FileSystemControl (IN PEXT2_IRP_CONTEXT IrpContext)
 
struct buffer_headext3_append (struct ext2_icb *icb, struct inode *inode, ext3_lblk_t *block, int *err)
 
void ext3_set_de_type (struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
 
__u32 ext3_current_time (struct inode *in)
 
void ext3_warning (struct super_block *sb, const char *function, char *fmt,...)
 
void ext3_update_dx_flag (struct inode *inode)
 
int ext3_mark_inode_dirty (struct ext2_icb *icb, struct inode *in)
 
void ext3_inc_count (struct inode *inode)
 
void ext3_dec_count (struct inode *inode)
 
struct buffer_headext3_find_entry (struct ext2_icb *icb, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir)
 
struct buffer_headext3_dx_find_entry (struct ext2_icb *, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir, int *err)
 
int ext3_dx_readdir (struct file *filp, filldir_t filldir, void *context)
 
struct buffer_headext3_bread (struct ext2_icb *icb, struct inode *inode, unsigned long block, int *err)
 
int add_dirent_to_buf (struct ext2_icb *icb, struct dentry *dentry, struct inode *inode, struct ext3_dir_entry_2 *de, struct buffer_head *bh)
 
struct ext3_dir_entry_2do_split (struct ext2_icb *icb, struct inode *dir, struct buffer_head **bh, struct dx_frame *frame, struct dx_hash_info *hinfo, int *error)
 
int ext3_add_entry (struct ext2_icb *icb, struct dentry *dentry, struct inode *inode)
 
int ext3_delete_entry (struct ext2_icb *icb, struct inode *dir, struct ext3_dir_entry_2 *de_del, struct buffer_head *bh)
 
int ext3_is_dir_empty (struct ext2_icb *icb, struct inode *inode)
 
NTSTATUS Ext2QueryGlobalParameters (IN PUNICODE_STRING RegistryPath)
 
BOOLEAN Ext2QueryRegistrySettings (IN PUNICODE_STRING RegistryPath)
 
VOID DriverUnload (IN PDRIVER_OBJECT DriverObject)
 
NTSTATUS Ext2MapIndirect (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
 
NTSTATUS Ext2ExpandIndirect (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Start, ULONG End, PLARGE_INTEGER Size)
 
NTSTATUS Ext2TruncateIndirect (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
 
int ext2_init_linux ()
 
void ext2_destroy_linux ()
 
NTSTATUS Ext2LockControl (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2FcbReaperThread (PVOID Context)
 
VOID Ext2McbReaperThread (PVOID Context)
 
VOID Ext2bhReaperThread (PVOID Context)
 
PEXT2_IRP_CONTEXT Ext2AllocateIrpContext (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID Ext2FreeIrpContext (IN PEXT2_IRP_CONTEXT IrpContext)
 
PEXT2_FCB Ext2AllocateFcb (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
 
VOID Ext2UnlinkFcb (IN PEXT2_FCB Fcb)
 
VOID Ext2FreeFcb (IN PEXT2_FCB Fcb)
 
VOID Ext2ReleaseFcb (IN PEXT2_FCB Fcb)
 
VOID Ext2InsertFcb (PEXT2_VCB Vcb, PEXT2_FCB Fcb)
 
PEXT2_CCB Ext2AllocateCcb (ULONG Flags, PEXT2_MCB SymLink)
 
VOID Ext2FreeMcb (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
 
VOID Ext2FreeCcb (IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb)
 
PEXT2_INODE Ext2AllocateInode (PEXT2_VCB Vcb)
 
VOID Ext2DestroyInode (IN PEXT2_VCB Vcb, IN PEXT2_INODE inode)
 
struct dentryExt2AllocateEntry ()
 
VOID Ext2FreeEntry (IN struct dentry *de)
 
struct dentryExt2BuildEntry (PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName)
 
PEXT2_EXTENT Ext2AllocateExtent ()
 
VOID Ext2FreeExtent (IN PEXT2_EXTENT Extent)
 
ULONG Ext2CountExtents (IN PEXT2_EXTENT Chain)
 
VOID Ext2JointExtents (IN PEXT2_EXTENT Chain, IN PEXT2_EXTENT Extent)
 
VOID Ext2DestroyExtentChain (IN PEXT2_EXTENT Chain)
 
NTSTATUS Ext2BuildExtents (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN ULONG Size, IN BOOLEAN bAlloc, OUT PEXT2_EXTENT *Chain)
 
BOOLEAN Ext2ListExtents (PLARGE_MCB Extents)
 
VOID Ext2CheckExtent (PLARGE_MCB Zone, LONGLONG Vbn, LONGLONG Lbn, LONGLONG Length, BOOLEAN bAdded)
 
VOID Ext2ClearAllExtents (PLARGE_MCB Zone)
 
BOOLEAN Ext2AddVcbExtent (IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
 
BOOLEAN Ext2RemoveVcbExtent (IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
 
BOOLEAN Ext2LookupVcbExtent (IN PEXT2_VCB Vcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
 
BOOLEAN Ext2AddMcbExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG Length)
 
BOOLEAN Ext2RemoveMcbExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Length)
 
BOOLEAN Ext2LookupMcbExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
 
BOOLEAN Ext2AddMcbMetaExts (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Block, IN ULONG Length)
 
BOOLEAN Ext2RemoveMcbMetaExts (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Block, IN ULONG Length)
 
BOOLEAN Ext2AddBlockExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Block, IN ULONG Number)
 
BOOLEAN Ext2LookupBlockExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN PULONG Block, IN PULONG Mapped)
 
BOOLEAN Ext2RemoveBlockExtent (IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Number)
 
NTSTATUS Ext2InitializeZone (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
 
BOOLEAN Ext2BuildName (IN OUT PUNICODE_STRING Target, IN PUNICODE_STRING File, IN PUNICODE_STRING Parent)
 
PEXT2_MCB Ext2AllocateMcb (IN PEXT2_VCB Vcb, IN PUNICODE_STRING FileName, IN PUNICODE_STRING Parent, IN ULONG FileAttr)
 
PEXT2_MCB Ext2SearchMcb (PEXT2_VCB Vcb, PEXT2_MCB Parent, PUNICODE_STRING FileName)
 
PEXT2_MCB Ext2SearchMcbWithoutLock (PEXT2_MCB Parent, PUNICODE_STRING FileName)
 
VOID Ext2InsertMcb (PEXT2_VCB Vcb, PEXT2_MCB Parent, PEXT2_MCB Child)
 
BOOLEAN Ext2RemoveMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
VOID Ext2CleanupAllMcbs (PEXT2_VCB Vcb)
 
BOOLEAN Ext2CheckSetBlock (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, LONGLONG Block)
 
BOOLEAN Ext2CheckBitmapConsistency (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 
VOID Ext2InsertVcb (PEXT2_VCB Vcb)
 
VOID Ext2RemoveVcb (PEXT2_VCB Vcb)
 
NTSTATUS Ext2InitializeLabel (IN PEXT2_VCB Vcb, IN PEXT2_SUPER_BLOCK Sb)
 
NTSTATUS Ext2InitializeVcb (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_SUPER_BLOCK Ext2Sb, PDEVICE_OBJECT TargetDevice, PDEVICE_OBJECT VolumeDevice, PVPB Vpb)
 
VOID Ext2TearDownStream (IN PEXT2_VCB Vcb)
 
VOID Ext2DestroyVcb (IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2CompleteIrpContext (IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
 
VOID Ext2SyncUninitializeCacheMap (IN PFILE_OBJECT FileObject)
 
VOID Ext2LinkTailMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
VOID Ext2LinkHeadMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
VOID Ext2UnlinkMcb (PEXT2_VCB Vcb, PEXT2_MCB Mcb)
 
PEXT2_MCB Ext2FirstUnusedMcb (PEXT2_VCB Vcb, BOOLEAN Wait, ULONG Number)
 
VOID Ext2ReaperThread (PVOID Context)
 
NTSTATUS Ext2StartReaper (PEXT2_REAPER, EXT2_REAPER_RELEASE)
 
VOID Ext2StopReaper (PEXT2_REAPER Reaper)
 
ULONG Ext2Log2 (ULONG Value)
 
LARGE_INTEGER Ext2NtTime (IN ULONG i_time)
 
ULONG Ext2LinuxTime (IN LARGE_INTEGER SysTime)
 
ULONG Ext2OEMToUnicodeSize (IN PEXT2_VCB Vcb, IN PANSI_STRING Oem)
 
NTSTATUS Ext2OEMToUnicode (IN PEXT2_VCB Vcb, IN OUT PUNICODE_STRING Oem, IN POEM_STRING Unicode)
 
ULONG Ext2UnicodeToOEMSize (IN PEXT2_VCB Vcb, IN PUNICODE_STRING Unicode)
 
NTSTATUS Ext2UnicodeToOEM (IN PEXT2_VCB Vcb, IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
 
VOID Ext2Sleep (ULONG ms)
 
int Ext2LinuxError (NTSTATUS Status)
 
NTSTATUS Ext2WinntError (int rc)
 
BOOLEAN Ext2IsDot (PUNICODE_STRING name)
 
BOOLEAN Ext2IsDotDot (PUNICODE_STRING name)
 
int Ext2LoadAllNls ()
 
VOID Ext2UnloadAllNls ()
 
NTSTATUS Ext2Pnp (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2PnpQueryRemove (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 
NTSTATUS Ext2PnpRemove (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 
NTSTATUS Ext2PnpCancelRemove (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 
NTSTATUS Ext2PnpSurpriseRemove (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 
NTSTATUS Ext2ReadInode (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN PVOID Buffer, IN ULONG Size, IN BOOLEAN bDirectIo, OUT PULONG dwReturn)
 
NTSTATUS Ext2Read (IN PEXT2_IRP_CONTEXT IrpContext)
 
PEXT2_MCB Ext2LoadInternalJournal (PEXT2_VCB Vcb, ULONG jNo)
 
INT Ext2CheckJournal (PEXT2_VCB Vcb, PULONG jNo)
 
INT Ext2RecoverJournal (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 
NTSTATUS Ext2ShutDown (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2QueryVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2SetVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2WriteInode (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN PVOID Buffer, IN ULONG Size, IN BOOLEAN bDirectIo, OUT PULONG dwReturn)
 
VOID Ext2StartFloppyFlushDpc (PEXT2_VCB Vcb, PEXT2_FCB Fcb, PFILE_OBJECT FileObject)
 
BOOLEAN Ext2ZeroData (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER Start, IN PLARGE_INTEGER End)
 
NTSTATUS Ext2Write (IN PEXT2_IRP_CONTEXT IrpContext)
 

Variables

PEXT2_GLOBAL Ext2Global
 
ULONG ProcessNameOffset
 

Macro Definition Documentation

◆ AUTO_MOUNT

#define AUTO_MOUNT   L"AutoMount"

Definition at line 152 of file ext2fs.h.

◆ BLOCK_BITS

#define BLOCK_BITS   (SUPER_BLOCK->s_log_block_size + 10)

Definition at line 94 of file ext2fs.h.

◆ BLOCK_SIZE

#define BLOCK_SIZE   (Vcb->BlockSize)

Definition at line 93 of file ext2fs.h.

◆ BLOCKS_PER_GROUP

#define BLOCKS_PER_GROUP   (SUPER_BLOCK->s_blocks_per_group)

Definition at line 100 of file ext2fs.h.

◆ BooleanFlagOn

#define BooleanFlagOn (   F,
  SF 
)    ((BOOLEAN)(((F) & (SF)) != 0))

Definition at line 183 of file ext2fs.h.

◆ CanExt2Wait

#define CanExt2Wait (   IRP)    IoIsOperationSynchronous(Irp)

Definition at line 1146 of file ext2fs.h.

◆ CanIWrite

#define CanIWrite (   Vcb)    (IsExt3ForceWrite() || (!IsVcbReadOnly(Vcb) && IsVcbForceWrite(Vcb)))

Definition at line 821 of file ext2fs.h.

◆ CCB_ALLOW_EXTENDED_DASD_IO

#define CCB_ALLOW_EXTENDED_DASD_IO   0x80000000

Definition at line 1037 of file ext2fs.h.

◆ CCB_DELETE_ON_CLOSE

#define CCB_DELETE_ON_CLOSE   0x00000010

Definition at line 1035 of file ext2fs.h.

◆ CCB_FROM_POOL

#define CCB_FROM_POOL   0x00000001

Definition at line 1031 of file ext2fs.h.

◆ CCB_LAST_WRITE_UPDATED

#define CCB_LAST_WRITE_UPDATED   0x00000004

Definition at line 1033 of file ext2fs.h.

◆ CCB_OPEN_REPARSE_POINT

#define CCB_OPEN_REPARSE_POINT   0x00000008

Definition at line 1034 of file ext2fs.h.

◆ CCB_VOLUME_DASD_PURGE

#define CCB_VOLUME_DASD_PURGE   0x00000002

Definition at line 1032 of file ext2fs.h.

◆ CDROM_NAME

#define CDROM_NAME   L"\\Ext2CdFsd"

Definition at line 138 of file ext2fs.h.

◆ CEILING_ALIGNED

#define CEILING_ALIGNED (   T,
  A,
  B 
)    (((A) + (B) - 1) & (~((T)(B) - 1)))

Definition at line 111 of file ext2fs.h.

◆ CHECKING_BITMAP

#define CHECKING_BITMAP   L"CheckingBitmap"

Definition at line 147 of file ext2fs.h.

◆ CL_ASSERT

#define CL_ASSERT (   cond)    do {switch('x') {case (cond): case 0: break;}} while (0)

Definition at line 132 of file ext2fs.h.

◆ ClearFlag

#define ClearFlag (   _F,
  _SF 
)    ((_F) &= ~(_SF))

Definition at line 191 of file ext2fs.h.

◆ ClearLongFlag

#define ClearLongFlag (   _F,
  _SF 
)    InterlockedAnd(&(_F), ~((ULONG)(_SF)))

Definition at line 259 of file ext2fs.h.

◆ COCKLOFT_ALIGNED

#define COCKLOFT_ALIGNED (   T,
  A,
  B 
)    (((A) + (B)) & (~((T)(B) - 1)))

Definition at line 112 of file ext2fs.h.

◆ CODEPAGE_NAME

#define CODEPAGE_NAME   L"CodePage"

Definition at line 149 of file ext2fs.h.

◆ DbgBreak

#define DbgBreak ( )

Definition at line 46 of file ext2fs.h.

◆ DEBUG

#define DEBUG (   _DL,
  arg 
)    do {if ((_DL) & DL_ERR) DbgPrint arg;} while(0)

Definition at line 1473 of file ext2fs.h.

◆ DEC_IRP_COUNT

#define DEC_IRP_COUNT (   IrpContext)    Ext2TraceIrpContext(FALSE, (IrpContext))

Definition at line 610 of file ext2fs.h.

◆ DEC_MEM_COUNT

#define DEC_MEM_COUNT (   _i,
  _p,
  _s 
)    do { ASSERT(_p); Ext2TraceMemory(FALSE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)

Definition at line 608 of file ext2fs.h.

◆ DEFAULT_SECTOR_SIZE

#define DEFAULT_SECTOR_SIZE   (0x200)

Definition at line 83 of file ext2fs.h.

◆ DEVICE_NAME

#define DEVICE_NAME   L"\\Ext2Fsd"

Definition at line 137 of file ext2fs.h.

◆ DL_BH

#define DL_BH   0x00008000 /* buffer head */

Definition at line 1448 of file ext2fs.h.

◆ DL_BLK

#define DL_BLK   0x00000100 /* data block allocation / free */

Definition at line 1441 of file ext2fs.h.

◆ DL_CP

#define DL_CP   0x00000200 /* code pages (create, querydir) */

Definition at line 1442 of file ext2fs.h.

◆ DL_DBG

#define DL_DBG   0x00000004

Definition at line 1435 of file ext2fs.h.

◆ DL_DEFAULT

#define DL_DEFAULT   (DL_ERR|DL_VIT)

Definition at line 1452 of file ext2fs.h.

◆ DL_ERR

#define DL_ERR   0x00000002

Definition at line 1434 of file ext2fs.h.

◆ DL_EXT

#define DL_EXT   0x00000400 /* mcb extents */

Definition at line 1443 of file ext2fs.h.

◆ DL_FUN

#define DL_FUN   0x00000010

Definition at line 1437 of file ext2fs.h.

◆ DL_HTI

#define DL_HTI   0x00002000 /* htree index */

Definition at line 1446 of file ext2fs.h.

◆ DL_INF

#define DL_INF   0x00000008

Definition at line 1436 of file ext2fs.h.

◆ DL_IO

#define DL_IO   0x00020000 /* file i/o */

Definition at line 1450 of file ext2fs.h.

◆ DL_JNL

#define DL_JNL   0x00001000 /* dump journal operations */

Definition at line 1445 of file ext2fs.h.

◆ DL_LOW

#define DL_LOW   0x00000020

Definition at line 1438 of file ext2fs.h.

◆ DL_MAP

#define DL_MAP   0x00000800 /* retrieval points */

Definition at line 1444 of file ext2fs.h.

◆ DL_NVR

#define DL_NVR   0

Definition at line 1432 of file ext2fs.h.

◆ DL_PNP

#define DL_PNP   0x00010000 /* pnp */

Definition at line 1449 of file ext2fs.h.

◆ DL_REN

#define DL_REN   0x00000040 /* renaming operation */

Definition at line 1439 of file ext2fs.h.

◆ DL_RES

#define DL_RES   0x00000080 /* entry reference managment */

Definition at line 1440 of file ext2fs.h.

◆ DL_VIT

#define DL_VIT   0x00000001

Definition at line 1433 of file ext2fs.h.

◆ DL_WRN

#define DL_WRN   0x00004000 /* warning */

Definition at line 1447 of file ext2fs.h.

◆ DOS_DEVICE_NAME

#define DOS_DEVICE_NAME   L"\\DosDevices\\Ext2Fsd"

Definition at line 159 of file ext2fs.h.

◆ DRIVER_NAME

#define DRIVER_NAME   "Ext2Fsd"

Definition at line 136 of file ext2fs.h.

◆ EGID

#define EGID   L"egid"

Definition at line 157 of file ext2fs.h.

◆ EUID

#define EUID   L"euid"

Definition at line 156 of file ext2fs.h.

◆ EXT2_AUTO_MOUNT

#define EXT2_AUTO_MOUNT   0x00000010

Definition at line 594 of file ext2fs.h.

◆ EXT2_BLOCK_TYPES

#define EXT2_BLOCK_TYPES   (0x04)

Definition at line 77 of file ext2fs.h.

◆ EXT2_BUGCHK_BLOCK

#define EXT2_BUGCHK_BLOCK   (0x00010000)

Definition at line 314 of file ext2fs.h.

◆ EXT2_BUGCHK_CLEANUP

#define EXT2_BUGCHK_CLEANUP   (0x00020000)

Definition at line 315 of file ext2fs.h.

◆ EXT2_BUGCHK_CLOSE

#define EXT2_BUGCHK_CLOSE   (0x00030000)

Definition at line 316 of file ext2fs.h.

◆ EXT2_BUGCHK_CMCB

#define EXT2_BUGCHK_CMCB   (0x00040000)

Definition at line 317 of file ext2fs.h.

◆ EXT2_BUGCHK_CREATE

#define EXT2_BUGCHK_CREATE   (0x00050000)

Definition at line 318 of file ext2fs.h.

◆ EXT2_BUGCHK_DEBUG

#define EXT2_BUGCHK_DEBUG   (0x00060000)

Definition at line 319 of file ext2fs.h.

◆ EXT2_BUGCHK_DEVCTL

#define EXT2_BUGCHK_DEVCTL   (0x00070000)

Definition at line 320 of file ext2fs.h.

◆ EXT2_BUGCHK_DIRCTL

#define EXT2_BUGCHK_DIRCTL   (0x00080000)

Definition at line 321 of file ext2fs.h.

◆ EXT2_BUGCHK_DISPATCH

#define EXT2_BUGCHK_DISPATCH   (0x00090000)

Definition at line 322 of file ext2fs.h.

◆ EXT2_BUGCHK_EXCEPT

#define EXT2_BUGCHK_EXCEPT   (0x000A0000)

Definition at line 323 of file ext2fs.h.

◆ EXT2_BUGCHK_EXT2

#define EXT2_BUGCHK_EXT2   (0x000B0000)

Definition at line 324 of file ext2fs.h.

◆ EXT2_BUGCHK_FASTIO

#define EXT2_BUGCHK_FASTIO   (0x000C0000)

Definition at line 325 of file ext2fs.h.

◆ EXT2_BUGCHK_FILEINFO

#define EXT2_BUGCHK_FILEINFO   (0x000D0000)

Definition at line 326 of file ext2fs.h.

◆ EXT2_BUGCHK_FLUSH

#define EXT2_BUGCHK_FLUSH   (0x000E0000)

Definition at line 327 of file ext2fs.h.

◆ EXT2_BUGCHK_FSCTL

#define EXT2_BUGCHK_FSCTL   (0x000F0000)

Definition at line 328 of file ext2fs.h.

◆ EXT2_BUGCHK_INIT

#define EXT2_BUGCHK_INIT   (0x00100000)

Definition at line 329 of file ext2fs.h.

◆ EXT2_BUGCHK_LAST

#define EXT2_BUGCHK_LAST   (0x00170000)

Definition at line 338 of file ext2fs.h.

◆ EXT2_BUGCHK_LOCK

#define EXT2_BUGCHK_LOCK   (0x0011000)

Definition at line 330 of file ext2fs.h.

◆ EXT2_BUGCHK_MEMORY

#define EXT2_BUGCHK_MEMORY   (0x0012000)

Definition at line 331 of file ext2fs.h.

◆ EXT2_BUGCHK_MISC

#define EXT2_BUGCHK_MISC   (0x0013000)

Definition at line 332 of file ext2fs.h.

◆ EXT2_BUGCHK_READ

#define EXT2_BUGCHK_READ   (0x00140000)

Definition at line 333 of file ext2fs.h.

◆ EXT2_BUGCHK_SHUTDOWN

#define EXT2_BUGCHK_SHUTDOWN   (0x00150000)

Definition at line 334 of file ext2fs.h.

◆ EXT2_BUGCHK_VOLINFO

#define EXT2_BUGCHK_VOLINFO   (0x00160000)

Definition at line 335 of file ext2fs.h.

◆ EXT2_BUGCHK_WRITE

#define EXT2_BUGCHK_WRITE   (0x00170000)

Definition at line 336 of file ext2fs.h.

◆ EXT2_CHECKING_BITMAP

#define EXT2_CHECKING_BITMAP   0x00000008

Definition at line 593 of file ext2fs.h.

◆ EXT2_DATA_MAGIC

#define EXT2_DATA_MAGIC   'BD2E'

Definition at line 296 of file ext2fs.h.

◆ EXT2_DEBUG

#define EXT2_DEBUG   0

Definition at line 34 of file ext2fs.h.

◆ EXT2_DENTRY_MAGIC

#define EXT2_DENTRY_MAGIC   'ED2E'

Definition at line 300 of file ext2fs.h.

◆ EXT2_DIRSP_MAGIC

#define EXT2_DIRSP_MAGIC   'SD2E'

Definition at line 301 of file ext2fs.h.

◆ EXT2_FILE_SYSTEM

#define EXT2_FILE_SYSTEM   (FILE_SYSTEM)

Definition at line 312 of file ext2fs.h.

◆ EXT2_FIRST_DATA_BLOCK

#define EXT2_FIRST_DATA_BLOCK   (SUPER_BLOCK->s_first_data_block)

Definition at line 103 of file ext2fs.h.

◆ EXT2_FLIST_MAGIC

#define EXT2_FLIST_MAGIC   'LF2E'

Definition at line 304 of file ext2fs.h.

◆ EXT2_FNAME_MAGIC

#define EXT2_FNAME_MAGIC   'NF2E'

Definition at line 298 of file ext2fs.h.

◆ EXT2_GD_MAGIC

#define EXT2_GD_MAGIC   'DG2E'

Definition at line 303 of file ext2fs.h.

◆ EXT2_INAME_MAGIC

#define EXT2_INAME_MAGIC   'NI2E'

Definition at line 297 of file ext2fs.h.

◆ EXT2_LINKLEN_IN_INODE

#define EXT2_LINKLEN_IN_INODE   (60)

Definition at line 76 of file ext2fs.h.

◆ EXT2_LOOKUP_FLAG_MASK

#define EXT2_LOOKUP_FLAG_MASK   (0xFF00000)

Definition at line 1379 of file ext2fs.h.

◆ EXT2_LOOKUP_NOT_FOLLOW

#define EXT2_LOOKUP_NOT_FOLLOW   (0x8000000)

Definition at line 1380 of file ext2fs.h.

◆ EXT2_MAX_NESTED_LINKS

#define EXT2_MAX_NESTED_LINKS   (8)

Definition at line 75 of file ext2fs.h.

◆ EXT2_MAX_USER_BLKSIZE

#define EXT2_MAX_USER_BLKSIZE   65536

Definition at line 353 of file ext2fs.h.

◆ EXT2_MIN_BLOCK

#define EXT2_MIN_BLOCK   1024

Definition at line 351 of file ext2fs.h.

◆ EXT2_MIN_FRAG

#define EXT2_MIN_FRAG   1024

Definition at line 352 of file ext2fs.h.

◆ EXT2_PARAM_MAGIC

#define EXT2_PARAM_MAGIC   'PP2E'

Definition at line 305 of file ext2fs.h.

◆ EXT2_PRE_ALLOCATION_SUPPORT

#define EXT2_PRE_ALLOCATION_SUPPORT   TRUE

Definition at line 69 of file ext2fs.h.

◆ EXT2_REAPER_FLAG_STOP

#define EXT2_REAPER_FLAG_STOP   (1 << 0)

Definition at line 511 of file ext2fs.h.

◆ EXT2_RW_CONTEXT_WRITE

#define EXT2_RW_CONTEXT_WRITE   1

Definition at line 3215 of file ext2fs.h.

◆ EXT2_RWC_MAGIC

#define EXT2_RWC_MAGIC   'WR2E'

Definition at line 306 of file ext2fs.h.

◆ EXT2_SB_MAGIC

#define EXT2_SB_MAGIC   'BS2E'

Definition at line 302 of file ext2fs.h.

◆ EXT2_SUPER_MAGIC

#define EXT2_SUPER_MAGIC   0xEF53

Definition at line 349 of file ext2fs.h.

◆ EXT2_SUPPORT_WRITING

#define EXT2_SUPPORT_WRITING   0x00000002

Definition at line 591 of file ext2fs.h.

◆ EXT2_UNLOAD

#define EXT2_UNLOAD   FALSE

Definition at line 65 of file ext2fs.h.

◆ EXT2_UNLOAD_PENDING

#define EXT2_UNLOAD_PENDING   0x00000001

Definition at line 590 of file ext2fs.h.

◆ EXT2_VNAME_MAGIC

#define EXT2_VNAME_MAGIC   'NV2E'

Definition at line 299 of file ext2fs.h.

◆ Ext2BugCheck

#define Ext2BugCheck (   A,
  B,
  C,
  D 
)    { KeBugCheckEx(EXT2_FILE_SYSTEM, A | __LINE__, B, C, D ); }

Definition at line 340 of file ext2fs.h.

◆ Ext2CanIWait

#define Ext2CanIWait ( )    (!IrpContext || IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT))

Definition at line 1100 of file ext2fs.h.

◆ Ext2CompleteRequest

#define Ext2CompleteRequest (   Irp,
  bPrint,
  PriorityBoost 
)     IoCompleteRequest(Irp, PriorityBoost)

Definition at line 1475 of file ext2fs.h.

◆ Ext2DerefMcb

#define Ext2DerefMcb (   Mcb)    Ext2DerefXcb(&Mcb->Refercount)

Definition at line 996 of file ext2fs.h.

◆ Ext2DerefXcb

#define Ext2DerefXcb (   _C)    DEC_OBJ_CNT(_C)

Definition at line 977 of file ext2fs.h.

◆ Ext2FileCanExecute

#define Ext2FileCanExecute   (0x4)

Definition at line 433 of file ext2fs.h.

◆ Ext2FileCanRead

#define Ext2FileCanRead   (0x1)

Definition at line 431 of file ext2fs.h.

◆ Ext2FileCanWrite

#define Ext2FileCanWrite   (0x2)

Definition at line 432 of file ext2fs.h.

◆ EXT2FSD_VERSION

#define EXT2FSD_VERSION   "0.69"

Definition at line 51 of file ext2fs.h.

◆ Ext2GetCurrentProcessName

#define Ext2GetCurrentProcessName ( )
Value:
( \
)
ULONG ProcessNameOffset
unsigned char * PUCHAR
Definition: typedefs.h:53
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Definition at line 1489 of file ext2fs.h.

◆ Ext2IsGroupReadable

#define Ext2IsGroupReadable (   m)    (((m) & S_IRGRP) == S_IRGRP)

Definition at line 421 of file ext2fs.h.

◆ Ext2IsGroupReadOnly

#define Ext2IsGroupReadOnly (   m)    (!(Ext2IsGroupWritable(m)) && Ext2IsGroupReadable(m))

Definition at line 422 of file ext2fs.h.

◆ Ext2IsGroupWritable

#define Ext2IsGroupWritable (   m)    (((m) & S_IWGRP) == S_IWGRP)

Definition at line 420 of file ext2fs.h.

◆ Ext2IsOtherReadable

#define Ext2IsOtherReadable (   m)    (((m) & S_IROTH) == S_IROTH)

Definition at line 425 of file ext2fs.h.

◆ Ext2IsOtherReadOnly

#define Ext2IsOtherReadOnly (   m)    (!(Ext2IsOtherWritable(m)) && Ext2IsOtherReadable(m))

Definition at line 426 of file ext2fs.h.

◆ Ext2IsOtherWritable

#define Ext2IsOtherWritable (   m)    (((m) & S_IWOTH) == S_IWOTH)

Definition at line 424 of file ext2fs.h.

◆ Ext2IsOwnerReadable

#define Ext2IsOwnerReadable (   m)    (((m) & S_IRUSR) == S_IRUSR)

Definition at line 417 of file ext2fs.h.

◆ Ext2IsOwnerReadOnly

#define Ext2IsOwnerReadOnly (   m)    (!(Ext2IsOwnerWritable(m)) && Ext2IsOwnerReadable(m))

Definition at line 418 of file ext2fs.h.

◆ Ext2IsOwnerWritable

#define Ext2IsOwnerWritable (   m)    (((m) & S_IWUSR) == S_IWUSR)

Definition at line 416 of file ext2fs.h.

◆ Ext2NormalizeAndRaiseStatus

#define Ext2NormalizeAndRaiseStatus (   IRPCONTEXT,
  STATUS 
)
Value:
{ \
(IRPCONTEXT)->ExceptionCode = STATUS; \
}
#define STATUS
Definition: blue.h:116
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1774
NTSTATUS NTAPI FsRtlNormalizeNtstatus(IN NTSTATUS NtStatusToNormalize, IN NTSTATUS NormalizedNtStatus)
Definition: filter.c:90
#define ExRaiseStatus
Definition: ntoskrnl.h:114
#define STATUS_UNEXPECTED_IO_ERROR
Definition: ntstatus.h:469
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130

Definition at line 268 of file ext2fs.h.

◆ Ext2RaiseStatus

#define Ext2RaiseStatus (   IRPCONTEXT,
  STATUS 
)
Value:
{ \
(IRPCONTEXT)->ExceptionCode = (STATUS); \
ExRaiseStatus((STATUS)); \
}

Definition at line 263 of file ext2fs.h.

◆ Ext2ReferMcb

#define Ext2ReferMcb (   Mcb)    Ext2ReferXcb(&Mcb->Refercount)

Definition at line 995 of file ext2fs.h.

◆ Ext2ReferXcb

#define Ext2ReferXcb (   _C)    InterlockedIncrement(_C)

Definition at line 976 of file ext2fs.h.

◆ Ext2SetOwnerReadOnly

#define Ext2SetOwnerReadOnly (   m)    do {(m) &= ~S_IWUSR;} while(0)

Definition at line 414 of file ext2fs.h.

◆ Ext2SetOwnerWritable

#define Ext2SetOwnerWritable (   m)    do {(m) |= S_IWUSR;} while(0)

Definition at line 413 of file ext2fs.h.

◆ Ext2SetReadable

#define Ext2SetReadable (   m)    do {(m) = (m) | (S_IRUSR | S_IRGRP | S_IROTH);} while(0)

Definition at line 410 of file ext2fs.h.

◆ Ext2SetReadOnly

#define Ext2SetReadOnly (   m)    do {(m) &= ~(S_IWUSR | S_IWGRP | S_IWOTH);} while(0)

Definition at line 428 of file ext2fs.h.

◆ Ext2SetWritable

#define Ext2SetWritable (   m)    do {(m) = (m) | (S_IWUSR | S_IWGRP | S_IWOTH);} while(0)

Definition at line 411 of file ext2fs.h.

◆ ext3_error

#define ext3_error   ext3_warning

Definition at line 2593 of file ext2fs.h.

◆ EXT3_FORCE_WRITING

#define EXT3_FORCE_WRITING   0x00000004

Definition at line 592 of file ext2fs.h.

◆ EXT3_FORCEWRITING

#define EXT3_FORCEWRITING   L"Ext3ForceWriting"

Definition at line 148 of file ext2fs.h.

◆ ext4_error

#define ext4_error   ext3_error

Definition at line 2594 of file ext2fs.h.

◆ EXT_DEBUG_BREAKPOINT

#define EXT_DEBUG_BREAKPOINT   FALSE

Definition at line 37 of file ext2fs.h.

◆ FCB_ALLOC_IN_CREATE

#define FCB_ALLOC_IN_CREATE   0x00000080

Definition at line 884 of file ext2fs.h.

◆ FCB_ALLOC_IN_SETINFO

#define FCB_ALLOC_IN_SETINFO   0x00000200

Definition at line 886 of file ext2fs.h.

◆ FCB_ALLOC_IN_WRITE

#define FCB_ALLOC_IN_WRITE   0x00000100

Definition at line 885 of file ext2fs.h.

◆ FCB_DELETE_PENDING

#define FCB_DELETE_PENDING   0x80000000

Definition at line 888 of file ext2fs.h.

◆ FCB_FILE_MODIFIED

#define FCB_FILE_MODIFIED   0x00000020

Definition at line 882 of file ext2fs.h.

◆ FCB_FROM_POOL

#define FCB_FROM_POOL   0x00000001

Definition at line 880 of file ext2fs.h.

◆ FCB_PAGE_FILE

#define FCB_PAGE_FILE   0x00000002

Definition at line 881 of file ext2fs.h.

◆ FILE_SUPPORTS_EXTENDED_ATTRIBUTES

#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES   0x00800000

Definition at line 1136 of file ext2fs.h.

◆ FILE_WRITE_TO_END_OF_FILE

#define FILE_WRITE_TO_END_OF_FILE   0xffffffff

Definition at line 278 of file ext2fs.h.

◆ FlagOn

#define FlagOn (   _F,
  _SF 
)    ((_F) & (_SF))

Definition at line 179 of file ext2fs.h.

◆ FSCTL_GET_RETRIEVAL_POINTER_BASE

#define FSCTL_GET_RETRIEVAL_POINTER_BASE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS)

Definition at line 1132 of file ext2fs.h.

◆ GID

#define GID   L"gid"

Definition at line 155 of file ext2fs.h.

◆ GROUP_DESC_SIZE

#define GROUP_DESC_SIZE   (Vcb->sbi.s_desc_size)

Definition at line 95 of file ext2fs.h.

◆ HIDING_PREFIX

#define HIDING_PREFIX   L"HidingPrefix"

Definition at line 150 of file ext2fs.h.

◆ HIDING_SUFFIX

#define HIDING_SUFFIX   L"HidingSuffix"

Definition at line 151 of file ext2fs.h.

◆ INC_IRP_COUNT

#define INC_IRP_COUNT (   IrpContext)    Ext2TraceIrpContext(TRUE, (IrpContext))

Definition at line 609 of file ext2fs.h.

◆ INC_MEM_COUNT

#define INC_MEM_COUNT (   _i,
  _p,
  _s 
)    do { ASSERT(_p); Ext2TraceMemory(TRUE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)

Definition at line 607 of file ext2fs.h.

◆ INODE_SIZE

#define INODE_SIZE   (Vcb->InodeSize)

Definition at line 92 of file ext2fs.h.

◆ INODES_COUNT

#define INODES_COUNT   (Vcb->SuperBlock->s_inodes_count)

Definition at line 97 of file ext2fs.h.

◆ INODES_PER_GROUP

#define INODES_PER_GROUP   (SUPER_BLOCK->s_inodes_per_group)

Definition at line 99 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_DEFERRED

#define IRP_CONTEXT_FLAG_DEFERRED   (0x00000040)

Definition at line 1091 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_DELAY_CLOSE

#define IRP_CONTEXT_FLAG_DELAY_CLOSE   (0x00000800)

Definition at line 1096 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_DISABLE_POPUPS

#define IRP_CONTEXT_FLAG_DISABLE_POPUPS   (0x00000020)

Definition at line 1090 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_FILE_BUSY

#define IRP_CONTEXT_FLAG_FILE_BUSY   (0x00001000)

Definition at line 1097 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_FLOPPY

#define IRP_CONTEXT_FLAG_FLOPPY   (0x00000008)

Definition at line 1089 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_FROM_POOL

#define IRP_CONTEXT_FLAG_FROM_POOL   (0x00000001)

Definition at line 1086 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_REQUEUED

#define IRP_CONTEXT_FLAG_REQUEUED   (0x00000200)

Definition at line 1094 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_USER_IO

#define IRP_CONTEXT_FLAG_USER_IO   (0x00000400)

Definition at line 1095 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_VERIFY_READ

#define IRP_CONTEXT_FLAG_VERIFY_READ   (0x00000080)

Definition at line 1092 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_WAIT

#define IRP_CONTEXT_FLAG_WAIT   (0x00000002)

Definition at line 1087 of file ext2fs.h.

◆ IRP_CONTEXT_FLAG_WRITE_THROUGH

#define IRP_CONTEXT_FLAG_WRITE_THROUGH   (0x00000004)

Definition at line 1088 of file ext2fs.h.

◆ IRP_CONTEXT_STACK_IO_CONTEXT

#define IRP_CONTEXT_STACK_IO_CONTEXT   (0x00000100)

Definition at line 1093 of file ext2fs.h.

◆ IsDirectory

#define IsDirectory (   Fcb)    IsMcbDirectory((Fcb)->Mcb)

Definition at line 283 of file ext2fs.h.

◆ IsDispending

#define IsDispending (   Vcb)    (IsFlagOn((Vcb)->Flags, VCB_DISMOUNT_PENDING))

Definition at line 813 of file ext2fs.h.

◆ IsExt2FsDevice

#define IsExt2FsDevice (   DO)
Value:
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define DO
Definition: ftp_var.h:15
PDEVICE_OBJECT DiskdevObject
Definition: ext2fs.h:539
PDEVICE_OBJECT CdromdevObject
Definition: ext2fs.h:542

Definition at line 616 of file ext2fs.h.

◆ IsExt3ForceWrite

#define IsExt3ForceWrite ( )    (IsFlagOn(Ext2Global->Flags, EXT3_FORCE_WRITING))

Definition at line 819 of file ext2fs.h.

◆ IsFileDeleted

#define IsFileDeleted (   Mcb)    IsFlagOn((Mcb)->Flags, MCB_FILE_DELETED)

Definition at line 968 of file ext2fs.h.

◆ IsFlagOn

#define IsFlagOn (   a,
  b 
)    ((BOOLEAN)(FlagOn(a,b) == b))

Definition at line 177 of file ext2fs.h.

◆ IsInodeSymLink

#define IsInodeSymLink (   I)    S_ISLNK((I)->i_mode)

Definition at line 286 of file ext2fs.h.

◆ IsLazyWriter

#define IsLazyWriter (   Fcb)    ((Fcb)->LazyWriterThread == PsGetCurrentThread())

Definition at line 822 of file ext2fs.h.

◆ IsLinkInvalid

#define IsLinkInvalid (   Mcb)    (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target))

Definition at line 970 of file ext2fs.h.

◆ IsMcbDirectory

#define IsMcbDirectory (   Mcb)    IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_DIRECTORY)

Definition at line 967 of file ext2fs.h.

◆ IsMcbReadonly

#define IsMcbReadonly (   Mcb)    IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_READONLY)

Definition at line 966 of file ext2fs.h.

◆ IsMcbRoot

#define IsMcbRoot (   Mcb)    ((Mcb)->Inode.i_ino == EXT2_ROOT_INO)

Definition at line 965 of file ext2fs.h.

◆ IsMcbSpecialFile

#define IsMcbSpecialFile (   Mcb)    IsFlagOn((Mcb)->Flags, MCB_TYPE_SPECIAL)

Definition at line 964 of file ext2fs.h.

◆ IsMcbSymLink

#define IsMcbSymLink (   Mcb)    IsFlagOn((Mcb)->Flags, MCB_TYPE_SYMLINK)

Definition at line 962 of file ext2fs.h.

◆ IsMcbUsed

#define IsMcbUsed (   Mcb)    ((Mcb)->Refercount > 0)

Definition at line 961 of file ext2fs.h.

◆ IsMounted

#define IsMounted (   Vcb)    (IsFlagOn((Vcb)->Flags, VCB_MOUNTED))

Definition at line 812 of file ext2fs.h.

◆ IsRoot

#define IsRoot (   Fcb)    IsMcbRoot((Fcb)->Mcb)

Definition at line 287 of file ext2fs.h.

◆ IsSpecialFile

#define IsSpecialFile (   Fcb)    IsMcbSpecialFile((Fcb)->Mcb)

Definition at line 284 of file ext2fs.h.

◆ IsSymLink

#define IsSymLink (   Fcb)    IsMcbSymLink((Fcb)->Mcb)

Definition at line 285 of file ext2fs.h.

◆ IsVcbForceWrite

#define IsVcbForceWrite (   Vcb)    (IsFlagOn((Vcb)->Flags, VCB_FORCE_WRITING))

Definition at line 820 of file ext2fs.h.

◆ IsVcbInited

#define IsVcbInited (   Vcb)    (IsFlagOn((Vcb)->Flags, VCB_INITIALIZED))

Definition at line 811 of file ext2fs.h.

◆ IsVcbReadOnly

#define IsVcbReadOnly (   Vcb)
Value:
IsFlagOn((Vcb)->Flags, VCB_RO_COMPAT_READ_ONLY) || \
IsFlagOn((Vcb)->Flags, VCB_WRITE_PROTECTED))
#define VCB_WRITE_PROTECTED
Definition: ext2fs.h:805
#define VCB_READ_ONLY
Definition: ext2fs.h:804
#define VCB_RO_COMPAT_READ_ONLY
Definition: ext2fs.h:803
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define Vcb
Definition: cdprocs.h:1415
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Definition at line 814 of file ext2fs.h.

◆ IsWritingToEof

#define IsWritingToEof (   Pos)
Value:
(((Pos).LowPart == FILE_WRITE_TO_END_OF_FILE) && \
((Pos).HighPart == -1 ))
ush Pos
Definition: deflate.h:92
#define FILE_WRITE_TO_END_OF_FILE
Definition: ext2fs.h:278

Definition at line 280 of file ext2fs.h.

◆ IsZoneInited

#define IsZoneInited (   Mcb)    IsFlagOn((Mcb)->Flags, MCB_ZONE_INITED)

Definition at line 963 of file ext2fs.h.

◆ max

#define max (   a,
  b 
)    (((a) > (b)) ? (a) : (b))

Definition at line 199 of file ext2fs.h.

◆ MAXIMUM_RECORD_LENGTH

#define MAXIMUM_RECORD_LENGTH   (0x10000)

Definition at line 79 of file ext2fs.h.

◆ MCB_ENTRY_TREE

#define MCB_ENTRY_TREE   0x00000004

Definition at line 954 of file ext2fs.h.

◆ MCB_FILE_DELETED

#define MCB_FILE_DELETED   0x00000008

Definition at line 955 of file ext2fs.h.

◆ MCB_FROM_POOL

#define MCB_FROM_POOL   0x00000001

Definition at line 952 of file ext2fs.h.

◆ MCB_TYPE_SPECIAL

#define MCB_TYPE_SPECIAL   0x40000000 /* unresolved symlink + device node */

Definition at line 958 of file ext2fs.h.

◆ MCB_TYPE_SYMLINK

#define MCB_TYPE_SYMLINK   0x80000000

Definition at line 959 of file ext2fs.h.

◆ MCB_VCB_LINK

#define MCB_VCB_LINK   0x00000002

Definition at line 953 of file ext2fs.h.

◆ MCB_ZONE_INITED

#define MCB_ZONE_INITED   0x20000000

Definition at line 957 of file ext2fs.h.

◆ min

#define min (   a,
  b 
)    (((a) < (b)) ? (a) : (b))

Definition at line 195 of file ext2fs.h.

◆ MOUNT_POINT

#define MOUNT_POINT   L"MountPoint"

Definition at line 153 of file ext2fs.h.

◆ NodeType

#define NodeType (   Ptr)    (*((EXT2_IDENTIFIER_TYPE *)(Ptr)))

Definition at line 482 of file ext2fs.h.

◆ PARAMETERS_KEY

#define PARAMETERS_KEY   L"\\Parameters"

Definition at line 142 of file ext2fs.h.

◆ READ_AHEAD_GRANULARITY

#define READ_AHEAD_GRANULARITY   (0x10000)

Definition at line 88 of file ext2fs.h.

◆ READING_ONLY

#define READING_ONLY   L"Readonly"

Definition at line 145 of file ext2fs.h.

◆ S_IALLUGO

#define S_IALLUGO   (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)

Definition at line 401 of file ext2fs.h.

◆ S_IFATTR

#define S_IFATTR   (S_IRWNU|S_IRWNG|S_IRWNO)

Definition at line 405 of file ext2fs.h.

◆ S_IFBLK

#define S_IFBLK   0x06000 /* 006 0000 */

Definition at line 362 of file ext2fs.h.

◆ S_IFCHR

#define S_IFCHR   0x02000 /* 002 0000 */

Definition at line 364 of file ext2fs.h.

◆ S_IFDIR

#define S_IFDIR   0x04000 /* 004 0000 */

Definition at line 363 of file ext2fs.h.

◆ S_IFIFO

#define S_IFIFO   0x01000 /* 001 0000 */

Definition at line 365 of file ext2fs.h.

◆ S_IFLNK

#define S_IFLNK   0x0A000 /* 012 0000 */

Definition at line 360 of file ext2fs.h.

◆ S_IFMT

#define S_IFMT   0x0F000 /* 017 0000 */

Definition at line 358 of file ext2fs.h.

◆ S_IFREG

#define S_IFREG   0x08000 /* 010 0000 */

Definition at line 361 of file ext2fs.h.

◆ S_IFSOCK

#define S_IFSOCK   0x0C000 /* 014 0000 */

Definition at line 359 of file ext2fs.h.

◆ S_IPERMISSION_MASK

#define S_IPERMISSION_MASK   0x1FF /* */

Definition at line 380 of file ext2fs.h.

◆ S_IRGRP

#define S_IRGRP   0x020 /* 0 0040 */

Definition at line 390 of file ext2fs.h.

◆ S_IROTH

#define S_IROTH   0x004 /* 0 0004 */

Definition at line 396 of file ext2fs.h.

◆ S_IRUGO

#define S_IRUGO   (S_IRUSR|S_IRGRP|S_IROTH)

Definition at line 402 of file ext2fs.h.

◆ S_IRUSR

#define S_IRUSR   0x100 /* 0 0400 */

Definition at line 384 of file ext2fs.h.

◆ S_IRWNG

#define S_IRWNG   0x030 /* 0 0060 */

Definition at line 389 of file ext2fs.h.

◆ S_IRWNO

#define S_IRWNO   0x006 /* 0 0006 */

Definition at line 395 of file ext2fs.h.

◆ S_IRWNU

#define S_IRWNU   0x180 /* 0 0600 */

Definition at line 383 of file ext2fs.h.

◆ S_IRWXG

#define S_IRWXG   0x038 /* 0 0070 */

Definition at line 388 of file ext2fs.h.

◆ S_IRWXO

#define S_IRWXO   0x007 /* 0 0007 */

Definition at line 394 of file ext2fs.h.

◆ S_IRWXU

#define S_IRWXU   0x1C0 /* 0 0700 */

Definition at line 382 of file ext2fs.h.

◆ S_IRWXUGO

#define S_IRWXUGO   (S_IRWXU|S_IRWXG|S_IRWXO)

Definition at line 400 of file ext2fs.h.

◆ S_ISBLK

#define S_ISBLK (   m)    (((m) & S_IFMT) == S_IFBLK)

Definition at line 375 of file ext2fs.h.

◆ S_ISCHR

#define S_ISCHR (   m)    (((m) & S_IFMT) == S_IFCHR)

Definition at line 377 of file ext2fs.h.

◆ S_ISDIR

#define S_ISDIR (   m)    (((m) & S_IFMT) == S_IFDIR)

Definition at line 376 of file ext2fs.h.

◆ S_ISFIFO

#define S_ISFIFO (   m)    (((m) & S_IFMT) == S_IFIFO)

Definition at line 378 of file ext2fs.h.

◆ S_ISFIL

#define S_ISFIL (   m)    (((m) & S_IFMT) == S_IFFIL)

Definition at line 374 of file ext2fs.h.

◆ S_ISGID

#define S_ISGID   0x00400 /* 000 2000 */

Definition at line 368 of file ext2fs.h.

◆ S_ISLNK

#define S_ISLNK (   m)    (((m) & S_IFMT) == S_IFLNK)

Definition at line 373 of file ext2fs.h.

◆ S_ISREADABLE

#define S_ISREADABLE (   m)    (((m) & S_IPERMISSION_MASK) == (S_IRUSR | S_IRGRP | S_IROTH))

Definition at line 407 of file ext2fs.h.

◆ S_ISREG

#define S_ISREG (   m)    (((m) & S_IFMT) == S_IFREG)

Definition at line 371 of file ext2fs.h.

◆ S_ISSOCK

#define S_ISSOCK (   m)    (((m) & S_IFMT) == S_IFSOCK)

Definition at line 372 of file ext2fs.h.

◆ S_ISUID

#define S_ISUID   0x00800 /* 000 4000 */

Definition at line 367 of file ext2fs.h.

◆ S_ISVTX

#define S_ISVTX   0x00200 /* 000 1000 */

Definition at line 369 of file ext2fs.h.

◆ S_ISWRITABLE

#define S_ISWRITABLE (   m)    (((m) & S_IPERMISSION_MASK) == (S_IWUSR | S_IWGRP | S_IWOTH))

Definition at line 408 of file ext2fs.h.

◆ S_IWGRP

#define S_IWGRP   0x010 /* 0 0020 */

Definition at line 391 of file ext2fs.h.

◆ S_IWOTH

#define S_IWOTH   0x002 /* 0 0002 */

Definition at line 397 of file ext2fs.h.

◆ S_IWUGO

#define S_IWUGO   (S_IWUSR|S_IWGRP|S_IWOTH)

Definition at line 403 of file ext2fs.h.

◆ S_IWUSR

#define S_IWUSR   0x080 /* 0 0200 */

Definition at line 385 of file ext2fs.h.

◆ S_IXGRP

#define S_IXGRP   0x008 /* 0 0010 */

Definition at line 392 of file ext2fs.h.

◆ S_IXOTH

#define S_IXOTH   0x001 /* 0 0001 */

Definition at line 398 of file ext2fs.h.

◆ S_IXUGO

#define S_IXUGO   (S_IXUSR|S_IXGRP|S_IXOTH)

Definition at line 404 of file ext2fs.h.

◆ S_IXUSR

#define S_IXUSR   0x040 /* 0 0100 */

Definition at line 386 of file ext2fs.h.

◆ SECTOR_BITS

#define SECTOR_BITS   (Vcb->SectorBits)

Definition at line 81 of file ext2fs.h.

◆ SECTOR_SIZE

#define SECTOR_SIZE   (Vcb->DiskGeometry.BytesPerSector)

Definition at line 82 of file ext2fs.h.

◆ SetFlag

#define SetFlag (   _F,
  _SF 
)    ((_F) |= (_SF))

Definition at line 187 of file ext2fs.h.

◆ SetLongFlag

#define SetLongFlag (   _F,
  _SF 
)    InterlockedOr(&(_F), (ULONG)(_SF))

Definition at line 258 of file ext2fs.h.

◆ SUPER_BLOCK

#define SUPER_BLOCK   (Vcb->SuperBlock)

Definition at line 90 of file ext2fs.h.

◆ SUPER_BLOCK_OFFSET

#define SUPER_BLOCK_OFFSET   (0x400)

Definition at line 85 of file ext2fs.h.

◆ SUPER_BLOCK_SIZE

#define SUPER_BLOCK_SIZE   (0x400)

Definition at line 86 of file ext2fs.h.

◆ TAG_VPB

#define TAG_VPB   ' bpV'

Definition at line 293 of file ext2fs.h.

◆ TOTAL_BLOCKS

#define TOTAL_BLOCKS   (ext3_blocks_count(SUPER_BLOCK))

Definition at line 101 of file ext2fs.h.

◆ UID

#define UID   L"uid"

Definition at line 154 of file ext2fs.h.

◆ VCB_ARRIVAL_NOTIFIED

#define VCB_ARRIVAL_NOTIFIED   0x00800000

Definition at line 802 of file ext2fs.h.

◆ VCB_BEING_CLOSED

#define VCB_BEING_CLOSED   0x00000020

Definition at line 793 of file ext2fs.h.

◆ VCB_BEING_DROPPED

#define VCB_BEING_DROPPED   0x00002000

Definition at line 798 of file ext2fs.h.

◆ VCB_DEVICE_REMOVED

#define VCB_DEVICE_REMOVED   0x00008000

Definition at line 800 of file ext2fs.h.

◆ VCB_DISMOUNT_PENDING

#define VCB_DISMOUNT_PENDING   0x00000008

Definition at line 791 of file ext2fs.h.

◆ VCB_FLOPPY_DISK

#define VCB_FLOPPY_DISK   0x20000000

Definition at line 806 of file ext2fs.h.

◆ VCB_FORCE_WRITING

#define VCB_FORCE_WRITING   0x00004000

Definition at line 799 of file ext2fs.h.

◆ VCB_GD_LOADED

#define VCB_GD_LOADED   0x00000100 /* group desc loaded */

Definition at line 796 of file ext2fs.h.

◆ VCB_INITIALIZED

#define VCB_INITIALIZED   0x00000001

Definition at line 788 of file ext2fs.h.

◆ VCB_JOURNAL_RECOVER

#define VCB_JOURNAL_RECOVER   0x00080000

Definition at line 801 of file ext2fs.h.

◆ VCB_MOUNTED

#define VCB_MOUNTED   0x00000004

Definition at line 790 of file ext2fs.h.

◆ VCB_NEW_VPB

#define VCB_NEW_VPB   0x00000010

Definition at line 792 of file ext2fs.h.

◆ VCB_READ_ONLY

#define VCB_READ_ONLY   0x08000000

Definition at line 804 of file ext2fs.h.

◆ VCB_REMOVABLE_MEDIA

#define VCB_REMOVABLE_MEDIA   0x80000000

Definition at line 808 of file ext2fs.h.

◆ VCB_REMOVAL_PREVENTED

#define VCB_REMOVAL_PREVENTED   0x40000000

Definition at line 807 of file ext2fs.h.

◆ VCB_RO_COMPAT_READ_ONLY

#define VCB_RO_COMPAT_READ_ONLY   0x01000000

Definition at line 803 of file ext2fs.h.

◆ VCB_USER_EIDS

#define VCB_USER_EIDS   0x00000080 /* euid/egid specified by user */

Definition at line 795 of file ext2fs.h.

◆ VCB_USER_IDS

#define VCB_USER_IDS   0x00000040 /* uid/gid specified by user */

Definition at line 794 of file ext2fs.h.

◆ VCB_VOLUME_LOCKED

#define VCB_VOLUME_LOCKED   0x00000002

Definition at line 789 of file ext2fs.h.

◆ VCB_WRITE_PROTECTED

#define VCB_WRITE_PROTECTED   0x10000000

Definition at line 805 of file ext2fs.h.

◆ VOLUMES_KEY

#define VOLUMES_KEY   L"\\Volumes"

Definition at line 143 of file ext2fs.h.

◆ VPB_SIZE

#define VPB_SIZE   sizeof(VPB)

Definition at line 294 of file ext2fs.h.

◆ WRITING_SUPPORT

#define WRITING_SUPPORT   L"WritingSupport"

Definition at line 146 of file ext2fs.h.

Typedef Documentation

◆ EXT2_ALLOC_HEADER

◆ EXT2_CCB

◆ EXT2_DIR_ENTRY

Definition at line 108 of file ext2fs.h.

◆ EXT2_DIR_ENTRY2

Definition at line 109 of file ext2fs.h.

◆ EXT2_EXTENT

◆ EXT2_FCB

◆ EXT2_FCBVCB

◆ EXT2_FILLDIR_CONTEXT

◆ EXT2_GLOBAL

◆ EXT2_GROUP_DESC

Definition at line 107 of file ext2fs.h.

◆ EXT2_IDENTIFIER

◆ EXT2_IDENTIFIER_TYPE

◆ EXT2_INODE

Definition at line 106 of file ext2fs.h.

◆ EXT2_IRP_CONTEXT

◆ EXT2_MCB

Definition at line 484 of file ext2fs.h.

◆ EXT2_REAPER

◆ EXT2_REAPER_RELEASE

typedef VOID(* EXT2_REAPER_RELEASE) (PVOID)

Definition at line 500 of file ext2fs.h.

◆ EXT2_RW_CONTEXT

◆ EXT2_SUPER_BLOCK

Definition at line 105 of file ext2fs.h.

◆ EXT2_VCB

◆ EXTENDED_IO_STACK_LOCATION

Definition at line 174 of file ext2fs.h.

◆ FCB_LIST_ENTRY

◆ filldir_t

typedef int(* filldir_t) (void *, const char *, int, unsigned long, __u32, unsigned)

Definition at line 2609 of file ext2fs.h.

◆ PBCB

typedef PVOID PBCB

Definition at line 487 of file ext2fs.h.

◆ PEXT2_ALLOC_HEADER

◆ PEXT2_CCB

◆ PEXT2_DIR_ENTRY

Definition at line 108 of file ext2fs.h.

◆ PEXT2_DIR_ENTRY2

Definition at line 109 of file ext2fs.h.

◆ PEXT2_EXTENT

◆ PEXT2_FCB

◆ PEXT2_FCBVCB

◆ PEXT2_FILLDIR_CONTEXT

◆ PEXT2_GLOBAL

◆ PEXT2_GROUP_DESC

Definition at line 107 of file ext2fs.h.

◆ PEXT2_IDENTIFIER

◆ PEXT2_INODE

Definition at line 106 of file ext2fs.h.

◆ PEXT2_IRP_CONTEXT

◆ PEXT2_MCB

Definition at line 484 of file ext2fs.h.

◆ PEXT2_REAPER

◆ PEXT2_RW_CONTEXT

◆ PEXT2_SUPER_BLOCK

Definition at line 105 of file ext2fs.h.

◆ PEXT2_VCB

◆ PEXTENDED_IO_STACK_LOCATION

Definition at line 174 of file ext2fs.h.

◆ PFCB_LIST_ENTRY

Enumeration Type Documentation

◆ _EXT2_IDENTIFIER_TYPE

Enumerator
EXT2FGD 
EXT2VCB 
EXT2FCB 
EXT2CCB 
EXT2ICX 
EXT2FSD 
EXT2MCB 

Definition at line 451 of file ext2fs.h.

451 {
452#ifdef _MSC_VER
453 EXT2FGD = ':DGF',
454 EXT2VCB = ':BCV',
455 EXT2FCB = ':BCF',
456 EXT2CCB = ':BCC',
457 EXT2ICX = ':XCI',
458 EXT2FSD = ':DSF',
459 EXT2MCB = ':BCM'
460#else
461 EXT2FGD = 0xE2FD0001,
462 EXT2VCB = 0xE2FD0002,
463 EXT2FCB = 0xE2FD0003,
464 EXT2CCB = 0xE2FD0004,
465 EXT2ICX = 0xE2FD0005,
466 EXT2FSD = 0xE2FD0006,
467 EXT2MCB = 0xE2FD0007
468#endif
@ EXT2FCB
Definition: ext2fs.h:463
@ EXT2ICX
Definition: ext2fs.h:465
@ EXT2FSD
Definition: ext2fs.h:466
@ EXT2VCB
Definition: ext2fs.h:462
@ EXT2MCB
Definition: ext2fs.h:467
@ EXT2FGD
Definition: ext2fs.h:461
@ EXT2CCB
Definition: ext2fs.h:464
enum _EXT2_IDENTIFIER_TYPE EXT2_IDENTIFIER_TYPE

Function Documentation

◆ add_dirent_to_buf()

int add_dirent_to_buf ( struct ext2_icb icb,
struct dentry dentry,
struct inode inode,
struct ext3_dir_entry_2 de,
struct buffer_head bh 
)

Definition at line 386 of file htree.c.

389{
390 struct inode *dir = dentry->d_parent->d_inode;
391 const char *name = dentry->d_name.name;
392 int namelen = dentry->d_name.len;
393 unsigned int offset = 0;
394 unsigned short reclen;
395 int nlen, rlen, err;
396 char *top;
397
398 reclen = EXT3_DIR_REC_LEN(namelen);
399 if (!de) {
400 de = (struct ext3_dir_entry_2 *)bh->b_data;
401 top = bh->b_data + dir->i_sb->s_blocksize - reclen;
402 while ((char *) de <= top) {
403 if (!ext3_check_dir_entry("ext3_add_entry", dir, de,
404 bh, offset)) {
405 __brelse(bh);
406 return -EIO;
407 }
408 if (ext3_match(namelen, name, de)) {
409 __brelse(bh);
410 return -EEXIST;
411 }
412 nlen = EXT3_DIR_REC_LEN(de->name_len);
414 if ((de->inode? rlen - nlen: rlen) >= reclen)
415 break;
416 de = (struct ext3_dir_entry_2 *)((char *)de + rlen);
417 offset += rlen;
418 }
419 if ((char *) de > top)
420 return -ENOSPC;
421 }
422
423 /* By now the buffer is marked for journaling */
424 nlen = EXT3_DIR_REC_LEN(de->name_len);
426 if (de->inode) {
427 struct ext3_dir_entry_2 *de1 = (struct ext3_dir_entry_2 *)((char *)de + nlen);
428 de1->rec_len = ext3_rec_len_to_disk(rlen - nlen);
429 de->rec_len = ext3_rec_len_to_disk(nlen);
430 de = de1;
431 }
433 if (inode) {
435 ext3_set_de_type(dir->i_sb, de, inode->i_mode);
436 } else
437 de->inode = 0;
438 de->name_len = (__u8)namelen;
439 memcpy(de->name, name, namelen);
440
441 /*
442 * XXX shouldn't update any times until successful
443 * completion of syscall, but too many callers depend
444 * on this.
445 *
446 * XXX similarly, too many callers depend on
447 * ext4_new_inode() setting the times, but error
448 * recovery deletes the inode, so the worst that can
449 * happen is that the times are slightly out of date
450 * and/or different from the directory change time.
451 */
452 dir->i_mtime = dir->i_ctime = ext3_current_time(dir);
454 dir->i_version++;
456 set_buffer_dirty(bh);
457 __brelse(bh);
458 return 0;
459}
#define EEXIST
Definition: acclib.h:88
#define EIO
Definition: acclib.h:81
unsigned int dir
Definition: maze.c:112
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#define ENOSPC
Definition: errno.h:34
int ext3_check_dir_entry(const char *function, struct inode *dir, struct ext3_dir_entry_2 *de, struct buffer_head *bh, unsigned long offset)
Definition: generic.c:2209
static __le16 ext3_rec_len_to_disk(unsigned len)
Definition: ext3_fs.h:880
#define EXT3_DIR_REC_LEN(len)
Definition: ext3_fs.h:867
#define EXT3_FT_UNKNOWN
Definition: ext3_fs.h:786
static unsigned ext3_rec_len_from_disk(__le16 dlen)
Definition: ext3_fs.h:871
GLint namelen
Definition: glext.h:7232
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLintptr offset
Definition: glext.h:5920
__u32 ext3_current_time(struct inode *in)
Definition: htree.c:204
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
void ext3_set_de_type(struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
Definition: htree.c:347
void ext3_update_dx_flag(struct inode *inode)
Definition: htree.c:368
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define cpu_to_le32
Definition: module.h:148
void __brelse(struct buffer_head *)
Definition: linux.c:808
#define err(...)
#define __u8
Definition: types.h:12
char * b_data
Definition: module.h:735
Definition: fs.h:117
struct dentry::@708 d_name
struct dentry * d_parent
Definition: fs.h:124
Definition: ext3_fs.h:774
char name[EXT3_NAME_LEN]
Definition: ext3_fs.h:779
__le32 inode
Definition: ext3_fs.h:775
__u8 name_len
Definition: ext3_fs.h:777
__le16 rec_len
Definition: ext3_fs.h:776
__u8 file_type
Definition: ext3_fs.h:778
Definition: fs.h:78
__u32 i_ino
Definition: fs.h:79
umode_t i_mode
Definition: fs.h:87
Definition: name.c:39

Referenced by ext3_add_entry().

◆ DEC_OBJ_CNT()

__inline ULONG DEC_OBJ_CNT ( PULONG  _C)

Definition at line 982 of file ext2fs.h.

982 {
983 if (*_C <= 0) {
984 DbgBreak();
985 }
986 return InterlockedDecrement(_C);
987}
#define InterlockedDecrement
Definition: armddk.h:52
#define DbgBreak()
Definition: ext2fs.h:46

◆ descriptor_loc()

ext3_fsblk_t descriptor_loc ( struct super_block sb,
ext3_fsblk_t  logical_sb_block,
unsigned int  nr 
)

Definition at line 2736 of file generic.c.

2738{
2739 struct ext3_sb_info *sbi = EXT3_SB(sb);
2740 ext3_group_t bg, first_meta_bg;
2741 int has_super = 0;
2742
2743 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
2744
2746 nr < first_meta_bg)
2747 return logical_sb_block + nr + 1;
2748 bg = sbi->s_desc_per_block * nr;
2749 if (ext3_bg_has_super(sb, bg))
2750 has_super = 1;
2751 return (has_super + ext3_group_first_block_no(sb, bg));
2752}
superblock * sb
Definition: btrfs.c:4261
#define EXT3_SB(sb)
Definition: ext3_fs.h:615
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
#define EXT4_FEATURE_INCOMPAT_META_BG
Definition: ext3_fs.h:708
unsigned int ext3_group_t
Definition: ext3_fs_i.h:34
int ext3_bg_has_super(struct super_block *sb, ext3_group_t group)
Definition: generic.c:2686
#define le32_to_cpu
Definition: module.h:149
ULONG nr
Definition: thread.c:7
struct ext3_super_block * s_es
Definition: ext3_fs_sb.h:61
unsigned long s_desc_per_block
Definition: ext3_fs_sb.h:39

Referenced by Ext2LoadGroup().

◆ do_split()

struct ext3_dir_entry_2 * do_split ( struct ext2_icb icb,
struct inode dir,
struct buffer_head **  bh,
struct dx_frame *  frame,
struct dx_hash_info *  hinfo,
int error 
)

◆ DriverUnload()

VOID DriverUnload ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 15 of file green.c.

16{
17 // nothing to do here yet
18}

◆ Ex2ProcessMountPoint()

NTSTATUS Ex2ProcessMountPoint ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_MOUNT_POINT  MountPoint,
IN ULONG  Length 
)

Definition at line 723 of file devctl.c.

728{
731 WCHAR Buffer[] = L"\\DosDevices\\Global\\Z:";
733
735
736 _SEH2_TRY {
737
738 ASSERT(IrpContext != NULL);
739 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
740 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
741
742 DeviceObject = IrpContext->DeviceObject;
746 }
747
748 if (Length != sizeof(EXT2_MOUNT_POINT) ||
749 MountPoint->Magic != EXT2_APP_MOUNTPOINT_MAGIC) {
752 }
753
755 Buffer[12] = MountPoint->Link[0];
756
757 switch (MountPoint->Command) {
758
760 RtlInitUnicodeString(&Target, &MountPoint->Name[0]);
762 break;
763
766 break;
767
768 default:
770 }
771
772 } _SEH2_FINALLY {
773
774 if (!IrpContext->ExceptionInProgress) {
775 Ext2CompleteIrpContext(IrpContext, status);
776 }
777 } _SEH2_END;
778
779 return status;
780}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define APP_CMD_DEL_DOS_SYMLINK
Definition: common.h:263
#define EXT2_APP_MOUNTPOINT_MAGIC
Definition: common.h:252
#define APP_CMD_ADD_DOS_SYMLINK
Definition: common.h:262
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:616
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_LEAVE
Definition: filesup.c:20
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ps.c:97
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static int Link(const char **args)
Definition: vfdcmd.c:2414
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Ext2DeviceControl().

◆ Ex2ProcessUserPerfStat()

NTSTATUS Ex2ProcessUserPerfStat ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_QUERY_PERFSTAT  QueryPerf,
IN ULONG  Length 
)

Definition at line 640 of file devctl.c.

645{
646
647#ifndef __REACTOS__
649#endif
651
652 BOOLEAN GlobalDataResourceAcquired = FALSE;
654
655 _SEH2_TRY {
656
657 ASSERT(IrpContext != NULL);
658 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
659 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
660
661 DeviceObject = IrpContext->DeviceObject;
663
664 if (QueryPerf->Magic != EXT2_QUERY_PERFSTAT_MAGIC) {
667 }
668
669 if (QueryPerf->Command != IOCTL_APP_QUERY_PERFSTAT) {
672 }
673
678 }
679
681 GlobalDataResourceAcquired = TRUE;
682
684 QueryPerf->Flags = EXT2_QUERY_PERFSTAT_VER2;
685 QueryPerf->PerfStatV2 = Ext2Global->PerfStat;
686 } else {
687 memcpy(&QueryPerf->PerfStatV1.Irps[0], &Ext2Global->PerfStat.Irps[0],
689 memcpy(&QueryPerf->PerfStatV1.Unit, &Ext2Global->PerfStat.Unit,
690 sizeof(EXT2_STAT_ARRAY_V1));
691 memcpy(&QueryPerf->PerfStatV1.Current, &Ext2Global->PerfStat.Current,
692 sizeof(EXT2_STAT_ARRAY_V1));
693 memcpy(&QueryPerf->PerfStatV1.Size, &Ext2Global->PerfStat.Size,
694 sizeof(EXT2_STAT_ARRAY_V1));
695 memcpy(&QueryPerf->PerfStatV1.Total, &Ext2Global->PerfStat.Total,
696 sizeof(EXT2_STAT_ARRAY_V1));
697 }
698
699 } else {
702 }
703
704 if (NT_SUCCESS(Status)) {
705 IrpContext->Irp->IoStatus.Information = Length;
706 }
707
708 } _SEH2_FINALLY {
709
710 if (GlobalDataResourceAcquired) {
712 }
713
714 if (!IrpContext->ExceptionInProgress) {
715 Ext2CompleteIrpContext(IrpContext, Status);
716 }
717 } _SEH2_END
718
719 return Status;
720}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXT2_QUERY_PERFSTAT_SZV1
Definition: common.h:248
#define IOCTL_APP_QUERY_PERFSTAT
Definition: common.h:8
#define EXT2_QUERY_PERFSTAT_VER2
Definition: common.h:236
#define EXT2_QUERY_PERFSTAT_SZV2
Definition: common.h:249
#define EXT2_QUERY_PERFSTAT_MAGIC
Definition: common.h:235
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
Unit
Definition: gdiplusenums.h:26
Status
Definition: gdiplustypes.h:25
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
EXT2_PERF_STATISTICS_V2 PerfStat
Definition: ext2fs.h:582
ERESOURCE Resource
Definition: ext2fs.h:519
struct _EXT2_PERF_STATISTICS_V2::@684 Irps[IRP_MJ_MAXIMUM_FUNCTION+1]
EXT2_STAT_ARRAY_V2 Unit
Definition: common.h:131
EXT2_STAT_ARRAY_V2 Total
Definition: common.h:140
EXT2_STAT_ARRAY_V2 Size
Definition: common.h:137
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by Ext2DeviceControl().

◆ ext2_destroy_linux()

void ext2_destroy_linux ( )

Definition at line 1019 of file linux.c.

1020{
1022}
void ext2_destroy_bh()
Definition: linux.c:318

Referenced by DriverEntry().

◆ ext2_init_linux()

int ext2_init_linux ( )

Definition at line 1004 of file linux.c.

1005{
1006 int rc = 0;
1007
1008 rc = ext2_init_bh();
1009 if (rc != 0) {
1010 goto errorout;
1011 }
1012
1013errorout:
1014
1015 return rc;
1016}
int ext2_init_bh()
Definition: linux.c:300

Referenced by DriverEntry().

◆ Ext2AcquireFileForCcFlush()

NTSTATUS Ext2AcquireFileForCcFlush ( IN PFILE_OBJECT  FileObject,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 1135 of file fastio.c.

1139{
1140 PEXT2_FCB Fcb = FileObject->FsContext;
1141
1142 if (Fcb->Header.Resource != NULL) {
1144 }
1145
1146 DEBUG(FASTIO_DEBUG_LEVEL, ("Ext2AcquireFileForCcFlush: Fcb=%p\n", Fcb));
1147
1148 return STATUS_SUCCESS;
1149}
#define DEBUG(args)
Definition: rdesktop.h:129
_In_ PFCB Fcb
Definition: cdprocs.h:159
#define FASTIO_DEBUG_LEVEL
Definition: fastio.c:20
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:925
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

Referenced by DriverEntry().

◆ Ext2AcquireFileForModWrite()

NTSTATUS Ext2AcquireFileForModWrite ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  EndingOffset,
OUT PERESOURCE ResourceToRelease,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 1081 of file fastio.c.

1088{
1089 BOOLEAN ResourceAcquired = FALSE;
1090
1091 PEXT2_FCB Fcb = FileObject->FsContext;
1092
1093 *ResourceToRelease = Fcb->Header.Resource;
1095 if (!ResourceAcquired) {
1097 }
1098
1099 DEBUG(FASTIO_DEBUG_LEVEL, ("Ext2AcquireFileForModWrite: Fcb=%p Acquired=%d\n",
1100 Fcb, ResourceAcquired));
1101
1102 return (ResourceAcquired ? STATUS_SUCCESS : STATUS_CANT_WAIT);
1103}
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
_In_ PLARGE_INTEGER _Out_ struct _ERESOURCE ** ResourceToRelease
Definition: iotypes.h:1598

Referenced by DriverEntry().

◆ Ext2AcquireForCreateSection()

VOID Ext2AcquireForCreateSection ( IN PFILE_OBJECT  FileObject)

Definition at line 1043 of file fastio.c.

1047{
1048 PEXT2_FCB Fcb = FileObject->FsContext;
1049
1050 if (Fcb->Header.Resource != NULL) {
1052 }
1053
1054 DEBUG(FASTIO_DEBUG_LEVEL, ("Ext2AcquireForCreateSection: Fcb=%p\n", Fcb));
1055}

Referenced by DriverEntry().

◆ Ext2AcquireForLazyWrite()

BOOLEAN Ext2AcquireForLazyWrite ( IN PVOID  Context,
IN BOOLEAN  Wait 
)

Definition at line 27 of file cmcb.c.

30{
31 //
32 // On a readonly filesystem this function still has to exist but it
33 // doesn't need to do anything.
34
36
38 ASSERT(Fcb != NULL);
40 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
41#if EXT2_DEBUG
42 DEBUG(CMCB_DEBUG_LEVEL, ("Ext2AcquireForLazyWrite: %s %s Fcb=%p\n",
43 Ext2GetCurrentProcessName(), "ACQUIRE_FOR_LAZY_WRITE", Fcb));
44#endif
46 return FALSE;
47 }
48
49 ASSERT(Fcb->LazyWriterThread == NULL);
50 Fcb->LazyWriterThread = PsGetCurrentThread();
51
54
55 return TRUE;
56}
#define CMCB_DEBUG_LEVEL
Definition: cmcb.c:20
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define Ext2GetCurrentProcessName()
Definition: ext2fs.h:1489
struct _EXT2_FCB * PEXT2_FCB
#define FSRTL_CACHE_TOP_LEVEL_IRP
Definition: fsrtltypes.h:60
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
ULONG Type
Definition: ntfs.h:95
ULONG Size
Definition: ntfs.h:96
NTFSIDENTIFIER Identifier
Definition: ntfs.h:515
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170

Referenced by DriverEntry().

◆ Ext2AcquireForReadAhead()

BOOLEAN Ext2AcquireForReadAhead ( IN PVOID  Context,
IN BOOLEAN  Wait 
)

Definition at line 92 of file cmcb.c.

94{
96
97 ASSERT(Fcb != NULL);
99 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
100
101 DEBUG(CMCB_DEBUG_LEVEL, ("Ext2AcquireForReadAhead: i=%xh Fcb=%p\n",
102 Fcb->Mcb->Inode.i_ino, Fcb));
103
105 return FALSE;
108
109 return TRUE;
110}
CD_MCB Mcb
Definition: cdstruc.h:1016

Referenced by DriverEntry().

◆ Ext2AddBlockExtent()

BOOLEAN Ext2AddBlockExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Start,
IN ULONG  Block,
IN ULONG  Number 
)

Definition at line 1027 of file memory.c.

1034{
1035 LONGLONG Vbn = 0;
1036 LONGLONG Lbn = 0;
1037 LONGLONG Length = 0;
1038
1039 Vbn = ((LONGLONG) Start) << BLOCK_BITS;
1040 Lbn = ((LONGLONG) Block) << BLOCK_BITS;
1042
1043 if (Mcb) {
1044#if EXT2_DEBUG
1045 ULONG _block = 0, _mapped = 0;
1046 BOOLEAN _rc = Ext2LookupBlockExtent(Vcb, Mcb, Start, &_block, &_mapped);
1047 if (_rc && _block != 0 && (_block != Block)) {
1048 DbgBreak();
1049 }
1050#endif
1051 return Ext2AddMcbExtent(Vcb, Mcb, Vbn, Lbn, Length);
1052
1053 }
1054
1055 ASSERT(Start == Block);
1056 return Ext2AddVcbExtent(Vcb, Vbn, Length);
1057}
#define BLOCK_BITS
Definition: stream.h:22
BOOLEAN Ext2LookupBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN PULONG Block, IN PULONG Mapped)
Definition: memory.c:1061
BOOLEAN Ext2AddMcbExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG Length)
Definition: memory.c:790
BOOLEAN Ext2AddVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
Definition: memory.c:648
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:348
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
_Must_inspect_result_ _In_ LONGLONG _In_ LONGLONG Lbn
Definition: fsrtlfuncs.h:480
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG
Definition: typedefs.h:59
@ Start
Definition: partlist.h:33

Referenced by Ext2BuildExtents(), Ext2ExpandBlock(), Ext2ExpandExtent(), Ext2ExpandLast(), Ext2InitializeZone(), submit_bh_mdl(), and submit_bh_pin().

◆ Ext2AddEntry()

NTSTATUS Ext2AddEntry ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Dcb,
IN struct inode Inode,
IN PUNICODE_STRING  FileName,
OUT struct dentry **  dentry 
)

◆ Ext2AddMcbExtent()

BOOLEAN Ext2AddMcbExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN LONGLONG  Vbn,
IN LONGLONG  Lbn,
IN LONGLONG  Length 
)

Definition at line 790 of file memory.c.

797{
798 ULONG TriedTimes = 0;
799 LONGLONG Base = 0;
800 UCHAR Bits = 0;
801 BOOLEAN rc = FALSE;
802
804 Bits = (UCHAR)BLOCK_BITS;
805
806 ASSERT ((Vbn & (Base - 1)) == 0);
807 ASSERT ((Lbn & (Base - 1)) == 0);
808 ASSERT ((Length & (Base - 1)) == 0);
809
810 Vbn = (Vbn >> Bits) + 1;
811 Lbn = (Lbn >> Bits) + 1;
812 Length = (Length >> Bits);
813
814Again:
815
816 _SEH2_TRY {
817
819 &Mcb->Extents,
820 Vbn,
821 Lbn,
822 Length
823 );
824
826
827 DbgBreak();
828 rc = FALSE;
829 } _SEH2_END;
830
831 if (!rc && ++TriedTimes < 10) {
832 Ext2Sleep(TriedTimes * 100);
833 goto Again;
834 }
835
836 DEBUG(DL_EXT, ("Ext2AddMcbExtent: Vbn=%I64xh Lbn=%I64xh Length=%I64xh,"
837 " rc=%d Runs=%u\n", Vbn, Lbn, Length, rc,
838 FsRtlNumberOfRunsInLargeMcb(&Mcb->Extents)));
839
840 if (rc) {
841 Ext2CheckExtent(&Mcb->Extents, Vbn, Lbn, Length, TRUE);
842 }
843
844 return rc;
845}
#define BLOCK_SIZE
Definition: dlist.c:220
VOID Ext2CheckExtent(PLARGE_MCB Zone, LONGLONG Vbn, LONGLONG Lbn, LONGLONG Length, BOOLEAN bAdded)
Definition: memory.c:583
#define DL_EXT
Definition: ext2fs.h:1443
VOID Ext2Sleep(ULONG ms)
Definition: misc.c:297
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOLEAN NTAPI FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG SectorCount)
Definition: largemcb.c:288
ULONG NTAPI FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:765
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by Ext2AddBlockExtent().

◆ Ext2AddMcbMetaExts()

BOOLEAN Ext2AddMcbMetaExts ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Block,
IN ULONG  Length 
)

Definition at line 941 of file memory.c.

947{
948 ULONG TriedTimes = 0;
949 LONGLONG Lbn = Block + 1;
950 BOOLEAN rc = TRUE;
951
952Again:
953
954 _SEH2_TRY {
955
957 &Mcb->MetaExts,
958 Lbn,
959 Lbn,
960 Length
961 );
962
964
965 DbgBreak();
966 rc = FALSE;
967 } _SEH2_END;
968
969 if (!rc && ++TriedTimes < 10) {
970 Ext2Sleep(TriedTimes * 100);
971 goto Again;
972 }
973
974 DEBUG(DL_EXT, ("Ext2AddMcbMetaExts: Block: %xh-%xh rc=%d Runs=%u\n", Block,
975 Length, rc, FsRtlNumberOfRunsInLargeMcb(&Mcb->MetaExts)));
976
977 if (rc) {
978 Ext2CheckExtent(&Mcb->MetaExts, Lbn, Lbn, Length, TRUE);
979 }
980
981 return rc;
982}

Referenced by Ext2ExpandBlock(), Ext2ExpandLast(), and Ext2GetBlock().

◆ Ext2AddVcbExtent()

BOOLEAN Ext2AddVcbExtent ( IN PEXT2_VCB  Vcb,
IN LONGLONG  Vbn,
IN LONGLONG  Length 
)

Definition at line 648 of file memory.c.

653{
654 ULONG TriedTimes = 0;
655
656 LONGLONG Offset = 0;
657 BOOLEAN rc = FALSE;
658
659 Offset = Vbn & (~(Vcb->IoUnitSize - 1));
660 Length = (Vbn - Offset + Length + Vcb->IoUnitSize - 1) &
661 ~(Vcb->IoUnitSize - 1);
662
663 ASSERT ((Offset & (Vcb->IoUnitSize - 1)) == 0);
664 ASSERT ((Length & (Vcb->IoUnitSize - 1)) == 0);
665
666 Offset = (Offset >> Vcb->IoUnitBits) + 1;
667 Length = (Length >> Vcb->IoUnitBits);
668
669Again:
670
671 _SEH2_TRY {
673 &Vcb->Extents,
674 Offset,
675 Offset,
676 Length
677 );
679 DbgBreak();
680 rc = FALSE;
681 } _SEH2_END;
682
683 if (!rc && ++TriedTimes < 10) {
684 Ext2Sleep(TriedTimes * 100);
685 goto Again;
686 }
687
688 DEBUG(DL_EXT, ("Ext2AddVcbExtent: Vbn=%I64xh Length=%I64xh,"
689 " rc=%d Runs=%u\n", Offset, Length, rc,
690 FsRtlNumberOfRunsInLargeMcb(&Vcb->Extents)));
691
692 if (rc) {
694 }
695
696 return rc;
697}
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101

Referenced by Ext2AddBlockExtent(), Ext2FreeBlock(), Ext2GetBlock(), Ext2TruncateBlock(), and Ext2WriteVolume().

◆ Ext2AllocateCcb()

PEXT2_CCB Ext2AllocateCcb ( ULONG  Flags,
PEXT2_MCB  SymLink 
)

Definition at line 320 of file memory.c.

321{
323
324 Ccb = (PEXT2_CCB) (ExAllocateFromNPagedLookasideList(
326 if (!Ccb) {
327 return NULL;
328 }
329
330 DEBUG(DL_RES, ( "ExtAllocateCcb: Ccb created: %ph.\n", Ccb));
331
332 RtlZeroMemory(Ccb, sizeof(EXT2_CCB));
333
335 Ccb->Identifier.Size = sizeof(EXT2_CCB);
336 Ccb->Flags = Flags;
337
338 Ccb->SymLink = SymLink;
339 if (SymLink) {
340 ASSERT(SymLink->Refercount > 0);
341 Ext2ReferMcb(SymLink);
342 DEBUG(DL_INF, ( "ExtAllocateCcb: Ccb SymLink: %wZ.\n",
343 &Ccb->SymLink->FullName));
344 }
345
346 Ccb->DirectorySearchPattern.Length = 0;
347 Ccb->DirectorySearchPattern.MaximumLength = 0;
348 Ccb->DirectorySearchPattern.Buffer = 0;
349
350 INC_MEM_COUNT(PS_CCB, Ccb, sizeof(EXT2_CCB));
351
352 return Ccb;
353}
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
#define PS_CCB
Definition: common.h:19
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
struct _EXT2_CCB EXT2_CCB
#define DL_INF
Definition: ext2fs.h:1436
struct _EXT2_CCB * PEXT2_CCB
#define Ext2ReferMcb(Mcb)
Definition: ext2fs.h:995
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:607
#define DL_RES
Definition: ext2fs.h:1440
NPAGED_LOOKASIDE_LIST Ext2CcbLookasideList
Definition: ext2fs.h:555
ULONG Refercount
Definition: ext2fs.h:926
ULONG Flags
Definition: ntfs.h:536
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by Ext2CreateFile(), and Ext2CreateVolume().

◆ Ext2AllocateEntry()

struct dentry * Ext2AllocateEntry ( )

Definition at line 416 of file memory.c.

417{
418 struct dentry *de;
419
420 de = (struct dentry *)ExAllocateFromNPagedLookasideList(
422 if (!de) {
423 return NULL;
424 }
425
426 RtlZeroMemory(de, sizeof(struct dentry));
427 INC_MEM_COUNT(PS_DENTRY, de, sizeof(struct dentry));
428
429 return de;
430}
#define PS_DENTRY
Definition: common.h:34
NPAGED_LOOKASIDE_LIST Ext2DentryLookasideList
Definition: ext2fs.h:558

Referenced by Ext2BuildEntry().

◆ Ext2AllocateExtent()

PEXT2_EXTENT Ext2AllocateExtent ( )

Definition at line 488 of file memory.c.

489{
491
492 Extent = (PEXT2_EXTENT)ExAllocateFromNPagedLookasideList(
494 if (!Extent) {
495 return NULL;
496 }
497
500
501 return Extent;
502}
#define PS_EXTENT
Definition: common.h:21
struct _EXT2_EXTENT * PEXT2_EXTENT
NPAGED_LOOKASIDE_LIST Ext2ExtLookasideList
Definition: ext2fs.h:557

Referenced by Ext2BuildExtents(), and Ext2WriteVolume().

◆ Ext2AllocateFcb()

PEXT2_FCB Ext2AllocateFcb ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb 
)

Definition at line 131 of file memory.c.

135{
137
139
140 Fcb = (PEXT2_FCB) ExAllocateFromNPagedLookasideList(
142
143 if (!Fcb) {
144 return NULL;
145 }
146
147 RtlZeroMemory(Fcb, sizeof(EXT2_FCB));
149 Fcb->Identifier.Size = sizeof(EXT2_FCB);
150
151#ifndef _WIN2K_TARGET_
152 ExInitializeFastMutex(&Fcb->Mutex);
153 FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->Mutex);
154#endif
155
156 FsRtlInitializeOplock(&Fcb->Oplock);
158 &Fcb->FileLockAnchor,
159 NULL,
160 NULL );
161
162 Fcb->OpenHandleCount = 0;
163 Fcb->ReferenceCount = 0;
164 Fcb->Vcb = Vcb;
165 Fcb->Inode = &Mcb->Inode;
166
167 ASSERT(Mcb->Fcb == NULL);
169 Fcb->Mcb = Mcb;
170 Mcb->Fcb = Fcb;
171
172 DEBUG(DL_RES, ("Ext2AllocateFcb: Fcb %p created: %wZ.\n",
173 Fcb, &Fcb->Mcb->FullName));
174
176 Fcb->Header.NodeTypeCode = (USHORT) EXT2FCB;
177 Fcb->Header.NodeByteSize = sizeof(EXT2_FCB);
178 Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
179 Fcb->Header.Resource = &(Fcb->MainResource);
180 Fcb->Header.PagingIoResource = &(Fcb->PagingIoResource);
181
182 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
183 Fcb->Header.ValidDataLength.QuadPart = Mcb->Inode.i_size;
184 Fcb->Header.AllocationSize.QuadPart = CEILING_ALIGNED(ULONGLONG,
185 Fcb->Header.FileSize.QuadPart, (ULONGLONG)Vcb->BlockSize);
186
187 Fcb->SectionObject.DataSectionObject = NULL;
188 Fcb->SectionObject.SharedCacheMap = NULL;
189 Fcb->SectionObject.ImageSectionObject = NULL;
190
193
195
196 INC_MEM_COUNT(PS_FCB, Fcb, sizeof(EXT2_FCB));
197
198 return Fcb;
199}
#define PS_FCB
Definition: common.h:18
VOID Ext2InsertFcb(PEXT2_VCB Vcb, PEXT2_FCB Fcb)
Definition: memory.c:309
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
struct _EXT2_FCB EXT2_FCB
#define CEILING_ALIGNED(T, A, B)
Definition: ext2fs.h:111
VOID NTAPI FsRtlInitializeFileLock(IN PFILE_LOCK FileLock, IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL)
Definition: filelock.c:1262
@ FastIoIsNotPossible
Definition: fsrtltypes.h:240
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1624
VOID NTAPI FsRtlInitializeOplock(IN OUT POPLOCK Oplock)
Definition: oplock.c:1400
unsigned short USHORT
Definition: pedump.c:61
NPAGED_LOOKASIDE_LIST Ext2FcbLookasideList
Definition: ext2fs.h:554
PVCB Vcb
Definition: cdstruc.h:933
ERESOURCE PagingIoResource
Definition: ntfs.h:527
ULONG OpenHandleCount
Definition: ntfs.h:537
ERESOURCE MainResource
Definition: ntfs.h:528
uint64_t ULONGLONG
Definition: typedefs.h:67
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274

Referenced by Ext2CreateFile(), Ext2DeleteFile(), Ext2DeleteReparsePoint(), Ext2SetLinkInfo(), Ext2SetRenameInfo(), and Ext2SetReparsePoint().

◆ Ext2AllocateInode()

PEXT2_INODE Ext2AllocateInode ( PEXT2_VCB  Vcb)

Definition at line 387 of file memory.c.

388{
389 PVOID inode = NULL;
390
391 inode = ExAllocateFromNPagedLookasideList(
392 &(Vcb->InodeLookasideList));
393 if (!inode) {
394 return NULL;
395 }
396
398
399 DEBUG(DL_INF, ("ExtAllocateInode: Inode created: %ph.\n", inode));
401
402 return inode;
403}
#define PS_EXT2_INODE
Definition: common.h:33
#define INODE_SIZE
Definition: ext2fs.h:92

Referenced by ext4_fs_get_xattr_ref().

◆ Ext2AllocateIrpContext()

PEXT2_IRP_CONTEXT Ext2AllocateIrpContext ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 35 of file memory.c.

37{
39 PEXT2_IRP_CONTEXT IrpContext;
40
42 ASSERT(Irp != NULL);
43
45
46 IrpContext = (PEXT2_IRP_CONTEXT) (
47 ExAllocateFromNPagedLookasideList(
49
50 if (IrpContext == NULL) {
51 return NULL;
52 }
53
54 RtlZeroMemory(IrpContext, sizeof(EXT2_IRP_CONTEXT) );
55
56 IrpContext->Identifier.Type = EXT2ICX;
57 IrpContext->Identifier.Size = sizeof(EXT2_IRP_CONTEXT);
58
59 IrpContext->Irp = Irp;
60 IrpContext->MajorFunction = irpSp->MajorFunction;
61 IrpContext->MinorFunction = irpSp->MinorFunction;
62 IrpContext->DeviceObject = DeviceObject;
63 IrpContext->FileObject = irpSp->FileObject;
64 if (NULL != IrpContext->FileObject) {
65 IrpContext->Fcb = (PEXT2_FCB)IrpContext->FileObject->FsContext;
66 IrpContext->Ccb = (PEXT2_CCB)IrpContext->FileObject->FsContext2;
67 }
68
69 if (IrpContext->FileObject != NULL) {
70 IrpContext->RealDevice = IrpContext->FileObject->DeviceObject;
71 } else if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL) {
72 if (irpSp->Parameters.MountVolume.Vpb) {
73 IrpContext->RealDevice = irpSp->Parameters.MountVolume.Vpb->RealDevice;
74 }
75 }
76
77 if (IsFlagOn(irpSp->Flags, SL_WRITE_THROUGH)) {
79 }
80
83 }
84
85 if (IrpContext->MajorFunction == IRP_MJ_CLEANUP ||
86 IrpContext->MajorFunction == IRP_MJ_CLOSE ||
87 IrpContext->MajorFunction == IRP_MJ_SHUTDOWN ||
89 IrpContext->MajorFunction == IRP_MJ_PNP ) {
90
91 if (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
92 IrpContext->MajorFunction == IRP_MJ_PNP) {
96 }
97 } else {
99 }
100
101 } else if (IoIsOperationSynchronous(Irp)) {
102
103 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
104 }
105
106 IrpContext->IsTopLevel = (IoGetTopLevelIrp() == Irp);
107 IrpContext->ExceptionInProgress = FALSE;
108 INC_IRP_COUNT(IrpContext);
109
110 return IrpContext;
111}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1215
_In_ PIRP Irp
Definition: csq.h:116
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
struct ext2_icb EXT2_IRP_CONTEXT
#define IRP_CONTEXT_FLAG_VERIFY_READ
Definition: ext2fs.h:1092
#define IRP_CONTEXT_FLAG_WRITE_THROUGH
Definition: ext2fs.h:1088
struct ext2_icb * PEXT2_IRP_CONTEXT
#define INC_IRP_COUNT(IrpContext)
Definition: ext2fs.h:609
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
Definition: irp.c:1882
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
NPAGED_LOOKASIDE_LIST Ext2IrpContextLookasideList
Definition: ext2fs.h:553
EXT2_IDENTIFIER_TYPE Type
Definition: ext2fs.h:477
PDEVICE_OBJECT RealDevice
Definition: ext2fs.h:1063
UCHAR MajorFunction
Definition: ext2fs.h:1056
PEXT2_CCB Ccb
Definition: ext2fs.h:1069
PEXT2_FCB Fcb
Definition: ext2fs.h:1068
PDEVICE_OBJECT DeviceObject
Definition: ext2fs.h:1060
UCHAR MinorFunction
Definition: ext2fs.h:1057
EXT2_IDENTIFIER Identifier
Definition: ext2fs.h:1047
ULONG Flags
Definition: ext2fs.h:1053
PIRP Irp
Definition: ext2fs.h:1050
PFILE_OBJECT FileObject
Definition: ext2fs.h:1066
BOOLEAN IsTopLevel
Definition: ext2fs.h:1072
BOOLEAN ExceptionInProgress
Definition: ext2fs.h:1078
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
irpSp
Definition: iofuncs.h:2719
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1823
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define SL_WRITE_THROUGH
Definition: iotypes.h:1824
#define IRP_MJ_CLEANUP

Referenced by Ext2BuildRequest().

◆ Ext2AllocateMcb()

PEXT2_MCB Ext2AllocateMcb ( IN PEXT2_VCB  Vcb,
IN PUNICODE_STRING  FileName,
IN PUNICODE_STRING  Parent,
IN ULONG  FileAttr 
)

Definition at line 1430 of file memory.c.

1436{
1437 PEXT2_MCB Mcb = NULL;
1439
1440 /* need wake the reaper thread if there are many Mcb allocated */
1441 if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 4)) {
1443 }
1444
1445 /* allocate Mcb from LookasideList */
1446 Mcb = (PEXT2_MCB) (ExAllocateFromNPagedLookasideList(
1448
1449 if (Mcb == NULL) {
1450 return NULL;
1451 }
1452
1453 /* initialize Mcb header */
1454 RtlZeroMemory(Mcb, sizeof(EXT2_MCB));
1455 Mcb->Identifier.Type = EXT2MCB;
1456 Mcb->Identifier.Size = sizeof(EXT2_MCB);
1457 Mcb->FileAttr = FileAttr;
1458
1459 Mcb->Inode.i_priv = (PVOID)Mcb;
1460 Mcb->Inode.i_sb = &Vcb->sb;
1461
1462 /* initialize Mcb names */
1463 if (FileName) {
1464
1465#if EXT2_DEBUG
1466 if ( FileName->Length == 2 &&
1467 FileName->Buffer[0] == L'\\') {
1468 DEBUG(DL_RES, ( "Ext2AllocateMcb: Root Mcb is to be created !\n"));
1469 }
1470
1471 if ( FileName->Length == 2 &&
1472 FileName->Buffer[0] == L'.') {
1473 DbgBreak();
1474 }
1475
1476 if ( FileName->Length == 4 &&
1477 FileName->Buffer[0] == L'.' &&
1478 FileName->Buffer[1] == L'.' ) {
1479 DbgBreak();
1480 }
1481#endif
1482
1483 if (( FileName->Length >= 4 && FileName->Buffer[0] == L'.') &&
1484 ((FileName->Length == 4 && FileName->Buffer[1] != L'.') ||
1485 FileName->Length >= 6 )) {
1486 SetFlag(Mcb->FileAttr, FILE_ATTRIBUTE_HIDDEN);
1487 }
1488
1489 if (!Ext2BuildName(&Mcb->ShortName, FileName, NULL)) {
1490 goto errorout;
1491 }
1492 if (!Ext2BuildName(&Mcb->FullName, FileName, Parent)) {
1493 goto errorout;
1494 }
1495 }
1496
1497 /* initialize Mcb Extents, it will raise an expcetion if failed */
1498 _SEH2_TRY {
1503 DbgBreak();
1504 } _SEH2_END;
1505
1506 if (!NT_SUCCESS(Status)) {
1507 goto errorout;
1508 }
1509
1510 INC_MEM_COUNT(PS_MCB, Mcb, sizeof(EXT2_MCB));
1511 DEBUG(DL_INF, ( "Ext2AllocateMcb: Mcb %wZ created.\n", &Mcb->FullName));
1512
1513 return Mcb;
1514
1515errorout:
1516
1517 if (Mcb) {
1518
1519 if (Mcb->ShortName.Buffer) {
1520 DEC_MEM_COUNT(PS_MCB_NAME, Mcb->ShortName.Buffer,
1521 Mcb->ShortName.MaximumLength);
1522 Ext2FreePool(Mcb->ShortName.Buffer, EXT2_FNAME_MAGIC);
1523 }
1524
1525 if (Mcb->FullName.Buffer) {
1526 DEC_MEM_COUNT(PS_MCB_NAME, Mcb->FullName.Buffer,
1527 Mcb->FullName.MaximumLength);
1528 Ext2FreePool(Mcb->FullName.Buffer, EXT2_FNAME_MAGIC);
1529 }
1530
1531 ExFreeToNPagedLookasideList(&(Ext2Global->Ext2McbLookasideList), Mcb);
1532 }
1533
1534 return NULL;
1535}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
#define PS_MCB
Definition: common.h:20
#define PS_MCB_NAME
Definition: common.h:25
BOOLEAN Ext2BuildName(IN OUT PUNICODE_STRING Target, IN PUNICODE_STRING File, IN PUNICODE_STRING Parent)
Definition: memory.c:1361
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define NonPagedPool
Definition: env_spec_w32.h:307
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define EXT2_FNAME_MAGIC
Definition: ext2fs.h:298
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:608
struct _EXT2_MCB * PEXT2_MCB
Definition: ext2fs.h:484
struct _EXT2_MCB EXT2_MCB
Definition: ext2fs.h:484
VOID NTAPI FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, IN POOL_TYPE PoolType)
Definition: largemcb.c:451
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
NPAGED_LOOKASIDE_LIST Ext2McbLookasideList
Definition: ext2fs.h:556
USHORT MaxDepth
Definition: ext2fs.h:559
EXT2_REAPER McbReaper
Definition: ext2fs.h:549
KEVENT Wait
Definition: ext2fs.h:506
void * PVOID
Definition: typedefs.h:50
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by Ext2InitializeVcb(), Ext2LoadInternalJournal(), and Ext2LookupFile().

◆ Ext2AllocatePool()

PVOID Ext2AllocatePool ( IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes,
IN ULONG  Tag 
)

Definition at line 2684 of file debug.c.

2689{
2690 return ExAllocatePoolWithTag(
2691 PoolType,
2693 Tag);
2694}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

Referenced by DriverEntry(), Ext2BuildName(), Ext2CreateFile(), Ext2ExpandLast(), Ext2FillEntry(), Ext2FollowLink(), Ext2GetReparsePoint(), Ext2LoadSuper(), Ext2QueryDirectory(), Ext2QueryExtentMappings(), Ext2QueryRegistrySettings(), Ext2QueryVolumeParams(), Ext2ReadDisk(), Ext2ReadSync(), Ext2ReadWriteBlocks(), Ext2SetParentEntry(), Ext2SetReparsePoint(), and Ext2StartFloppyFlushDpc().

◆ Ext2AllowExtendedDasdIo()

NTSTATUS Ext2AllowExtendedDasdIo ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 407 of file fsctl.c.

408{
413
414 IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
415
416 Vcb = (PEXT2_VCB) IrpSp->FileObject->FsContext;
417 Ccb = (PEXT2_CCB) IrpSp->FileObject->FsContext2;
418
419 ASSERT(Vcb != NULL);
420
421 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
422 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
423
425
426 if (Ccb) {
429 } else {
431 }
432
433 Ext2CompleteIrpContext(IrpContext, status);
434 return status;
435}
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IsMounted(Vcb)
Definition: ext2fs.h:812
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:258
struct _EXT2_VCB * PEXT2_VCB
#define CCB_ALLOW_EXTENDED_DASD_IO
Definition: ext2fs.h:1037
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

Referenced by Ext2UserFsRequest().

◆ Ext2bhReaperThread()

VOID Ext2bhReaperThread ( PVOID  Context)

Definition at line 3239 of file memory.c.

3242{
3243 PEXT2_REAPER Reaper = Context;
3244 PEXT2_VCB Vcb = NULL;
3247
3248 BOOLEAN GlobalAcquired = FALSE;
3249 BOOLEAN DidNothing = FALSE;
3250 BOOLEAN NonWait = FALSE;
3251
3252 _SEH2_TRY {
3253
3254 Reaper->Thread = PsGetCurrentThread();
3255
3256 /* wake up DirverEntry */
3257 KeSetEvent(&Reaper->Engine, 0, FALSE);
3258
3259 /* now process looping */
3260 while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3261
3262 /* wait until it is waken or it times out */
3263 if (NonWait) {
3264 Timeout.QuadPart = (LONGLONG)-10*1000*10;
3265 NonWait = FALSE;
3266 } else if (DidNothing) {
3267 Timeout.QuadPart = Timeout.QuadPart * 2;
3268 } else {
3269 Timeout.QuadPart = (LONGLONG)-10*1000*1000*10; /* 10 seconds */
3270 }
3272 &Reaper->Wait,
3273 Executive,
3274 KernelMode,
3275 FALSE,
3276 &Timeout
3277 );
3278
3279 if (IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP))
3280 break;
3281
3283
3284 /* acquire global exclusive lock */
3286 GlobalAcquired = TRUE;
3287 /* search all Vcb to get unused resources freed to system */
3288 for (Link = Ext2Global->VcbList.Flink;
3289 Link != &(Ext2Global->VcbList);
3290 Link = Link->Flink ) {
3291
3293 NonWait = Ext2QueryUnusedBH(Vcb, &List);
3294 }
3295 DidNothing = IsListEmpty(&List);
3296 if (DidNothing) {
3297 KeClearEvent(&Reaper->Wait);
3298 }
3299 if (GlobalAcquired) {
3301 GlobalAcquired = FALSE;
3302 }
3303
3304 while (!IsListEmpty(&List)) {
3305 struct buffer_head *bh;
3308 ASSERT(0 == atomic_read(&bh->b_count));
3309 free_buffer_head(bh);
3310 }
3311 }
3312
3313 } _SEH2_FINALLY {
3314
3315 if (GlobalAcquired) {
3317 }
3318
3319 KeSetEvent(&Reaper->Engine, 0, FALSE);
3320 } _SEH2_END;
3321
3323}
#define atomic_read(v)
Definition: atomic.h:23
BOOLEAN Ext2QueryUnusedBH(PEXT2_VCB Vcb, PLIST_ENTRY head)
Definition: memory.c:3186
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define EXT2_REAPER_FLAG_STOP
Definition: ext2fs.h:511
void free_buffer_head(struct buffer_head *bh)
Definition: linux.c:346
#define KernelMode
Definition: asm.h:34
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1145
static ULONG Timeout
Definition: ping.c:61
LIST_ENTRY VcbList
Definition: ext2fs.h:545
KEVENT Engine
Definition: ext2fs.h:505
ULONG Flags
Definition: ext2fs.h:508
PETHREAD Thread
Definition: ext2fs.h:504
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY b_link
Definition: module.h:724
atomic_t b_count
Definition: module.h:740
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
@ Executive
Definition: ketypes.h:415

Referenced by DriverEntry().

◆ Ext2BlockMap()

NTSTATUS Ext2BlockMap ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Index,
IN BOOLEAN  bAlloc,
OUT PULONG  pBlock,
OUT PULONG  Number 
)

Definition at line 1127 of file fileinfo.c.

1136{
1138
1139 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1140 status = Ext2MapExtent(IrpContext, Vcb, Mcb, Index,
1141 bAlloc, pBlock, Number );
1142 } else {
1143 status = Ext2MapIndirect(IrpContext, Vcb, Mcb, Index,
1144 bAlloc, pBlock, Number );
1145 }
1146
1147 return status;
1148}
NTSTATUS Ext2MapExtent(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN Alloc, OUT PULONG Block, OUT PULONG Number)
Definition: extents.c:25
NTSTATUS Ext2MapIndirect(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
Definition: indirect.c:835
#define INODE_HAS_EXTENT(i)
Definition: ext4_ext.h:228
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by Ext2BuildExtents().

◆ Ext2BuildEntry()

struct dentry * Ext2BuildEntry ( PEXT2_VCB  Vcb,
PEXT2_MCB  Dcb,
PUNICODE_STRING  FileName 
)

Definition at line 444 of file memory.c.

445{
446 OEM_STRING Oem = { 0 };
447 struct dentry *de = NULL;
449
450 _SEH2_TRY {
451
452 de = Ext2AllocateEntry();
453 if (!de) {
454 DEBUG(DL_ERR, ("Ext2BuildEntry: failed to allocate dentry.\n"));
456 }
457 de->d_sb = &Vcb->sb;
458 if (Dcb)
459 de->d_parent = Dcb->de;
460
461 Oem.MaximumLength = (USHORT)Ext2UnicodeToOEMSize(Vcb, FileName) + 1;
462 Oem.Buffer = ExAllocatePool(PagedPool, Oem.MaximumLength);
463 if (!Oem.Buffer) {
464 DEBUG(DL_ERR, ( "Ex2BuildEntry: failed to allocate OEM name.\n"));
466 }
467 de->d_name.name = Oem.Buffer;
468 RtlZeroMemory(Oem.Buffer, Oem.MaximumLength);
470 if (!NT_SUCCESS(Status)) {
471 DEBUG(DL_CP, ("Ext2BuildEntry: failed to convert %S to OEM.\n", FileName->Buffer));
473 }
474 de->d_name.len = Oem.Length;
475
476 } _SEH2_FINALLY {
477
478 if (!NT_SUCCESS(Status)) {
479 if (de)
480 Ext2FreeEntry(de);
481 }
482 } _SEH2_END;
483
484 return de;
485}
struct dentry * Ext2AllocateEntry()
Definition: memory.c:416
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4140
#define PagedPool
Definition: env_spec_w32.h:308
ULONG Ext2UnicodeToOEMSize(IN PEXT2_VCB Vcb, IN PUNICODE_STRING Unicode)
Definition: misc.c:239
NTSTATUS Ext2UnicodeToOEM(IN PEXT2_VCB Vcb, IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:261
#define DL_ERR
Definition: ext2fs.h:1434
#define DL_CP
Definition: ext2fs.h:1442
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
struct super_block * d_sb
Definition: fs.h:126
STRING OEM_STRING
Definition: umtypes.h:203

Referenced by Ext2AddEntry(), Ext2InitializeVcb(), and Ext2ScanDir().

◆ Ext2BuildExtents()

NTSTATUS Ext2BuildExtents ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONGLONG  Offset,
IN ULONG  Size,
IN BOOLEAN  bAlloc,
OUT PEXT2_EXTENT Chain 
)

Definition at line 1207 of file memory.c.

1216{
1217 ULONG Start, End;
1218 ULONG Total = 0;
1219
1220 LONGLONG Lba = 0;
1222
1224 PEXT2_EXTENT List = *Chain = NULL;
1225
1226 if (!IsZoneInited(Mcb)) {
1227 Status = Ext2InitializeZone(IrpContext, Vcb, Mcb);
1228 if (!NT_SUCCESS(Status)) {
1229 DbgBreak();
1230 }
1231 }
1232
1233 if ((IrpContext && IrpContext->Irp) &&
1234 ((IrpContext->Irp->Flags & IRP_NOCACHE) ||
1235 (IrpContext->Irp->Flags & IRP_PAGING_IO))) {
1236 Size = (Size + SECTOR_SIZE - 1) & (~(SECTOR_SIZE - 1));
1237 }
1238
1239 Start = (ULONG)(Offset >> BLOCK_BITS);
1240 End = (ULONG)((Size + Offset + BLOCK_SIZE - 1) >> BLOCK_BITS);
1241
1242 if (End > (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS) ) {
1243 End = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1244 }
1245
1246 while (Size > 0 && Start < End) {
1247
1248 ULONG Mapped = 0;
1249 ULONG Length = 0;
1250 ULONG Block = 0;
1251
1252 BOOLEAN rc = FALSE;
1253
1254 /* try to map file offset to ext2 block upon Extents cache */
1255 if (IsZoneInited(Mcb)) {
1257 Vcb,
1258 Mcb,
1259 Start,
1260 &Block,
1261 &Mapped);
1262
1263 if (!rc) {
1264 /* we likely get a sparse file here */
1265 Mapped = 1;
1266 Block = 0;
1267 }
1268 }
1269
1270 /* try to BlockMap in case failed to access Extents cache */
1271 if (!IsZoneInited(Mcb) || (bAlloc && Block == 0)) {
1272
1274 IrpContext,
1275 Vcb,
1276 Mcb,
1277 Start,
1278 bAlloc,
1279 &Block,
1280 &Mapped
1281 );
1282 if (!NT_SUCCESS(Status)) {
1283 break;
1284 }
1285
1286 /* skip wrong blocks, in case wrongly treating symlink
1287 target names as blocks, silly */
1288 if (Block >= TOTAL_BLOCKS) {
1289 Block = 0;
1290 }
1291
1292 /* add new allocated blocks to Mcb zone */
1293 if (IsZoneInited(Mcb) && Block) {
1294 if (!Ext2AddBlockExtent(Vcb, Mcb, Start, Block, Mapped)) {
1295 DbgBreak();
1296 ClearFlag(Mcb->Flags, MCB_ZONE_INITED);
1297 Ext2ClearAllExtents(&Mcb->Extents);
1298 }
1299 }
1300 }
1301
1302 /* calculate i/o extent */
1303 Lba = ((LONGLONG)Block << BLOCK_BITS) + Offset - ((LONGLONG)Start << BLOCK_BITS);
1304 Length = (ULONG)(((LONGLONG)(Start + Mapped) << BLOCK_BITS) - Offset);
1305 if (Length > Size) {
1306 Length = Size;
1307 }
1308
1309 if (0 == Length) {
1310 DbgBreak();
1311 break;
1312 }
1313
1314 Start += Mapped;
1316
1317 if (Block != 0) {
1318
1319 if (List && List->Lba + List->Length == Lba) {
1320
1321 /* it's continuous upon previous Extent */
1322 List->Length += Length;
1323
1324 } else {
1325
1326 /* have to allocate a new Extent */
1328 if (!Extent) {
1330 DbgBreak();
1331 break;
1332 }
1333
1334 Extent->Lba = Lba;
1335 Extent->Length = Length;
1336 Extent->Offset = Total;
1337
1338 /* insert new Extent to chain */
1339 if (List) {
1340 List->Next = Extent;
1341 List = Extent;
1342 } else {
1343 *Chain = List = Extent;
1344 }
1345 }
1346 } else {
1347 if (bAlloc) {
1348 DbgBreak();
1349 }
1350 }
1351
1352 Total += Length;
1353 Size -= Length;
1354 }
1355
1356 return Status;
1357}
#define SECTOR_SIZE
Definition: fs.h:22
NTSTATUS Ext2InitializeZone(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1121
PEXT2_EXTENT Ext2AllocateExtent()
Definition: memory.c:488
BOOLEAN Ext2AddBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Block, IN ULONG Number)
Definition: memory.c:1027
VOID Ext2ClearAllExtents(PLARGE_MCB Zone)
Definition: memory.c:637
NTSTATUS Ext2BlockMap(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
Definition: fileinfo.c:1127
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
#define MCB_ZONE_INITED
Definition: ext2fs.h:957
#define IsZoneInited(Mcb)
Definition: ext2fs.h:963
uint64 Length
Definition: DriveVolume.h:48
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define IRP_PAGING_IO
#define IRP_NOCACHE

Referenced by bmap(), Ext2GetRetrievalPointers(), Ext2QueryExtentMappings(), Ext2ReadInode(), and Ext2WriteInode().

◆ Ext2BuildName()

BOOLEAN Ext2BuildName ( IN OUT PUNICODE_STRING  Target,
IN PUNICODE_STRING  File,
IN PUNICODE_STRING  Parent 
)

Definition at line 1361 of file memory.c.

1366{
1367 USHORT Length = 0;
1368 USHORT ParentLen = 0;
1369 BOOLEAN bBackslash = TRUE;
1370
1371 /* free the original buffer */
1372 if (Target->Buffer) {
1373 DEC_MEM_COUNT(PS_MCB_NAME, Target->Buffer, Target->MaximumLength);
1375 Target->Length = Target->MaximumLength = 0;
1376 }
1377
1378 /* check the parent directory's name and backslash */
1379 if (Parent && Parent->Buffer && Parent->Length > 0) {
1380 ParentLen = Parent->Length / sizeof(WCHAR);
1381 if (Parent->Buffer[ParentLen - 1] == L'\\') {
1382 bBackslash = FALSE;
1383 }
1384 }
1385
1386 if (Parent == NULL || File->Buffer[0] == L'\\') {
1387 /* must be root inode */
1388 ASSERT(ParentLen == 0);
1389 bBackslash = FALSE;
1390 }
1391
1392 /* allocate and initialize new name buffer */
1393 Length = File->Length;
1394 Length += (ParentLen + (bBackslash ? 1 : 0)) * sizeof(WCHAR);
1395
1396 Target->Buffer = Ext2AllocatePool(
1397 PagedPool,
1398 Length + 2,
1400 );
1401
1402 if (!Target->Buffer) {
1403 DEBUG(DL_ERR, ( "Ex2BuildName: failed to allocate name bufer.\n"));
1404 return FALSE;
1405 }
1406 RtlZeroMemory(Target->Buffer, Length + 2);
1407
1408 if (ParentLen) {
1409 RtlCopyMemory(&Target->Buffer[0],
1410 Parent->Buffer,
1411 ParentLen * sizeof(WCHAR));
1412 }
1413
1414 if (bBackslash) {
1415 Target->Buffer[ParentLen++] = L'\\';
1416 }
1417
1418 RtlCopyMemory( &Target->Buffer[ParentLen],
1419 File->Buffer,
1420 File->Length);
1421
1422 INC_MEM_COUNT(PS_MCB_NAME, Target->Buffer, Length + 2);
1423 Target->Length = Length;
1424 Target->MaximumLength = Length + 2;
1425
1426 return TRUE;
1427}
Definition: File.h:16
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684
UINT32 Length
Definition: actbl.h:109
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by Ext2AllocateMcb(), and Ext2SetRenameInfo().

◆ Ext2BuildRequest()

NTSTATUS Ext2BuildRequest ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Referenced by DriverEntry().

◆ Ext2CheckBitmapConsistency()

BOOLEAN Ext2CheckBitmapConsistency ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

Definition at line 1899 of file memory.c.

1900{
1901 ULONG i, j, InodeBlocks;
1902
1903 for (i = 0; i < Vcb->sbi.s_groups_count; i++) {
1904
1906 struct buffer_head *bh = NULL;
1907
1908 gd = ext4_get_group_desc(&Vcb->sb, i, &bh);
1909 if (!gd)
1910 continue;
1911 Ext2CheckSetBlock(IrpContext, Vcb, ext4_block_bitmap(&Vcb->sb, gd));
1912 Ext2CheckSetBlock(IrpContext, Vcb, ext4_inode_bitmap(&Vcb->sb, gd));
1913
1914
1915 if (i == Vcb->sbi.s_groups_count - 1) {
1916 InodeBlocks = ((INODES_COUNT % INODES_PER_GROUP) *
1917 Vcb->InodeSize + Vcb->BlockSize - 1) /
1918 (Vcb->BlockSize);
1919 } else {
1920 InodeBlocks = (INODES_PER_GROUP * Vcb->InodeSize +
1921 Vcb->BlockSize - 1) / (Vcb->BlockSize);
1922 }
1923
1924 for (j = 0; j < InodeBlocks; j++ )
1925 Ext2CheckSetBlock(IrpContext, Vcb, ext4_inode_table(&Vcb->sb, gd) + j);
1926
1927 fini_bh(&bh);
1928 }
1929
1930 return TRUE;
1931}
BOOLEAN Ext2CheckSetBlock(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, LONGLONG Block)
Definition: memory.c:1848
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2459
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2467
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2976
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2475
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define INODES_COUNT
Definition: ext2fs.h:97
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static void fini_bh(struct buffer_head **bh)
Definition: module.h:961

Referenced by Ext2InitializeVcb().

◆ Ext2CheckDismount()

BOOLEAN Ext2CheckDismount ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN BOOLEAN  bForce 
)

Definition at line 2592 of file fsctl.c.

2596{
2597 KIRQL Irql;
2598 PVPB Vpb = Vcb->Vpb, NewVpb = NULL;
2599 BOOLEAN bDeleted = FALSE, bTearDown = FALSE;
2600 ULONG UnCleanCount = 0;
2601
2603 if (NewVpb == NULL) {
2604 DEBUG(DL_ERR, ( "Ex2CheckDismount: failed to allocate NewVpb.\n"));
2605 return FALSE;
2606 }
2607 DEBUG(DL_DBG, ("Ext2CheckDismount: NewVpb allocated: %p\n", NewVpb));
2608 INC_MEM_COUNT(PS_VPB, NewVpb, sizeof(VPB));
2609 memset(NewVpb, '_', VPB_SIZE);
2610 RtlZeroMemory(NewVpb, sizeof(VPB));
2611
2614
2616 &Vcb->MainResource, TRUE );
2617
2618 if (IrpContext &&
2619 IrpContext->MajorFunction == IRP_MJ_CREATE &&
2620 IrpContext->RealDevice == Vcb->RealDevice) {
2621 UnCleanCount = 2;
2622 } else {
2623 UnCleanCount = 1;
2624 }
2625
2627
2628 DEBUG(DL_DBG, ("Ext2CheckDismount: Vpb %p ioctl=%d Device %p\n",
2629 Vpb, Vpb->ReferenceCount, Vpb->RealDevice));
2630
2631 if (Vpb->ReferenceCount <= UnCleanCount) {
2632
2633 if (!IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
2634
2635 ClearFlag(Vpb->Flags, VPB_MOUNTED);
2636 ClearFlag(Vpb->Flags, VPB_LOCKED);
2637
2638 if ((Vcb->RealDevice != Vpb->RealDevice) &&
2639 (Vcb->RealDevice->Vpb == Vpb)) {
2640 SetFlag(Vcb->RealDevice->Flags, DO_DEVICE_INITIALIZING);
2641 SetFlag(Vpb->Flags, VPB_PERSISTENT );
2642 }
2643
2646 }
2647
2648 if (Vpb->ReferenceCount) {
2649 bTearDown = TRUE;
2650 } else {
2651 bDeleted = TRUE;
2652 Vpb->DeviceObject = NULL;
2653 }
2654
2655 DEBUG(DL_DBG, ("Ext2CheckDismount: Vpb: %p bDeleted=%d bTearDown=%d\n",
2656 Vpb, bDeleted, bTearDown));
2657
2658
2659 } else if (bForce) {
2660
2661 DEBUG(DL_DBG, ( "Ext2CheckDismount: New/Old Vpb %p/%p Realdevice = %p\n",
2662 NewVpb, Vcb->Vpb, Vpb->RealDevice));
2663
2664 /* keep vpb president and later we'll free it */
2665 SetFlag(Vpb->Flags, VPB_PERSISTENT);
2666
2667 Vcb->Vpb2 = Vcb->Vpb;
2668 NewVpb->Type = IO_TYPE_VPB;
2669 NewVpb->Size = sizeof(VPB);
2670 NewVpb->Flags = Vpb->Flags & VPB_REMOVE_PENDING;
2671 NewVpb->RealDevice = Vpb->RealDevice;
2672 NewVpb->RealDevice->Vpb = NewVpb;
2673 NewVpb = NULL;
2674 ClearFlag(Vpb->Flags, VPB_MOUNTED);
2675 SetLongFlag(Vcb->Flags, VCB_NEW_VPB);
2676 ClearLongFlag(Vcb->Flags, VCB_MOUNTED);
2677 }
2678
2680
2681 ExReleaseResourceLite(&Vcb->MainResource);
2683
2684 if (bTearDown) {
2685 DEBUG(DL_DBG, ( "Ext2CheckDismount: Tearing vcb %p ...\n", Vcb));
2687 }
2688
2689 if (bDeleted) {
2690 DEBUG(DL_DBG, ( "Ext2CheckDismount: Deleting vcb %p ...\n", Vcb));
2692 }
2693
2694 if (NewVpb != NULL) {
2695 DEBUG(DL_DBG, ( "Ext2CheckDismount: freeing new Vpb %p\n", NewVpb));
2696 ExFreePoolWithTag(NewVpb, TAG_VPB);
2697 DEC_MEM_COUNT(PS_VPB, NewVpb, sizeof(VPB));
2698 }
2699
2700 return bDeleted;
2701}
#define TAG_VPB
Definition: cdprocs.h:106
_Out_ PKIRQL Irql
Definition: csq.h:179
#define PS_VPB
Definition: common.h:23
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
VOID Ext2RemoveVcb(PEXT2_VCB Vcb)
Definition: memory.c:1943
#define VPB_SIZE
Definition: ext2fs.h:294
VOID Ext2TearDownStream(IN PEXT2_VCB Vcb)
Definition: memory.c:2798
#define VCB_DISMOUNT_PENDING
Definition: ext2fs.h:791
#define VCB_NEW_VPB
Definition: ext2fs.h:792
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:259
VOID Ext2DestroyVcb(IN PEXT2_VCB Vcb)
Definition: memory.c:2825
#define VCB_MOUNTED
Definition: ext2fs.h:790
#define DL_DBG
Definition: ext2fs.h:1435
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1675
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define VPB_REMOVE_PENDING
Definition: ntifs_ex.h:428
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1215
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1204
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define memset(x, y, z)
Definition: compat.h:39
PVPB Vpb
Definition: cdstruc.h:511
Definition: iotypes.h:189
#define VPB_MOUNTED
Definition: iotypes.h:1807
#define IO_TYPE_VPB
#define VPB_PERSISTENT
Definition: iotypes.h:1809
struct _VPB VPB
#define VPB_LOCKED
Definition: iotypes.h:1808

Referenced by Ext2DismountVolume(), Ext2ExceptionHandler(), Ext2FreeFcb(), and Ext2InvalidateVolumes().

◆ Ext2CheckExtent()

VOID Ext2CheckExtent ( PLARGE_MCB  Zone,
LONGLONG  Vbn,
LONGLONG  Lbn,
LONGLONG  Length,
BOOLEAN  bAdded 
)

Definition at line 583 of file memory.c.

590{
591#if EXT2_DEBUG
592 LONGLONG DirtyLbn;
593 LONGLONG DirtyLen;
594 LONGLONG RunStart;
595 LONGLONG RunLength;
596 ULONG Index;
597 BOOLEAN bFound = FALSE;
598
600 Zone,
601 Vbn,
602 &DirtyLbn,
603 &DirtyLen,
604 &RunStart,
605 &RunLength,
606 &Index );
607
608 if (!bAdded && (!bFound || DirtyLbn == -1)) {
609 return;
610 }
611
612 if ( !bFound || (DirtyLbn == -1) ||
613 (DirtyLbn != Lbn) ||
614 (DirtyLen < Length)) {
615
616 DbgBreak();
617
618 for (Index = 0; TRUE; Index++) {
619
621 Zone,
622 Index,
623 &Vbn,
624 &Lbn,
625 &Length)) {
626 break;
627 }
628
629 DEBUG(DL_EXT, ("Index = %xh Vbn = %I64xh Lbn = %I64xh Len = %I64xh\n",
630 Index, Vbn, Lbn, Length ));
631 }
632 }
633#endif
634}
BOOLEAN NTAPI FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn OPTIONAL, OUT PLONGLONG SectorCountFromLbn OPTIONAL, OUT PLONGLONG StartingLbn OPTIONAL, OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL)
Definition: largemcb.c:560
BOOLEAN NTAPI FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, IN ULONG RunIndex, OUT PLONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount)
Definition: largemcb.c:392

Referenced by Ext2AddMcbExtent(), Ext2AddMcbMetaExts(), Ext2AddVcbExtent(), Ext2RemoveMcbExtent(), Ext2RemoveMcbMetaExts(), and Ext2RemoveVcbExtent().

◆ Ext2CheckFileAccess()

int Ext2CheckFileAccess ( PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
int  attempt 
)

Definition at line 51 of file access.c.

52{
53 return Ext2CheckInodeAccess(Vcb, &Mcb->Inode, attempt);
54}
int Ext2CheckInodeAccess(PEXT2_VCB Vcb, struct inode *in, int attempt)
Definition: access.c:20

Referenced by Ext2CreateFile(), Ext2LookupFile(), Ext2SetFileInformation(), and Ext2WriteFile().

◆ Ext2CheckInodeAccess()

int Ext2CheckInodeAccess ( PEXT2_VCB  Vcb,
struct inode in,
int  attempt 
)

Definition at line 20 of file access.c.

21{
22 int granted = 0;
23
24 uid_t uid = Vcb->uid;
25 gid_t gid = Vcb->gid;
26
27 if (IsFlagOn(Vcb->Flags, VCB_USER_EIDS)) {
28 uid = Vcb->euid;
29 gid = Vcb->egid;
30 }
31
32 if (!uid || uid == in->i_uid) {
33 /* grant all access for inode owner or root */
35 } else if (gid == in->i_gid) {
36 if (Ext2IsGroupReadOnly(in->i_mode))
38 else if (Ext2IsGroupWritable(in->i_mode))
40 } else {
41 if (Ext2IsOtherReadOnly(in->i_mode))
43 else if (Ext2IsOtherWritable(in->i_mode))
45
46 }
47
48 return IsFlagOn(granted, attempt);
49}
long uid_t
Definition: various.h:8
UINT gid_t
Definition: types.h:89
#define Ext2FileCanWrite
Definition: ext2fs.h:432
#define Ext2FileCanRead
Definition: ext2fs.h:431
#define Ext2IsGroupReadOnly(m)
Definition: ext2fs.h:422
#define Ext2IsGroupWritable(m)
Definition: ext2fs.h:420
#define Ext2IsOtherWritable(m)
Definition: ext2fs.h:424
#define Ext2FileCanExecute
Definition: ext2fs.h:433
#define Ext2IsOtherReadOnly(m)
Definition: ext2fs.h:426
#define VCB_USER_EIDS
Definition: ext2fs.h:795
GLuint in
Definition: glext.h:9616

Referenced by Ext2CheckFileAccess(), and Ext2ProcessEntry().

◆ Ext2CheckJournal()

INT Ext2CheckJournal ( PEXT2_VCB  Vcb,
PULONG  jNo 
)

Definition at line 55 of file recover.c.

59{
60 struct ext3_super_block* esb = NULL;
61
62 /* check ext3 super block */
63 esb = (struct ext3_super_block *)Vcb->SuperBlock;
67 }
68
69 /* must stop here if volume is read-only */
70 if (IsVcbReadOnly(Vcb)) {
71 goto errorout;
72 }
73
74 /* journal is external ? */
75 if (esb->s_journal_inum == 0) {
76 goto errorout;
77 }
78
79 /* oops: volume is corrupted */
80 if (esb->s_journal_dev) {
81 goto errorout;
82 }
83
84 /* return the journal inode number */
85 *jNo = esb->s_journal_inum;
86
87 return TRUE;
88
89errorout:
90
91 return FALSE;
92}
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:814
#define VCB_JOURNAL_RECOVER
Definition: ext2fs.h:801
#define EXT3_FEATURE_INCOMPAT_RECOVER
Definition: ext3_fs.h:680
if(dx< 0)
Definition: linetemp.h:194
__le32 s_journal_inum
Definition: ext3_fs.h:561
__le32 s_feature_incompat
Definition: ext3_fs.h:538
__le32 s_journal_dev
Definition: ext3_fs.h:562

Referenced by Ext2RecoverJournal().

◆ Ext2CheckSetBlock()

BOOLEAN Ext2CheckSetBlock ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
LONGLONG  Block 
)

Definition at line 1848 of file memory.c.

1849{
1851 struct buffer_head *gb = NULL;
1852 struct buffer_head *bh = NULL;
1853 ULONG group, dwBlk, Length;
1855 BOOLEAN bModified = FALSE;
1856
1858 dwBlk = (ULONG)(Block - EXT2_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1859
1860 gd = ext4_get_group_desc(&Vcb->sb, group, &gb);
1861 if (!gd) {
1862 return FALSE;
1863 }
1864 bh = sb_getblk(&Vcb->sb, ext4_block_bitmap(&Vcb->sb, gd));
1865
1866 if (group == Vcb->sbi.s_groups_count - 1) {
1868
1869 /* s_blocks_count is integer multiple of s_blocks_per_group */
1870 if (Length == 0)
1872 } else {
1874 }
1875
1876 if (dwBlk >= Length) {
1877 fini_bh(&gb);
1878 fini_bh(&bh);
1879 return FALSE;
1880 }
1881
1882
1884
1885 if (RtlCheckBit(&bitmap, dwBlk) == 0) {
1886 DbgBreak();
1887 RtlSetBits(&bitmap, dwBlk, 1);
1888 bModified = TRUE;
1890 }
1891
1892 fini_bh(&gb);
1893 fini_bh(&bh);
1894
1895 return (!bModified);
1896}
#define EXT2_FIRST_DATA_BLOCK
Definition: ext2fs.h:103
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100
GLboolean GLuint group
Definition: glext.h:11120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:976
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:914
Definition: uimain.c:89
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3152

Referenced by Ext2CheckBitmapConsistency().

◆ Ext2Cleanup()

NTSTATUS Ext2Cleanup ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 21 of file cleanup.c.

22{
29 PIRP Irp = NULL;
31
32
33 BOOLEAN VcbResourceAcquired = FALSE;
34 BOOLEAN FcbResourceAcquired = FALSE;
35 BOOLEAN FcbPagingIoResourceAcquired = FALSE;
36 BOOLEAN SymLinkDelete = FALSE;
37
38 _SEH2_TRY {
39
40 ASSERT(IrpContext != NULL);
41 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
42 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
43
44 DeviceObject = IrpContext->DeviceObject;
48 }
49
50 Irp = IrpContext->Irp;
51 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
52 ASSERT(Vcb != NULL);
53 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
54 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
55
56 if (!IsVcbInited(Vcb)) {
59 }
60
61 FileObject = IrpContext->FileObject;
62 Fcb = (PEXT2_FCB) FileObject->FsContext;
63 if (!Fcb || (Fcb->Identifier.Type != EXT2VCB &&
67 }
68 Mcb = Fcb->Mcb;
69 Ccb = (PEXT2_CCB) FileObject->FsContext2;
70
74 }
75
76 if (Fcb->Identifier.Type == EXT2VCB) {
77
79 &Vcb->MainResource, TRUE);
80 VcbResourceAcquired = TRUE;
81
82 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED) &&
83 Vcb->LockFile == FileObject ){
84
86 Vcb->LockFile = NULL;
88 }
89
90 if (Ccb) {
91 Ext2DerefXcb(&Vcb->OpenHandleCount);
92 Ext2DerefXcb(&Vcb->OpenVolumeCount);
93 }
94
95 IoRemoveShareAccess(FileObject, &Vcb->ShareAccess);
96
99 }
100
102 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
103
104 FcbResourceAcquired =
107 TRUE
108 );
109
111 if (IsFlagOn(FileObject->Flags, FO_FILE_MODIFIED) &&
112 IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK) &&
113 !IsVcbReadOnly(Vcb) ) {
114 Status = Ext2FlushFile(IrpContext, Fcb, Ccb);
115 }
117 }
118
119 if (Ccb == NULL) {
122 }
123
124 if (IsDirectory(Fcb)) {
127
129 Vcb->NotifySync,
130 &Vcb->NotifyList,
131 Ccb,
132 NULL,
133 FALSE,
134 FALSE,
135 0,
136 NULL,
137 NULL,
138 NULL );
139 }
140
141 FsRtlNotifyCleanup(Vcb->NotifySync, &Vcb->NotifyList, Ccb);
142 }
143
145 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
146
147 Ext2DerefXcb(&Vcb->OpenHandleCount);
149
150 if (IsFlagOn(FileObject->Flags, FO_FILE_MODIFIED)) {
151 Fcb->Mcb->FileAttr |= FILE_ATTRIBUTE_ARCHIVE;
152 }
153
154 if (IsDirectory(Fcb)) {
155
156 ext3_release_dir(Fcb->Inode, &Ccb->filp);
157
158 } else {
159
160 if ( IsFlagOn(FileObject->Flags, FO_FILE_MODIFIED) &&
162
163 LARGE_INTEGER SysTime;
164 KeQuerySystemTime(&SysTime);
165
166 Fcb->Inode->i_atime =
167 Fcb->Inode->i_mtime = Ext2LinuxTime(SysTime);
168 Fcb->Mcb->LastAccessTime =
169 Fcb->Mcb->LastWriteTime = Ext2NtTime(Fcb->Inode->i_atime);
170
171 Ext2SaveInode(IrpContext, Vcb, Fcb->Inode);
172
174 IrpContext,
175 Vcb,
176 Fcb->Mcb,
181 }
182
183 FsRtlCheckOplock( &Fcb->Oplock,
184 Irp,
185 IrpContext,
186 NULL,
187 NULL );
188
189 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
190
191 if (!IsFlagOn(FileObject->Flags, FO_CACHE_SUPPORTED)) {
192 Fcb->NonCachedOpenCount--;
193 }
194
196 if (Ccb->SymLink || IsInodeSymLink(&Mcb->Inode)) {
197 SymLinkDelete = TRUE;
198 } else {
200 }
201 }
202
203 //
204 // Drop any byte range locks this process may have on the file.
205 //
206
208 &Fcb->FileLockAnchor,
211 NULL );
212
213 //
214 // If there are no byte range locks owned by other processes on the
215 // file the fast I/O read/write functions doesn't have to check for
216 // locks so we set IsFastIoPossible to FastIoIsPossible again.
217 //
218 if (!FsRtlGetNextFileLock(&Fcb->FileLockAnchor, TRUE)) {
219 if (Fcb->Header.IsFastIoPossible != FastIoIsPossible) {
220#if EXT2_DEBUG
221 DEBUG(DL_INF, (": %-16.16s %-31s %wZ\n",
223 "FastIoIsPossible",
224 &Fcb->Mcb->FullName
225 ));
226#endif
227
228 Fcb->Header.IsFastIoPossible = FastIoIsPossible;
229 }
230 }
231
234
236 if (Fcb->Header.ValidDataLength.QuadPart < Fcb->Header.FileSize.QuadPart) {
237 if (!INODE_HAS_EXTENT(Fcb->Inode)) {
238 #if EXT2_PRE_ALLOCATION_SUPPORT
239 _SEH2_TRY {
241 &Fcb->Header.ValidDataLength,
242 &Fcb->Header.AllocationSize,
243 TRUE);
245 DbgBreak();
246 } _SEH2_END;
247 #endif
248 }
249 }
250 }
251
253
255
257 FcbPagingIoResourceAcquired = TRUE;
258
259 Size.QuadPart = CEILING_ALIGNED(ULONGLONG,
260 (ULONGLONG)Fcb->Mcb->Inode.i_size,
263
264 Ext2TruncateFile(IrpContext, Vcb, Fcb->Mcb, &Size);
265 Fcb->Header.AllocationSize = Size;
266 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
267 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart)
268 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
271 (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
272 }
273 }
276 FcbPagingIoResourceAcquired = FALSE;
277 }
278 }
279 }
280
282
283 if (!IsDirectory(Fcb)) {
284
285 if ( IsFlagOn(FileObject->Flags, FO_CACHE_SUPPORTED) &&
286 (Fcb->NonCachedOpenCount == Fcb->OpenHandleCount) &&
287 (Fcb->SectionObject.DataSectionObject != NULL)) {
288
289 if (!IsVcbReadOnly(Vcb)) {
290 CcFlushCache(&Fcb->SectionObject, NULL, 0, NULL);
292 }
293
294 /* purge cache if all remaining openings are non-cached */
295 if (Fcb->NonCachedOpenCount > 0 ||
299 }
300
301 /* CcPurge could generate recursive IRP_MJ_CLOSE request */
302 CcPurgeCacheSection( &Fcb->SectionObject,
303 NULL,
304 0,
305 FALSE );
306 }
307 }
308
310 }
311
312 if (SymLinkDelete ||
314 Fcb->OpenHandleCount == 0) ) {
315
316 //
317 // Ext2DeleteFile will acquire these lock inside
318 //
319
320 if (FcbResourceAcquired) {
322 FcbResourceAcquired = FALSE;
323 }
324
325 //
326 // this file is to be deleted ...
327 //
328 if (Ccb->SymLink) {
329 Mcb = Ccb->SymLink;
330 FileObject->DeletePending = FALSE;
331 }
332
333 Status = Ext2DeleteFile(IrpContext, Vcb, Fcb, Mcb);
334
335 if (NT_SUCCESS(Status)) {
336 if (IsMcbDirectory(Mcb)) {
337 Ext2NotifyReportChange( IrpContext, Vcb, Mcb,
340 } else {
341 Ext2NotifyReportChange( IrpContext, Vcb, Mcb,
344 }
345 }
346
347 //
348 // re-acquire the main resource lock
349 //
350
351 FcbResourceAcquired =
354 TRUE
355 );
356 if (!SymLinkDelete) {
360 (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
361 }
362 }
363 }
364
365 DEBUG(DL_INF, ( "Ext2Cleanup: OpenCount=%u ReferCount=%u NonCahcedCount=%xh %wZ\n",
366 Fcb->OpenHandleCount, Fcb->ReferenceCount, Fcb->NonCachedOpenCount, &Fcb->Mcb->FullName));
367
369
370 if (FileObject) {
372 }
373
374 } _SEH2_FINALLY {
375
376 if (FcbPagingIoResourceAcquired) {
378 }
379
380 if (FcbResourceAcquired) {
382 }
383
384 if (VcbResourceAcquired) {
385 ExReleaseResourceLite(&Vcb->MainResource);
386 }
387
388 if (!IrpContext->ExceptionInProgress) {
389 if (Status == STATUS_PENDING) {
390 Ext2QueueRequest(IrpContext);
391 } else {
392 IrpContext->Irp->IoStatus.Status = Status;
393 Ext2CompleteIrpContext(IrpContext, Status);
394 }
395 }
396 } _SEH2_END;
397
398 return Status;
399}
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
#define CcIsFileCached(FO)
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define VCB_VOLUME_LOCKED
Definition: ext2fs.h:789
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define IsDirectory(Fcb)
Definition: ext2fs.h:283
NTSTATUS Ext2TruncateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER AllocationSize)
Definition: fileinfo.c:1204
LARGE_INTEGER Ext2NtTime(IN ULONG i_time)
Definition: misc.c:40
BOOLEAN Ext2SaveInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:552
NTSTATUS Ext2DeleteFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_MCB Mcb)
Definition: fileinfo.c:1920
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:158
#define FCB_ALLOC_IN_WRITE
Definition: ext2fs.h:885
#define FCB_FILE_MODIFIED
Definition: ext2fs.h:882
VOID Ext2ClearVpbFlag(IN PVPB Vpb, IN USHORT Flag)
Definition: fsctl.c:56
#define FCB_ALLOC_IN_SETINFO
Definition: ext2fs.h:886
ULONG Ext2LinuxTime(IN LARGE_INTEGER SysTime)
Definition: misc.c:51
NTSTATUS Ext2FlushFile(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
Definition: flush.c:58
VOID Ext2NotifyReportChange(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Filter, IN ULONG Action)
Definition: dirctl.c:1209
#define IsMcbDirectory(Mcb)
Definition: ext2fs.h:967
#define IsInodeSymLink(I)
Definition: ext2fs.h:286
#define FCB_DELETE_PENDING
Definition: ext2fs.h:888
#define FCB_ALLOC_IN_CREATE
Definition: ext2fs.h:884
#define CCB_DELETE_ON_CLOSE
Definition: ext2fs.h:1035
#define CCB_LAST_WRITE_UPDATED
Definition: ext2fs.h:1033
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:806
#define IsVcbInited(Vcb)
Definition: ext2fs.h:811
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:977
FAST_IO_POSSIBLE Ext2IsFastIoPossible(IN PEXT2_FCB Fcb)
Definition: fastio.c:38
int ext3_release_dir(struct inode *inode, struct file *filp)
Definition: htree.c:1929
PFILE_LOCK_INFO NTAPI FsRtlGetNextFileLock(IN PFILE_LOCK FileLock, IN BOOLEAN Restart)
Definition: filelock.c:255
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
Definition: filelock.c:1025
@ FastIoIsPossible
Definition: fsrtltypes.h:241
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:356
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
BOOLEAN NTAPI CcZeroData(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER StartOffset, IN PLARGE_INTEGER EndOffset, IN BOOLEAN Wait)
Definition: fssup.c:414
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:386
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
VOID NTAPI FsRtlNotifyCleanup(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext)
Definition: notify.c:659
VOID NTAPI FsRtlNotifyFullChangeDirectory(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext, IN PSTRING FullDirectoryName, IN BOOLEAN WatchTree, IN BOOLEAN IgnoreBuffer, IN ULONG CompletionFilter, IN PIRP NotifyIrp, IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL)
Definition: notify.c:1487
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
Definition: file.c:3478
PEPROCESS NTAPI IoGetRequestorProcess(IN PIRP Irp)
Definition: irp.c:1782
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
Definition: oplock.c:1170
SHARE_ACCESS ShareAccess
Definition: cdstruc.h:1009
#define FILE_ACTION_MODIFIED
#define FILE_NOTIFY_CHANGE_LAST_ACCESS
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_ACTION_REMOVED
#define FO_FILE_MODIFIED
Definition: iotypes.h:1788
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FO_CLEANUP_COMPLETE
Definition: iotypes.h:1790
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FO_CACHE_SUPPORTED
Definition: iotypes.h:1781
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define FILE_NOTIFY_CHANGE_DIR_NAME

Referenced by Ext2DispatchRequest().

◆ Ext2CleanupAllMcbs()

VOID Ext2CleanupAllMcbs ( PEXT2_VCB  Vcb)

Definition at line 1810 of file memory.c.

1811{
1812 BOOLEAN LockAcquired = FALSE;
1813 PEXT2_MCB Mcb = NULL;
1814
1815 _SEH2_TRY {
1816
1818 &Vcb->McbLock,
1819 TRUE );
1820 LockAcquired = TRUE;
1821
1822#ifdef __REACTOS__
1823 while ((Mcb = Ext2FirstUnusedMcb(Vcb, TRUE, Vcb->NumOfMcb)) != 0) {
1824#else
1825 while (Mcb = Ext2FirstUnusedMcb(Vcb, TRUE, Vcb->NumOfMcb)) {
1826#endif
1827 while (Mcb) {
1828 PEXT2_MCB Next = Mcb->Next;
1829 if (IsMcbSymLink(Mcb)) {
1830 Mcb->Target = NULL;
1831 }
1833 Mcb = Next;
1834 }
1835 }
1836 Ext2FreeMcb(Vcb, Vcb->McbTree);
1837 Vcb->McbTree = NULL;
1838
1839 } _SEH2_FINALLY {
1840
1841 if (LockAcquired) {
1842 ExReleaseResourceLite(&Vcb->McbLock);
1843 }
1844 } _SEH2_END;
1845}
VOID Ext2FreeMcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1538
PEXT2_MCB Ext2FirstUnusedMcb(PEXT2_VCB Vcb, BOOLEAN Wait, ULONG Number)
Definition: memory.c:2979
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:962

Referenced by Ext2DestroyVcb().

◆ Ext2ClearAllExtents()

VOID Ext2ClearAllExtents ( PLARGE_MCB  Zone)

Definition at line 637 of file memory.c.

638{
639 _SEH2_TRY {
642 DbgBreak();
643 } _SEH2_END;
644}
VOID NTAPI FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, IN LONGLONG Vbn)
Definition: largemcb.c:1059

Referenced by Ext2BuildExtents(), Ext2ExpandBlock(), Ext2ExpandExtent(), Ext2ExpandLast(), Ext2InitializeZone(), Ext2TruncateBlock(), Ext2TruncateExtent(), Ext2TruncateFile(), and Ext2TruncateIndirectFast().

◆ Ext2ClearInode()

BOOLEAN Ext2ClearInode ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  inode 
)

Definition at line 530 of file generic.c.

534{
535 LONGLONG Offset = 0;
536 BOOLEAN rc;
537
538 rc = Ext2GetInodeLba(Vcb, Inode, &Offset);
539 if (!rc) {
540 DEBUG(DL_ERR, ( "Ext2SaveInode: failed inode %u.\n", Inode));
541 goto errorout;
542 }
543
544 rc = Ext2ZeroBuffer(IrpContext, Vcb, Offset, Vcb->InodeSize);
545
546errorout:
547
548 return rc;
549}
BOOLEAN Ext2ZeroBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size)
Definition: generic.c:795
BOOLEAN Ext2GetInodeLba(IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: generic.c:418

Referenced by Ext2CreateInode().

◆ Ext2ClearVpbFlag()

VOID Ext2ClearVpbFlag ( IN PVPB  Vpb,
IN USHORT  Flag 
)

Definition at line 56 of file fsctl.c.

59{
61
63 Vpb->Flags &= ~Flag;
65}
Definition: xml2sdb.h:80
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by Ext2Cleanup(), and Ext2UnlockVcb().

◆ Ext2Close()

NTSTATUS Ext2Close ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 26 of file close.c.

27{
34
35 BOOLEAN VcbResourceAcquired = FALSE;
36 BOOLEAN FcbResourceAcquired = FALSE;
37 BOOLEAN FcbDerefDeferred = FALSE;
38
39 _SEH2_TRY {
40
41 ASSERT(IrpContext != NULL);
42 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
43 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
44
45 DeviceObject = IrpContext->DeviceObject;
48 Vcb = NULL;
50 }
51
52 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
53 ASSERT(Vcb != NULL);
54 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
55 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
56
57 if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_DELAY_CLOSE)) {
58
60 Fcb = IrpContext->Fcb;
61 Ccb = IrpContext->Ccb;
62
63 } else {
64
65 FileObject = IrpContext->FileObject;
66 Fcb = (PEXT2_FCB) FileObject->FsContext;
67 if (!Fcb) {
70 }
71 ASSERT(Fcb != NULL);
72 Ccb = (PEXT2_CCB) FileObject->FsContext2;
73 }
74
75 DEBUG(DL_INF, ( "Ext2Close: (VCB) Vcb = %p ReferCount = %d\n",
76 Vcb, Vcb->ReferenceCount));
77
78 /*
79 * WARNING: don't release Vcb resource lock here.
80 *
81 * CcPurgeCacheSection will lead a recursive irp: IRP_MJ_CLOSE
82 * which would cause revrese order of lock acquirision:
83 * 1) IRP_MJ_CLEANUP: a) Vcb lock -> b) Fcb lock
84 * 2) IRP_MJ_CLOSE: c) Vcb lock -> d) Fcb lock
85 */
86
87 if (Fcb->Identifier.Type == EXT2VCB) {
88
90 &Vcb->MainResource,
91 TRUE )) {
92 DEBUG(DL_INF, ("Ext2Close: PENDING ... Vcb: %xh/%xh\n",
93 Vcb->OpenHandleCount, Vcb->ReferenceCount));
96 }
97 VcbResourceAcquired = TRUE;
98
99 if (Ccb) {
100
101 Ext2DerefXcb(&Vcb->ReferenceCount);
103
104 if (FileObject) {
105 FileObject->FsContext2 = Ccb = NULL;
106 }
107 }
108
111 }
112
113 if ( Fcb->Identifier.Type != EXT2FCB ||
114 Fcb->Identifier.Size != sizeof(EXT2_FCB)) {
116 }
117
120 TRUE )) {
123 }
124 FcbResourceAcquired = TRUE;
125
126 Fcb->Header.IsFastIoPossible = FastIoIsNotPossible;
127
128 if (Ccb == NULL ||
130 Ccb->Identifier.Size != sizeof(EXT2_CCB)) {
133 }
134
135 DEBUG(DL_INF, ( "Ext2Close: Fcb = %p OpenHandleCount= %u ReferenceCount=%u NonCachedCount=%u %wZ\n",
136 Fcb, Fcb->OpenHandleCount, Fcb->ReferenceCount, Fcb->NonCachedOpenCount, &Fcb->Mcb->FullName ));
137
139 if (FileObject) {
140 FileObject->FsContext2 = Ccb = NULL;
141 }
142
143 /* only deref fcb, Ext2ReleaseFcb might lead deadlock */
144 FcbDerefDeferred = TRUE;
146 NULL == Fcb->Mcb ||
148 Fcb->TsDrop.QuadPart = 0;
149 } else {
150 KeQuerySystemTime(&Fcb->TsDrop);
151 }
152 Ext2DerefXcb(&Vcb->ReferenceCount);
153
154 if (FileObject) {
155 FileObject->FsContext = NULL;
156 }
157
159
160 } _SEH2_FINALLY {
161
162 if (FcbResourceAcquired) {
164 }
165
166 if (VcbResourceAcquired) {
167 ExReleaseResourceLite(&Vcb->MainResource);
168 }
169
170 if (!IrpContext->ExceptionInProgress) {
171
172 if (Status == STATUS_PENDING) {
173
174 Ext2QueueCloseRequest(IrpContext);
175
176 } else {
177
178 Ext2CompleteIrpContext(IrpContext, Status);
179 }
180 }
181
182 if (FcbDerefDeferred)
183 Ext2DerefXcb(&Fcb->ReferenceCount);
184 } _SEH2_END;
185
186 return Status;
187}
VOID Ext2QueueCloseRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: close.c:190
#define IsFileDeleted(Mcb)
Definition: ext2fs.h:968
#define IRP_CONTEXT_FLAG_DELAY_CLOSE
Definition: ext2fs.h:1096
VOID Ext2FreeCcb(IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb)
Definition: memory.c:356
struct _FCB::@719::@722 Fcb
PFILE_OBJECT FileObject
Definition: ntfs.h:520

Referenced by Ext2DeQueueCloseRequest().

◆ Ext2CompleteIrpContext()

NTSTATUS Ext2CompleteIrpContext ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN NTSTATUS  Status 
)

Definition at line 32 of file read.c.

35{
36 PIRP Irp = NULL;
37 BOOLEAN bPrint;
38
39 Irp = IrpContext->Irp;
40
41 if (Irp != NULL) {
42
43 if (NT_ERROR(Status)) {
44 Irp->IoStatus.Information = 0;
45 }
46
47 Irp->IoStatus.Status = Status;
48 bPrint = !IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_REQUEUED);
49
51 Irp, bPrint, (CCHAR)(NT_SUCCESS(Status)?
53
54 IrpContext->Irp = NULL;
55 }
56
57 Ext2FreeIrpContext(IrpContext);
58
59 return Status;
60}
VOID Ext2FreeIrpContext(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: memory.c:114
#define Ext2CompleteRequest(Irp, bPrint, PriorityBoost)
Definition: ext2fs.h:1475
#define IRP_CONTEXT_FLAG_REQUEUED
Definition: ext2fs.h:1094
char CCHAR
Definition: typedefs.h:51
#define NT_ERROR(Status)
Definition: umtypes.h:106
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IO_DISK_INCREMENT
Definition: iotypes.h:600

Referenced by Ex2ProcessMountPoint(), Ex2ProcessUserPerfStat(), Ext2AllowExtendedDasdIo(), Ext2Cleanup(), Ext2Close(), Ext2Create(), Ext2DeleteReparsePoint(), Ext2DeviceControlNormal(), Ext2DirectoryControl(), Ext2DismountVolume(), Ext2DispatchRequest(), Ext2ExceptionHandler(), Ext2FileSystemControl(), Ext2Flush(), Ext2GetReparsePoint(), Ext2GetRetrievalPointerBase(), Ext2GetRetrievalPointers(), Ext2InvalidateVolumes(), Ext2IsVolumeDirty(), Ext2IsVolumeMounted(), Ext2LockControl(), Ext2LockVolume(), Ext2MountVolume(), Ext2NotifyChangeDirectory(), Ext2OplockComplete(), Ext2OplockRequest(), Ext2ProcessUserProperty(), Ext2QueryDirectory(), Ext2QueryEa(), Ext2QueryFileInformation(), Ext2QueryRetrievalPointers(), Ext2QueryVolumeInformation(), Ext2Read(), Ext2ReadComplete(), Ext2ReadFile(), Ext2ReadVolume(), Ext2SetEa(), Ext2SetFileInformation(), Ext2SetReparsePoint(), Ext2SetVolumeInformation(), Ext2ShutDown(), Ext2UnlockVolume(), Ext2UserFsRequest(), Ext2VerifyVolume(), Ext2Write(), Ext2WriteComplete(), Ext2WriteFile(), and Ext2WriteVolume().

◆ Ext2CountExtents()

ULONG Ext2CountExtents ( IN PEXT2_EXTENT  Chain)

Definition at line 513 of file memory.c.

514{
515 ULONG count = 0;
516 PEXT2_EXTENT List = Chain;
517
518 while (List) {
519 count += 1;
520 List = List->Next;
521 }
522
523 return count;
524}
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct _EXT2_EXTENT * Next
Definition: ext2fs.h:1124

Referenced by Ext2QueryExtentMappings().

◆ Ext2Create()

NTSTATUS Ext2Create ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1951 of file create.c.

1952{
1954 PIRP Irp;
1956 PEXT2_VCB Vcb = 0;
1958 PEXT2_FCBVCB Xcb = NULL;
1959 BOOLEAN PostIrp = FALSE;
1960 BOOLEAN VcbResourceAcquired = FALSE;
1961
1962 DeviceObject = IrpContext->DeviceObject;
1963 Irp = IrpContext->Irp;
1965
1966 Xcb = (PEXT2_FCBVCB) (IrpSp->FileObject->FsContext);
1967
1969
1970 DEBUG(DL_INF, ( "Ext2Create: Create on main device object.\n"));
1971
1973 Irp->IoStatus.Information = FILE_OPENED;
1974
1975 Ext2CompleteIrpContext(IrpContext, Status);
1976
1977 return Status;
1978 }
1979
1980 _SEH2_TRY {
1981
1982 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
1983 ASSERT(Vcb->Identifier.Type == EXT2VCB);
1984 IrpSp->FileObject->Vpb = Vcb->Vpb;
1985
1986 if (!IsMounted(Vcb)) {
1987 DbgBreak();
1988 if (IsFlagOn(Vcb->Flags, VCB_DEVICE_REMOVED)) {
1990 } else {
1992 }
1994 }
1995
1997 &Vcb->MainResource, TRUE)) {
2000 }
2001 VcbResourceAcquired = TRUE;
2002
2003 Ext2VerifyVcb(IrpContext, Vcb);
2004
2005 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
2007 if (IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
2009 }
2011 }
2012
2013 if ( ((IrpSp->FileObject->FileName.Length == 0) &&
2014 (IrpSp->FileObject->RelatedFileObject == NULL)) ||
2015 (Xcb && Xcb->Identifier.Type == EXT2VCB) ) {
2016 Status = Ext2CreateVolume(IrpContext, Vcb);
2017 } else {
2018
2019 Status = Ext2CreateFile(IrpContext, Vcb, &PostIrp);
2020 }
2021
2022 } _SEH2_FINALLY {
2023
2024 if (VcbResourceAcquired) {
2025 ExReleaseResourceLite(&Vcb->MainResource);
2026 }
2027
2028 if (!IrpContext->ExceptionInProgress && !PostIrp) {
2029 if ( Status == STATUS_PENDING ||
2031 Status = Ext2QueueRequest(IrpContext);
2032 } else {
2033 Ext2CompleteIrpContext(IrpContext, Status);
2034 }
2035 }
2036 } _SEH2_END;
2037
2038 return Status;
2039}
NTSTATUS Ext2CreateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PBOOLEAN OpPostIrp)
Definition: create.c:829
NTSTATUS Ext2CreateVolume(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
Definition: create.c:1839
struct _EXT2_FCBVCB * PEXT2_FCBVCB
VOID Ext2VerifyVcb(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: fsctl.c:2277
#define VCB_DEVICE_REMOVED
Definition: ext2fs.h:800
#define FILE_OPENED
Definition: nt_native.h:769
#define STATUS_VOLUME_DISMOUNTED
Definition: ntstatus.h:747
EXT2_IDENTIFIER Identifier
Definition: ext2fs.h:633
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by Ext2DispatchRequest().

◆ Ext2CreateFile()

NTSTATUS Ext2CreateFile ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
OUT PBOOLEAN  OpPostIrp 
)

◆ Ext2CreateInode()

NTSTATUS Ext2CreateInode ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  pParentFcb,
IN ULONG  Type,
IN ULONG  FileAttr,
IN PUNICODE_STRING  FileName 
)

◆ Ext2CreateMdl()

PMDL Ext2CreateMdl ( IN PVOID  Buffer,
IN ULONG  Length,
IN LOCK_OPERATION  Operation 
)

Definition at line 64 of file block.c.

69{
71 PMDL Mdl = NULL;
72
73 ASSERT (Buffer != NULL);
75 if (Mdl == NULL) {
77 } else {
78 _SEH2_TRY {
81 } else {
83 }
86 IoFreeMdl (Mdl);
87 Mdl = NULL;
88 DbgBreak();
90 } _SEH2_END;
91 }
92 return Mdl;
93}
UINT op
Definition: effect.c:236
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:424
BOOLEAN NTAPI MmIsNonPagedSystemAddressValid(IN PVOID VirtualAddress)
Definition: mmsup.c:204
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl

Referenced by get_block_bh_mdl().

◆ Ext2CreateVolume()

NTSTATUS Ext2CreateVolume ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

◆ Ext2DbgPrintCall()

VOID Ext2DbgPrintCall ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Referenced by Ext2BuildRequest().

◆ Ext2DbgPrintComplete()

VOID Ext2DbgPrintComplete ( IN PIRP  Irp,
IN BOOLEAN  bPrint 
)

◆ Ext2DeleteFile()

NTSTATUS Ext2DeleteFile ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_FCB  Fcb,
PEXT2_MCB  Mcb 
)

Definition at line 1920 of file fileinfo.c.

1926{
1927 PEXT2_FCB Dcb = NULL;
1928
1930
1931 BOOLEAN VcbResourceAcquired = FALSE;
1932 BOOLEAN FcbPagingIoAcquired = FALSE;
1933 BOOLEAN FcbResourceAcquired = FALSE;
1934 BOOLEAN DcbResourceAcquired = FALSE;
1935
1937 LARGE_INTEGER SysTime;
1938
1939 BOOLEAN bFcbLockAcquired = FALSE;
1940
1941 DEBUG(DL_INF, ( "Ext2DeleteFile: File %wZ (%xh) will be deleted!\n",
1942 &Mcb->FullName, Mcb->Inode.i_ino));
1943
1944 if (IsFlagOn(Mcb->Flags, MCB_FILE_DELETED)) {
1945 return STATUS_SUCCESS;
1946 }
1947
1948 if (!IsMcbSymLink(Mcb) && IsMcbDirectory(Mcb)) {
1949 if (!Ext2IsDirectoryEmpty(IrpContext, Vcb, Mcb)) {
1951 }
1952 }
1953
1954 _SEH2_TRY {
1955
1957
1958 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
1959 VcbResourceAcquired = TRUE;
1960
1962 bFcbLockAcquired = TRUE;
1963
1964 /* Mcb->Parent could be NULL when working with layered file systems */
1965 if (Mcb->Parent) {
1966 Dcb = Mcb->Parent->Fcb;
1967 if (!Dcb)
1968 Dcb = Ext2AllocateFcb(Vcb, Mcb->Parent);
1969 }
1970 if (Dcb)
1971 Ext2ReferXcb(&Dcb->ReferenceCount);
1972
1973 if (bFcbLockAcquired) {
1974 ExReleaseResourceLite(&Vcb->FcbLock);
1975 bFcbLockAcquired = FALSE;
1976 }
1977
1978 if (Dcb) {
1979 DcbResourceAcquired =
1980 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1981
1982 /* remove it's entry form it's parent */
1983 Status = Ext2RemoveEntry(IrpContext, Vcb, Dcb, Mcb);
1984 }
1985
1986 if (NT_SUCCESS(Status)) {
1987
1988 SetFlag(Mcb->Flags, MCB_FILE_DELETED);
1990
1991 if (Fcb) {
1992 FcbResourceAcquired =
1994
1995 FcbPagingIoAcquired =
1997 }
1998
1999 if (DcbResourceAcquired) {
2000 ExReleaseResourceLite(&Dcb->MainResource);
2001 DcbResourceAcquired = FALSE;
2002 }
2003
2004 if (VcbResourceAcquired) {
2005 ExReleaseResourceLite(&Vcb->MainResource);
2006 VcbResourceAcquired = FALSE;
2007 }
2008
2009 if (IsMcbSymLink(Mcb)) {
2010 if (Mcb->Inode.i_nlink > 0) {
2013 }
2014 } else if (!IsMcbDirectory(Mcb)) {
2015 if (Mcb->Inode.i_nlink > 0) {
2017 }
2018 } else {
2019 if (Mcb->Inode.i_nlink >= 2) {
2021 }
2022 }
2023
2024 if (S_ISLNK(Mcb->Inode.i_mode)) {
2025
2026 /* for symlink, we should do differenctly */
2027 if (Mcb->Inode.i_size > EXT2_LINKLEN_IN_INODE) {
2028 Size.QuadPart = (LONGLONG)0;
2029 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &Size);
2030 }
2031
2032 } else {
2033
2034 /* truncate file size */
2035 Size.QuadPart = (LONGLONG)0;
2036 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &Size);
2037
2038 /* check file offset mappings */
2039 DEBUG(DL_EXT, ("Ext2DeleteFile ...: %wZ\n", &Mcb->FullName));
2040
2041 if (Fcb) {
2042 Fcb->Header.AllocationSize.QuadPart = Size.QuadPart;
2043 if (Fcb->Header.FileSize.QuadPart > Size.QuadPart) {
2044 Fcb->Header.FileSize.QuadPart = Size.QuadPart;
2045 Fcb->Mcb->Inode.i_size = Size.QuadPart;
2046 }
2047 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
2048 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
2049 }
2050 } else if (Mcb) {
2051 /* Update the inode's data length . It should be ZERO if succeeds. */
2052 if (Mcb->Inode.i_size > (loff_t)Size.QuadPart) {
2053 Mcb->Inode.i_size = Size.QuadPart;
2054 }
2055 }
2056 }
2057
2058 /* set delete time and free the inode */
2059 KeQuerySystemTime(&SysTime);
2060 Mcb->Inode.i_nlink = 0;
2061 Mcb->Inode.i_dtime = Ext2LinuxTime(SysTime);
2062 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
2063 Ext2FreeInode(IrpContext, Vcb, Mcb->Inode.i_ino, Ext2InodeType(Mcb));
2064 }
2065
2066 } _SEH2_FINALLY {
2067
2068 if (FcbPagingIoAcquired) {
2070 }
2071
2072 if (FcbResourceAcquired) {
2074 }
2075
2076 if (DcbResourceAcquired) {
2077 ExReleaseResourceLite(&Dcb->MainResource);
2078 }
2079
2080 if (bFcbLockAcquired) {
2081 ExReleaseResourceLite(&Vcb->FcbLock);
2082 }
2083
2084 if (VcbResourceAcquired) {
2085 ExReleaseResourceLite(&Vcb->MainResource);
2086 }
2087
2088 if (Dcb) {
2090 }
2091
2093 } _SEH2_END;
2094
2095 DEBUG(DL_INF, ( "Ext2DeleteFile: %wZ Succeed... EXT2SB->S_FREE_BLOCKS = %I64xh .\n",
2096 &Mcb->FullName, ext3_free_blocks_count(SUPER_BLOCK)));
2097
2098 return Status;
2099}
unsigned __int64 loff_t
Definition: types.h:84
NTSTATUS Ext2TruncateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1204
ULONG Ext2InodeType(PEXT2_MCB Mcb)
Definition: fileinfo.c:1906
VOID Ext2ReleaseFcb(IN PEXT2_FCB Fcb)
Definition: memory.c:276
static ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1757
NTSTATUS Ext2FreeInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Inode, IN ULONG Type)
Definition: generic.c:1766
#define EXT2_LINKLEN_IN_INODE
Definition: ext2fs.h:76
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:976
#define SUPER_BLOCK
Definition: ext2fs.h:90
#define S_ISLNK(m)
Definition: ext2fs.h:373
#define Ext2DerefMcb(Mcb)
Definition: ext2fs.h:996
BOOLEAN Ext2RemoveMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:1746
NTSTATUS Ext2RemoveEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN PEXT2_MCB Mcb)
Definition: generic.c:2021
BOOLEAN Ext2IsDirectoryEmpty(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
#define MCB_FILE_DELETED
Definition: ext2fs.h:955
PEXT2_FCB Ext2AllocateFcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:131
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define STATUS_DIRECTORY_NOT_EMPTY
Definition: udferr_usr.h:167
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by Ext2Cleanup(), Ext2CreateFile(), Ext2SetLinkInfo(), and Ext2SetRenameInfo().

◆ Ext2DeQueueCloseRequest()

VOID Ext2DeQueueCloseRequest ( IN PVOID  Context)

Definition at line 222 of file close.c.

223{
224 PEXT2_IRP_CONTEXT IrpContext;
225
226 IrpContext = (PEXT2_IRP_CONTEXT) Context;
227 ASSERT(IrpContext);
228 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
229 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
230
231 _SEH2_TRY {
232
233 _SEH2_TRY {
234
236 Ext2Close(IrpContext);
237
239
240 Ext2ExceptionHandler(IrpContext);
241 } _SEH2_END;
242
243 } _SEH2_FINALLY {
244
246 } _SEH2_END;
247}
NTSTATUS Ext2Close(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: close.c:26
NTSTATUS Ext2ExceptionHandler(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: except.c:112
NTSTATUS Ext2ExceptionFilter(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXCEPTION_POINTERS ExceptionPointer)
Definition: except.c:21
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:158

Referenced by Ext2QueueCloseRequest().

◆ Ext2DeQueueRequest()

VOID Ext2DeQueueRequest ( IN PVOID  Context)

Definition at line 190 of file dispatch.c.

191{
192 PEXT2_IRP_CONTEXT IrpContext;
193
194 IrpContext = (PEXT2_IRP_CONTEXT) Context;
195
196 ASSERT(IrpContext);
197
198 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
199 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
200
201 _SEH2_TRY {
202
203 _SEH2_TRY {
204
206
207 if (!IrpContext->IsTopLevel) {
209 }
210
211 Ext2DispatchRequest(IrpContext);
212
214
215 Ext2ExceptionHandler(IrpContext);
216 } _SEH2_END;
217
218 } _SEH2_FINALLY {
219
221
223 } _SEH2_END;
224}
NTSTATUS Ext2DispatchRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:228
#define FSRTL_FSP_TOP_LEVEL_IRP
Definition: fsrtltypes.h:59

Referenced by Ext2QueueRequest().

◆ Ext2DestroyExtentChain()

VOID Ext2DestroyExtentChain ( IN PEXT2_EXTENT  Chain)

Definition at line 546 of file memory.c.

547{
548 PEXT2_EXTENT Extent = NULL, List = Chain;
549
550 while (List) {
551 Extent = List->Next;
553 List = Extent;
554 }
555}
VOID Ext2FreeExtent(IN PEXT2_EXTENT Extent)
Definition: memory.c:505

Referenced by Ext2GetRetrievalPointers(), Ext2QueryExtentMappings(), Ext2ReadInode(), Ext2WriteInode(), and Ext2WriteVolume().

◆ Ext2DestroyInode()

VOID Ext2DestroyInode ( IN PEXT2_VCB  Vcb,
IN PEXT2_INODE  inode 
)

Definition at line 406 of file memory.c.

407{
408 ASSERT(inode != NULL);
409
410 DEBUG(DL_INF, ("Ext2FreeInode: Inode = %ph.\n", inode));
411
412 ExFreeToNPagedLookasideList(&(Vcb->InodeLookasideList), inode);
414}

Referenced by ext4_fs_get_xattr_ref(), and ext4_fs_put_xattr_ref().

◆ Ext2DestroyMdl()

VOID Ext2DestroyMdl ( IN PMDL  Mdl)

Definition at line 97 of file block.c.

98{
99 ASSERT (Mdl != NULL);
100 while (Mdl) {
101 PMDL Next;
102 Next = Mdl->Next;
103 Mdl->Next = NULL;
104 if (IsFlagOn(Mdl->MdlFlags, MDL_PAGES_LOCKED)) {
106 }
107 IoFreeMdl (Mdl);
108 Mdl = Next;
109 }
110}
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19

Referenced by free_buffer_head().

◆ Ext2DestroyVcb()

VOID Ext2DestroyVcb ( IN PEXT2_VCB  Vcb)

Definition at line 2825 of file memory.c.

2826{
2827 ASSERT(Vcb != NULL);
2828 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2829 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2830
2831 DEBUG(DL_FUN, ("Ext2DestroyVcb ...\n"));
2832
2833 if (Vcb->Volume) {
2835 }
2836 ASSERT(NULL == Vcb->Volume);
2837
2838 FsRtlNotifyUninitializeSync(&Vcb->NotifySync);
2839 Ext2ListExtents(&Vcb->Extents);
2840 FsRtlUninitializeLargeMcb(&(Vcb->Extents));
2841
2843
2844 Ext2DropBH(Vcb);
2845
2846 if (Vcb->bd.bd_bh_cache)
2847 kmem_cache_destroy(Vcb->bd.bd_bh_cache);
2848 ExDeleteResourceLite(&Vcb->bd.bd_bh_lock);
2849
2850 if (Vcb->SuperBlock) {
2851 Ext2FreePool(Vcb->SuperBlock, EXT2_SB_MAGIC);
2852 Vcb->SuperBlock = NULL;
2853 }
2854
2855 if (IsFlagOn(Vcb->Flags, VCB_NEW_VPB)) {
2856 ASSERT(Vcb->Vpb2 != NULL);
2857 DEBUG(DL_DBG, ("Ext2DestroyVcb: Vpb2 to be freed: %p\n", Vcb->Vpb2));
2859 DEC_MEM_COUNT(PS_VPB, Vcb->Vpb2, sizeof(VPB));
2860 Vcb->Vpb2 = NULL;
2861 }
2862
2863 ObDereferenceObject(Vcb->TargetDeviceObject);
2864
2865 ExDeleteNPagedLookasideList(&(Vcb->InodeLookasideList));
2866 ExDeleteResourceLite(&Vcb->FcbLock);
2867 ExDeleteResourceLite(&Vcb->McbLock);
2868 ExDeleteResourceLite(&Vcb->MetaInode);
2869 ExDeleteResourceLite(&Vcb->MetaBlock);
2870 ExDeleteResourceLite(&Vcb->sbi.s_gd_lock);
2871 ExDeleteResourceLite(&Vcb->PagingIoResource);
2872 ExDeleteResourceLite(&Vcb->MainResource);
2873
2874 DEBUG(DL_DBG, ("Ext2DestroyVcb: DevObject=%p Vcb=%p\n", Vcb->DeviceObject, Vcb));
2875 IoDeleteDevice(Vcb->DeviceObject);
2876 DEC_MEM_COUNT(PS_VCB, Vcb->DeviceObject, sizeof(EXT2_VCB));
2877}
#define PS_VCB
Definition: common.h:17
VOID Ext2TearDownStream(IN PEXT2_VCB Vcb)
Definition: memory.c:2798
BOOLEAN Ext2ListExtents(PLARGE_MCB Extents)
Definition: memory.c:558
VOID Ext2CleanupAllMcbs(PEXT2_VCB Vcb)
Definition: memory.c:1810
#define ExDeleteResourceLite(res)
Definition: env_spec_w32.h:647
#define EXT2_SB_MAGIC
Definition: ext2fs.h:302
VOID Ext2DropBH(IN PEXT2_VCB Vcb)
Definition: generic.c:266
#define DL_FUN
Definition: ext2fs.h:1437
VOID NTAPI FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
Definition: largemcb.c:1096
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:170
int kmem_cache_destroy(kmem_cache_t *kc)
Definition: linux.c:82
VOID NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1668
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by Ext2CheckDismount(), and Ext2MountVolume().

◆ Ext2DeviceControl()

NTSTATUS Ext2DeviceControl ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 783 of file devctl.c.

784{
785 PIRP Irp;
787 ULONG code;
790
791 ASSERT(IrpContext);
792
793 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
794 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
795
796 Irp = IrpContext->Irp;
797
799
800 code = irpSp->Parameters.DeviceIoControl.IoControlCode;
801 length = irpSp->Parameters.DeviceIoControl.OutputBufferLength;
802
803 switch (code) {
804
807 IrpContext,
808 Irp->AssociatedIrp.SystemBuffer,
809 length
810 );
811 break;
812
815 IrpContext,
816 Irp->AssociatedIrp.SystemBuffer,
817 length
818 );
819 break;
820
823 IrpContext,
824 Irp->AssociatedIrp.SystemBuffer,
825 length
826 );
827 break;
828
829#if EXT2_UNLOAD
830 case IOCTL_PREPARE_TO_UNLOAD:
831 Status = Ext2PrepareToUnload(IrpContext);
832 break;
833#endif
834 default:
835 Status = Ext2DeviceControlNormal(IrpContext);
836 }
837
838 return Status;
839}
#define IOCTL_APP_MOUNT_POINT
Definition: common.h:11
#define IOCTL_APP_VOLUME_PROPERTY
Definition: common.h:5
NTSTATUS Ext2DeviceControlNormal(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: devctl.c:65
NTSTATUS Ext2ProcessUserProperty(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VOLUME_PROPERTY3 Property, IN ULONG Length)
Definition: devctl.c:591
NTSTATUS Ex2ProcessMountPoint(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_MOUNT_POINT MountPoint, IN ULONG Length)
Definition: devctl.c:723
NTSTATUS Ex2ProcessUserPerfStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_QUERY_PERFSTAT QueryPerf, IN ULONG Length)
Definition: devctl.c:640
NTSTATUS Ext2PrepareToUnload(IN PEXT2_IRP_CONTEXT IrpContext)
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
Definition: inflate.c:139

Referenced by Ext2DispatchRequest().

◆ Ext2DeviceControlNormal()

NTSTATUS Ext2DeviceControlNormal ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 65 of file devctl.c.

66{
70
72
73 PIRP Irp;
75 PIO_STACK_LOCATION NextIrpSp;
76
78
79 _SEH2_TRY {
80
81 ASSERT(IrpContext != NULL);
82
83 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
84 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
85
87
88 DeviceObject = IrpContext->DeviceObject;
89
93 }
94
95 Irp = IrpContext->Irp;
97
98 Vcb = (PEXT2_VCB) IrpSp->FileObject->FsContext;
99
100 if (!((Vcb) && (Vcb->Identifier.Type == EXT2VCB) &&
101 (Vcb->Identifier.Size == sizeof(EXT2_VCB)))) {
104 }
105
106 TargetDeviceObject = Vcb->TargetDeviceObject;
107
108 //
109 // Pass on the IOCTL to the driver below
110 //
111
113
114 NextIrpSp = IoGetNextIrpStackLocation( Irp );
115 *NextIrpSp = *IrpSp;
116
118 Irp,
120 NULL,
121 FALSE,
122 TRUE,
123 TRUE );
124
126
127 } _SEH2_FINALLY {
128
129 if (!IrpContext->ExceptionInProgress) {
130 if (IrpContext) {
131 if (!CompleteRequest) {
132 IrpContext->Irp = NULL;
133 }
134
135 Ext2CompleteIrpContext(IrpContext, Status);
136 }
137 }
138 } _SEH2_END;
139
140 return Status;
141}
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
NTSTATUS Ext2DeviceControlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: devctl.c:50
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1674
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695

Referenced by Ext2DeviceControl().

◆ Ext2DirectoryControl()

NTSTATUS Ext2DirectoryControl ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1236 of file dirctl.c.

1237{
1239
1240 ASSERT(IrpContext);
1241
1242 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
1243 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
1244
1245 switch (IrpContext->MinorFunction) {
1246
1248 Status = Ext2QueryDirectory(IrpContext);
1249 break;
1250
1252 Status = Ext2NotifyChangeDirectory(IrpContext);
1253 break;
1254
1255 default:
1257 Ext2CompleteIrpContext(IrpContext, Status);
1258 }
1259
1260 return Status;
1261}
NTSTATUS Ext2QueryDirectory(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dirctl.c:525
NTSTATUS Ext2NotifyChangeDirectory(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dirctl.c:1029
#define IRP_MN_QUERY_DIRECTORY
Definition: rdpdr.c:55
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY
Definition: rdpdr.c:56

Referenced by Ext2DispatchRequest().

◆ Ext2DiskIoControl()

NTSTATUS Ext2DiskIoControl ( IN PDEVICE_OBJECT  DeviceOjbect,
IN ULONG  IoctlCode,
IN PVOID  InputBuffer,
IN ULONG  InputBufferSize,
IN OUT PVOID  OutputBuffer,
IN OUT PULONG  OutputBufferSize 
)

Definition at line 609 of file block.c.

616{
619 PIRP Irp;
622
624
625 if (OutputBufferSize)
626 {
627 OutBufferSize = *OutputBufferSize;
628 }
629
631
633 IoctlCode,
636 InputBufferSize,
639 FALSE,
640 &Event,
641 &IoStatus
642 );
643
644 if (Irp == NULL) {
645 DEBUG(DL_ERR, ( "Ext2DiskIoControl: failed to build Irp!\n"));
647 }
648
650
651 if (Status == STATUS_PENDING) {
653 Status = IoStatus.Status;
654 }
655
656 if (OutputBufferSize) {
657 *OutputBufferSize = (ULONG)(IoStatus.Information);
658 }
659
660 return Status;
661}
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
@ NotificationEvent
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG IoctlCode
Definition: wdfiotarget.h:1043
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87

Referenced by Ext2InitializeVcb(), Ext2MountVolume(), Ext2VerifyVcb(), and Ext2VerifyVolume().

◆ Ext2DiskShutDown()

NTSTATUS Ext2DiskShutDown ( PEXT2_VCB  Vcb)

Definition at line 748 of file block.c.

749{
750 PIRP Irp;
752
755
757
759 Vcb->TargetDeviceObject,
760 NULL,
761 0,
762 NULL,
763 &Event,
764 &IoStatus);
765
766 if (Irp) {
767 Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
768
769 if (Status == STATUS_PENDING) {
771 Executive,
773 FALSE,
774 NULL);
775
776 Status = IoStatus.Status;
777 }
778 } else {
779 Status = IoStatus.Status;
780 }
781
782 return Status;
783}
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069

Referenced by Ext2ShutDown().

◆ Ext2DismountVolume()

NTSTATUS Ext2DismountVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2521 of file fsctl.c.

2522{
2525 PEXT2_VCB Vcb = NULL;
2526 BOOLEAN VcbResourceAcquired = FALSE;
2527
2528 _SEH2_TRY {
2529
2530 ASSERT(IrpContext != NULL);
2531
2532 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2533 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2534
2535 DeviceObject = IrpContext->DeviceObject;
2536
2537 //
2538 // This request is not allowed on the main device object
2539 //
2543 }
2544
2545 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
2546
2547 ASSERT(Vcb != NULL);
2548
2549 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2550 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2551
2553
2555 &Vcb->MainResource,
2556 TRUE );
2557
2558 VcbResourceAcquired = TRUE;
2559
2560 if ( IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
2563 }
2564
2565 Ext2FlushFiles(IrpContext, Vcb, FALSE);
2566 Ext2FlushVolume(IrpContext, Vcb, FALSE);
2567
2568 ExReleaseResourceLite(&Vcb->MainResource);
2569 VcbResourceAcquired = FALSE;
2570
2572 Ext2CheckDismount(IrpContext, Vcb, TRUE);
2573
2574 DEBUG(DL_INF, ( "Ext2Dismount: Volume dismount pending.\n"));
2576
2577 } _SEH2_FINALLY {
2578
2579 if (VcbResourceAcquired) {
2580 ExReleaseResourceLite(&Vcb->MainResource);
2581 }
2582
2583 if (!IrpContext->ExceptionInProgress) {
2584 Ext2CompleteIrpContext(IrpContext, Status);
2585 }
2586 } _SEH2_END;
2587
2588 return Status;
2589}
NTSTATUS Ext2PurgeVolume(IN PEXT2_VCB Vcb, IN BOOLEAN FlushBeforePurge)
Definition: fsctl.c:2704
BOOLEAN Ext2CheckDismount(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bForce)
Definition: fsctl.c:2592
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:112
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:43

Referenced by Ext2UserFsRequest().

◆ Ext2DispatchRequest()

NTSTATUS Ext2DispatchRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 228 of file dispatch.c.

229{
230 ASSERT(IrpContext);
231
232 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
233 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
234
235 switch (IrpContext->MajorFunction) {
236
237 case IRP_MJ_CREATE:
238 return Ext2Create(IrpContext);
239
240 case IRP_MJ_CLOSE:
241 return Ext2Close(IrpContext);
242
243 case IRP_MJ_READ:
244 return Ext2Read(IrpContext);
245
246 case IRP_MJ_WRITE:
247 return Ext2Write(IrpContext);
248
250 return Ext2Flush(IrpContext);
251
253 return Ext2QueryFileInformation(IrpContext);
254
256 return Ext2SetFileInformation(IrpContext);
257
259 return Ext2QueryVolumeInformation(IrpContext);
260
262 return Ext2SetVolumeInformation(IrpContext);
263
265 return Ext2DirectoryControl(IrpContext);
266
268 return Ext2FileSystemControl(IrpContext);
269
271 return Ext2DeviceControl(IrpContext);
272
274 return Ext2LockControl(IrpContext);
275
276 case IRP_MJ_CLEANUP:
277 return Ext2Cleanup(IrpContext);
278
279 case IRP_MJ_SHUTDOWN:
280 return Ext2ShutDown(IrpContext);
281
282 case IRP_MJ_QUERY_EA:
283 return Ext2QueryEa(IrpContext);
284
285 case IRP_MJ_SET_EA:
286 return Ext2SetEa(IrpContext);
287
288#if (_WIN32_WINNT >= 0x0500)
289 case IRP_MJ_PNP:
290 return Ext2Pnp(IrpContext);
291#endif //(_WIN32_WINNT >= 0x0500)
292 default:
293 DEBUG(DL_ERR, ( "Ext2DispatchRequest: Unexpected major function: %xh\n",
294 IrpContext->MajorFunction));
295
297
299 }
300}
ARC_STATUS Ext2Close(ULONG FileId)
Definition: ext2.c:1192
ARC_STATUS Ext2Read(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: ext2.c:1240
NTSTATUS Ext2QueryEa(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: ea.c:94
NTSTATUS Ext2Pnp(IN PEXT2_IRP_CONTEXT IrpContext)
NTSTATUS Ext2Flush(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: flush.c:148
NTSTATUS Ext2ShutDown(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: shutdown.c:25
NTSTATUS Ext2Cleanup(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: cleanup.c:21
NTSTATUS Ext2DirectoryControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dirctl.c:1236
NTSTATUS Ext2Create(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: create.c:1951
NTSTATUS Ext2SetFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:514
NTSTATUS Ext2QueryVolumeInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: volinfo.c:27
NTSTATUS Ext2LockControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: lock.c:25
NTSTATUS Ext2FileSystemControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2848
NTSTATUS Ext2SetVolumeInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: volinfo.c:292
NTSTATUS Ext2DeviceControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: devctl.c:783
NTSTATUS Ext2Write(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: write.c:1355
NTSTATUS Ext2QueryFileInformation(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fileinfo.c:48
NTSTATUS Ext2SetEa(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: ea.c:436
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_DRIVER_INTERNAL_ERROR
Definition: udferr_usr.h:177
#define IRP_MJ_QUERY_EA
#define IRP_MJ_SET_VOLUME_INFORMATION
#define IRP_MJ_SET_EA
#define IRP_MJ_FLUSH_BUFFERS

Referenced by Ext2BuildRequest(), and Ext2DeQueueRequest().

◆ Ext2DropBH()

VOID Ext2DropBH ( IN PEXT2_VCB  Vcb)

Definition at line 266 of file generic.c.

267{
268 struct ext3_sb_info *sbi = &Vcb->sbi;
269
270 /* do nothing if Vcb is not initialized yet */
271 if (!IsFlagOn(Vcb->Flags, VCB_INITIALIZED))
272 return;
273
274 _SEH2_TRY {
275
276 /* acquire bd lock to avoid bh creation */
277 ExAcquireResourceExclusiveLite(&Vcb->bd.bd_bh_lock, TRUE);
278
281
282 while (!IsListEmpty(&Vcb->bd.bd_bh_free)) {
283 struct buffer_head *bh;
285 l = RemoveHeadList(&Vcb->bd.bd_bh_free);
286 bh = CONTAINING_RECORD(l, struct buffer_head, b_link);
288 if (0 == atomic_read(&bh->b_count)) {
289 buffer_head_remove(&Vcb->bd, bh);
291 }
292 }
293
294 } _SEH2_FINALLY {
295 ExReleaseResourceLite(&Vcb->bd.bd_bh_lock);
296 } _SEH2_END;
297
299}
r l[0]
Definition: byte_order.h:168
#define VCB_INITIALIZED
Definition: ext2fs.h:788
#define VCB_BEING_DROPPED
Definition: ext2fs.h:798
VOID Ext2DropGroupBH(IN PEXT2_VCB Vcb)
Definition: generic.c:132
void buffer_head_remove(struct block_device *bdev, struct buffer_head *bh)
Definition: linux.c:424

Referenced by Ext2DestroyVcb(), Ext2FlushVcb(), and Ext2PurgeVolume().

◆ Ext2DropGroupBH()

VOID Ext2DropGroupBH ( IN PEXT2_VCB  Vcb)

Definition at line 132 of file generic.c.

133{
134 struct ext3_sb_info *sbi = &Vcb->sbi;
135 unsigned long i;
136
137 if (NULL == Vcb->sbi.s_gd) {
138 return;
139 }
140
141 for (i = 0; i < Vcb->sbi.s_gdb_count; i++) {
142 if (Vcb->sbi.s_gd[i].bh) {
143 fini_bh(&sbi->s_gd[i].bh);
144 Vcb->sbi.s_gd[i].bh = NULL;
145 }
146 }
147}
struct ext3_gd * s_gd
Definition: ext3_fs_sb.h:35

Referenced by Ext2DropBH(), and Ext2PutGroup().

◆ Ext2ExceptionFilter()

NTSTATUS Ext2ExceptionFilter ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXCEPTION_POINTERS  ExceptionPointer 
)

Definition at line 21 of file except.c.

25{
28 PEXCEPTION_RECORD ExceptRecord;
29
30 ExceptRecord = ExceptionPointer->ExceptionRecord;
31 ExceptionCode = ExceptRecord->ExceptionCode;
32
33 DbgPrint("-------------------------------------------------------------\n");
34 DbgPrint("Exception happends in Ext2Fsd (code %xh):\n", ExceptionCode);
35 DbgPrint(".exr %p;.cxr %p;\n", ExceptionPointer->ExceptionRecord,
36 ExceptionPointer->ContextRecord);
37 DbgPrint("-------------------------------------------------------------\n");
38
39 DbgBreak();
40
41 //
42 // Check IrpContext is valid or not
43 //
44
45 if (IrpContext) {
46 if ((IrpContext->Identifier.Type != EXT2ICX) ||
47 (IrpContext->Identifier.Size != sizeof(EXT2_IRP_CONTEXT))) {
48 DbgBreak();
49 IrpContext = NULL;
50 } else if (IrpContext->DeviceObject) {
52 Vcb = (PEXT2_VCB) IrpContext->DeviceObject->DeviceExtension;
53 if (NULL == Vcb) {
55 } else {
56 if (Vcb->Identifier.Type == EXT2VCB && !IsMounted(Vcb)) {
58 }
59 }
60 }
61 } else {
64 } else {
66 (ULONG_PTR)ExceptionPointer->ContextRecord,
67 (ULONG_PTR)ExceptRecord->ExceptionAddress );
68 }
69 }
70
71 if (IrpContext) {
72 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
73 }
74
77 //
78 // If the exception is expected execute our handler
79 //
80
81 DEBUG(DL_ERR, ( "Ext2ExceptionFilter: Catching exception %xh\n",
83
85
86 if (IrpContext) {
87 IrpContext->ExceptionInProgress = TRUE;
88 IrpContext->ExceptionCode = ExceptionCode;
89 }
90
91 } else {
92
93 //
94 // Continue search for an higher level exception handler
95 //
96
97 DEBUG(DL_ERR, ( "Ext2ExceptionFilter: Passing on exception %#x\n",
99
101
102 if (IrpContext) {
103 Ext2FreeIrpContext(IrpContext);
104 }
105 }
106
107 return Status;
108}
#define EXT2_BUGCHK_EXCEPT
Definition: ext2fs.h:323
#define Ext2BugCheck(A, B, C, D)
Definition: ext2fs.h:340
#define DbgPrint
Definition: hal.h:12
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
BOOLEAN NTAPI FsRtlIsNtstatusExpected(IN NTSTATUS NtStatus)
Definition: filter.c:61
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
DWORD ExceptionCode
Definition: compat.h:208
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by Ext2BuildRequest(), Ext2DeQueueCloseRequest(), and Ext2DeQueueRequest().

◆ Ext2ExceptionHandler()

NTSTATUS Ext2ExceptionHandler ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 112 of file except.c.

113{
115
116 if (IrpContext) {
117
118 if ( (IrpContext->Identifier.Type != EXT2ICX) ||
119 (IrpContext->Identifier.Size != sizeof(EXT2_IRP_CONTEXT))) {
120 DbgBreak();
121 return STATUS_UNSUCCESSFUL;
122 }
123
124 Status = IrpContext->ExceptionCode;
125
126 if (IrpContext->Irp) {
127
128 //
129 // Check if this error is a result of user actions
130 //
131
133 PIRP Irp = IrpContext->Irp;
135
137 Vcb = (PEXT2_VCB) IrpContext->DeviceObject->DeviceExtension;
138
139 if (NULL == Vcb) {
141 } else if (Vcb->Identifier.Type != EXT2VCB) {
143 } else if (!IsMounted(Vcb)) {
144 if (IsFlagOn(Vcb->Flags, VCB_DEVICE_REMOVED)) {
146 } else {
148 }
149 } else {
150
151 /* queue it again if our request is at top level */
152 if (IrpContext->IsTopLevel &&
153 ((Status == STATUS_CANT_WAIT) ||
155 (KeGetCurrentIrql() >= APC_LEVEL)))) {
156
157 Status = Ext2QueueRequest(IrpContext);
158 }
159 }
160
161 if (Status == STATUS_PENDING) {
162 goto errorout;
163 }
164
165 Irp->IoStatus.Status = Status;
166
168
169 //
170 // Now we will generate a pop-up to user
171 //
172
173 PDEVICE_OBJECT RealDevice;
174 PVPB Vpb = NULL;
176
177 if (IrpSp->FileObject != NULL) {
178 Vpb = IrpSp->FileObject->Vpb;
179 }
180
181 //
182 // Get the initial thread
183 //
184
185 Thread = Irp->Tail.Overlay.Thread;
186 RealDevice = IoGetDeviceToVerify( Thread );
187
188 if (RealDevice == NULL) {
189 //
190 // Get current thread
191 //
192
194 RealDevice = IoGetDeviceToVerify( Thread );
195
196 ASSERT( RealDevice != NULL );
197 }
198
199 Status = IrpContext->ExceptionCode;
200
201 if (RealDevice != NULL) {
202
203 if (IrpContext->ExceptionCode == STATUS_VERIFY_REQUIRED) {
204
205 Status = IoVerifyVolume (RealDevice, FALSE);
206
207 ExAcquireResourceSharedLite(&Vcb->MainResource, TRUE);
208 if (NT_SUCCESS(Status) && (!IsMounted(Vcb) ||
211 }
212 ExReleaseResourceLite(&Vcb->MainResource);
213
214 if (Ext2CheckDismount(IrpContext, Vcb, FALSE)) {
217 Irp = NULL;
218 goto errorout;
219 }
220
221 if ( (IrpContext->MajorFunction == IRP_MJ_CREATE) &&
222 (IrpContext->FileObject->RelatedFileObject == NULL) &&
224
225 Irp->IoStatus.Information = IO_REMOUNT;
226
229 Irp = NULL;
230 }
231
232 if (Irp) {
233
234 if (!NT_SUCCESS(Status)) {
238 }
239
240 Status = Ext2QueueRequest(IrpContext);
241 }
242
243 goto errorout;
244
245 } else {
246
248
250 IoRaiseHardError( Irp, Vpb, RealDevice );
252 goto release_context;
253 }
254 }
255 }
256
258 }
259
260release_context:
261
262 Ext2FreeIrpContext(IrpContext);
263
264 } else {
265
267 }
268
269errorout:
270
271 return Status;
272}
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
BOOLEAN Ext2CheckDismount(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bForce)
Definition: fsctl.c:2592
#define Ext2NormalizeAndRaiseStatus(IRPCONTEXT, STATUS)
Definition: ext2fs.h:268
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
IoMarkIrpPending(Irp)
VOID NTAPI IoRaiseHardError(IN PIRP Irp, IN PVPB Vpb, IN PDEVICE_OBJECT RealDeviceObject)
Definition: error.c:664
VOID NTAPI IoSetDeviceToVerify(IN PETHREAD Thread, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:304
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
PDEVICE_OBJECT NTAPI IoGetDeviceToVerify(IN PETHREAD Thread)
Definition: util.c:336
NTSTATUS NTAPI IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount)
Definition: volume.c:877
#define STATUS_REPARSE
Definition: ntstatus.h:83
#define STATUS_WRONG_VOLUME
Definition: udferr_usr.h:140
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2817
#define IO_REMOUNT
Definition: iotypes.h:544

Referenced by Ext2BuildRequest(), Ext2DeQueueCloseRequest(), and Ext2DeQueueRequest().

◆ Ext2ExpandExtent()

NTSTATUS Ext2ExpandExtent ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
ULONG  Start,
ULONG  End,
PLARGE_INTEGER  Size 
)

Definition at line 151 of file extents.c.

159{
160 ULONG Count = 0, Number = 0, Block = 0;
162
163 if (End <= Start)
164 return Status;
165
166 while (End > Start + Count) {
167
168 Number = End - Start - Count;
169 Status = Ext2DoExtentExpand(IrpContext, Vcb, Mcb, Start + Count,
170 &Block, &Number);
171 if (!NT_SUCCESS(Status)) {
173 break;
174 }
175 if (Number == 0) {
177 break;
178 }
179
180 if (Block && IsZoneInited(Mcb)) {
181 if (!Ext2AddBlockExtent(Vcb, Mcb, Start + Count, Block, Number)) {
182 DbgBreak();
184 Ext2ClearAllExtents(&Mcb->Extents);
185 }
186 }
187 Count += Number;
188 }
189
190 Size->QuadPart = ((LONGLONG)(Start + Count)) << BLOCK_BITS;
191
192 /* save inode whatever it succeeds to expand or not */
193 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
194
195 return Status;
196}
BOOLEAN Ext2AddBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Block, IN ULONG Number)
Definition: memory.c:1027
VOID Ext2ClearAllExtents(PLARGE_MCB Zone)
Definition: memory.c:637
NTSTATUS Ext2DoExtentExpand(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN OUT PULONG Block, IN OUT PULONG Number)
Definition: extents.c:105
int Count
Definition: noreturn.cpp:7

Referenced by Ext2ExpandFile().

◆ Ext2ExpandFile()

NTSTATUS Ext2ExpandFile ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
PLARGE_INTEGER  Size 
)

Definition at line 1152 of file fileinfo.c.

1158{
1160 ULONG Start = 0;
1161 ULONG End = 0;
1162
1163 Start = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1164 End = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1165
1166 /* it's a truncate operation, not expanding */
1167 if (Start >= End) {
1168 Size->QuadPart = ((LONGLONG) Start) << BLOCK_BITS;
1169 return STATUS_SUCCESS;
1170 }
1171
1172 /* ignore special files */
1173 if (IsMcbSpecialFile(Mcb)) {
1175 }
1176
1177 /* expandind file extents */
1178 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1179
1180 status = Ext2ExpandExtent(IrpContext, Vcb, Mcb, Start, End, Size);
1181
1182 } else {
1183
1184 BOOLEAN do_expand;
1185
1186#if EXT2_PRE_ALLOCATION_SUPPORT
1187 do_expand = TRUE;
1188#else
1189 do_expand = (IrpContext->MajorFunction == IRP_MJ_WRITE) ||
1191#endif
1192 if (!do_expand)
1193 goto errorout;
1194
1195 status = Ext2ExpandIndirect(IrpContext, Vcb, Mcb, Start, End, Size);
1196 }
1197
1198errorout:
1199 return status;
1200}
NTSTATUS Ext2ExpandIndirect(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Start, ULONG End, PLARGE_INTEGER Size)
Definition: indirect.c:948
#define IsMcbSpecialFile(Mcb)
Definition: ext2fs.h:964
NTSTATUS Ext2ExpandExtent(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Start, ULONG End, PLARGE_INTEGER Size)
Definition: extents.c:151

Referenced by Ext2CreateFile(), Ext2SetFileInformation(), Ext2SupersedeOrOverWriteFile(), Ext2WriteFile(), and ext3_append().

◆ Ext2ExpandIndirect()

NTSTATUS Ext2ExpandIndirect ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
ULONG  Start,
ULONG  End,
PLARGE_INTEGER  Size 
)

Definition at line 948 of file indirect.c.

956{
958
959 ULONG Layer = 0;
960 ULONG Extra = 0;
961 ULONG Hint = 0;
962 ULONG Slot = 0;
963 ULONG Base = 0;
964
965 Extra = End - Start;
966
967 /* exceeds the biggest file size (indirect) */
968 if (End > Vcb->max_data_blocks) {
970 }
971
972 for (Layer = 0; Layer < EXT2_BLOCK_TYPES && Extra; Layer++) {
973
974 if (Start >= Vcb->max_blocks_per_layer[Layer]) {
975
976 Base += Vcb->max_blocks_per_layer[Layer];
977 Start -= Vcb->max_blocks_per_layer[Layer];
978
979 } else {
980
981 /* get the slot in i_block array */
982 if (Layer == 0) {
983 Base = Slot = Start;
984 } else {
985 Slot = Layer + EXT2_NDIR_BLOCKS - 1;
986 }
987
988 /* set block hint to avoid fragments */
989 if (Hint == 0) {
990 if (Mcb->Inode.i_block[Slot] != 0) {
991 Hint = Mcb->Inode.i_block[Slot];
992 } else if (Slot > 1) {
993 Hint = Mcb->Inode.i_block[Slot-1];
994 }
995 }
996
997 /* now expand this slot */
999 IrpContext,
1000 Vcb,
1001 Mcb,
1002 Base,
1003 Layer,
1004 Start,
1005 (Layer == 0) ? (Vcb->max_blocks_per_layer[Layer] - Start) : 1,
1006#ifdef __REACTOS__
1007 (PULONG)&Mcb->Inode.i_block[Slot],
1008#else
1009 &Mcb->Inode.i_block[Slot],
1010#endif
1011 &Hint,
1012 &Extra
1013 );
1014 if (!NT_SUCCESS(Status)) {
1015 break;
1016 }
1017
1018 Start = 0;
1019 if (Layer == 0) {
1020 Base = 0;
1021 }
1022 Base += Vcb->max_blocks_per_layer[Layer];
1023 }
1024 }
1025
1026 Size->QuadPart = ((LONGLONG)(End - Extra)) << BLOCK_BITS;
1027
1028 /* save inode whatever it succeeds to expand or not */
1029 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
1030
1031 return Status;
1032}
#define EXT2_NDIR_BLOCKS
Definition: ext2_fs.h:177
#define EXT2_BLOCK_TYPES
Definition: ext2fs.h:77
NTSTATUS Ext2ExpandBlock(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Base, IN ULONG Layer, IN ULONG Start, IN ULONG SizeArray, IN PULONG BlockArray, IN PULONG Hint, IN PULONG Extra)
Definition: indirect.c:345
Definition: xml2sdb.h:111

Referenced by Ext2ExpandFile().

◆ Ext2FastIoCheckIfPossible()

BOOLEAN Ext2FastIoCheckIfPossible ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN ULONG  Length,
IN BOOLEAN  Wait,
IN ULONG  LockKey,
IN BOOLEAN  CheckForReadOperation,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 64 of file fastio.c.

74{
75 BOOLEAN bPossible = FastIoIsNotPossible;
78 LARGE_INTEGER lLength;
79
80 lLength.QuadPart = Length;
81
82 _SEH2_TRY {
83
85
86 _SEH2_TRY {
87
90 }
91
92 Fcb = (PEXT2_FCB) FileObject->FsContext;
93 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
95 }
96
98 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
99
100 /* do nothing if target fie was deleted */
103 }
104
105 if (IsDirectory(Fcb)) {
107 }
108
109 Ccb = (PEXT2_CCB) FileObject->FsContext2;
110 if (Ccb == NULL) {
112 }
113
115
116 bPossible = FsRtlFastCheckLockForRead(
117 &Fcb->FileLockAnchor,
119 &lLength,
120 LockKey,
123
124 } else {
125
126 if (!IsVcbReadOnly(Fcb->Vcb)) {
127 bPossible = FsRtlFastCheckLockForWrite(
128 &Fcb->FileLockAnchor,
130 &lLength,
131 LockKey,
134 }
135 }
136
137#if EXT2_DEBUG
138 DEBUG(DL_INF, ("Ext2FastIIOCheckPossible: %s %s %wZ\n",
140 "FASTIO_CHECK_IF_POSSIBLE",
141 &Fcb->Mcb->FullName
142 ));
143
144 DEBUG(DL_INF, (
145 "Ext2FastIIOCheckPossible: Offset: %I64xg Length: %xh Key: %u %s %s\n",
146 FileOffset->QuadPart,
147 Length,
148 LockKey,
149 (CheckForReadOperation ? "CheckForReadOperation:" :
150 "CheckForWriteOperation:"),
151 (bPossible ? "Succeeded" : "Failed")));
152#endif
153
155 bPossible = FastIoIsNotPossible;
156 } _SEH2_END;
157
158 } _SEH2_FINALLY {
159
161 } _SEH2_END;
162
163 return bPossible;
164}
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2665
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN CheckForReadOperation
Definition: fatprocs.h:2666
BOOLEAN NTAPI FsRtlFastCheckLockForWrite(IN PFILE_LOCK FileLock, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN PFILE_OBJECT FileObject, IN PVOID Process)
Definition: filelock.c:782
BOOLEAN NTAPI FsRtlFastCheckLockForRead(IN PFILE_LOCK FileLock, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN PFILE_OBJECT FileObject, IN PVOID Process)
Definition: filelock.c:748
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by DriverEntry().

◆ Ext2FastIoLock()

BOOLEAN Ext2FastIoLock ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN PLARGE_INTEGER  Length,
IN PEPROCESS  Process,
IN ULONG  Key,
IN BOOLEAN  FailImmediately,
IN BOOLEAN  ExclusiveLock,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 517 of file fastio.c.

528{
531
532 _SEH2_TRY {
533
535
536 _SEH2_TRY {
537
541 }
542
543 Fcb = (PEXT2_FCB) FileObject->FsContext;
544 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
547 }
548
550 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
551
552 if (IsDirectory(Fcb)) {
553 DbgBreak();
556 }
557#if EXT2_DEBUG
558 DEBUG(DL_INF, (
559 "Ext2FastIoLock: %s %s %wZ\n",
561 "FASTIO_LOCK",
562 &Fcb->Mcb->FullName ));
563
564 DEBUG(DL_INF, (
565 "Ext2FastIoLock: Offset: %I64xh Length: %I64xh Key: %u %s%s\n",
566 FileOffset->QuadPart,
567 Length->QuadPart,
568 Key,
569 (FailImmediately ? "FailImmediately " : ""),
570 (ExclusiveLock ? "ExclusiveLock " : "") ));
571#endif
572
573 if (!FsRtlOplockIsFastIoPossible(&Fcb->Oplock)) {
575 }
576
578 &Fcb->FileLockAnchor,
581 Length,
582 Process,
583 Key,
586 IoStatus,
587 NULL,
588 FALSE);
589
590 if (Status) {
591 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
592 }
593
596 } _SEH2_END;
597
598 } _SEH2_FINALLY {
599
601 } _SEH2_END;
602
603#if EXT2_DEBUG
604 if (Status == FALSE) {
605 DEBUG(DL_ERR, (
606 "Ext2FastIoLock: %s %s *** Status: FALSE ***\n",
608 "FASTIO_LOCK"
609 ));
610 } else if (IoStatus->Status != STATUS_SUCCESS) {
611 DEBUG(DL_ERR, (
612 "Ext2FastIoLock: %s %s *** Status: %s (%#x) ***\n",
614 "FASTIO_LOCK",
616 IoStatus->Status
617 ));
618 }
619#endif
620
621 return Status;
622}
FAST_IO_POSSIBLE Ext2IsFastIoPossible(IN PEXT2_FCB Fcb)
Definition: fastio.c:38
PUCHAR Ext2NtStatusToString(IN NTSTATUS Status)
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN BOOLEAN ExclusiveLock
Definition: fatprocs.h:2714
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN FailImmediately
Definition: fatprocs.h:2713
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
Definition: fsrtlfuncs.h:1581
BOOLEAN NTAPI FsRtlOplockIsFastIoPossible(IN POPLOCK Oplock)
Definition: oplock.c:1564
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159

Referenced by DriverEntry().

◆ Ext2FastIoQueryBasicInfo()

BOOLEAN Ext2FastIoQueryBasicInfo ( IN PFILE_OBJECT  FileObject,
IN BOOLEAN  Wait,
OUT PFILE_BASIC_INFORMATION  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 280 of file fastio.c.

286{
291 BOOLEAN FcbMainResourceAcquired = FALSE;
292
293 _SEH2_TRY {
294
296
297 _SEH2_TRY {
298
302 }
303
304 Fcb = (PEXT2_FCB) FileObject->FsContext;
305 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
308 }
309 Ccb = (PEXT2_CCB) FileObject->FsContext2;
310 Mcb = Fcb->Mcb;
312 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
313#if EXT2_DEBUG
314 DEBUG(DL_INF, (
315 "Ext2FastIoQueryBasicInfo: %s %s %wZ\n",
317 "FASTIO_QUERY_BASIC_INFO",
318 &Fcb->Mcb->FullName
319 ));
320#endif
324 Wait)) {
326 }
327 FcbMainResourceAcquired = TRUE;
328 }
329
331
332 /*
333 typedef struct _FILE_BASIC_INFORMATION {
334 LARGE_INTEGER CreationTime;
335 LARGE_INTEGER LastAccessTime;
336 LARGE_INTEGER LastWriteTime;
337 LARGE_INTEGER ChangeTime;
338 ULONG FileAttributes;
339 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
340 */
341
342 Buffer->CreationTime = Mcb->CreationTime;
343 Buffer->LastAccessTime = Mcb->LastAccessTime;
344 Buffer->LastWriteTime = Mcb->LastWriteTime;
345 Buffer->ChangeTime = Mcb->ChangeTime;
346 Buffer->FileAttributes = Mcb->FileAttr;
347 if (Buffer->FileAttributes == 0) {
348 Buffer->FileAttributes = FILE_ATTRIBUTE_NORMAL;
349 }
350
351 IoStatus->Information = sizeof(FILE_BASIC_INFORMATION);
352 IoStatus->Status = STATUS_SUCCESS;
353
354 Status = TRUE;
355
358 } _SEH2_END;
359
360 } _SEH2_FINALLY {
361
362 if (FcbMainResourceAcquired) {
364 }
365
367 } _SEH2_END;
368
369#if EXT2_DEBUG
370
371 if (Status == FALSE) {
372
373 DEBUG(DL_ERR, ("Ext2FastIoQueryBasicInfo: %s %s Status: FALSE ***\n",
375 "FASTIO_QUERY_BASIC_INFO"));
376
377 } else if (IoStatus->Status != STATUS_SUCCESS) {
378
379 DEBUG(DL_ERR, (
380 "Ext2FastIoQueryBasicInfo: %s %s Status: %#x ***\n",
382 "FASTIO_QUERY_BASIC_INFO",
383 IoStatus->Status
384 ));
385 }
386#endif
387
388 return Status;
389}
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOLEAN Ext2FastIoQueryBasicInfo(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:280
#define FCB_PAGE_FILE
Definition: ext2fs.h:881
#define FILE_BASIC_INFORMATION
Definition: disk.h:53

Referenced by DriverEntry(), and Ext2FastIoQueryBasicInfo().

◆ Ext2FastIoQueryNetworkOpenInfo()

BOOLEAN Ext2FastIoQueryNetworkOpenInfo ( IN PFILE_OBJECT  FileObject,
IN BOOLEAN  Wait,
OUT PFILE_NETWORK_OPEN_INFORMATION  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Referenced by DriverEntry().

◆ Ext2FastIoQueryStandardInfo()

BOOLEAN Ext2FastIoQueryStandardInfo ( IN PFILE_OBJECT  FileObject,
IN BOOLEAN  Wait,
OUT PFILE_STANDARD_INFORMATION  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 396 of file fastio.c.

403{
404
408 BOOLEAN FcbMainResourceAcquired = FALSE;
409
410 _SEH2_TRY {
411
413
414 _SEH2_TRY {
415
419 }
420
421 Fcb = (PEXT2_FCB) FileObject->FsContext;
422 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
425 }
426
428 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
429
430#if EXT2_DEBUG
431 DEBUG(DL_INF, (
432 "Ext2FastIoQueryStandardInfo: %s %s %wZ\n",
434 "FASTIO_QUERY_STANDARD_INFO",
435 &Fcb->Mcb->FullName ));
436#endif
437 Vcb = Fcb->Vcb;
438
442 Wait )) {
444 }
445 FcbMainResourceAcquired = TRUE;
446 }
447
449
450 /*
451 typedef struct _FILE_STANDARD_INFORMATION {
452 LARGE_INTEGER AllocationSize;
453 LARGE_INTEGER EndOfFile;
454 ULONG NumberOfLinks;
455 BOOLEAN DeletePending;
456 BOOLEAN Directory;
457 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
458 */
459
460 Buffer->NumberOfLinks = Fcb->Inode->i_nlink;
461 Buffer->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
462
463 if (IsDirectory(Fcb)) {
464 Buffer->Directory = IsDirectory(Fcb);
465 Buffer->AllocationSize.QuadPart = 0;
466 Buffer->EndOfFile.QuadPart = 0;
467 } else {
468 Buffer->Directory = FALSE;
469 Buffer->AllocationSize = Fcb->Header.AllocationSize;
470 Buffer->EndOfFile = Fcb->Header.FileSize;
471 }
472
473 IoStatus->Information = sizeof(FILE_STANDARD_INFORMATION);
474 IoStatus->Status = STATUS_SUCCESS;
475#if EXT2_DEBUG
476 DEBUG(DL_INF, ( "Ext2FastIoQueryStandInfo: AllocatieonSize = %I64xh FileSize = %I64xh\n",
477 Buffer->AllocationSize.QuadPart, Buffer->EndOfFile.QuadPart));
478#endif
479 Status = TRUE;
480
483 } _SEH2_END;
484
485 } _SEH2_FINALLY {
486
487 if (FcbMainResourceAcquired) {
489 }
490
492 } _SEH2_END;
493
494#if EXT2_DEBUG
495 if (Status == FALSE) {
496 DEBUG(DL_INF, (
497 "Ext2FastIoQueryStandardInfo: %s %s Status: FALSE ***\n",
499 "FASTIO_QUERY_STANDARD_INFO" ));
500 } else if (IoStatus->Status != STATUS_SUCCESS) {
501 DEBUG(DL_INF, (
502 "Ext2FastIoQueryStandardInfo: %s %s Status: %#x ***\n",
504 "FASTIO_QUERY_STANDARD_INFO",
505 IoStatus->Status ));
506 }
507#endif
508
509 return Status;
510}
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54

Referenced by DriverEntry().

◆ Ext2FastIoRead()

BOOLEAN Ext2FastIoRead ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN ULONG  Length,
IN BOOLEAN  Wait,
IN ULONG  LockKey,
OUT PVOID  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 172 of file fastio.c.

180{
183
184 Fcb = (PEXT2_FCB) FileObject->FsContext;
185 if (Fcb == NULL) {
186 return FALSE;
187 }
188
190 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
191
195
196 DEBUG(DL_IO, ("Ext2FastIoRead: %wZ Offset: %I64xh Length: %xh Key: %u Status: %d\n",
197 &Fcb->Mcb->ShortName, FileOffset->QuadPart, Length, LockKey, Status));
198
199 return Status;
200}
#define DL_IO
Definition: ext2fs.h:1450
BOOLEAN NTAPI FsRtlCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:64

Referenced by DriverEntry().

◆ Ext2FastIoUnlockAll()

BOOLEAN Ext2FastIoUnlockAll ( IN PFILE_OBJECT  FileObject,
IN PEPROCESS  Process,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 736 of file fastio.c.

741{
744
745 _SEH2_TRY {
746
748
749 _SEH2_TRY {
750
754 }
755
756 Fcb = (PEXT2_FCB) FileObject->FsContext;
757 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
758 DbgBreak();
761 }
762
764 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
765
766 if (IsDirectory(Fcb)) {
767 DbgBreak();
770 }
771#if EXT2_DEBUG
772 DEBUG(DL_INF, (
773 "Ext2FastIoUnlockSingle: %s %s %wZ\n",
775 "FASTIO_UNLOCK_ALL",
776 &Fcb->Mcb->FullName
777 ));
778#endif
779
780 if (!FsRtlOplockIsFastIoPossible(&Fcb->Oplock)) {
782 }
783
785 &Fcb->FileLockAnchor,
787 Process,
788 NULL );
789
790 IoStatus->Information = 0;
791 Status = TRUE;
792
793 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
794
797 } _SEH2_END;
798
799 } _SEH2_FINALLY {
800
802 } _SEH2_END;
803
804#if EXT2_DEBUG
805 if (Status == FALSE) {
806
807 DEBUG(DL_ERR, (
808 "Ext2FastIoUnlockSingle: %s %s *** Status: FALSE ***\n",
810 "FASTIO_UNLOCK_ALL"
811 ));
812 } else if (IoStatus->Status != STATUS_SUCCESS) {
813 DEBUG(DL_ERR, (
814 "Ext2FastIoUnlockSingle: %s %s *** Status: %s (%#x) ***\n",
816 "FASTIO_UNLOCK_ALL",
818 IoStatus->Status
819 ));
820 }
821#endif
822
823 return Status;
824}

Referenced by DriverEntry().

◆ Ext2FastIoUnlockAllByKey()

BOOLEAN Ext2FastIoUnlockAllByKey ( IN PFILE_OBJECT  FileObject,
IN PEPROCESS  Process,
IN ULONG  Key,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 831 of file fastio.c.

842{
845
846 _SEH2_TRY {
847
849
850 _SEH2_TRY {
851
855 }
856
857 Fcb = (PEXT2_FCB) FileObject->FsContext;
858 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
859 DbgBreak();
862 }
863
865 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
866
867 if (IsDirectory(Fcb)) {
868 DbgBreak();
871 }
872
873#if EXT2_DEBUG
874 DEBUG(DL_INF, (
875 "Ext2FastIoUnlockAllByKey: %s %s %wZ\n",
877 "FASTIO_UNLOCK_ALL_BY_KEY",
878 &Fcb->Mcb->FullName
879 ));
880
881 DEBUG(DL_INF, (
882 "Ext2FastIoUnlockAllByKey: Key: %u\n",
883 Key
884 ));
885#endif
886
887 if (!FsRtlOplockIsFastIoPossible(&Fcb->Oplock)) {
889 }
890
892 &Fcb->FileLockAnchor,
894 Process,
895 Key,
896 NULL
897 );
898
899 IoStatus->Information = 0;
900 Status = TRUE;
901
902 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
903
906 } _SEH2_END;
907
908 } _SEH2_FINALLY {
909
911 } _SEH2_END;
912
913#if EXT2_DEBUG
914 if (Status == FALSE) {
915
916 DEBUG(DL_ERR, (
917 "Ext2FastIoUnlockAllByKey: %s %s *** Status: FALSE ***\n",
919 "FASTIO_UNLOCK_ALL_BY_KEY"
920 ));
921 } else if (IoStatus->Status != STATUS_SUCCESS) {
922
923 DEBUG(DL_ERR, (
924 "Ext2FastIoUnlockAllByKey: %s %s *** Status: %s (%#x) ***\n",
926 "FASTIO_UNLOCK_ALL_BY_KEY",
928 IoStatus->Status
929 ));
930 }
931#endif
932
933 return Status;
934}
NTSTATUS NTAPI FsRtlFastUnlockAllByKey(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN ULONG Key, IN PVOID Context OPTIONAL)
Definition: filelock.c:1086

Referenced by DriverEntry().

◆ Ext2FastIoUnlockSingle()

BOOLEAN Ext2FastIoUnlockSingle ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN PLARGE_INTEGER  Length,
IN PEPROCESS  Process,
IN ULONG  Key,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 629 of file fastio.c.

638{
641
642 _SEH2_TRY {
643
645
646 _SEH2_TRY {
647
651 }
652
653 Fcb = (PEXT2_FCB) FileObject->FsContext;
654 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
655 DbgBreak();
658 }
659
661 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
662
663 if (IsDirectory(Fcb)) {
664 DbgBreak();
667 }
668
669#if EXT2_DEBUG
670 DEBUG(DL_INF, (
671 "Ext2FastIoUnlockSingle: %s %s %wZ\n",
673 "FASTIO_UNLOCK_SINGLE",
674 &Fcb->Mcb->FullName ));
675
676 DEBUG(DL_INF, (
677 "Ext2FastIoUnlockSingle: Offset: %I64xh Length: %I64xh Key: %u\n",
678 FileOffset->QuadPart,
679 Length->QuadPart,
680 Key ));
681#endif
682
683 if (!FsRtlOplockIsFastIoPossible(&Fcb->Oplock)) {
685 }
686
688 &Fcb->FileLockAnchor,
691 Length,
692 Process,
693 Key,
694 NULL,
695 FALSE);
696
697 IoStatus->Information = 0;
698 Status = TRUE;
699
700 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
701
704 } _SEH2_END;
705
706 } _SEH2_FINALLY {
707
709 } _SEH2_END;
710
711#if EXT2_DEBUG
712 if (Status == FALSE) {
713
714 DEBUG(DL_ERR, (
715 "Ext2FastIoUnlockSingle: %s %s *** Status: FALSE ***\n",
717 "FASTIO_UNLOCK_SINGLE" ));
718 } else if (IoStatus->Status != STATUS_SUCCESS) {
719 DEBUG(DL_ERR, (
720 "Ext2FastIoUnlockSingle: %s %s *** Status: %s (%#x) ***\n",
722 "FASTIO_UNLOCK_SINGLE",
724 IoStatus->Status ));
725 }
726#endif
727
728 return Status;
729}
NTSTATUS NTAPI FsRtlFastUnlockSingle(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN PEPROCESS Process, IN ULONG Key, IN PVOID Context OPTIONAL, IN BOOLEAN AlreadySynchronized)
Definition: filelock.c:825

Referenced by DriverEntry().

◆ Ext2FastIoWrite()

BOOLEAN Ext2FastIoWrite ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN ULONG  Length,
IN BOOLEAN  Wait,
IN ULONG  LockKey,
OUT PVOID  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 207 of file fastio.c.

216{
220
221 Fcb = (PEXT2_FCB) FileObject->FsContext;
222 if (Fcb == NULL)
223 return FALSE;
224
225 _SEH2_TRY {
226
228
230 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
231
232 if (IsVcbReadOnly(Fcb->Vcb)) {
234 }
235
236 if (!ExAcquireResourceSharedLite(Fcb->Header.Resource, Wait)) {
238 }
239 Locked = TRUE;
240
242 Fcb->Header.ValidDataLength.QuadPart < FileOffset->QuadPart + Length ||
243 Fcb->Header.FileSize.QuadPart < FileOffset->QuadPart + Length ) {
244 Status = FALSE;
246 }
247
248 if (Locked) {
250 Locked = FALSE;
251 }
252
255 if (Status) {
256 if (IoStatus)
257 Length = (ULONG)IoStatus->Information;
258 }
259
260 } _SEH2_FINALLY {
261
262 if (Locked) {
264 }
265
267 } _SEH2_END;
268
269 DEBUG(DL_IO, ("Ext2FastIoWrite: %wZ Offset: %I64xh Length: %xh Key: %xh Status=%d\n",
270 &Fcb->Mcb->ShortName, FileOffset->QuadPart, Length, LockKey, Status));
271
272 return Status;
273}
#define IsWritingToEof(Pos)
Definition: ext2fs.h:280
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:209
BOOLEAN NTAPI FsRtlCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:264

Referenced by DriverEntry().

◆ Ext2FcbReaperThread()

VOID Ext2FcbReaperThread ( PVOID  Context)

Definition at line 3391 of file memory.c.

3394{
3395 PEXT2_REAPER Reaper = Context;
3396 PEXT2_VCB Vcb = NULL;
3399
3400 BOOLEAN GlobalAcquired = FALSE;
3401 BOOLEAN DidNothing = FALSE;
3402 BOOLEAN NonWait = FALSE;
3403
3404 _SEH2_TRY {
3405
3406 Reaper->Thread = PsGetCurrentThread();
3407
3408 /* wake up DirverEntry */
3409 KeSetEvent(&Reaper->Engine, 0, FALSE);
3410
3411 /* now process looping */
3412 while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3413
3414 /* wait until it is waken or it times out */
3415 if (NonWait) {
3416 Timeout.QuadPart = (LONGLONG)-10*1000*100;
3417 NonWait = FALSE;
3418 } else if (DidNothing) {
3419 Timeout.QuadPart = Timeout.QuadPart * 2;
3420 } else {
3421 Timeout.QuadPart = (LONGLONG)-10*1000*1000*20; /* 20 seconds */
3422 }
3424 &Reaper->Wait,
3425 Executive,
3426 KernelMode,
3427 FALSE,
3428 &Timeout
3429 );
3430
3431 if (IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP))
3432 break;
3433
3435
3436 /* acquire global exclusive lock */
3438 GlobalAcquired = TRUE;
3439 /* search all Vcb to get unused resources freed to system */
3440 for (Link = Ext2Global->VcbList.Flink;
3441 Link != &(Ext2Global->VcbList);
3442 Link = Link->Flink ) {
3443
3445 NonWait = Ext2QueryUnusedFcb(Vcb, &List);
3446 }
3447 DidNothing = IsListEmpty(&List);
3448 if (DidNothing) {
3449 KeClearEvent(&Reaper->Wait);
3450 }
3451 if (GlobalAcquired) {
3453 GlobalAcquired = FALSE;
3454 }
3455
3456 while (!IsListEmpty(&List)) {
3457 PEXT2_FCB Fcb;
3460 ASSERT(0 == Fcb->ReferenceCount);
3462 }
3463 }
3464
3465 } _SEH2_FINALLY {
3466
3467 if (GlobalAcquired) {
3469 }
3470
3471 KeSetEvent(&Reaper->Engine, 0, FALSE);
3472 } _SEH2_END;
3473
3475}
BOOLEAN Ext2QueryUnusedFcb(PEXT2_VCB Vcb, PLIST_ENTRY list)
Definition: memory.c:3328
VOID Ext2FreeFcb(IN PEXT2_FCB Fcb)
Definition: memory.c:240

Referenced by DriverEntry().

◆ Ext2FileSystemControl()

NTSTATUS Ext2FileSystemControl ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2848 of file fsctl.c.

2849{
2851
2852 ASSERT(IrpContext);
2853
2854 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2855 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2856
2857 switch (IrpContext->MinorFunction) {
2858
2860 Status = Ext2UserFsRequest(IrpContext);
2861 break;
2862
2864 Status = Ext2MountVolume(IrpContext);
2865 break;
2866
2868 Status = Ext2VerifyVolume(IrpContext);
2869 break;
2870
2871 default:
2872
2873 DEBUG(DL_ERR, ( "Ext2FilsSystemControl: Invalid Device Request.\n"));
2875 Ext2CompleteIrpContext(IrpContext, Status);
2876 }
2877
2878 return Status;
2879}
NTSTATUS Ext2VerifyVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2378
NTSTATUS Ext2UserFsRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1903
NTSTATUS Ext2MountVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2050
#define IRP_MN_VERIFY_VOLUME
Definition: iotypes.h:4405
#define IRP_MN_USER_FS_REQUEST
Definition: iotypes.h:4403
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4404

Referenced by Ext2DispatchRequest().

◆ Ext2FirstUnusedMcb()

PEXT2_MCB Ext2FirstUnusedMcb ( PEXT2_VCB  Vcb,
BOOLEAN  Wait,
ULONG  Number 
)

Definition at line 2979 of file memory.c.

2980{
2981 PEXT2_MCB Head = NULL;
2982 PEXT2_MCB Tail = NULL;
2983 PEXT2_MCB Mcb = NULL;
2985 ULONG i = 0;
2987
2988 if (!ExAcquireResourceExclusiveLite(&Vcb->McbLock, Wait)) {
2989 return NULL;
2990 }
2991
2993
2994 while (Number--) {
2995
2996 BOOLEAN Skip = TRUE;
2997
2998 if (IsListEmpty(&Vcb->McbList)) {
2999 break;
3000 }
3001
3002 while (i++ < Vcb->NumOfMcb) {
3003
3005 if (now.QuadPart > start.QuadPart + (LONGLONG)10*1000*1000) {
3006 break;
3007 }
3008
3009 List = RemoveHeadList(&Vcb->McbList);
3011 ASSERT(IsFlagOn(Mcb->Flags, MCB_VCB_LINK));
3012
3013 if (Mcb->Fcb == NULL && !IsMcbRoot(Mcb) &&
3014 Mcb->Refercount == 0 &&
3015 (Mcb->Child == NULL || IsMcbSymLink(Mcb))) {
3016
3019 Ext2DerefXcb(&Vcb->NumOfMcb);
3020
3021 /* attach all Mcb into a chain*/
3022 if (Head) {
3023 ASSERT(Tail != NULL);
3024 Tail->Next = Mcb;
3025 Tail = Mcb;
3026 } else {
3027 Head = Tail = Mcb;
3028 }
3029 Tail->Next = NULL;
3030 Skip = FALSE;
3031
3032 } else {
3033
3034 InsertTailList(&Vcb->McbList, &Mcb->Link);
3035 Mcb = NULL;
3036 }
3037 }
3038
3039 if (Skip)
3040 break;
3041 }
3042
3043 ExReleaseResourceLite(&Vcb->McbLock);
3044
3045 return Head;
3046}
BOOLEAN Ext2RemoveMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:1746
#define InsertTailList(ListHead, Entry)
#define IsMcbRoot(Mcb)
Definition: ext2fs.h:965
#define MCB_VCB_LINK
Definition: ext2fs.h:953
time_t now
Definition: finger.c:65
GLuint start
Definition: gl.h:1545
PEXT2_MCB Next
Definition: ext2fs.h:904

Referenced by Ext2CleanupAllMcbs(), and Ext2McbReaperThread().

◆ Ext2Flush()

NTSTATUS Ext2Flush ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 148 of file flush.c.

149{
151
152 PIRP Irp = NULL;
154
157 PEXT2_FCBVCB FcbOrVcb = NULL;
160
162
163 BOOLEAN MainResourceAcquired = FALSE;
164
165 _SEH2_TRY {
166
167 ASSERT(IrpContext);
168
169 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
170 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
171
172 DeviceObject = IrpContext->DeviceObject;
173
174 //
175 // This request is not allowed on the main device object
176 //
180 }
181
182 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
183 ASSERT(Vcb != NULL);
184 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
185 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
186
188 if (IsVcbReadOnly(Vcb)) {
191 }
192
193 Irp = IrpContext->Irp;
195
196 FileObject = IrpContext->FileObject;
197 FcbOrVcb = (PEXT2_FCBVCB) FileObject->FsContext;
198 ASSERT(FcbOrVcb != NULL);
199
200 Ccb = (PEXT2_CCB) FileObject->FsContext2;
201 if (Ccb == NULL) {
204 }
205
206 MainResourceAcquired =
208 ASSERT(MainResourceAcquired);
209 DEBUG(DL_INF, ("Ext2Flush-pre: total mcb records=%u\n",
210 FsRtlNumberOfRunsInLargeMcb(&Vcb->Extents)));
211
212 if (FcbOrVcb->Identifier.Type == EXT2VCB) {
213
214 Ext2VerifyVcb(IrpContext, Vcb);
215 Status = Ext2FlushFiles(IrpContext, (PEXT2_VCB)(FcbOrVcb), FALSE);
216 if (NT_SUCCESS(Status)) {
218 }
219
220 Status = Ext2FlushVolume(IrpContext, (PEXT2_VCB)(FcbOrVcb), FALSE);
221
222 if (NT_SUCCESS(Status) && IsFlagOn(Vcb->Volume->Flags, FO_FILE_MODIFIED)) {
223 ClearFlag(Vcb->Volume->Flags, FO_FILE_MODIFIED);
224 }
225
226 } else if (FcbOrVcb->Identifier.Type == EXT2FCB) {
227
228 Fcb = (PEXT2_FCB)(FcbOrVcb);
229
230 Status = Ext2FlushFile(IrpContext, Fcb, Ccb);
231 if (NT_SUCCESS(Status)) {
232 if (IsFlagOn(FileObject->Flags, FO_FILE_MODIFIED)) {
233 Fcb->Mcb->FileAttr |= FILE_ATTRIBUTE_ARCHIVE;
235 }
236 }
237 }
238
239 DEBUG(DL_INF, ("Ext2Flush-post: total mcb records=%u\n",
240 FsRtlNumberOfRunsInLargeMcb(&Vcb->Extents)));
241
242
243 } _SEH2_FINALLY {
244
245 if (MainResourceAcquired) {
247 }
248
249 if (!IrpContext->ExceptionInProgress) {
250
251 if (Vcb && Irp && IrpSp && !IsVcbReadOnly(Vcb)) {
252
253 // Call the disk driver to flush the physial media.
254 NTSTATUS DriverStatus;
255 PIO_STACK_LOCATION NextIrpSp;
256
257 NextIrpSp = IoGetNextIrpStackLocation(Irp);
258
259 *NextIrpSp = *IrpSp;
260
263 NULL,
264 TRUE,
265 TRUE,
266 TRUE );
267
268 DriverStatus = IoCallDriver(Vcb->TargetDeviceObject, Irp);
269
270 Status = (DriverStatus == STATUS_INVALID_DEVICE_REQUEST) ?
271 Status : DriverStatus;
272
273 IrpContext->Irp = Irp = NULL;
274 }
275
276 Ext2CompleteIrpContext(IrpContext, Status);
277 }
278 } _SEH2_END;
279
280 return Status;
281}
NTSTATUS Ext2FlushFile(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
Definition: flush.c:58
NTSTATUS Ext2FlushCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: flush.c:26
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:112
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:43
ERESOURCE MainResource
Definition: ext2fs.h:637

Referenced by Ext2DispatchRequest().

◆ Ext2FlushFile()

NTSTATUS Ext2FlushFile ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_FCB  Fcb,
IN PEXT2_CCB  Ccb 
)

Definition at line 58 of file flush.c.

63{
65
66 ASSERT(Fcb != NULL);
68 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
69
70 _SEH2_TRY {
71
72 /* do nothing if target fie was deleted */
76 }
77
78 /* update timestamp and achieve attribute */
79 if (Ccb != NULL) {
80
82
83 LARGE_INTEGER SysTime;
84 KeQuerySystemTime(&SysTime);
85
86 Fcb->Inode->i_mtime = Ext2LinuxTime(SysTime);
87 Fcb->Mcb->LastWriteTime = Ext2NtTime(Fcb->Inode->i_mtime);
88 Ext2SaveInode(IrpContext, Fcb->Vcb, Fcb->Inode);
89 }
90 }
91
92 if (IsDirectory(Fcb)) {
93 IoStatus.Status = STATUS_SUCCESS;
95 }
96
97 DEBUG(DL_INF, ( "Ext2FlushFile: Flushing File Inode=%xh %S ...\n",
98 Fcb->Inode->i_ino, Fcb->Mcb->ShortName.Buffer));
99
100 CcFlushCache(&(Fcb->SectionObject), NULL, 0, &IoStatus);
102
103 } _SEH2_FINALLY {
104
105 /* do cleanup here */
106 } _SEH2_END;
107
108 return IoStatus.Status;
109}
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172

Referenced by Ext2Cleanup(), Ext2Flush(), and Ext2FlushFiles().

◆ Ext2FlushFiles()

NTSTATUS Ext2FlushFiles ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN BOOLEAN  bShutDown 
)

Definition at line 112 of file flush.c.

117{
119
121 PLIST_ENTRY ListEntry;
122
123 if (IsVcbReadOnly(Vcb)) {
124 return STATUS_SUCCESS;
125 }
126
127 IoStatus.Status = STATUS_SUCCESS;
128
129 DEBUG(DL_INF, ( "Flushing Files ...\n"));
130
131 // Flush all Fcbs in Vcb list queue.
132 for (ListEntry = Vcb->FcbList.Flink;
133 ListEntry != &Vcb->FcbList;
134 ListEntry = ListEntry->Flink ) {
135
136 Fcb = CONTAINING_RECORD(ListEntry, EXT2_FCB, Next);
139 Ext2FlushFile(IrpContext, Fcb, NULL);
141 }
142
143 return IoStatus.Status;
144}

Referenced by Ext2CreateVolume(), Ext2DismountVolume(), Ext2Flush(), Ext2LockVolume(), Ext2ProcessVolumeProperty(), and Ext2ShutDown().

◆ Ext2FlushVcb()

NTSTATUS Ext2FlushVcb ( IN PEXT2_VCB  Vcb)

Definition at line 323 of file generic.c.

324{
325 LARGE_INTEGER s = {0}, o;
326 struct ext3_sb_info *sbi = &Vcb->sbi;
327 struct rb_node *node;
328 struct buffer_head *bh;
329
330 if (!IsFlagOn(Vcb->Flags, VCB_GD_LOADED)) {
331 CcFlushCache(&Vcb->SectionObject, NULL, 0, NULL);
332 goto errorout;
333 }
334
336
337 _SEH2_TRY {
338
339 /* acqurie gd block */
340 ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
341
342 /* acquire bd lock to avoid bh creation */
343 ExAcquireResourceExclusiveLite(&Vcb->bd.bd_bh_lock, TRUE);
344
345 /* drop unused bh */
347
348 /* flush volume with all outstanding bh skipped */
349
350 node = rb_first(&Vcb->bd.bd_bh_root);
351 while (node) {
352
353 bh = container_of(node, struct buffer_head, b_rb_node);
354 node = rb_next(node);
355
356 o.QuadPart = bh->b_blocknr << BLOCK_BITS;
357 ASSERT(o.QuadPart >= s.QuadPart);
358
359 if (o.QuadPart == s.QuadPart) {
360 s.QuadPart = s.QuadPart + bh->b_size;
361 continue;
362 }
363
364 if (o.QuadPart > s.QuadPart) {
365 Ext2FlushRange(Vcb, s, o);
366 s.QuadPart = (bh->b_blocknr << BLOCK_BITS) + bh->b_size;
367 continue;
368 }
369 }
370
371 o = Vcb->PartitionInformation.PartitionLength;
372 Ext2FlushRange(Vcb, s, o);
373
374 } _SEH2_FINALLY {
375
376 ExReleaseResourceLite(&Vcb->bd.bd_bh_lock);
377 ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
378 } _SEH2_END;
379
380errorout:
381 return STATUS_SUCCESS;
382}
struct rb_node * rb_first(struct rb_root *)
Definition: rbtree.c:294
struct rb_node * rb_next(struct rb_node *)
Definition: rbtree.c:320
#define VCB_GD_LOADED
Definition: ext2fs.h:796
VOID Ext2FlushRange(IN PEXT2_VCB Vcb, LARGE_INTEGER s, LARGE_INTEGER e)
Definition: generic.c:303
VOID Ext2DropBH(IN PEXT2_VCB Vcb)
Definition: generic.c:266
GLdouble s
Definition: gl.h:2039
#define container_of(ptr, type, member)
Definition: glue.h:15
struct rb_node b_rb_node
Definition: module.h:741
size_t b_size
Definition: module.h:734
blkcnt_t b_blocknr
Definition: module.h:733
Definition: rbtree.h:98
Definition: dlist.c:348

Referenced by Ext2FloppyFlush(), and Ext2FlushVolume().

◆ Ext2FlushVolume()

NTSTATUS Ext2FlushVolume ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN BOOLEAN  bShutDown 
)

Definition at line 43 of file flush.c.

48{
49 DEBUG(DL_INF, ( "Ext2FlushVolume: Flushing Vcb ...\n"));
50
51 ExAcquireSharedStarveExclusive(&Vcb->PagingIoResource, TRUE);
52 ExReleaseResourceLite(&Vcb->PagingIoResource);
53
54 return Ext2FlushVcb(Vcb);
55}
NTSTATUS Ext2FlushVcb(IN PEXT2_VCB Vcb)
Definition: generic.c:323
BOOLEAN NTAPI ExAcquireSharedStarveExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:1068

Referenced by Ext2CreateVolume(), Ext2DismountVolume(), Ext2Flush(), Ext2LockVolume(), Ext2ProcessVolumeProperty(), Ext2ReadVolume(), Ext2ShutDown(), and sync_blockdev().

◆ Ext2FollowLink()

NTSTATUS Ext2FollowLink ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Parent,
IN PEXT2_MCB  Mcb,
IN ULONG  Linkdep 
)

Definition at line 67 of file create.c.

74{
76
77 UNICODE_STRING UniName;
79 BOOLEAN bOemBuffer = FALSE;
80
82
83 USHORT i;
84
85 _SEH2_TRY {
86
87 RtlZeroMemory(&UniName, sizeof(UNICODE_STRING));
89
90 /* exit if we jump into a possible symlink forever loop */
91 if ((Linkdep + 1) > EXT2_MAX_NESTED_LINKS ||
92 IoGetRemainingStackSize() < 1024) {
94 }
95
96 /* read the symlink target path */
97 if (!Mcb->Inode.i_blocks) {
98
99 OemName.Buffer = (PUCHAR) (&Mcb->Inode.i_block[0]);
100 OemName.Length = (USHORT)Mcb->Inode.i_size;
101 OemName.MaximumLength = OemName.Length + 1;
102
103 } else {
104
105 OemName.Length = (USHORT)Mcb->Inode.i_size;
106 OemName.MaximumLength = OemName.Length + 1;
108 OemName.MaximumLength,
109 'NL2E');
110 if (OemName.Buffer == NULL) {
113 }
114 bOemBuffer = TRUE;
115 RtlZeroMemory(OemName.Buffer, OemName.MaximumLength);
116
118 IrpContext,
119 Vcb,
120 Mcb,
121 OemName.Buffer,
122 (ULONG)(Mcb->Inode.i_size),
123 NULL);
124 if (!NT_SUCCESS(Status)) {
126 }
127 }
128
129 /* convert Linux slash to Windows backslash */
130 for (i=0; i < OemName.Length; i++) {
131 if (OemName.Buffer[i] == '/') {
132 OemName.Buffer[i] = '\\';
133 }
134 }
135
136 /* convert oem string to unicode string */
138 if (UniName.MaximumLength <= 0) {
141 }
142
143 UniName.MaximumLength += 2;
145 UniName.MaximumLength,
146 'NL2E');
147 if (UniName.Buffer == NULL) {
150 }
151 RtlZeroMemory(UniName.Buffer, UniName.MaximumLength);
152 Status = Ext2OEMToUnicode(Vcb, &UniName, &OemName);
153 if (!NT_SUCCESS(Status)) {
156 }
157
158 /* search the real target */
160 IrpContext,
161 Vcb,
162 &UniName,
163 Parent,
164 &Target,
165 Linkdep
166 );
167 if (Target == NULL) {
169 }
170
171 if (Target == NULL /* link target doesn't exist */ ||
172 Target == Mcb /* symlink points to itself */ ||
173 IsMcbSpecialFile(Target) /* target not resolved*/ ||
174 IsFileDeleted(Target) /* target deleted */ ) {
175
176 if (Target) {
177 ASSERT(Target->Refercount > 0);
179 }
182 Mcb->Target = NULL;
183
184 } else if (IsMcbSymLink(Target)) {
185
186 ASSERT(Target->Refercount > 0);
187 ASSERT(Target->Target != NULL);
188 Ext2ReferMcb(Target->Target);
189 Mcb->Target = Target->Target;
191 ASSERT(!IsMcbSymLink(Target->Target));
194 ASSERT(Mcb->Target->Refercount > 0);
195
196 } else {
197
198 Mcb->Target = Target;
201 ASSERT(Mcb->Target->Refercount > 0);
202 }
203
204 /* add directory flag to file attribute */
205 if (Mcb->Target && IsMcbDirectory(Mcb->Target)) {
206 Mcb->FileAttr |= FILE_ATTRIBUTE_DIRECTORY;
207 }
208
209 } _SEH2_FINALLY {
210
211 if (bOemBuffer) {
212 Ext2FreePool(OemName.Buffer, 'NL2E');
213 }
214
215 if (UniName.Buffer) {
216 Ext2FreePool(UniName.Buffer, 'NL2E');
217 }
218 } _SEH2_END;
219
220 return Status;
221}
NTSTATUS Ext2LookupFile(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PUNICODE_STRING FullName, IN PEXT2_MCB Parent, OUT PEXT2_MCB *Ext2Mcb, IN ULONG Linkdep)
Definition: create.c:273
#define EXT2_MAX_NESTED_LINKS
Definition: ext2fs.h:75
NTSTATUS Ext2OEMToUnicode(IN PEXT2_VCB Vcb, IN OUT PUNICODE_STRING Oem, IN POEM_STRING Unicode)
Definition: misc.c:206
NTSTATUS Ext2ReadSymlink(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesRead)
Definition: fsctl.c:1364
#define MCB_TYPE_SYMLINK
Definition: ext2fs.h:959
#define MCB_TYPE_SPECIAL
Definition: ext2fs.h:958
ULONG Ext2OEMToUnicodeSize(IN PEXT2_VCB Vcb, IN PANSI_STRING Oem)
Definition: misc.c:183
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1304
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define STATUS_LINK_FAILED
Definition: ntstatus.h:554
USHORT MaximumLength
Definition: env_spec_w32.h:370

Referenced by Ext2LookupFile(), and Ext2ProcessEntry().

◆ Ext2FreeBlock()

NTSTATUS Ext2FreeBlock ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  Block,
IN ULONG  Number 
)

Definition at line 1217 of file generic.c.

1223{
1224 struct super_block *sb = &Vcb->sb;
1226 struct buffer_head *gb = NULL;
1227 ext4_fsblk_t bitmap_blk;
1228
1229 RTL_BITMAP BlockBitmap;
1231
1232 PBCB BitmapBcb;
1233 PVOID BitmapCache;
1234
1235 ULONG Group;
1236 ULONG Index;
1237 ULONG Length;
1238 ULONG Count;
1239
1241
1243
1244 DEBUG(DL_INF, ("Ext2FreeBlock: Block %xh - %x to be freed.\n",
1245 Block, Block + Number));
1246
1249
1250Again:
1251
1252 if (gb)
1253 fini_bh(&gb);
1254
1255 if ( Block < EXT2_FIRST_DATA_BLOCK ||
1256 Block >= TOTAL_BLOCKS ||
1257 Group >= Vcb->sbi.s_groups_count) {
1258
1259 DbgBreak();
1261
1262 } else {
1263
1264 gd = ext4_get_group_desc(sb, Group, &gb);
1265 if (!gd) {
1266 DbgBreak();
1268 goto errorout;
1269 }
1270 bitmap_blk = ext4_block_bitmap(sb, gd);
1271
1272 /* check the block is valid or not */
1273 if (bitmap_blk >= TOTAL_BLOCKS) {
1274 DbgBreak();
1276 goto errorout;
1277 }
1278
1279 /* get bitmap block offset and length */
1280 Offset.QuadPart = bitmap_blk;
1281 Offset.QuadPart = Offset.QuadPart << BLOCK_BITS;
1282
1283 if (Group == Vcb->sbi.s_groups_count - 1) {
1284
1286
1287 /* s_blocks_count is integer multiple of s_blocks_per_group */
1288 if (Length == 0) {
1290 }
1291
1292 } else {
1294 }
1295
1296 /* read and initialize bitmap */
1297 if (!CcPinRead( Vcb->Volume,
1298 &Offset,
1299 Vcb->BlockSize,
1300 PIN_WAIT,
1301 &BitmapBcb,
1302 &BitmapCache ) ) {
1303
1304 DEBUG(DL_ERR, ("Ext2FreeBlock: failed to PinLock bitmap block %xh.\n",
1305 bitmap_blk));
1307 DbgBreak();
1308 goto errorout;
1309 }
1310
1311 /* clear usused bits */
1312 RtlInitializeBitMap(&BlockBitmap, BitmapCache, Length);
1313 Count = min(Length - Index, Number);
1314 RtlClearBits(&BlockBitmap, Index, Count);
1315
1316 /* update group description table */
1317 ext4_free_blks_set(sb, gd, RtlNumberOfClearBits(&BlockBitmap));
1318
1319 /* indict the cache range is dirty */
1320 CcSetDirtyPinnedData(BitmapBcb, NULL );
1321 Ext2AddVcbExtent(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1322 CcUnpinData(BitmapBcb);
1323 BitmapBcb = NULL;
1324 BitmapCache = NULL;
1325 Ext2SaveGroup(IrpContext, Vcb, Group);
1326
1327 /* remove dirty MCB to prevent Volume's lazy writing. */
1328 if (Ext2RemoveBlockExtent(Vcb, NULL, Block, Count)) {
1329 } else {
1330 DbgBreak();
1332 }
1333
1334 /* save super block (used/unused blocks statics) */
1335 Ext2UpdateVcbStat(IrpContext, Vcb);
1336
1337 /* try next group to clear all remaining */
1338 Number -= Count;
1339 if (Number) {
1340 Group += 1;
1341 if (Group < Vcb->sbi.s_groups_count) {
1342 Index = 0;
1343 Block += Count;
1344 goto Again;
1345 } else {
1346 DEBUG(DL_ERR, ("Ext2FreeBlock: block number beyonds max group.\n"));
1347 goto errorout;
1348 }
1349 }
1350 }
1351
1353
1354errorout:
1355
1356 if (gb)
1357 fini_bh(&gb);
1358
1359 ExReleaseResourceLite(&Vcb->MetaBlock);
1360
1361 return Status;
1362}
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
BOOLEAN Ext2RemoveBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Number)
Definition: memory.c:1097
BOOLEAN Ext2AddVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
Definition: memory.c:648
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2459
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2976
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2539
VOID Ext2UpdateVcbStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:997
BOOLEAN Ext2SaveGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:386
NTSYSAPI ULONG WINAPI RtlNumberOfClearBits(PCRTL_BITMAP)
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define min(a, b)
Definition: monoChain.cc:55
_In_opt_ PSID Group
Definition: rtlfuncs.h:1646
#define PIN_WAIT
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
Definition: fs.h:64
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147

Referenced by Ext2ExpandLast(), Ext2TruncateBlock(), Ext2TruncateIndirectFast(), and ext4_free_blocks().

◆ Ext2FreeCcb()

VOID Ext2FreeCcb ( IN PEXT2_VCB  Vcb,
IN PEXT2_CCB  Ccb 
)

Definition at line 356 of file memory.c.

357{
358 ASSERT(Ccb != NULL);
360 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
361
362 DEBUG(DL_RES, ( "Ext2FreeCcb: Ccb = %ph.\n", Ccb));
363
364 if (Ccb->SymLink) {
365 DEBUG(DL_INF, ( "Ext2FreeCcb: Ccb SymLink: %wZ.\n",
366 &Ccb->SymLink->FullName));
367 if (IsFileDeleted(Ccb->SymLink->Target)) {
368 Ext2UnlinkMcb(Vcb, Ccb->SymLink);
369 Ext2DerefMcb(Ccb->SymLink);
370 Ext2LinkHeadMcb(Vcb, Ccb->SymLink);
371 } else {
372 Ext2DerefMcb(Ccb->SymLink);
373 }
374 }
375
376 if (Ccb->DirectorySearchPattern.Buffer != NULL) {
377 DEC_MEM_COUNT(PS_DIR_PATTERN, Ccb->DirectorySearchPattern.Buffer,
378 Ccb->DirectorySearchPattern.MaximumLength );
379 Ext2FreePool(Ccb->DirectorySearchPattern.Buffer, EXT2_DIRSP_MAGIC);
380 }
381
382 ExFreeToNPagedLookasideList(&(Ext2Global->Ext2CcbLookasideList), Ccb);
383 DEC_MEM_COUNT(PS_CCB, Ccb, sizeof(EXT2_CCB));
384}
#define PS_DIR_PATTERN
Definition: common.h:28
VOID Ext2UnlinkMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:2957
VOID Ext2LinkHeadMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:2935
#define EXT2_DIRSP_MAGIC
Definition: ext2fs.h:301

Referenced by Ext2Close(), and Ext2CreateFile().

◆ Ext2FreeEntry()

VOID Ext2FreeEntry ( IN struct dentry de)

Definition at line 432 of file memory.c.

433{
434 ASSERT(de != NULL);
435
436 if (de->d_name.name)
437 ExFreePool(de->d_name.name);
438
439 ExFreeToNPagedLookasideList(&(Ext2Global->Ext2DentryLookasideList), de);
440 DEC_MEM_COUNT(PS_DENTRY, de, sizeof(struct dentry));
441}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by Ext2AddEntry(), Ext2BuildEntry(), Ext2CreateInode(), Ext2FreeMcb(), Ext2LookupFile(), Ext2ScanDir(), and Ext2SetRenameInfo().

◆ Ext2FreeExtent()

VOID Ext2FreeExtent ( IN PEXT2_EXTENT  Extent)

Definition at line 505 of file memory.c.

506{
507 ASSERT(Extent != NULL);
508 ExFreeToNPagedLookasideList(&(Ext2Global->Ext2ExtLookasideList), Extent);
510}

Referenced by bmap(), and Ext2DestroyExtentChain().

◆ Ext2FreeFcb()

VOID Ext2FreeFcb ( IN PEXT2_FCB  Fcb)

Definition at line 240 of file memory.c.

241{
242 PEXT2_VCB Vcb = Fcb->Vcb;
243
244 _SEH2_TRY {
245
246 ASSERT((Fcb != NULL) && (Fcb->Identifier.Type == EXT2FCB) &&
247 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
248 ASSERT(0 == Fcb->ReferenceCount);
249
250#ifndef _WIN2K_TARGET_
252#endif
253
254 FsRtlUninitializeFileLock(&Fcb->FileLockAnchor);
258
259 Fcb->Identifier.Type = 0;
260 Fcb->Identifier.Size = 0;
261
262 ExFreeToNPagedLookasideList(&(Ext2Global->Ext2FcbLookasideList), Fcb);
263 DEC_MEM_COUNT(PS_FCB, Fcb, sizeof(EXT2_FCB));
264
265 if (0 == Ext2DerefXcb(&Vcb->ReferenceCount)) {
266 if (!IsMounted(Vcb) || IsDispending(Vcb)) {
268 }
269 }
270
271 } _SEH2_FINALLY {
272 } _SEH2_END;
273}
#define IsDispending(Vcb)
Definition: ext2fs.h:813
VOID NTAPI FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock)
Definition: filelock.c:1279
VOID NTAPI FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader)
Definition: filtrctx.c:368
VOID NTAPI FsRtlUninitializeOplock(IN POPLOCK Oplock)
Definition: oplock.c:1600

Referenced by Ext2FcbReaperThread().

◆ Ext2FreeInode()

NTSTATUS Ext2FreeInode ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  Inode,
IN ULONG  Type 
)

Definition at line 1766 of file generic.c.

1772{
1773 struct super_block *sb = &Vcb->sb;
1775 struct buffer_head *gb = NULL;
1776 struct buffer_head *bh = NULL;
1777 ext4_fsblk_t bitmap_blk;
1778
1779 RTL_BITMAP InodeBitmap;
1780 ULONG Group;
1781 ULONG Length;
1783
1784 ULONG dwIno;
1785 BOOLEAN bModified = FALSE;
1786
1788
1790
1791 Group = (Inode - 1) / INODES_PER_GROUP;
1792 dwIno = (Inode - 1) % INODES_PER_GROUP;
1793
1794 DEBUG(DL_INF, ( "Ext2FreeInode: Inode: %xh (Group/Off = %xh/%xh)\n",
1795 Inode, Group, dwIno));
1796
1797 if (Group >= Vcb->sbi.s_groups_count) {
1798 DbgBreak();
1799 goto errorout;
1800 }
1801
1802 gd = ext4_get_group_desc(sb, Group, &gb);
1803 if (!gd) {
1804 DbgBreak();
1806 goto errorout;
1807 }
1808
1809 bitmap_blk = ext4_inode_bitmap(sb, gd);
1810 bh = sb_getblk(sb, bitmap_blk);
1811 if (!bh) {
1812 DbgBreak();
1814 goto errorout;
1815 }
1816 if (!buffer_uptodate(bh)) {
1817 int err = bh_submit_read(bh);
1818 if (err < 0) {
1819 DbgPrint("bh_submit_read error! err: %d\n", err);
1821 goto errorout;
1822 }
1823 }
1824
1825 if (Group == Vcb->sbi.s_groups_count - 1) {
1826
1828 if (!Length) {
1829 /* s_inodes_count is integer multiple of s_inodes_per_group */
1831 }
1832 } else {
1834 }
1835
1836 RtlInitializeBitMap(&InodeBitmap, (PULONG)bh->b_data, Length);
1837
1838 if (RtlCheckBit(&InodeBitmap, dwIno) == 0) {
1839 DbgBreak();
1841 } else {
1842 RtlClearBits(&InodeBitmap, dwIno, 1);
1843 bModified = TRUE;
1844 }
1845
1846 if (bModified) {
1847 /* update group free inodes */
1849 RtlNumberOfClearBits(&InodeBitmap));
1850
1851 /* set inode block dirty and add to vcb dirty range */
1853
1854 /* update group_desc and super_block */
1855 if (Type == EXT2_FT_DIR) {
1857 ext4_used_dirs_count(sb, gd) - 1);
1858 }
1859 Ext2SaveGroup(IrpContext, Vcb, Group);
1860 Ext2UpdateVcbStat(IrpContext, Vcb);
1862 }
1863
1864errorout:
1865
1866 ExReleaseResourceLite(&Vcb->MetaInode);
1867
1868 if (bh)
1869 fini_bh(&bh);
1870
1871 if (gb)
1872 fini_bh(&gb);
1873
1874 return Status;
1875}
Type
Definition: Type.h:7
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
void ext4_used_dirs_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2555
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2467
__u32 ext4_used_dirs_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2499
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2547
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:892
#define EXT2_FT_DIR
Definition: ext2_fs.h:531

Referenced by Ext2CreateInode(), and Ext2DeleteFile().

◆ Ext2FreeIrpContext()

VOID Ext2FreeIrpContext ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 114 of file memory.c.

115{
116 ASSERT(IrpContext != NULL);
117
118 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
119 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
120
121 /* free the IrpContext to NonPagedList */
122 IrpContext->Identifier.Type = 0;
123 IrpContext->Identifier.Size = 0;
124
125 DEC_IRP_COUNT(IrpContext);
126 ExFreeToNPagedLookasideList(&(Ext2Global->Ext2IrpContextLookasideList), IrpContext);
127}
#define DEC_IRP_COUNT(IrpContext)
Definition: ext2fs.h:610

Referenced by Ext2CompleteIrpContext(), Ext2ExceptionFilter(), Ext2ExceptionHandler(), Ext2ReadFile(), Ext2ReadVolume(), Ext2WriteFile(), and Ext2WriteVolume().

◆ Ext2FreeMcb()

VOID Ext2FreeMcb ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb 
)

Definition at line 1538 of file memory.c.

1539{
1540#ifndef __REACTOS__
1541 PEXT2_MCB Parent = Mcb->Parent;
1542#endif
1543
1544 ASSERT(Mcb != NULL);
1545
1546 ASSERT((Mcb->Identifier.Type == EXT2MCB) &&
1547 (Mcb->Identifier.Size == sizeof(EXT2_MCB)));
1548
1549 if ((Mcb->Identifier.Type != EXT2MCB) ||
1550 (Mcb->Identifier.Size != sizeof(EXT2_MCB))) {
1551 return;
1552 }
1553
1554 DEBUG(DL_INF, ( "Ext2FreeMcb: Mcb %wZ will be freed.\n", &Mcb->FullName));
1555
1556 if (IsMcbSymLink(Mcb) && Mcb->Target) {
1557 Ext2DerefMcb(Mcb->Target);
1558 }
1559
1560 if (FsRtlNumberOfRunsInLargeMcb(&Mcb->Extents)) {
1561 DEBUG(DL_EXT, ("List data extents for: %wZ\n", &Mcb->FullName));
1562 Ext2ListExtents(&Mcb->Extents);
1563 }
1564 FsRtlUninitializeLargeMcb(&(Mcb->Extents));
1565 if (FsRtlNumberOfRunsInLargeMcb(&Mcb->MetaExts)) {
1566 DEBUG(DL_EXT, ("List meta extents for: %wZ\n", &Mcb->FullName));
1567 Ext2ListExtents(&Mcb->MetaExts);
1568 }
1569 FsRtlUninitializeLargeMcb(&(Mcb->MetaExts));
1571
1572 if (Mcb->ShortName.Buffer) {
1573 DEC_MEM_COUNT(PS_MCB_NAME, Mcb->ShortName.Buffer,
1574 Mcb->ShortName.MaximumLength);
1575 Ext2FreePool(Mcb->ShortName.Buffer, EXT2_FNAME_MAGIC);
1576 }
1577
1578 if (Mcb->FullName.Buffer) {
1579 DEC_MEM_COUNT(PS_MCB_NAME, Mcb->FullName.Buffer,
1580 Mcb->FullName.MaximumLength);
1581 Ext2FreePool(Mcb->FullName.Buffer, EXT2_FNAME_MAGIC);
1582 }
1583
1584 /* free dentry */
1585 if (Mcb->de) {
1586 Ext2FreeEntry(Mcb->de);
1587 }
1588
1589 Mcb->Identifier.Type = 0;
1590 Mcb->Identifier.Size = 0;
1591
1592 ExFreeToNPagedLookasideList(&(Ext2Global->Ext2McbLookasideList), Mcb);
1593 DEC_MEM_COUNT(PS_MCB, Mcb, sizeof(EXT2_MCB));
1594}

Referenced by Ext2CleanupAllMcbs(), Ext2InitializeVcb(), Ext2LoadInternalJournal(), Ext2LookupFile(), Ext2McbReaperThread(), and Ext2RecoverJournal().

◆ Ext2FreePool()

◆ Ext2GetBlock()

NTSTATUS Ext2GetBlock ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Base,
IN ULONG  Layer,
IN ULONG  Start,
IN ULONG  SizeArray,
IN PULONG  BlockArray,
IN BOOLEAN  bAlloc,
IN OUT PULONG  Hint,
OUT PULONG  Block,
OUT PULONG  Number 
)

Definition at line 136 of file indirect.c.

150{
152 PBCB Bcb = NULL;
153 PULONG pData = NULL;
154 ULONG Slot = 0, i = 0;
155 ULONG Unit = 1;
156
158
159 if (Layer == 0) {
160
161 *Number = 1;
162 if (BlockArray[0] == 0 && bAlloc) {
163
164 /* now allocate new block */
166 IrpContext,
167 Vcb,
168 Mcb,
169 Base,
170 Layer,
171 NULL,
172 Hint,
173 &BlockArray[0],
174 Number
175 );
176
177 if (!NT_SUCCESS(Status)) {
178 goto errorout;
179 }
180 } else {
181 /* check the block is valid or not */
182 if (BlockArray[0] >= TOTAL_BLOCKS) {
183 DbgBreak();
185 goto errorout;
186 }
187 }
188
189 *Block = BlockArray[0];
190 for (i=1; i < SizeArray; i++) {
191 if (BlockArray[i] == BlockArray[i-1] + 1) {
192 *Number = *Number + 1;
193 } else {
194 break;
195 }
196 }
197 *Hint = BlockArray[*Number - 1];
198
199 } else if (Layer <= 3) {
200
201 /* check the block is valid or not */
202 if (BlockArray[0] == 0 || BlockArray[0] >= TOTAL_BLOCKS) {
203 DbgBreak();
205 goto errorout;
206 }
207
208 /* add block to meta extents */
209 if (!Ext2AddMcbMetaExts(Vcb, Mcb, BlockArray[0], 1)) {
210 DbgBreak();
211 Ext2Sleep(500);
212 Ext2AddMcbMetaExts(Vcb, Mcb, BlockArray[0], 1);
213 }
214
215 /* map memory in cache for the index block */
216 Offset.QuadPart = ((LONGLONG)BlockArray[0]) << BLOCK_BITS;
217 if ( !CcPinRead( Vcb->Volume,
220 PIN_WAIT,
221 &Bcb,
222#ifdef __REACTOS__
223 (void **)&pData )) {
224#else
225 &pData )) {
226#endif
227
228 DEBUG(DL_ERR, ( "Ext2GetBlock: Failed to PinLock block: %xh ...\n",
229 BlockArray[0] ));
231 goto errorout;
232 }
233
234 if (Layer > 1) {
235 Unit = Vcb->max_blocks_per_layer[Layer - 1];
236 } else {
237 Unit = 1;
238 }
239
240 Slot = Start / Unit;
241 Start = Start % Unit;
242
243 if (pData[Slot] == 0) {
244
245 if (bAlloc) {
246
247 /* we need allocate new block and zero all data in case
248 it's an in-direct block. Index stores the new block no. */
249 ULONG Count = 1;
251 IrpContext,
252 Vcb,
253 Mcb,
254 Base,
255 Layer,
256 NULL,
257 Hint,
258 &pData[Slot],
259 &Count
260 );
261
262 if (!NT_SUCCESS(Status)) {
263 goto errorout;
264 }
265
266 /* refresh hint block */
267 *Hint = pData[Slot];
268
269 /* set dirty bit to notify system to flush */
271 SetFlag(Vcb->Volume->Flags, FO_FILE_MODIFIED);
272 if (!Ext2AddVcbExtent(Vcb, Offset.QuadPart,
274 DbgBreak();
275 Ext2Sleep(100);
276 if (!Ext2AddVcbExtent(Vcb, Offset.QuadPart,
279 goto errorout;
280 }
281 }
282
283 /* save inode information here */
284 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
285
286 } else {
287
288 *Number = 1;
289
290 if (Layer == 1) {
291 for (i = Slot + 1; i < BLOCK_SIZE/4; i++) {
292 if (pData[i] == 0) {
293 *Number = *Number + 1;
294 } else {
295 break;
296 }
297 }
298 } else if (Layer == 2) {
299 *Number = BLOCK_SIZE/4 - Start;
300 } else {
301 *Number = BLOCK_SIZE/4;
302 }
303
304 goto errorout;
305 }
306 }
307
308 /* transfer to next recursion call */
310 IrpContext,
311 Vcb,
312 Mcb,
313 Base,
314 Layer - 1,
315 Start,
316 BLOCK_SIZE/4 - Slot,
317 &pData[Slot],
318 bAlloc,
319 Hint,
320 Block,
321 Number
322 );
323
324 if (!NT_SUCCESS(Status)) {
325 goto errorout;
326 }
327 }
328
329errorout:
330
331 /* free the memory of pData */
332 if (Bcb) {
334 }
335
336 if (!NT_SUCCESS(Status)) {
337 *Block = 0;
338 }
339
340 return Status;
341}
BOOLEAN Ext2AddMcbMetaExts(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Block, IN ULONG Length)
Definition: memory.c:941
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:414
NTSTATUS Ext2GetBlock(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Base, IN ULONG Layer, IN ULONG Start, IN ULONG SizeArray, IN PULONG BlockArray, IN BOOLEAN bAlloc, IN OUT PULONG Hint, OUT PULONG Block, OUT PULONG Number)
Definition: indirect.c:136
NTSTATUS Ext2ExpandLast(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Base, IN ULONG Layer, IN PULONG *Data, IN PULONG Hint, IN PULONG Block, IN OUT PULONG Number)
Definition: indirect.c:25
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by Ext2GetBlock(), and Ext2MapIndirect().

◆ Ext2GetInfoLength()

ULONG Ext2GetInfoLength ( IN FILE_INFORMATION_CLASS  FileInformationClass)

Definition at line 30 of file dirctl.c.

31{
32 switch (FileInformationClass) {
33
36
39
42
45
48
51
52 default:
53 break;
54 }
55
56 return 0;
57}
@ FileDirectoryInformation
Definition: from_kernel.h:62
@ FileIdBothDirectoryInformation
Definition: from_kernel.h:98
@ FileNamesInformation
Definition: from_kernel.h:73
@ FileFullDirectoryInformation
Definition: from_kernel.h:63
@ FileBothDirectoryInformation
Definition: from_kernel.h:64
@ FileIdFullDirectoryInformation
Definition: from_kernel.h:99
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75

Referenced by Ext2FillEntry(), and Ext2ProcessEntry().

◆ Ext2GetInodeLba()

BOOLEAN Ext2GetInodeLba ( IN PEXT2_VCB  Vcb,
IN ULONG  inode,
OUT PLONGLONG  offset 
)

Definition at line 418 of file generic.c.

423{
425 struct buffer_head *bh = NULL;
426 ext4_fsblk_t loc;
427 int group;
428
429 if (inode < 1 || inode > INODES_COUNT) {
430 DEBUG(DL_ERR, ( "Ext2GetInodeLba: Inode value %xh is invalid.\n",inode));
431 *offset = 0;
432 return FALSE;
433 }
434
435 group = (inode - 1) / INODES_PER_GROUP ;
436 gd = ext4_get_group_desc(&Vcb->sb, group, &bh);
437 if (!bh) {
438 *offset = 0;
439 DbgBreak();
440 return FALSE;
441 }
442 loc = (LONGLONG)ext4_inode_table(&Vcb->sb, gd);
443 loc = loc << BLOCK_BITS;
444 loc = loc + ((inode - 1) % INODES_PER_GROUP) * Vcb->InodeSize;
445
446 *offset = loc;
447 __brelse(bh);
448
449 return TRUE;
450}
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2475

Referenced by Ext2ClearInode(), Ext2LoadInode(), Ext2LoadInodeXattr(), Ext2SaveInode(), and Ext2SaveInodeXattr().

◆ Ext2GetProcessNameOffset()

ULONG Ext2GetProcessNameOffset ( VOID  )

Referenced by DriverEntry().

◆ Ext2GetRetrievalPointerBase()

NTSTATUS Ext2GetRetrievalPointerBase ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1160 of file fsctl.c.

1163{
1164 PIRP Irp = NULL;
1167
1170
1171 PEXT2_VCB Vcb = NULL;
1172 PEXT2_FCB Fcb = NULL;
1173 PEXT2_CCB Ccb = NULL;
1174
1175 PLARGE_INTEGER FileAreaOffset;
1176
1177 ULONG OutputSize;
1178
1180
1181 BOOLEAN FcbResourceAcquired = FALSE;
1182
1183 _SEH2_TRY {
1184
1185 ASSERT(IrpContext);
1186 Irp = IrpContext->Irp;
1187 ASSERT(Irp);
1188
1191 ASSERT(IrpSp);
1192
1193 OutputSize = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
1194
1195 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
1196 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
1197
1198 DeviceObject = IrpContext->DeviceObject;
1199
1200 /* This request is not allowed on the main device object */
1204 }
1205
1206 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
1207 ASSERT(Vcb != NULL);
1208 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
1209 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
1211
1212 FileObject = IrpContext->FileObject;
1213 Fcb = (PEXT2_FCB) FileObject->FsContext;
1214
1215 /* check Fcb is valid or not */
1216 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
1219 }
1220
1222 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
1223
1224 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
1227 }
1228
1229 Ccb = (PEXT2_CCB) FileObject->FsContext2;
1230 if (Ccb == NULL) {
1233 }
1234
1236 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
1237
1238 if (OutputSize < sizeof(LARGE_INTEGER)) {
1241 }
1242
1247 }
1248 FcbResourceAcquired = TRUE;
1249
1250 FileAreaOffset = (PLARGE_INTEGER) Ext2GetUserBuffer(Irp);
1251
1252 /* probe user buffer */
1253
1254 _SEH2_TRY {
1255 if (Irp->RequestorMode != KernelMode) {
1256 ProbeForWrite(FileAreaOffset, OutputSize, sizeof(UCHAR));
1257 }
1258
1260
1262 } _SEH2_END;
1263
1264 if (!NT_SUCCESS(Status)) {
1266 }
1267
1268 DEBUG(DL_DBG, ("Ext2GetRetrievalPointerBase: FileAreaOffset is 0.\n"));
1269
1270 FileAreaOffset->QuadPart = 0; // sector offset to the first allocatable unit on the filesystem
1271
1272 Irp->IoStatus.Information = sizeof(LARGE_INTEGER);
1273
1274 } _SEH2_FINALLY {
1275
1276 if (FcbResourceAcquired) {
1278 }
1279
1282 Status = Ext2QueueRequest(IrpContext);
1283 } else {
1284 Ext2CompleteIrpContext(IrpContext, Status);
1285 }
1286 }
1287 } _SEH2_END;
1288
1289 return Status;
1290}
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
PVOID Ext2GetUserBuffer(IN PIRP Irp)
Definition: block.c:146
#define Ext2CanIWait()
Definition: ext2fs.h:1100
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:160
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
union _LARGE_INTEGER LARGE_INTEGER
union _LARGE_INTEGER * PLARGE_INTEGER
Definition: file.c:85
#define PEXTENDED_IO_STACK_LOCATION
Definition: udffs.h:121

Referenced by Ext2UserFsRequest().

◆ Ext2GetRetrievalPointers()

NTSTATUS Ext2GetRetrievalPointers ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 911 of file fsctl.c.

914{
915 PIRP Irp = NULL;
918
921
925
928
929 PEXT2_EXTENT Chain = NULL;
931
932 LONGLONG Vbn = 0;
933 ULONG Length = 0;
934 ULONG i = 0;
935
936 ULONG UsedSize = 0;
937 ULONG InputSize;
938 ULONG OutputSize;
939
941
942 BOOLEAN FcbResourceAcquired = FALSE;
943
944 _SEH2_TRY {
945
946 ASSERT(IrpContext);
947 Irp = IrpContext->Irp;
948 ASSERT(Irp);
949
952 ASSERT(IrpSp);
953
954 InputSize = EIrpSp->Parameters.FileSystemControl.InputBufferLength;
955 OutputSize = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
956
957 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
958 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
959
960 DeviceObject = IrpContext->DeviceObject;
961
962 /* This request is not allowed on the main device object */
966 }
967
968 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
969 ASSERT(Vcb != NULL);
970 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
971 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
973
974 FileObject = IrpContext->FileObject;
975 Fcb = (PEXT2_FCB) FileObject->FsContext;
976
977 /* check Fcb is valid or not */
978 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
981 }
982
984 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
985
986 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
989 }
990
991 Ccb = (PEXT2_CCB) FileObject->FsContext2;
992 if (Ccb == NULL) {
995 }
996
998 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
999
1000 if (InputSize < sizeof(STARTING_VCN_INPUT_BUFFER) ||
1001 OutputSize < sizeof(RETRIEVAL_POINTERS_BUFFER) ) {
1004 }
1005
1010 }
1011 FcbResourceAcquired = TRUE;
1012
1014 EIrpSp->Parameters.FileSystemControl.Type3InputBuffer;
1016
1017 /* probe user buffer */
1018
1019 _SEH2_TRY {
1020 if (Irp->RequestorMode != KernelMode) {
1021 ProbeForRead (SVIB, InputSize, sizeof(UCHAR));
1022 ProbeForWrite(RPSB, OutputSize, sizeof(UCHAR));
1023 }
1026 } _SEH2_END;
1027
1028 if (!NT_SUCCESS(Status)) {
1030 }
1031
1032 UsedSize = FIELD_OFFSET(RETRIEVAL_POINTERS_BUFFER, Extents[0]);
1033
1034 /* request size beyonds whole file size ? */
1035 DEBUG(DL_DBG, ("Ext2GetRetrievalPointers: Startin from Vbn: %I64xh\n",
1036 SVIB->StartingVcn.QuadPart));
1037 Vbn = (SVIB->StartingVcn.QuadPart << BLOCK_BITS);
1038 if (Vbn >= Fcb->Header.AllocationSize.QuadPart ) {
1041 }
1042
1043 /* now building all the request extents */
1044 while (Vbn < Fcb->Header.AllocationSize.QuadPart) {
1045
1046 ASSERT(Chain == NULL);
1047 Length = 0x80000000; /* 2g bytes */
1048 if (Fcb->Header.AllocationSize.QuadPart < Vbn + Length) {
1049 Length = (ULONG)(Fcb->Header.AllocationSize.QuadPart - Vbn);
1050 }
1051
1052 /* build extents for sub-range */
1054 IrpContext,
1055 Vcb,
1056 Fcb->Mcb,
1057 Vbn,
1058 Length,
1059 FALSE,
1060 &Chain);
1061
1062 if (!NT_SUCCESS(Status)) {
1063 DbgBreak();
1065 }
1066
1067 /* fill user buffer of RETRIEVAL_POINTERS_BUFFER */
1068 Extent = Chain;
1069 while (Extent) {
1070
1071 DEBUG(DL_MAP, ("Ext2GetRetrievalPointers: %wZ %d Vbn = %I64xh Lbn = %I64xh\n",
1072 &Fcb->Mcb->FullName, i,
1073 ((Vbn + Extent->Offset) >> BLOCK_BITS),
1074 Extent->Lba));
1075
1076 RPSB->Extents[i].Lcn.QuadPart = (Extent->Lba >> BLOCK_BITS);
1077 RPSB->Extents[i].NextVcn.QuadPart = ((Vbn + Extent->Offset + Extent->Length) >> BLOCK_BITS);
1078 if (i == 0) {
1079 RPSB->StartingVcn.QuadPart = ((Vbn + Extent->Offset) >> BLOCK_BITS);
1080 } else {
1081 ASSERT(RPSB->Extents[i-1].NextVcn.QuadPart == ((Vbn + Extent->Offset) >> BLOCK_BITS));
1082 }
1083 if (UsedSize + sizeof(RETRIEVAL_POINTERS_BUFFER) > OutputSize) {
1086 }
1087 UsedSize += sizeof(LARGE_INTEGER) * 2;
1088 Irp->IoStatus.Information = (ULONG_PTR)UsedSize;
1089 RPSB->ExtentCount = ++i;
1090 Extent = Extent->Next;
1091 }
1092
1093 if (Chain) {
1095 Chain = NULL;
1096 }
1097
1098 Vbn = Vbn + Length;
1099 }
1100
1101#if 0
1102 {
1103 NTSTATUS _s;
1104 ULONG _i = 0;
1105 LARGE_INTEGER RequestVbn = Fcb->Header.AllocationSize;
1106 PLARGE_INTEGER MappedRuns = NULL;
1107
1109 IrpContext,
1110 Vcb,
1111 Fcb,
1112 &RequestVbn,
1113 &MappedRuns
1114 );
1115 if (!NT_SUCCESS(_s) || NULL == MappedRuns) {
1116 DbgBreak();
1117 goto exit_to_get_rps;
1118 }
1119
1120 while (MappedRuns[_i*2 + 0].QuadPart != 0 ||
1121 MappedRuns[_i*2 + 1].QuadPart != 0 ) {
1122 DEBUG(DL_MAP, ("Ext2QueryExtentMappings: %wZ %d Vbn = %I64xh Lbn = %I64xh\n",
1123 &Fcb->Mcb->FullName, _i,
1124 MappedRuns[_i*2 + 0].QuadPart,
1125 MappedRuns[_i*2 + 1].QuadPart));
1126 _i++;
1127 }
1128
1129exit_to_get_rps:
1130
1131 if (MappedRuns) {
1132 Ext2FreePool(MappedRuns, 'RE2E');
1133 }
1134 }
1135#endif
1136
1137 } _SEH2_FINALLY {
1138
1139 if (FcbResourceAcquired) {
1141 }
1142
1143 if (Chain) {
1145 }
1146
1149 Status = Ext2QueueRequest(IrpContext);
1150 } else {
1151 Ext2CompleteIrpContext(IrpContext, Status);
1152 }
1153 }
1154 } _SEH2_END;
1155
1156 return Status;
1157}
Definition: Header.h:9
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
NTSTATUS Ext2QueryExtentMappings(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PLARGE_INTEGER RequestVbn, OUT PLARGE_INTEGER *pMappedRuns)
Definition: fsctl.c:670
VOID Ext2DestroyExtentChain(IN PEXT2_EXTENT Chain)
Definition: memory.c:546
NTSTATUS Ext2BuildExtents(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN ULONG Size, IN BOOLEAN bAlloc, OUT PEXT2_EXTENT *Chain)
Definition: memory.c:1207
#define DL_MAP
Definition: ext2fs.h:1444
struct STARTING_VCN_INPUT_BUFFER * PSTARTING_VCN_INPUT_BUFFER
#define STATUS_END_OF_FILE
Definition: shellext.h:67
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
struct RETRIEVAL_POINTERS_BUFFER::@3328 Extents[1]
LARGE_INTEGER StartingVcn
Definition: winioctl.h:608
LARGE_INTEGER StartingVcn
Definition: winioctl.h:623
ret QuadPart
Definition: rtlfuncs.h:3089

Referenced by Ext2UserFsRequest().

◆ Ext2GetUserBuffer()

PVOID Ext2GetUserBuffer ( IN PIRP  Irp)

Definition at line 146 of file block.c.

147{
148 ASSERT(Irp != NULL);
149
150 if (Irp->MdlAddress) {
151
152#if (_WIN32_WINNT >= 0x0500)
154#else
155 return MmGetSystemAddressForMdl(Irp->MdlAddress);
156#endif
157 } else {
158
159 return Irp->UserBuffer;
160 }
161}
@ NormalPagePriority
Definition: imports.h:56
#define MmGetSystemAddressForMdl(Mdl)
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)

Referenced by Ext2GetRetrievalPointerBase(), Ext2GetRetrievalPointers(), Ext2QueryDirectory(), Ext2QueryEa(), Ext2ReadFile(), Ext2ReadInode(), Ext2ReadVolume(), Ext2WriteFile(), and Ext2WriteVolume().

◆ Ext2InitializeLabel()

NTSTATUS Ext2InitializeLabel ( IN PEXT2_VCB  Vcb,
IN PEXT2_SUPER_BLOCK  Sb 
)

Definition at line 2253 of file memory.c.

2257{
2259
2260 USHORT Length;
2263
2264 Label.MaximumLength = 16 * sizeof(WCHAR);
2265 Label.Length = 0;
2266 Label.Buffer = Vcb->Vpb->VolumeLabel;
2267 Vcb->Vpb->VolumeLabelLength = 0;
2268 RtlZeroMemory(Label.Buffer, Label.MaximumLength);
2269
2270 Length = 16;
2271 while ( (Length > 0) &&
2272 ((Sb->s_volume_name[Length -1] == 0x00) ||
2273 (Sb->s_volume_name[Length - 1] == 0x20) )
2274 ) {
2275 Length--;
2276 }
2277
2278 if (Length == 0) {
2279 return STATUS_SUCCESS;
2280 }
2281
2282 OemName.Buffer = Sb->s_volume_name;
2283 OemName.MaximumLength = 16;
2284 OemName.Length = Length;
2285
2287 if (NT_SUCCESS(status)) {
2288 Vcb->Vpb->VolumeLabelLength = Label.Length;
2289 }
2290
2291 return status;
2292}
PWCHAR Label
Definition: format.c:70

Referenced by Ext2InitializeVcb(), and Ext2ProcessVolumeProperty().

◆ Ext2InitializeVcb()

NTSTATUS Ext2InitializeVcb ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_SUPER_BLOCK  Ext2Sb,
PDEVICE_OBJECT  TargetDevice,
PDEVICE_OBJECT  VolumeDevice,
PVPB  Vpb 
)

Referenced by Ext2MountVolume().

◆ Ext2InitializeZone()

NTSTATUS Ext2InitializeZone ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb 
)

Definition at line 1121 of file memory.c.

1126{
1128
1129 ULONG Start = 0;
1130 ULONG End;
1131 ULONG Block;
1132 ULONG Mapped;
1133
1134 Ext2ClearAllExtents(&Mcb->Extents);
1135 Ext2ClearAllExtents(&Mcb->MetaExts);
1136
1137 ASSERT(Mcb != NULL);
1138 End = (ULONG)((Mcb->Inode.i_size + BLOCK_SIZE - 1) >> BLOCK_BITS);
1139
1140 while (Start < End) {
1141
1142 Block = Mapped = 0;
1143
1144 /* mapping file offset to ext2 block */
1145 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1147 IrpContext,
1148 Vcb,
1149 Mcb,
1150 Start,
1151 FALSE,
1152 &Block,
1153 &Mapped
1154 );
1155 } else {
1157 IrpContext,
1158 Vcb,
1159 Mcb,
1160 Start,
1161 FALSE,
1162 &Block,
1163 &Mapped
1164 );
1165 }
1166
1167 if (!NT_SUCCESS(Status)) {
1168 goto errorout;
1169 }
1170
1171 /* skip wrong blocks, in case wrongly treating symlink
1172 target names as blocks, silly */
1173 if (Block >= TOTAL_BLOCKS) {
1174 Block = 0;
1175 }
1176
1177 if (Block) {
1178 if (!Ext2AddBlockExtent(Vcb, Mcb, Start, Block, Mapped)) {
1179 DbgBreak();
1180 ClearFlag(Mcb->Flags, MCB_ZONE_INITED);
1181 Ext2ClearAllExtents(&Mcb->Extents);
1183 goto errorout;
1184 }
1185 DEBUG(DL_MAP, ("Ext2InitializeZone %wZ: Block = %xh Mapped = %xh\n",
1186 &Mcb->FullName, Block, Mapped));
1187 }
1188
1189 /* Mapped is total number of continous blocks or NULL blocks */
1190 Start += Mapped;
1191 }
1192
1193 /* set mcb zone as initialized */
1195
1196errorout:
1197
1198 if (!IsZoneInited(Mcb)) {
1199 Ext2ClearAllExtents(&Mcb->Extents);
1200 Ext2ClearAllExtents(&Mcb->MetaExts);
1201 }
1202
1203 return Status;
1204}

Referenced by Ext2BuildExtents(), and Ext2TruncateIndirectFast().

◆ Ext2InodeType()

ULONG Ext2InodeType ( PEXT2_MCB  Mcb)

Definition at line 1906 of file fileinfo.c.

1907{
1908 if (IsMcbSymLink(Mcb)) {
1909 return EXT2_FT_SYMLINK;
1910 }
1911
1912 if (IsMcbDirectory(Mcb)) {
1913 return EXT2_FT_DIR;
1914 }
1915
1916 return EXT2_FT_REG_FILE;
1917}
#define EXT2_FT_SYMLINK
Definition: ext2_fs.h:536
#define EXT2_FT_REG_FILE
Definition: ext2_fs.h:530

Referenced by Ext2DeleteFile().

◆ Ext2InsertFcb()

VOID Ext2InsertFcb ( PEXT2_VCB  Vcb,
PEXT2_FCB  Fcb 
)

Definition at line 309 of file memory.c.

310{
312
313 KeQuerySystemTime(&Fcb->TsDrop);
314 Ext2ReferXcb(&Vcb->FcbCount);
315 Ext2ReferXcb(&Vcb->ReferenceCount);
316 InsertTailList(&Vcb->FcbList, &Fcb->Next);
317}

Referenced by Ext2AllocateFcb().

◆ Ext2InsertMcb()

VOID Ext2InsertMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Parent,
PEXT2_MCB  Child 
)

Definition at line 1686 of file memory.c.

1691{
1692 BOOLEAN LockAcquired = FALSE;
1693 PEXT2_MCB Mcb = NULL;
1694
1695 _SEH2_TRY {
1696
1698 &Vcb->McbLock,
1699 TRUE );
1700 LockAcquired = TRUE;
1701
1702 /* use it's target if it's a symlink */
1703 if (IsMcbSymLink(Parent)) {
1704 Parent = Parent->Target;
1706 }
1707
1708 Mcb = Parent->Child;
1709 while (Mcb) {
1710 if (Mcb == Child) {
1711 break;
1712 }
1713 Mcb = Mcb->Next;
1714 }
1715
1716 if (Mcb) {
1717 /* already attached in the list */
1718 DEBUG(DL_ERR, ( "Ext2InsertMcb: Child Mcb is alreay attached.\n"));
1719 if (!IsFlagOn(Mcb->Flags, MCB_ENTRY_TREE)) {
1721 DEBUG(DL_ERR, ( "Ext2InsertMcb: Child Mcb's flag isn't set.\n"));
1722 }
1723
1724 DbgBreak();
1725
1726 } else {
1727
1728 /* insert this Mcb into the head */
1729 Child->Next = Parent->Child;
1730 Parent->Child = Child;
1731 Child->Parent = Parent;
1732 Child->de->d_parent = Parent->de;
1735 }
1736
1737 } _SEH2_FINALLY {
1738
1739 if (LockAcquired) {
1740 ExReleaseResourceLite(&Vcb->McbLock);
1741 }
1742 } _SEH2_END;
1743}
#define MCB_ENTRY_TREE
Definition: ext2fs.h:954
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536

Referenced by Ext2LookupFile(), and Ext2SetRenameInfo().

◆ Ext2InsertVcb()

VOID Ext2InsertVcb ( PEXT2_VCB  Vcb)

Definition at line 1935 of file memory.c.

1936{
1937 InsertTailList(&(Ext2Global->VcbList), &Vcb->Next);
1938}

Referenced by Ext2MountVolume().

◆ Ext2IsDirectoryEmpty()

BOOLEAN Ext2IsDirectoryEmpty ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb 
)

◆ Ext2IsDot()

BOOLEAN Ext2IsDot ( PUNICODE_STRING  name)

Definition at line 524 of file misc.c.

525{
526 return (name->Length == 2 && name->Buffer[0] == L'.');
527}

Referenced by Ext2SearchMcbWithoutLock().

◆ Ext2IsDotDot()

BOOLEAN Ext2IsDotDot ( PUNICODE_STRING  name)

Definition at line 529 of file misc.c.

530{
531 return (name->Length == 4 && name->Buffer[0] == L'.' &&
532 name->Buffer[1] == L'.');
533}

Referenced by Ext2SearchMcbWithoutLock().

◆ Ext2IsEaNameValid()

BOOLEAN Ext2IsEaNameValid ( IN OEM_STRING  Name)

Definition at line 389 of file ea.c.

392{
393 ULONG Index;
394 UCHAR Char;
395
396 //
397 // Empty names are not valid
398 //
399
400 if (Name.Length == 0)
401 return FALSE;
402
403 //
404 // Do not allow EA name longer than 255 bytes
405 //
406 if (Name.Length > 255)
407 return FALSE;
408
409 for (Index = 0; Index < (ULONG)Name.Length; Index += 1) {
410
411 Char = Name.Buffer[Index];
412
413 //
414 // Skip over and Dbcs chacters
415 //
416 if (FsRtlIsLeadDbcsCharacter(Char)) {
417
418 ASSERT(Index != (ULONG)(Name.Length - 1));
419 Index += 1;
420 continue;
421 }
422
423 //
424 // Make sure this character is legal, and if a wild card, that
425 // wild cards are permissible.
426 //
428 return FALSE;
429
430 }
431
432 return TRUE;
433}
#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR)
Definition: init.c:428
#define FsRtlIsAnsiCharacterLegalFat(C, WILD)
Definition: fsrtlfuncs.h:1611

Referenced by Ext2OverwriteEa(), and Ext2SetEa().

◆ Ext2IsFastIoPossible()

FAST_IO_POSSIBLE Ext2IsFastIoPossible ( IN PEXT2_FCB  Fcb)

Definition at line 38 of file fastio.c.

41{
43
44 if (!Fcb || !FsRtlOplockIsFastIoPossible(&Fcb->Oplock))
45 return IsPossible;
46
47 IsPossible = FastIoIsQuestionable;
48
49 if (!FsRtlAreThereCurrentFileLocks(&Fcb->FileLockAnchor)) {
50 if (!IsVcbReadOnly(Fcb->Vcb) && !FlagOn(Fcb->Vcb->Flags, VCB_VOLUME_LOCKED)) {
51 IsPossible = FastIoIsPossible;
52 }
53 }
54
55 return IsPossible;
56}
#define FsRtlAreThereCurrentFileLocks(FL)
Definition: fsrtlfuncs.h:1584
@ FastIoIsQuestionable
Definition: fsrtltypes.h:242
enum _FAST_IO_POSSIBLE FAST_IO_POSSIBLE

Referenced by Ext2Cleanup(), Ext2FastIoLock(), Ext2FastIoUnlockAll(), Ext2FastIoUnlockAllByKey(), Ext2FastIoUnlockSingle(), Ext2LockControl(), Ext2OplockRequest(), Ext2ReadFile(), Ext2SetFileInformation(), and Ext2WriteFile().

◆ Ext2IsFileRemovable()

NTSTATUS Ext2IsFileRemovable ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Fcb,
IN PEXT2_CCB  Ccb 
)

Definition at line 1239 of file fileinfo.c.

1245{
1246 PEXT2_MCB Mcb = Fcb->Mcb;
1247
1248 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
1249 return STATUS_CANNOT_DELETE;
1250 }
1251
1252 if (IsMcbDirectory(Mcb)) {
1253 if (!Ext2IsDirectoryEmpty(IrpContext, Vcb, Mcb)) {
1255 }
1256 }
1257
1258 if (!MmFlushImageSection(&Fcb->SectionObject,
1259 MmFlushForDelete )) {
1260 return STATUS_CANNOT_DELETE;
1261 }
1262
1263 if (IsMcbDirectory(Mcb)) {
1265 Vcb->NotifySync,
1266 &Vcb->NotifyList,
1267 Ccb,
1268 NULL,
1269 FALSE,
1270 FALSE,
1271 0,
1272 NULL,
1273 NULL,
1274 NULL
1275 );
1276 }
1277
1278 return STATUS_SUCCESS;
1279}
#define EXT2_ROOT_INO
Definition: ext2.h:177
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4356

Referenced by Ext2CreateFile(), Ext2SetDispositionInfo(), Ext2SetLinkInfo(), and Ext2SetRenameInfo().

◆ Ext2IsHandleCountZero()

BOOLEAN Ext2IsHandleCountZero ( IN PEXT2_VCB  Vcb)

Definition at line 68 of file fsctl.c.

69{
72
73 for ( List = Vcb->FcbList.Flink;
74 List != &Vcb->FcbList;
75 List = List->Flink ) {
76
78
80 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
81
82 DEBUG(DL_INF, ( "Ext2IsHandleCountZero: Inode:%xh File:%S OpenHandleCount=%xh\n",
83 Fcb->Inode->i_ino, Fcb->Mcb->ShortName.Buffer, Fcb->OpenHandleCount));
84
85 if (Fcb->OpenHandleCount) {
86 return FALSE;
87 }
88 }
89
90 return TRUE;
91}

Referenced by Ext2LockVcb().

◆ Ext2IsMediaWriteProtected()

BOOLEAN Ext2IsMediaWriteProtected ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PDEVICE_OBJECT  TargetDevice 
)

Definition at line 2005 of file fsctl.c.

2009{
2010 PIRP Irp;
2011 KEVENT Event;
2014
2016
2019 NULL,
2020 0,
2021 NULL,
2022 0,
2023 FALSE,
2024 &Event,
2025 &IoStatus );
2026
2027 if (Irp == NULL) {
2028 return FALSE;
2029 }
2030
2032
2034
2035 if (Status == STATUS_PENDING) {
2036
2038 Executive,
2039 KernelMode,
2040 FALSE,
2042
2043 Status = IoStatus.Status;
2044 }
2045
2047}
#define VOID
Definition: acefi.h:82
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:691

Referenced by Ext2InitializeVcb(), and Ext2VerifyVolume().

◆ Ext2IsNameValid()

BOOLEAN Ext2IsNameValid ( PUNICODE_STRING  FileName)

Definition at line 36 of file create.c.

37{
38 USHORT i = 0;
39 PUSHORT pName = (PUSHORT) FileName->Buffer;
40
41 if (FileName == NULL) {
42 return FALSE;
43 }
44
45 while (i < (FileName->Length / sizeof(WCHAR))) {
46
47 if (pName[i] == 0) {
48 break;
49 }
50
51 if (pName[i] == L'|' || pName[i] == L':' ||
52 pName[i] == L'/' || pName[i] == L'*' ||
53 pName[i] == L'?' || pName[i] == L'\"' ||
54 pName[i] == L'<' || pName[i] == L'>' ) {
55
56 return FALSE;
57 }
58
59 i++;
60 }
61
62 return TRUE;
63}
static LPSTR pName
Definition: security.c:75
uint16_t * PUSHORT
Definition: typedefs.h:56

Referenced by Ext2CreateFile(), and Ext2LookupFile().

◆ Ext2IsSpecialSystemFile()

BOOLEAN Ext2IsSpecialSystemFile ( IN PUNICODE_STRING  FileName,
IN BOOLEAN  bDirectory 
)

Definition at line 224 of file create.c.

228{
229 PWSTR SpecialFileList[] = {
230 L"pagefile.sys",
231 L"swapfile.sys",
232 L"hiberfil.sys",
233 NULL
234 };
235
236 PWSTR SpecialDirList[] = {
237 L"Recycled",
238 L"RECYCLER",
239 L"$RECYCLE.BIN",
240 NULL
241 };
242
243 PWSTR entryName;
245 int i;
246
247 for (i = 0; TRUE; i++) {
248
249 if (bDirectory) {
250 entryName = SpecialDirList[i];
251 } else {
252 entryName = SpecialFileList[i];
253 }
254
255 if (NULL == entryName) {
256 break;
257 }
258
259 length = wcslen(entryName) * sizeof(WCHAR);
260 if (FileName->Length == length) {
261 if ( 0 == _wcsnicmp( entryName,
262 FileName->Buffer,
263 length / sizeof(WCHAR) )) {
264 return TRUE;
265 }
266 }
267 }
268
269 return FALSE;
270}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by Ext2LookupFile(), and Ext2ProcessEntry().

◆ Ext2IsVolumeMounted()

NTSTATUS Ext2IsVolumeMounted ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2494 of file fsctl.c.

2495{
2497 PEXT2_VCB Vcb = 0;
2499
2500 ASSERT(IrpContext);
2501
2502 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2503 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2504
2505
2506 DeviceObject = IrpContext->DeviceObject;
2507
2508 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
2509
2511
2512 Ext2VerifyVcb (IrpContext, Vcb);
2513
2514 Ext2CompleteIrpContext(IrpContext, Status);
2515
2516 return Status;
2517}
VOID Ext2VerifyVcb(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: fsctl.c:2277

Referenced by Ext2UserFsRequest().

◆ Ext2IsWearingCloak()

BOOLEAN Ext2IsWearingCloak ( IN PEXT2_VCB  Vcb,
IN POEM_STRING  OeName 
)

Definition at line 372 of file dirctl.c.

376{
377 size_t PatLen = 0;
378
379 /* we could not filter the files: "." and ".." */
380 if (OemName->Length >= 1 && OemName->Buffer[0] == '.') {
381
382 if ( OemName->Length == 2 && OemName->Buffer[1] == '.') {
383 return FALSE;
384 } else if (OemName->Length == 1) {
385 return FALSE;
386 }
387 }
388
389 /* checking name prefix */
390 if (Vcb->bHidingPrefix) {
391 PatLen = strlen(&Vcb->sHidingPrefix[0]);
392 if (PatLen > 0 && PatLen <= OemName->Length) {
393 if ( _strnicmp( OemName->Buffer,
394 Vcb->sHidingPrefix,
395 PatLen ) == 0) {
396 return TRUE;
397 }
398 }
399 }
400
401 /* checking name suffix */
402 if (Vcb->bHidingSuffix) {
403 PatLen = strlen(&Vcb->sHidingSuffix[0]);
404 if (PatLen > 0 && PatLen <= OemName->Length) {
405 if ( _strnicmp(&OemName->Buffer[OemName->Length - PatLen],
406 Vcb->sHidingSuffix, PatLen ) == 0) {
407 return TRUE;
408 }
409 }
410 }
411
412 return FALSE;
413}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23

Referenced by Ext2FillEntry(), and Ext2QueryDirectory().

◆ Ext2JointExtents()

VOID Ext2JointExtents ( IN PEXT2_EXTENT  Chain,
IN PEXT2_EXTENT  Extent 
)

Definition at line 527 of file memory.c.

531{
532#ifndef __REACTOS__
533 ULONG count = 0;
534#endif
535 PEXT2_EXTENT List = Chain;
536
537 while (List->Next) {
538 List = List->Next;
539 }
540
541 List->Next = Extent;
542}
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] STATPROPSETSTG *rgelt, [out] ULONG *pceltFetched)

Referenced by Ext2QueryExtentMappings().

◆ Ext2LinkHeadMcb()

VOID Ext2LinkHeadMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb 
)

Definition at line 2935 of file memory.c.

2936{
2937 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
2938 return;
2939 }
2940
2942
2943 if (!IsFlagOn(Mcb->Flags, MCB_VCB_LINK)) {
2944 InsertHeadList(&Vcb->McbList, &Mcb->Link);
2945 SetLongFlag(Mcb->Flags, MCB_VCB_LINK);
2946 Ext2ReferXcb(&Vcb->NumOfMcb);
2947 } else {
2948 DEBUG(DL_RES, ( "Ext2LinkHeadMcb: %wZ already linked.\n",
2949 &Mcb->FullName));
2950 }
2951 ExReleaseResourceLite(&Vcb->McbLock);
2952}
#define InsertHeadList(ListHead, Entry)

Referenced by Ext2FreeCcb(), and Ext2UnlinkFcb().

◆ Ext2LinkTailMcb()

VOID Ext2LinkTailMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb 
)

Definition at line 2912 of file memory.c.

2913{
2914 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
2915 return;
2916 }
2917
2919
2920 if (IsFlagOn(Mcb->Flags, MCB_VCB_LINK)) {
2921 DEBUG(DL_RES, ( "Ext2LinkTailMcb: %wZ already linked.\n",
2922 &Mcb->FullName));
2923 } else {
2924 InsertTailList(&Vcb->McbList, &Mcb->Link);
2925 SetLongFlag(Mcb->Flags, MCB_VCB_LINK);
2926 Ext2ReferXcb(&Vcb->NumOfMcb);
2927 }
2928
2929 ExReleaseResourceLite(&Vcb->McbLock);
2930}

Referenced by Ext2LookupFile().

◆ Ext2LinuxError()

int Ext2LinuxError ( NTSTATUS  Status)

Definition at line 304 of file misc.c.

305{
306 switch (Status) {
308 return (-EACCES);
309
311 return (-EFAULT);
312
314 return (-ETOOSMALL);
315
317 return (-EINVAL);
318
321 return (-EOPNOTSUPP);
322
325 return (-EADDRNOTAVAIL);
326
334 return (-ENETDOWN);
335
339 return (-ENETUNREACH);
340
344 return (-ECONNABORTED);
345
351 return (-ECONNRESET);
352
354 return (-ENOMEM);
355
357 case STATUS_NO_MEMORY:
365 return (-ENOBUFS);
366
368 return (-ENOTCONN);
369
371 return (-ESHUTDOWN);
372
373 case STATUS_TIMEOUT:
376 return (-ETIMEDOUT);
377
380 return (-ECONNREFUSED);
381
383 return (-EHOSTUNREACH);
384
385 case STATUS_CANT_WAIT:
386 case STATUS_PENDING:
387 return (-EAGAIN);
388
390 return (-EIO);
391
392 case STATUS_CANCELLED:
394 return (-EINTR);
395
398 return (-EMSGSIZE);
399
401 return (-EADDRINUSE);
402 }
403
404 if (NT_SUCCESS (Status))
405 return 0;
406
407 return (-EINVAL);
408}
#define EINVAL
Definition: acclib.h:90
#define EFAULT
Definition: acclib.h:86
#define EINTR
Definition: acclib.h:80
#define ENOMEM
Definition: acclib.h:84
#define EACCES
Definition: acclib.h:85
#define EAGAIN
Definition: acclib.h:83
#define ETOOSMALL
Definition: errno.h:149
#define ESHUTDOWN
Definition: errno.h:119
#define ENETUNREACH
Definition: errno.h:112
#define ECONNABORTED
Definition: errno.h:114
#define EOPNOTSUPP
Definition: errno.h:104
#define EHOSTUNREACH
Definition: errno.h:124
#define EADDRNOTAVAIL
Definition: errno.h:110
#define ETIMEDOUT
Definition: errno.h:121
#define EADDRINUSE
Definition: errno.h:109
#define ENOBUFS
Definition: errno.h:116
#define ENETDOWN
Definition: errno.h:111
#define ECONNREFUSED
Definition: errno.h:122
#define ECONNRESET
Definition: errno.h:115
#define EMSGSIZE
Definition: errno.h:97
#define ENOTCONN
Definition: errno.h:118
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:412
#define STATUS_INVALID_ADDRESS
Definition: ntstatus.h:557
#define STATUS_QUOTA_EXCEEDED
Definition: ntstatus.h:304
#define STATUS_NETWORK_UNREACHABLE
Definition: ntstatus.h:704
#define STATUS_PROTOCOL_UNREACHABLE
Definition: ntstatus.h:706
#define STATUS_ADDRESS_ALREADY_EXISTS
Definition: ntstatus.h:654
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define STATUS_TRANSACTION_ABORTED
Definition: ntstatus.h:659
#define STATUS_HOST_UNREACHABLE
Definition: ntstatus.h:705
#define STATUS_WORKING_SET_QUOTA
Definition: ntstatus.h:397
#define STATUS_REMOTE_DISCONNECT
Definition: ntstatus.h:552
#define STATUS_INVALID_CONNECTION
Definition: ntstatus.h:556
#define STATUS_PORT_UNREACHABLE
Definition: ntstatus.h:707
#define STATUS_NETWORK_BUSY
Definition: ntstatus.h:427
#define STATUS_INVALID_NETWORK_RESPONSE
Definition: ntstatus.h:431
#define STATUS_CONNECTION_RESET
Definition: ntstatus.h:657
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_CONNECTION_ABORTED
Definition: ntstatus.h:709
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_BAD_NETWORK_PATH
Definition: ntstatus.h:426
#define STATUS_CONNECTION_REFUSED
Definition: ntstatus.h:698
#define STATUS_INVALID_ADDRESS_COMPONENT
Definition: ntstatus.h:651
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_CONNECTION_DISCONNECTED
Definition: ntstatus.h:656
#define STATUS_LINK_TIMEOUT
Definition: ntstatus.h:555
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:261
#define STATUS_REMOTE_NOT_LISTENING
Definition: ntstatus.h:424
#define STATUS_REMOTE_RESOURCES
Definition: ntstatus.h:553
#define STATUS_UNEXPECTED_NETWORK_ERROR
Definition: ntstatus.h:432
#define STATUS_LOCAL_DISCONNECT
Definition: ntstatus.h:551
#define STATUS_PAGEFILE_QUOTA
Definition: ntstatus.h:244
#define STATUS_TOO_MANY_ADDRESSES
Definition: ntstatus.h:653
#define STATUS_TOO_MANY_PAGING_FILES
Definition: ntstatus.h:387
#define STATUS_COMMITMENT_LIMIT
Definition: ntstatus.h:537
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
#define STATUS_REQUEST_ABORTED
Definition: udferr_usr.h:183
#define STATUS_NO_SUCH_FILE
Definition: udferr_usr.h:137
#define STATUS_CANCELLED
Definition: udferr_usr.h:170

Referenced by ext3_bread(), and ext4_new_meta_blocks().

◆ Ext2LinuxTime()

ULONG Ext2LinuxTime ( IN LARGE_INTEGER  SysTime)

Definition at line 51 of file misc.c.

52{
53 ULONG Ext2Time = 0;
54
55 if (!RtlTimeToSecondsSince1970(&SysTime, &Ext2Time)) {
59 }
60
61 return Ext2Time;
62}
_In_ PLARGE_INTEGER NtTime
Definition: fatprocs.h:1914
BOOLEAN NTAPI RtlTimeToSecondsSince1970(PLARGE_INTEGER Time, PULONG ElapsedSeconds)

Referenced by Ext2Cleanup(), Ext2CreateInode(), Ext2DeleteFile(), Ext2FlushFile(), Ext2SetFileInformation(), Ext2SupersedeOrOverWriteFile(), and ext3_current_time().

◆ Ext2ListExtents()

BOOLEAN Ext2ListExtents ( PLARGE_MCB  Extents)

Definition at line 558 of file memory.c.

559{
560 if (FsRtlNumberOfRunsInLargeMcb(Extents) != 0) {
561
562 LONGLONG DirtyVba;
563 LONGLONG DirtyLba;
564 LONGLONG DirtyLength;
565 int i, n = 0;
566
568 Extents, i, &DirtyVba,
569 &DirtyLba, &DirtyLength); i++) {
570 if (DirtyVba > 0 && DirtyLba != -1) {
571 DEBUG(DL_EXT, ("Vba:%I64xh Lba:%I64xh Len:%I64xh.\n", DirtyVba, DirtyLba, DirtyLength));
572 n++;
573 }
574 }
575
576 return n ? TRUE : FALSE;
577 }
578
579 return FALSE;
580}
GLdouble n
Definition: glext.h:7729

Referenced by Ext2DestroyVcb(), Ext2FreeMcb(), and Ext2TruncateFile().

◆ Ext2LoadAllNls()

int Ext2LoadAllNls ( )

Definition at line 118 of file nls.c.

119{
120 int rc;
121
122 tables = NULL;
124
125 /* loading utf8 ... */
127
128#ifdef FULL_CODEPAGES_SUPPORT
129
130 /* loading chinese gb2312 and big5... */
133
134 /* loading all others */
135
173
174#endif //FULL_CODEPAGES_SUPPORT
175
176 return rc;
177}
struct nls_table * tables
Definition: nls_base.c:22
spinlock_t nls_lock
Definition: nls_base.c:23
#define LOAD_NLS
Definition: module.h:292
#define spin_lock_init(sl)
Definition: module.h:305
static int __init init_nls_ascii(void)
Definition: nls_ascii.c:155
static int __init init_nls_cp1250(void)
Definition: nls_cp1250.c:336
static int __init init_nls_cp1251(void)
Definition: nls_cp1251.c:290
static int __init init_nls_cp1255(void)
Definition: nls_cp1255.c:371
static int __init init_nls_cp437(void)
Definition: nls_cp437.c:376
static int __init init_nls_cp737(void)
Definition: nls_cp737.c:339
static int __init init_nls_cp775(void)
Definition: nls_cp775.c:308
static int __init init_nls_cp850(void)
Definition: nls_cp850.c:304
static int __init init_nls_cp852(void)
Definition: nls_cp852.c:326
static int __init init_nls_cp855(void)
Definition: nls_cp855.c:288
static int __init init_nls_cp857(void)
Definition: nls_cp857.c:290
static int __init init_nls_cp860(void)
Definition: nls_cp860.c:353
static int __init init_nls_cp861(void)
Definition: nls_cp861.c:376
static int __init init_nls_cp862(void)
Definition: nls_cp862.c:410
static int __init init_nls_cp863(void)
Definition: nls_cp863.c:370
static int __init init_nls_cp864(void)
Definition: nls_cp864.c:396
static int __init init_nls_cp865(void)
Definition: nls_cp865.c:376
static int __init init_nls_cp866(void)
Definition: nls_cp866.c:294
static int __init init_nls_cp869(void)
Definition: nls_cp869.c:304
static int __init init_nls_cp874(void)
Definition: nls_cp874.c:262
static int __init init_nls_cp932(void)
Definition: nls_cp932.c:7932
static int __init init_nls_cp936(void)
Definition: nls_cp936.c:11017
static int __init init_nls_cp949(void)
Definition: nls_cp949.c:13934
static int __init init_nls_cp950(void)
Definition: nls_cp950.c:9473
static int __init init_nls_euc_jp(void)
Definition: nls_euc-jp.c:565
static int __init init_nls_iso8859_13(void)
static int __init init_nls_iso8859_14(void)
static int __init init_nls_iso8859_15(void)
static int __init init_nls_iso8859_1(void)
static int __init init_nls_iso8859_2(void)
static int __init init_nls_iso8859_3(void)
static int __init init_nls_iso8859_4(void)
static int __init init_nls_iso8859_5(void)
static int __init init_nls_iso8859_6(void)
static int __init init_nls_iso8859_7(void)
static int __init init_nls_iso8859_9(void)
static int __init init_nls_koi8_r(void)
Definition: nls_koi8-r.c:312
static int __init init_nls_koi8_ru(void)
Definition: nls_koi8-ru.c:63
static int __init init_nls_koi8_u(void)
Definition: nls_koi8-u.c:319
static int __init init_nls_utf8(void)
Definition: nls_utf8.c:46

Referenced by DriverEntry().

◆ Ext2LoadBlock()

BOOLEAN Ext2LoadBlock ( IN PEXT2_VCB  Vcb,
IN ULONG  dwBlk,
IN PVOID  Buffer 
)

Definition at line 659 of file generic.c.

662{
663 struct buffer_head *bh = NULL;
664 BOOLEAN rc = 0;
665
666 _SEH2_TRY {
667
668 bh = sb_getblk(&Vcb->sb, (sector_t)Index);
669
670 if (!bh) {
671 DEBUG(DL_ERR, ("Ext2Loadblock: can't load block %u\n", Index));
672 DbgBreak();
674 }
675
676 if (!buffer_uptodate(bh)) {
677 int err = bh_submit_read(bh);
678 if (err < 0) {
679 DEBUG(DL_ERR, ("Ext2LoadBlock: reading failed %d\n", err));
681 }
682 }
683
685 rc = TRUE;
686
687 } _SEH2_FINALLY {
688
689 if (bh)
690 fini_bh(&bh);
691 } _SEH2_END;
692
693 return rc;
694}
unsigned __int64 sector_t
Definition: types.h:82

◆ Ext2LoadBuffer()

BOOLEAN Ext2LoadBuffer ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN LONGLONG  Offset,
IN ULONG  Size,
IN PVOID  Buf 
)

Definition at line 733 of file generic.c.

738{
739 struct buffer_head *bh = NULL;
740 BOOLEAN rc;
741
742 _SEH2_TRY {
743
744 while (size) {
745
747 ULONG len = 0, delta = 0;
748
750 delta = (ULONG)offset & (BLOCK_SIZE - 1);
751 len = BLOCK_SIZE - delta;
752 if (size < len)
753 len = size;
754
755 bh = sb_getblk(&Vcb->sb, block);
756 if (!bh) {
757 DEBUG(DL_ERR, ("Ext2SaveBuffer: can't load block %I64u\n", block));
758 DbgBreak();
760 }
761
762 if (!buffer_uptodate(bh)) {
763 int err = bh_submit_read(bh);
764 if (err < 0) {
765 DEBUG(DL_ERR, ("Ext2SaveBuffer: bh_submit_read failed: %d\n", err));
767 }
768 }
769
770 _SEH2_TRY {
771 RtlCopyMemory(buf, bh->b_data + delta, len);
772 } _SEH2_FINALLY {
773 fini_bh(&bh);
774 } _SEH2_END;
775
776 buf = (PUCHAR)buf + len;
777 offset = offset + len;
778 size = size - len;
779 }
780
781 rc = TRUE;
782
783 } _SEH2_FINALLY {
784
785 if (bh)
786 fini_bh(&bh);
787
788 } _SEH2_END;
789
790 return rc;
791}
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
static unsigned int block
Definition: xmlmemory.c:101

Referenced by Ext2LoadInode(), and Ext2SaveInode().

◆ Ext2LoadGroup()

BOOLEAN Ext2LoadGroup ( IN PEXT2_VCB  Vcb)

Definition at line 207 of file generic.c.

208{
209 struct super_block *sb = &Vcb->sb;
210 struct ext3_sb_info *sbi = &Vcb->sbi;
211 ext3_fsblk_t sb_block = 1;
212 unsigned long i;
213 BOOLEAN rc = FALSE;
214
215 _SEH2_TRY {
216
217 ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
218
219 if (NULL == sbi->s_gd) {
220 sbi->s_gd = kzalloc(sbi->s_gdb_count * sizeof(struct ext3_gd),
221 GFP_KERNEL);
222 }
223 if (sbi->s_gd == NULL) {
224 DEBUG(DL_ERR, ("Ext2LoadGroup: not enough memory.\n"));
226 }
227
229 sb_block = EXT4_MIN_BLOCK_SIZE / BLOCK_SIZE;
230 }
231
232 for (i = 0; i < sbi->s_gdb_count; i++) {
233 sbi->s_gd[i].block = descriptor_loc(sb, sb_block, i);
234 if (!sbi->s_gd[i].block) {
235 DEBUG(DL_ERR, ("Ext2LoadGroup: can't locate group descriptor %d\n", i));
237 }
238 }
239
240 if (!Ext2LoadGroupBH(Vcb)) {
241 DEBUG(DL_ERR, ("Ext2LoadGroup: Failed to load group descriptions !\n"));
243 }
244
246 DbgBreak();
247 DEBUG(DL_ERR, ("Ext2LoadGroup: group descriptors corrupted !\n"));
249 }
250
251 SetFlag(Vcb->Flags, VCB_GD_LOADED);
252 rc = TRUE;
253
254 } _SEH2_FINALLY {
255
256 if (!rc)
258
259 ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
260 } _SEH2_END;
261
262 return rc;
263}
#define EXT4_MIN_BLOCK_SIZE
Definition: ext3_fs.h:169
#define EXT3_MIN_BLOCK_SIZE
Definition: ext3_fs.h:75
unsigned long long ext3_fsblk_t
Definition: ext3_fs_i.h:26
BOOLEAN Ext2LoadGroupBH(IN PEXT2_VCB Vcb)
Definition: generic.c:170
int ext4_check_descriptors(struct super_block *sb)
Definition: generic.c:3091
VOID Ext2PutGroup(IN PEXT2_VCB Vcb)
Definition: generic.c:150
ext3_fsblk_t descriptor_loc(struct super_block *sb, ext3_fsblk_t logical_sb_block, unsigned int nr)
Definition: generic.c:2736
#define GFP_KERNEL
Definition: module.h:668
void * kzalloc(int size, int flags)
Definition: linux.c:34
unsigned long s_gdb_count
Definition: ext3_fs_sb.h:38

Referenced by Ext2InitializeVcb(), and ext4_get_group_desc().

◆ Ext2LoadGroupBH()

BOOLEAN Ext2LoadGroupBH ( IN PEXT2_VCB  Vcb)

Definition at line 170 of file generic.c.

171{
172 struct super_block *sb = &Vcb->sb;
173 struct ext3_sb_info *sbi = &Vcb->sbi;
174 unsigned long i;
175 BOOLEAN rc = FALSE;
176
177 _SEH2_TRY {
178
179 ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
180 ASSERT (NULL != sbi->s_gd);
181
182 for (i = 0; i < sbi->s_gdb_count; i++) {
183 ASSERT (sbi->s_gd[i].block);
184 if (sbi->s_gd[i].bh)
185 continue;
186 sbi->s_gd[i].bh = sb_getblk(sb, sbi->s_gd[i].block);
187 if (!sbi->s_gd[i].bh) {
188 DEBUG(DL_ERR, ("Ext2LoadGroupBH: can't read group descriptor %d\n", i));
189 DbgBreak();
191 }
192 sbi->s_gd[i].gd = (struct ext4_group_desc *)sbi->s_gd[i].bh->b_data;
193 }
194
195 rc = TRUE;
196
197 } _SEH2_FINALLY {
198
199 ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
200 } _SEH2_END;
201
202 return rc;
203}

Referenced by Ext2LoadGroup(), and ext4_get_group_desc().

◆ Ext2LoadInode()

BOOLEAN Ext2LoadInode ( IN PEXT2_VCB  Vcb,
IN struct inode Inode 
)

Definition at line 508 of file generic.c.

510{
511 struct ext3_inode ext3i = {0};
513
514 if (!Ext2GetInodeLba(Vcb, Inode->i_ino, &offset)) {
515 DEBUG(DL_ERR, ("Ext2LoadInode: failed inode %u.\n", Inode->i_ino));
516 return FALSE;
517 }
518
519 if (!Ext2LoadBuffer(NULL, Vcb, offset, sizeof(ext3i), &ext3i)) {
520 return FALSE;
521 }
522
523 Ext2DecodeInode(Inode, &ext3i);
524
525 return TRUE;
526}
void Ext2DecodeInode(struct inode *dst, struct ext3_inode *src)
Definition: generic.c:452
BOOLEAN Ext2LoadBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:733

Referenced by Ext2InitializeVcb(), Ext2LoadInternalJournal(), Ext2LookupFile(), Ext2ProcessEntry(), and Ext2RefreshSuper().

◆ Ext2LoadInodeXattr()

BOOLEAN Ext2LoadInodeXattr ( IN PEXT2_VCB  Vcb,
IN struct inode Inode,
IN PEXT2_INODE  InodeXattr 
)

Definition at line 590 of file generic.c.

593{
596
597 if (!Ext2GetInodeLba(Vcb, Inode->i_ino, &Offset)) {
598 DEBUG(DL_ERR, ("Ext2LoadRawInode: error get inode(%xh)'s addr.\n", Inode->i_ino));
599 return FALSE;
600 }
601
602 if (!CcCopyRead(
603 Vcb->Volume,
605 Vcb->InodeSize,
606 PIN_WAIT,
607 (PVOID)InodeXattr,
608 &IoStatus)) {
609 return FALSE;
610 }
611
612 if (!NT_SUCCESS(IoStatus.Status)) {
613 return FALSE;
614 }
615
616 Ext2EncodeInode(InodeXattr, Inode);
617 return TRUE;
618}
void Ext2EncodeInode(struct ext3_inode *dst, struct inode *src)
Definition: generic.c:479
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43

Referenced by ext4_fs_get_xattr_ref().

◆ Ext2LoadInternalJournal()

PEXT2_MCB Ext2LoadInternalJournal ( PEXT2_VCB  Vcb,
ULONG  jNo 
)

Definition at line 29 of file recover.c.

33{
34 PEXT2_MCB Jcb = NULL;
35
36 Jcb = Ext2AllocateMcb(Vcb, NULL, NULL, 0);
37 if (!Jcb) {
38 goto errorout;
39 }
40
41 Jcb->Inode.i_ino = jNo;
42 Jcb->Inode.i_sb = &Vcb->sb;
43 if (!Ext2LoadInode(Vcb, &Jcb->Inode)) {
44 DbgBreak();
45 Ext2FreeMcb(Vcb, Jcb);
46 goto errorout;
47 }
48
49errorout:
50
51 return Jcb;
52}
VOID Ext2FreeMcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1538
BOOLEAN Ext2LoadInode(IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:508
PEXT2_MCB Ext2AllocateMcb(IN PEXT2_VCB Vcb, IN PUNICODE_STRING FileName, IN PUNICODE_STRING Parent, IN ULONG FileAttr)
Definition: memory.c:1430
struct inode Inode
Definition: ext2fs.h:945

Referenced by Ext2RecoverJournal().

◆ Ext2LoadSuper()

NTSTATUS Ext2LoadSuper ( IN PEXT2_VCB  Vcb,
IN BOOLEAN  bVerify,
OUT PEXT2_SUPER_BLOCK Sb 
)

Definition at line 29 of file generic.c.

32{
34 PEXT2_SUPER_BLOCK Ext2Sb = NULL;
35
36 Ext2Sb = (PEXT2_SUPER_BLOCK)
41 );
42 if (!Ext2Sb) {
44 goto errorout;
45 }
46
48 Vcb,
51 (PVOID) Ext2Sb,
52 bVerify );
53
54 if (!NT_SUCCESS(Status)) {
56 Ext2Sb = NULL;
57 }
58
59errorout:
60
61 *Sb = Ext2Sb;
62 return Status;
63}
struct ext2_sblock * PEXT2_SUPER_BLOCK
Definition: ext2.h:171
#define SUPER_BLOCK_SIZE
Definition: ext2fs.h:86
NTSTATUS Ext2ReadDisk(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:559
#define SUPER_BLOCK_OFFSET
Definition: ext2fs.h:85
static BOOL bVerify
Definition: verify.c:27

Referenced by Ext2MountVolume(), and Ext2VerifyVolume().

◆ Ext2LockControl()

NTSTATUS Ext2LockControl ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 25 of file lock.c.

26{
30 PIRP Irp = NULL;
31
33 BOOLEAN CompleteContext = TRUE;
35 BOOLEAN bFcbAcquired = FALSE;
36
37 _SEH2_TRY {
38
39 ASSERT(IrpContext != NULL);
40
41 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
42 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
43
44 DeviceObject = IrpContext->DeviceObject;
45
49 }
50
51 FileObject = IrpContext->FileObject;
52
53 Fcb = (PEXT2_FCB) FileObject->FsContext;
54 ASSERT(Fcb != NULL);
55 if (Fcb->Identifier.Type == EXT2VCB) {
58 }
59
61 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
62
63 if (FlagOn(Fcb->Mcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY)) {
66 }
67
69 bFcbAcquired = TRUE;
70
71 Irp = IrpContext->Irp;
72
74
75 Status = FsRtlCheckOplock( &Fcb->Oplock,
76 Irp,
77 IrpContext,
79 NULL );
80
81 if (Status != STATUS_SUCCESS) {
82 CompleteContext = FALSE;
84 }
85
86 //
87 // FsRtlProcessFileLock acquires FileObject->FsContext->Resource while
88 // modifying the file locks and calls IoCompleteRequest when it's done.
89 //
90
92 &Fcb->FileLockAnchor,
93 Irp,
94 NULL );
95#if EXT2_DEBUG
96 if (!NT_SUCCESS(Status)) {
97 DEBUG(DL_ERR, (
98 "Ext2LockControl: %-16.16s %-31s Status: %#x ***\n",
100 "IRP_MJ_LOCK_CONTROL",
101 Status ));
102 }
103#endif
104 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
105
106 } _SEH2_FINALLY {
107
108 if (bFcbAcquired) {
110 }
111
112 if (!IrpContext->ExceptionInProgress) {
113
114 if (!CompleteIrp) {
115 IrpContext->Irp = NULL;
116 }
117
118 if (CompleteContext) {
119 Ext2CompleteIrpContext(IrpContext, Status);
120 }
121 }
122 } _SEH2_END;
123
124 return Status;
125}
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
VOID Ext2OplockComplete(IN PVOID Context, IN PIRP Irp)
Definition: dispatch.c:45
NTSTATUS NTAPI FsRtlProcessFileLock(IN PFILE_LOCK FileLock, IN PIRP Irp, IN PVOID Context OPTIONAL)
Definition: filelock.c:1152

Referenced by Ext2DispatchRequest().

◆ Ext2LockIrp()

VOID Ext2LockIrp ( IN PVOID  Context,
IN PIRP  Irp 
)

Definition at line 94 of file dispatch.c.

98{
100 PEXT2_IRP_CONTEXT IrpContext;
101
102 if (Irp == NULL) {
103 return;
104 }
105
107
108 IrpContext = (PEXT2_IRP_CONTEXT) Context;
109
110 if ( IrpContext->MajorFunction == IRP_MJ_READ ||
111 IrpContext->MajorFunction == IRP_MJ_WRITE ) {
112
113 //
114 // lock the user's buffer to MDL, if the I/O is bufferred
115 //
116
117 if (!IsFlagOn(IrpContext->MinorFunction, IRP_MN_MDL)) {
118
119 Ext2LockUserBuffer( Irp, IrpSp->Parameters.Write.Length,
120 (IrpContext->MajorFunction == IRP_MJ_READ) ?
122 }
123
124 } else if (IrpContext->MajorFunction == IRP_MJ_DIRECTORY_CONTROL
125 && IrpContext->MinorFunction == IRP_MN_QUERY_DIRECTORY) {
126
127 ULONG Length = ((PEXTENDED_IO_STACK_LOCATION) IrpSp)->Parameters.QueryDirectory.Length;
129
130 } else if (IrpContext->MajorFunction == IRP_MJ_QUERY_EA) {
131
132 ULONG Length = ((PEXTENDED_IO_STACK_LOCATION) IrpSp)->Parameters.QueryEa.Length;
134
135 } else if (IrpContext->MajorFunction == IRP_MJ_SET_EA) {
136 ULONG Length = ((PEXTENDED_IO_STACK_LOCATION) IrpSp)->Parameters.SetEa.Length;
138
139 } else if ( (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL) &&
140 (IrpContext->MinorFunction == IRP_MN_USER_FS_REQUEST) ) {
142 if ( (EIrpSp->Parameters.FileSystemControl.FsControlCode == FSCTL_GET_VOLUME_BITMAP) ||
143 (EIrpSp->Parameters.FileSystemControl.FsControlCode == FSCTL_GET_RETRIEVAL_POINTERS) ||
144 (EIrpSp->Parameters.FileSystemControl.FsControlCode == FSCTL_GET_RETRIEVAL_POINTER_BASE) ) {
145 ULONG Length = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
147 }
148 }
149
150 // Mark the request as pending status
151
153
154 return;
155}
NTSTATUS Ext2LockUserBuffer(IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
Definition: block.c:113
#define FSCTL_GET_RETRIEVAL_POINTER_BASE
Definition: ext2fs.h:1132
#define FSCTL_GET_RETRIEVAL_POINTERS
Definition: winioctl.h:95
#define FSCTL_GET_VOLUME_BITMAP
Definition: winioctl.h:94
#define IRP_MN_MDL
Definition: iotypes.h:4419
@ IoReadAccess
Definition: ketypes.h:863
@ IoWriteAccess
Definition: ketypes.h:864

Referenced by Ext2CreateFile(), Ext2QueueRequest(), Ext2ReadFile(), and Ext2WriteFile().

◆ Ext2LockUserBuffer()

NTSTATUS Ext2LockUserBuffer ( IN PIRP  Irp,
IN ULONG  Length,
IN LOCK_OPERATION  Operation 
)

Definition at line 113 of file block.c.

116{
118 ASSERT(Irp != NULL);
119
120 if (Irp->MdlAddress != NULL) {
121 return STATUS_SUCCESS;
122 }
123
124 IoAllocateMdl(Irp->UserBuffer, Length, FALSE, FALSE, Irp);
125 if (Irp->MdlAddress == NULL) {
127 }
128
129 _SEH2_TRY {
130
131 MmProbeAndLockPages(Irp->MdlAddress, Irp->RequestorMode, Operation);
133
135
136 DbgBreak();
137 IoFreeMdl(Irp->MdlAddress);
138 Irp->MdlAddress = NULL;
140 } _SEH2_END;
141
142 return Status;
143}
FP_OP Operation
Definition: fpcontrol.c:150

Referenced by Ext2LockIrp(), Ext2QueryDirectory(), Ext2ReadFile(), Ext2ReadVolume(), Ext2WriteFile(), and Ext2WriteVolume().

◆ Ext2LockVcb()

NTSTATUS Ext2LockVcb ( IN PEXT2_VCB  Vcb,
IN PFILE_OBJECT  FileObject 
)

Definition at line 94 of file fsctl.c.

96{
98
99 _SEH2_TRY {
100
101 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
102 DEBUG(DL_INF, ( "Ext2LockVolume: Volume is already locked.\n"));
105 }
106
107 if (Vcb->OpenHandleCount > (ULONG)(FileObject ? 1 : 0)) {
108 DEBUG(DL_INF, ( "Ext2LockVcb: There are still opened files.\n"));
109
112 }
113
115 DEBUG(DL_INF, ( "Ext2LockVcb: Thare are still opened files.\n"));
116
119 }
120
123 Vcb->LockFile = FileObject;
124
125 DEBUG(DL_INF, ( "Ext2LockVcb: Volume locked.\n"));
126
127 } _SEH2_FINALLY {
128 // Nothing
129 } _SEH2_END;
130
131 return Status;
132}
BOOLEAN Ext2IsHandleCountZero(IN PEXT2_VCB Vcb)
Definition: fsctl.c:68
VOID Ext2SetVpbFlag(IN PVPB Vpb, IN USHORT Flag)
Definition: fsctl.c:44

Referenced by Ext2LockVolume().

◆ Ext2LockVolume()

NTSTATUS Ext2LockVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 136 of file fsctl.c.

137{
142 BOOLEAN VcbResourceAcquired = FALSE;
143
144 _SEH2_TRY {
145
146 ASSERT(IrpContext != NULL);
147
148 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
149 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
150
151 DeviceObject = IrpContext->DeviceObject;
152
154
155 //
156 // This request is not allowed on the main device object
157 //
161 }
162
163 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
164
165 ASSERT(Vcb != NULL);
166
167 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
168 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
169
171
172 IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
173
174#if (_WIN32_WINNT >= 0x0500)
176#endif
178 &Vcb->MainResource,
179 TRUE );
180
181 VcbResourceAcquired = TRUE;
182
183 /* flush dirty data before locking the volume */
184 if (!IsVcbReadOnly(Vcb)) {
185 Ext2FlushFiles(IrpContext, Vcb, FALSE);
186 Ext2FlushVolume(IrpContext, Vcb, FALSE);
187 }
188
190
191 } _SEH2_FINALLY {
192
193 if (VcbResourceAcquired) {
194 ExReleaseResourceLite(&Vcb->MainResource);
195 }
196
197 if (!IrpContext->ExceptionInProgress) {
198 Ext2CompleteIrpContext(IrpContext, Status);
199 }
200 } _SEH2_END;
201
202 return Status;
203}
NTSTATUS Ext2LockVcb(IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject)
Definition: fsctl.c:94
NTSTATUS NTAPI CcWaitForCurrentLazyWriterActivity(VOID)
Definition: lazyrite.c:30

Referenced by Ext2Format(), and Ext2UserFsRequest().

◆ Ext2Log2()

ULONG Ext2Log2 ( ULONG  Value)

Definition at line 25 of file misc.c.

26{
27 ULONG Order = 0;
28
29 ASSERT(Value > 0);
30
31 while (Value) {
32 Order++;
33 Value >>= 1;
34 }
35
36 return (Order - 1);
37}
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by Ext2InitializeVcb().

◆ Ext2LookupBlockExtent()

BOOLEAN Ext2LookupBlockExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Start,
IN PULONG  Block,
IN PULONG  Mapped 
)

Definition at line 1061 of file memory.c.

1068{
1069 LONGLONG Vbn = 0;
1070 LONGLONG Lbn = 0;
1071 LONGLONG Length = 0;
1072
1073 BOOLEAN rc = FALSE;
1074
1075 Vbn = ((LONGLONG) Start) << BLOCK_BITS;
1076
1077 if (Mcb) {
1079 } else {
1081 }
1082
1083 if (rc) {
1084 *Mapped = (ULONG)(Length >> BLOCK_BITS);
1085 if (Lbn != -1 && Length > 0) {
1086 *Block = (ULONG)(Lbn >> BLOCK_BITS);
1087 } else {
1088 *Block = 0;
1089 }
1090 }
1091
1092 return rc;
1093}
BOOLEAN Ext2LookupMcbExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
Definition: memory.c:897
BOOLEAN Ext2LookupVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG Length)
Definition: memory.c:747

Referenced by Ext2AddBlockExtent(), and Ext2BuildExtents().

◆ Ext2LookupFile()

NTSTATUS Ext2LookupFile ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PUNICODE_STRING  FullName,
IN PEXT2_MCB  Parent,
OUT PEXT2_MCB Ext2Mcb,
IN ULONG  Linkdep 
)

Definition at line 273 of file create.c.

281{
285 struct dentry *de = NULL;
286
287 USHORT i = 0, End;
288 ULONG Inode;
289
290 BOOLEAN bParent = FALSE;
291 BOOLEAN bDirectory = FALSE;
292 BOOLEAN LockAcquired = FALSE;
293 BOOLEAN bNotFollow = FALSE;
294
295 _SEH2_TRY {
296
298 LockAcquired = TRUE;
299
300 bNotFollow = IsFlagOn(Linkdep, EXT2_LOOKUP_NOT_FOLLOW);
301#ifndef __REACTOS__
302 Linkdep = ClearFlag(Linkdep, EXT2_LOOKUP_FLAG_MASK);
303#else
305#endif
306
307 *Ext2Mcb = NULL;
308
309 DEBUG(DL_RES, ("Ext2LookupFile: %wZ\n", FullName));
310
311 /* check names and parameters */
312 if (FullName->Buffer[0] == L'\\') {
313 Parent = Vcb->McbTree;
314 } else if (Parent) {
315 bParent = TRUE;
316 } else {
317 Parent = Vcb->McbTree;
318 }
319
320 /* make sure the parent is NULL */
321 if (!IsMcbDirectory(Parent)) {
324 }
325
326 /* use symlink's target as parent directory */
327 if (IsMcbSymLink(Parent)) {
328 Parent = Parent->Target;
330 if (IsFileDeleted(Parent)) {
333 }
334 }
335
336 if (NULL == Parent) {
339 }
340
341 /* default is the parent Mcb*/
343 Mcb = Parent;
344
345 /* is empty file name or root node */
346 End = FullName->Length/sizeof(WCHAR);
347 if ( (End == 0) || (End == 1 &&
348 FullName->Buffer[0] == L'\\')) {
351 }
352
353 /* is a directory expected ? */
354 while (FullName->Buffer[End - 1] == L'\\') {
355 bDirectory = TRUE;
356 End -= 1;
357 }
358
359 /* loop with every sub name */
360 while (i < End) {
361
362 USHORT Start = 0;
363
364 /* zero the prefix '\' */
365 while (i < End && FullName->Buffer[i] == L'\\') i++;
366 Start = i;
367
368 /* zero the suffix '\' */
369 while (i < End && (FullName->Buffer[i] != L'\\')) i++;
370
371 if (i > Start) {
372
374 FileName.Buffer += Start;
375 FileName.Length = (USHORT)((i - Start) * 2);
376
377 /* make sure the parent is NULL */
378 if (!IsMcbDirectory(Parent)) {
381 break;
382 }
383
384 if (IsMcbSymLink(Parent)) {
385 if (IsFileDeleted(Parent->Target)) {
388 break;
389 } else {
390 Ext2ReferMcb(Parent->Target);
392 Parent = Parent->Target;
393 }
394 }
395
396 /* search cached Mcb nodes */
398
399 if (Mcb) {
400
401 /* derefer the parent Mcb */
404 Parent = Mcb;
405
406 if (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target) &&
407 Mcb->Refercount == 1) {
408
409 ASSERT(Mcb->Target);
410 ASSERT(Mcb->Target->Refercount > 0);
411 Ext2DerefMcb(Mcb->Target);
412 Mcb->Target = NULL;
415 Mcb->FileAttr = FILE_ATTRIBUTE_NORMAL;
416 }
417
418 } else {
419
420 /* need create new Mcb node */
421
422 /* is a valid ext2 name */
423 if (!Ext2IsNameValid(&FileName)) {
426 break;
427 }
428
429 /* seach the disk */
430 de = NULL;
432 IrpContext,
433 Vcb,
434 Parent,
435 &FileName,
436 &Inode,
437 &de);
438
439 if (NT_SUCCESS(Status)) {
440
441 /* check it's real parent */
443
444 /* allocate Mcb ... */
445 Mcb = Ext2AllocateMcb(Vcb, &FileName, &Parent->FullName, 0);
446 if (!Mcb) {
449 break;
450 }
451 Mcb->de = de;
452 Mcb->de->d_inode = &Mcb->Inode;
453 Mcb->Inode.i_ino = Inode;
454 Mcb->Inode.i_sb = &Vcb->sb;
455 de = NULL;
456
457 /* load inode information */
458 if (!Ext2LoadInode(Vcb, &Mcb->Inode)) {
462 break;
463 }
464
465 /* set inode attribute */
468 }
469
470 if (S_ISDIR(Mcb->Inode.i_mode)) {
472 } else {
473 if (S_ISREG(Mcb->Inode.i_mode)) {
475 } else if (S_ISLNK(Mcb->Inode.i_mode)) {
477 } else {
479 }
480 }
481
482 /* process special files under root directory */
483 if (IsMcbRoot(Parent)) {
484 /* set hidden and system attributes for
485 Recycled / RECYCLER / pagefile.sys */
487 if (Ext2IsSpecialSystemFile(&Mcb->ShortName, IsDirectory)) {
490 }
491 }
492
493 Mcb->CreationTime = Ext2NtTime(Mcb->Inode.i_ctime);
494 Mcb->LastAccessTime = Ext2NtTime(Mcb->Inode.i_atime);
495 Mcb->LastWriteTime = Ext2NtTime(Mcb->Inode.i_mtime);
496 Mcb->ChangeTime = Ext2NtTime(Mcb->Inode.i_mtime);
497
498 /* process symlink */
499 if (S_ISLNK(Mcb->Inode.i_mode) && !bNotFollow) {
500 Ext2FollowLink( IrpContext,
501 Vcb,
502 Parent,
503 Mcb,
504 Linkdep+1
505 );
506 }
507
508 /* add reference ... */
510
511 /* add Mcb to it's parent tree*/
513
514 /* it's safe to deref Parent Mcb */
516
517 /* linking this Mcb*/
519
520 /* set parent to preare re-scan */
521 Parent = Mcb;
522
523 } else {
524
525 /* derefernce it's parent */
527 break;
528 }
529 }
530
531 } else {
532
533 /* there seems too many \ or / */
534 /* Mcb should be already set to Parent */
535 ASSERT(Mcb == Parent);
537 break;
538 }
539 }
540
541 } _SEH2_FINALLY {
542
543 if (de) {
544 Ext2FreeEntry(de);
545 }
546
547 if (NT_SUCCESS(Status)) {
548 if (bDirectory) {
549 if (IsMcbDirectory(Mcb)) {
550 *Ext2Mcb = Mcb;
551 } else {
554 }
555 } else {
556 *Ext2Mcb = Mcb;
557 }
558 }
559
560 if (LockAcquired) {
561 ExReleaseResourceLite(&Vcb->McbLock);
562 }
563 } _SEH2_END;
564
565 return Status;
566}
#define S_ISDIR(mode)
Definition: various.h:18
#define S_ISREG(mode)
Definition: various.h:17
BOOLEAN Ext2IsSpecialSystemFile(IN PUNICODE_STRING FileName, IN BOOLEAN bDirectory)
Definition: create.c:224
NTSTATUS Ext2ScanDir(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Parent, IN PUNICODE_STRING FileName, OUT PULONG Inode, OUT struct dentry **dentry)
Definition: create.c:570
BOOLEAN Ext2IsNameValid(PUNICODE_STRING FileName)
Definition: create.c:36
NTSTATUS Ext2FollowLink(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Parent, IN PEXT2_MCB Mcb, IN ULONG Linkdep)
Definition: create.c:67
#define EXT2_LOOKUP_NOT_FOLLOW
Definition: ext2fs.h:1380
#define EXT2_LOOKUP_FLAG_MASK
Definition: ext2fs.h:1379
PEXT2_MCB Ext2SearchMcbWithoutLock(PEXT2_MCB Parent, PUNICODE_STRING FileName)
Definition: memory.c:1622
VOID Ext2LinkTailMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: memory.c:2912
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
VOID Ext2InsertMcb(PEXT2_VCB Vcb, PEXT2_MCB Parent, PEXT2_MCB Child)
Definition: memory.c:1686
int Ext2CheckFileAccess(PEXT2_VCB Vcb, PEXT2_MCB Mcb, int attempt)
Definition: access.c:51
struct _FileName FileName
Definition: fatprocs.h:896
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
_In_ PSTRING FullName
Definition: rtlfuncs.h:1648

Referenced by Ext2CreateFile(), and Ext2FollowLink().

◆ Ext2LookupMcbExtent()

BOOLEAN Ext2LookupMcbExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN LONGLONG  Vbn,
OUT PLONGLONG  Lbn,
OUT PLONGLONG  Length 
)

Definition at line 897 of file memory.c.

904{
906 BOOLEAN rc;
907
908 offset = Vbn & (~((LONGLONG)BLOCK_SIZE - 1));
909 ASSERT ((offset & (BLOCK_SIZE - 1)) == 0);
910 offset = (offset >> BLOCK_BITS) + 1;
911
913 &(Mcb->Extents),
914 offset,
915 Lbn,
916 Length,
917 NULL,
918 NULL,
919 NULL
920 );
921
922 if (rc) {
923
924 if (Lbn && ((*Lbn) != -1)) {
925 ASSERT((*Lbn) > 0);
926 (*Lbn) = (((*Lbn) - 1) << BLOCK_BITS);
927 (*Lbn) += ((Vbn) & ((LONGLONG)BLOCK_SIZE - 1));
928 }
929
930 if (Length && *Length) {
931 (*Length) <<= BLOCK_BITS;
932 (*Length) -= ((Vbn) & ((LONGLONG)BLOCK_SIZE - 1));
933 }
934 }
935
936 return rc;
937}

Referenced by Ext2LookupBlockExtent().

◆ Ext2LookupVcbExtent()

BOOLEAN Ext2LookupVcbExtent ( IN PEXT2_VCB  Vcb,
IN LONGLONG  Vbn,
OUT PLONGLONG  Lbn,
OUT PLONGLONG  Length 
)

Definition at line 747 of file memory.c.

753{
755 BOOLEAN rc;
756
757 offset = Vbn & (~(Vcb->IoUnitSize - 1));
758 ASSERT ((offset & (Vcb->IoUnitSize - 1)) == 0);
759 offset = (offset >> Vcb->IoUnitBits) + 1;
760
762 &(Vcb->Extents),
763 offset,
764 Lbn,
765 Length,
766 NULL,
767 NULL,
768 NULL
769 );
770
771 if (rc) {
772
773 if (Lbn && ((*Lbn) != -1)) {
774 ASSERT((*Lbn) > 0);
775 (*Lbn) = (((*Lbn) - 1) << Vcb->IoUnitBits);
776 (*Lbn) += ((Vbn) & (Vcb->IoUnitSize - 1));
777 }
778
779 if (Length && *Length) {
780 (*Length) <<= Vcb->IoUnitBits;
781 (*Length) -= ((Vbn) & (Vcb->IoUnitSize - 1));
782 }
783 }
784
785 return rc;
786}

Referenced by Ext2LookupBlockExtent(), and Ext2WriteVolume().

◆ Ext2MapExtent()

NTSTATUS Ext2MapExtent ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Index,
IN BOOLEAN  Alloc,
OUT PULONG  Block,
OUT PULONG  Number 
)

Definition at line 25 of file extents.c.

34{
35 EXT4_EXTENT_HEADER *eh;
36 struct buffer_head bh_got = {0};
37 int flags, rc;
38 ULONG max_blocks = 0;
39
40 memset(&bh_got, 0, sizeof(struct buffer_head));
41 eh = get_ext4_header(&Mcb->Inode);
42
43 if (eh->eh_magic != EXT4_EXT_MAGIC) {
44 if (Alloc) {
45 /* now initialize inode extent root node */
46 ext4_ext_tree_init(IrpContext, NULL, &Mcb->Inode);
47 } else {
48 /* return empty-mapping when inode extent isn't initialized */
49 if (Block)
50 *Block = 0;
51 if (Number) {
52 LONGLONG _len = _len = Mcb->Inode.i_size;
53 if (Mcb->Fcb)
54 _len = Mcb->Fcb->Header.AllocationSize.QuadPart;
55 *Number = (ULONG)((_len + BLOCK_SIZE - 1) >> BLOCK_BITS);
56 }
57 return STATUS_SUCCESS;
58 }
59 }
60
61 /* IrpContext is NULL when called during journal initialization */
62 if (IsMcbDirectory(Mcb) || IrpContext == NULL ||
63 IrpContext->MajorFunction == IRP_MJ_WRITE || !Alloc){
65 max_blocks = EXT_INIT_MAX_LEN;
66 } else {
68 max_blocks = EXT_UNWRITTEN_MAX_LEN;
69 }
70
71 if (Alloc) {
72 if (Number && !*Number) {
73 if (max_blocks > *Number) {
74 max_blocks = *Number;
75 }
76 } else {
77 max_blocks = 1;
78 }
79 }
80
81 if ((rc = ext4_ext_get_blocks(
82 IrpContext,
83 NULL,
84 &Mcb->Inode,
85 Index,
86 max_blocks,
87 &bh_got,
88 Alloc,
89 flags)) < 0) {
90 DEBUG(DL_ERR, ("Block insufficient resources, err: %d\n", rc));
91 return Ext2WinntError(rc);
92 }
93 if (Alloc)
94 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
95 if (Number)
96 *Number = rc ? rc : 1;
97 if (Block)
98 *Block = (ULONG)bh_got.b_blocknr;
99
100 return STATUS_SUCCESS;
101}
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: main.c:63
#define EXT4_GET_BLOCKS_IO_CREATE_EXT
Definition: ext4.h:33
#define EXT4_GET_BLOCKS_IO_CONVERT_EXT
Definition: ext4.h:36
int ext4_ext_tree_init(void *icb, handle_t *handle, struct inode *inode)
#define get_ext4_header(i)
Definition: ext4_ext.h:51
#define EXT_UNWRITTEN_MAX_LEN
Definition: ext4_ext.h:102
#define EXT4_EXT_MAGIC
Definition: ext4_ext.h:50
#define EXT_INIT_MAX_LEN
Definition: ext4_ext.h:101
int ext4_ext_get_blocks(void *icb, handle_t *handle, struct inode *inode, ext4_fsblk_t iblock, unsigned long max_blocks, struct buffer_head *bh_result, int create, int flags)
GLbitfield flags
Definition: glext.h:7161

Referenced by Ext2BlockMap(), Ext2InitializeZone(), and ext3_bread().

◆ Ext2MapIndirect()

NTSTATUS Ext2MapIndirect ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Index,
IN BOOLEAN  bAlloc,
OUT PULONG  pBlock,
OUT PULONG  Number 
)

Definition at line 835 of file indirect.c.

844{
845 ULONG Layer;
846 ULONG Slot;
847
848 ULONG Base = Index;
849
851
852 *pBlock = 0;
853 *Number = 0;
854
855 for (Layer = 0; Layer < EXT2_BLOCK_TYPES; Layer++) {
856
857 if (Index < Vcb->max_blocks_per_layer[Layer]) {
858
859 ULONG dwRet = 0, dwBlk = 0, dwHint = 0, dwArray = 0;
860
861 Slot = (Layer==0) ? (Index):(Layer + EXT2_NDIR_BLOCKS - 1);
862 dwBlk = Mcb->Inode.i_block[Slot];
863
864 if (dwBlk == 0) {
865
866 if (!bAlloc) {
867
868 *Number = 1;
869 goto errorout;
870
871 } else {
872
873 if (Slot) {
874 dwHint = Mcb->Inode.i_block[Slot - 1];
875 }
876
877 /* allocate and zero block if necessary */
878 *Number = 1;
880 IrpContext,
881 Vcb,
882 Mcb,
883 Base,
884 Layer,
885 NULL,
886 &dwHint,
887 &dwBlk,
888 Number
889 );
890
891 if (!NT_SUCCESS(Status)) {
892 goto errorout;
893 }
894
895 /* save the it into inode*/
896 Mcb->Inode.i_block[Slot] = dwBlk;
897
898 /* save the inode */
899 if (!Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode)) {
900 DbgBreak();
902 goto errorout;
903 }
904 }
905 }
906
907 if (Layer == 0)
908 dwArray = Vcb->max_blocks_per_layer[Layer] - Index;
909 else
910 dwArray = 1;
911
912 /* querying block number of the index-th file block */
914 IrpContext,
915 Vcb,
916 Mcb,
917 Base,
918 Layer,
919 Index,
920 dwArray,
921#ifdef __REACTOS__
922 (PULONG)&Mcb->Inode.i_block[Slot],
923#else
924 &Mcb->Inode.i_block[Slot],
925#endif
926 bAlloc,
927 &dwHint,
928 &dwRet,
929 Number
930 );
931
932 if (NT_SUCCESS(Status)) {
933 *pBlock = dwRet;
934 }
935
936 break;
937 }
938
939 Index -= Vcb->max_blocks_per_layer[Layer];
940 }
941
942errorout:
943
944 return Status;
945}

Referenced by Ext2BlockMap(), Ext2InitializeZone(), and ext3_bread().

◆ Ext2McbReaperThread()

VOID Ext2McbReaperThread ( PVOID  Context)

Definition at line 3055 of file memory.c.

3058{
3059 PEXT2_REAPER Reaper = Context;
3062
3063 PEXT2_VCB Vcb = NULL;
3064 PEXT2_MCB Mcb = NULL;
3065
3066 ULONG i, NumOfMcbs;
3067
3068 BOOLEAN GlobalAcquired = FALSE;
3069
3070 BOOLEAN DidNothing = TRUE;
3072 BOOLEAN WaitLock;
3073
3074 _SEH2_TRY {
3075
3076 Reaper->Thread = PsGetCurrentThread();
3077
3078 /* wake up DirverEntry */
3079 KeSetEvent(&Reaper->Engine, 0, FALSE);
3080
3081 /* now process looping */
3082 while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3083
3084 WaitLock = FALSE;
3085
3086 /* calculate how long we need wait */
3087 if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 128)) {
3088 Timeout.QuadPart = (LONGLONG)-1000*1000; /* 0.1 second */
3089 NumOfMcbs = Ext2Global->MaxDepth * 4;
3090 WaitLock = TRUE;
3091 } else if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 32)) {
3092 Timeout.QuadPart = (LONGLONG)-1000*1000*5; /* 0.5 second */
3093 NumOfMcbs = Ext2Global->MaxDepth * 2;
3094 WaitLock = TRUE;
3095 } else if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 8)) {
3096 Timeout.QuadPart = (LONGLONG)-1000*1000*10; /* 1 second */
3097 NumOfMcbs = Ext2Global->MaxDepth;
3098 } else if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 2)) {
3099 Timeout.QuadPart = (LONGLONG)-2*1000*1000*10; /* 2 second */
3100 NumOfMcbs = Ext2Global->MaxDepth / 4;
3101 } else if (Ext2Global->PerfStat.Current.Mcb > (ULONG)Ext2Global->MaxDepth) {
3102 Timeout.QuadPart = (LONGLONG)-4*1000*1000*10; /* 4 seconds */
3103 NumOfMcbs = Ext2Global->MaxDepth / 8;
3104 } else if (DidNothing) {
3105 Timeout.QuadPart = (LONGLONG)-8*1000*1000*10; /* 8 seconds */
3106 if (LastState) {
3107 Timeout.QuadPart *= 2;
3108 }
3109 NumOfMcbs = Ext2Global->MaxDepth / 16;
3110 } else {
3111 Timeout.QuadPart = (LONGLONG)-5*1000*1000*10; /* 5 seconds */
3112 if (LastState) {
3113 Timeout.QuadPart *= 2;
3114 }
3115 NumOfMcbs = Ext2Global->MaxDepth / 32;
3116 }
3117
3118 if (NumOfMcbs == 0)
3119 NumOfMcbs = 1;
3120
3121 LastState = DidNothing;
3122
3123 /* wait until it is waken or it times out */
3125 &Reaper->Wait,
3126 Executive,
3127 KernelMode,
3128 FALSE,
3129 &Timeout
3130 );
3131
3132 if (IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP))
3133 break;
3134
3135 DidNothing = TRUE;
3136
3137 /* acquire global exclusive lock */
3139 continue;
3140 }
3141 GlobalAcquired = TRUE;
3142
3143 /* search all Vcb to get unused resources freed to system */
3144 for (List = Ext2Global->VcbList.Flink;
3145 List != &(Ext2Global->VcbList);
3146 List = List->Flink ) {
3147
3149
3150 Mcb = Ext2FirstUnusedMcb(Vcb, WaitLock, NumOfMcbs);
3151 while (Mcb) {
3152 PEXT2_MCB Next = Mcb->Next;
3153 DEBUG(DL_RES, ( "Ext2ReaperThread: releasing Mcb (%p): %wZ"
3154 " Total: %xh\n", Mcb, &Mcb->FullName,
3157 Mcb = Next;
3158 LastState = DidNothing = FALSE;
3159 }
3160 }
3161 if (DidNothing) {
3162 KeClearEvent(&Reaper->Wait);
3163 }
3164 if (GlobalAcquired) {
3166 GlobalAcquired = FALSE;
3167 }
3168 }
3169
3170 } _SEH2_FINALLY {
3171
3172 if (GlobalAcquired) {
3174 }
3175
3176 KeSetEvent(&Reaper->Engine, 0, FALSE);
3177 } _SEH2_END;
3178
3180}
BOOLEAN LastState
Definition: hwsynkp.c:39

Referenced by DriverEntry().

◆ Ext2MediaEjectControl()

VOID Ext2MediaEjectControl ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN BOOLEAN  bPrevent 
)

Definition at line 685 of file block.c.

690{
691 PIRP Irp;
694 PREVENT_MEDIA_REMOVAL Prevent;
696
697
699 &Vcb->MainResource,
700 TRUE );
701
702 if (bPrevent != IsFlagOn(Vcb->Flags, VCB_REMOVAL_PREVENTED)) {
703 if (bPrevent) {
705 } else {
707 }
708 }
709
710 ExReleaseResourceLite(&Vcb->MainResource);
711
712 Prevent.PreventMediaRemoval = bPrevent;
713
715
717 Vcb->TargetDeviceObject,
718 &Prevent,
719 sizeof(PREVENT_MEDIA_REMOVAL),
720 NULL,
721 0,
722 FALSE,
723 NULL,
724 &IoStatus );
725
726 if (Irp != NULL) {
729 &Event,
730 TRUE,
731 TRUE,
732 TRUE );
733
734 Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
735
736 if (Status == STATUS_PENDING) {
738 Executive,
740 FALSE,
741 NULL );
742 }
743 }
744}
NTSTATUS Ext2MediaEjectControlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
Definition: block.c:669
#define IOCTL_DISK_MEDIA_REMOVAL
Definition: cdrw_usr.h:176
#define VCB_REMOVAL_PREVENTED
Definition: ext2fs.h:807
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:343

◆ Ext2MountVolume()

NTSTATUS Ext2MountVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2050 of file fsctl.c.

2051{
2053 BOOLEAN GlobalDataResourceAcquired = FALSE;
2054 PIRP Irp;
2055 PIO_STACK_LOCATION IoStackLocation;
2058 PDEVICE_OBJECT VolumeDeviceObject = NULL;
2059 PEXT2_VCB Vcb = NULL, OldVcb = NULL;
2060 PVPB OldVpb = NULL, Vpb = NULL;
2061 PEXT2_SUPER_BLOCK Ext2Sb = NULL;
2062 ULONG dwBytes;
2063 DISK_GEOMETRY DiskGeometry;
2064
2065 _SEH2_TRY {
2066
2067 ASSERT(IrpContext != NULL);
2068 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2069 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2070
2071 MainDeviceObject = IrpContext->DeviceObject;
2072
2073 //
2074 // Make sure we can wait.
2075 //
2076
2077 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
2078
2079 //
2080 // This request is only allowed on the main device object
2081 //
2085 }
2086
2090 }
2091
2092#if 0
2093 if (IrpContext->RealDevice->Size >= sizeof(ULONG) + sizeof(DEVICE_OBJECT) &&
2094 *((PULONG)IrpContext->RealDevice->DeviceExtension) == 'DSSA') {
2095 } else {
2098 }
2099#endif
2100
2101 Irp = IrpContext->Irp;
2102 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
2104 IoStackLocation->Parameters.MountVolume.DeviceObject;
2105
2106 dwBytes = sizeof(DISK_GEOMETRY);
2110 NULL,
2111 0,
2112 &DiskGeometry,
2113 &dwBytes );
2114
2115 if (!NT_SUCCESS(Status)) {
2117 }
2118
2120 MainDeviceObject->DriverObject,
2121 sizeof(EXT2_VCB),
2122 NULL,
2124 0,
2125 FALSE,
2126 &VolumeDeviceObject );
2127
2128 if (!NT_SUCCESS(Status)) {
2130 }
2131 INC_MEM_COUNT(PS_VCB, VolumeDeviceObject, sizeof(EXT2_VCB));
2132
2133#ifdef _PNP_POWER_
2134 /* don't care about power management requests */
2135 VolumeDeviceObject->DeviceObjectExtension->PowerControlNeeded = FALSE;
2136#endif
2137
2138 VolumeDeviceObject->StackSize = (CCHAR)(TargetDeviceObject->StackSize + 1);
2139 ClearFlag(VolumeDeviceObject->Flags, DO_DEVICE_INITIALIZING);
2140
2141/*
2142 These are for buffer-address alignment requirements.
2143 Never do this check, unless you want fail user requests :)
2144
2145 if (TargetDeviceObject->AlignmentRequirement >
2146 VolumeDeviceObject->AlignmentRequirement) {
2147
2148 VolumeDeviceObject->AlignmentRequirement =
2149 TargetDeviceObject->AlignmentRequirement;
2150 }
2151
2152 if (DiskGeometry.BytesPerSector - 1 >
2153 VolumeDeviceObject->AlignmentRequirement) {
2154 VolumeDeviceObject->AlignmentRequirement =
2155 DiskGeometry.BytesPerSector - 1;
2156 TargetDeviceObject->AlignmentRequirement =
2157 DiskGeometry.BytesPerSector - 1;
2158 }
2159*/
2160 (IoStackLocation->Parameters.MountVolume.Vpb)->DeviceObject =
2161 VolumeDeviceObject;
2162 Vpb = IoStackLocation->Parameters.MountVolume.Vpb;
2163
2164 Vcb = (PEXT2_VCB) VolumeDeviceObject->DeviceExtension;
2165
2166 RtlZeroMemory(Vcb, sizeof(EXT2_VCB));
2167 Vcb->Identifier.Type = EXT2VCB;
2168 Vcb->Identifier.Size = sizeof(EXT2_VCB);
2169 Vcb->TargetDeviceObject = TargetDeviceObject;
2170 Vcb->DiskGeometry = DiskGeometry;
2171 InitializeListHead(&Vcb->Next);
2172
2173 Status = Ext2LoadSuper(Vcb, FALSE, &Ext2Sb);
2174 if (!NT_SUCCESS(Status)) {
2175 Vcb = NULL;
2178 }
2179 ASSERT (NULL != Ext2Sb);
2180
2181 /* check Linux Ext2/Ext3 volume magic */
2182 if (Ext2Sb->s_magic == EXT2_SUPER_MAGIC) {
2183 DEBUG(DL_INF, ( "Volume of ext2 file system is found.\n"));
2184 } else {
2186 Vcb = NULL;
2188 }
2189
2190 DEBUG(DL_DBG, ("Ext2MountVolume: DevObject=%p Vcb=%p\n", VolumeDeviceObject, Vcb));
2191
2192 /* initialize Vcb structure */
2193 Status = Ext2InitializeVcb( IrpContext, Vcb, Ext2Sb,
2195 VolumeDeviceObject, Vpb);
2196
2197 if (NT_SUCCESS(Status)) {
2198
2200
2202 GlobalDataResourceAcquired = TRUE;
2203
2204 for (List = Ext2Global->VcbList.Flink;
2205 List != &Ext2Global->VcbList;
2206 List = List->Flink) {
2207
2208 OldVcb = CONTAINING_RECORD(List, EXT2_VCB, Next);
2209 OldVpb = OldVcb->Vpb;
2210
2211 /* in case we are already in the queue, should not happen */
2212 if (OldVpb == Vpb) {
2213 continue;
2214 }
2215
2216 if ( (OldVpb->SerialNumber == Vpb->SerialNumber) &&
2217 (!IsMounted(OldVcb)) && (IsFlagOn(OldVcb->Flags, VCB_NEW_VPB)) &&
2218 (OldVpb->RealDevice == TargetDeviceObject) &&
2219 (OldVpb->VolumeLabelLength == Vpb->VolumeLabelLength) &&
2220 (RtlEqualMemory(&OldVpb->VolumeLabel[0],
2221 &Vpb->VolumeLabel[0],
2222 Vpb->VolumeLabelLength)) &&
2223 (RtlEqualMemory(&OldVcb->SuperBlock->s_uuid[0],
2224 &Vcb->SuperBlock->s_uuid[0], 16)) ) {
2225 ClearFlag(OldVcb->Flags, VCB_MOUNTED);
2226 }
2227 }
2228
2229 SetLongFlag(Vcb->Flags, VCB_MOUNTED);
2230 SetFlag(Vcb->Vpb->Flags, VPB_MOUNTED);
2232 Vcb = NULL;
2233 Vpb = NULL;
2235
2236 } else {
2237
2238 Vcb = NULL;
2239 }
2240
2241 } _SEH2_FINALLY {
2242
2243 if (GlobalDataResourceAcquired) {
2245 }
2246
2247 if (!NT_SUCCESS(Status)) {
2248
2249 if (!NT_SUCCESS(Status)) {
2250 if ( Vpb != NULL ) {
2251 Vpb->DeviceObject = NULL;
2252 }
2253 }
2254
2255 if (Vcb) {
2257 } else {
2258 if (Ext2Sb) {
2259 Ext2FreePool(Ext2Sb, EXT2_SB_MAGIC);
2260 }
2261 if (VolumeDeviceObject) {
2262 IoDeleteDevice(VolumeDeviceObject);
2263 DEC_MEM_COUNT(PS_VCB, VolumeDeviceObject, sizeof(EXT2_VCB));
2264 }
2265 }
2266 }
2267
2268 if (!IrpContext->ExceptionInProgress) {
2269 Ext2CompleteIrpContext(IrpContext, Status);
2270 }
2271 } _SEH2_END;
2272
2273 return Status;
2274}
static PDEVICE_OBJECT MainDeviceObject
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
struct _EXT2_VCB EXT2_VCB
#define EXT2_SUPER_MAGIC
Definition: ext2fs.h:349
NTSTATUS Ext2InitializeVcb(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_SUPER_BLOCK Ext2Sb, PDEVICE_OBJECT TargetDevice, PDEVICE_OBJECT VolumeDevice, PVPB Vpb)
#define EXT2_UNLOAD_PENDING
Definition: ext2fs.h:590
NTSTATUS Ext2LoadSuper(IN PEXT2_VCB Vcb, IN BOOLEAN bVerify, OUT PEXT2_SUPER_BLOCK *Sb)
Definition: generic.c:29
VOID Ext2InsertVcb(PEXT2_VCB Vcb)
Definition: memory.c:1935
NTSTATUS Ext2DiskIoControl(IN PDEVICE_OBJECT DeviceOjbect, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
Definition: block.c:609
#define RtlEqualMemory(a, b, c)
Definition: kdvm.h:18
struct _DISK_GEOMETRY DISK_GEOMETRY
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:114
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ULONG Flags
Definition: ext2fs.h:523
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH/sizeof(WCHAR)]
Definition: iotypes.h:198
USHORT VolumeLabelLength
Definition: iotypes.h:193
ULONG SerialNumber
Definition: iotypes.h:196
struct _DEVICE_OBJECT * RealDevice
Definition: iotypes.h:195
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173

Referenced by Ext2FileSystemControl().

◆ Ext2NewBlock()

NTSTATUS Ext2NewBlock ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  GroupHint,
IN ULONG  BlockHint,
OUT PULONG  Block,
IN OUT PULONG  Number 
)

Definition at line 1008 of file generic.c.

1016{
1017 struct super_block *sb = &Vcb->sb;
1019 struct buffer_head *gb = NULL;
1020 struct buffer_head *bh = NULL;
1021 ext4_fsblk_t bitmap_blk;
1022
1023 RTL_BITMAP BlockBitmap;
1024
1025 ULONG Group = 0;
1026 ULONG Index = 0xFFFFFFFF;
1027 ULONG dwHint = 0;
1028 ULONG Count = 0;
1029 ULONG Length = 0;
1030
1032
1033 *Block = 0;
1034
1036
1037 /* validate the hint group and hint block */
1038 if (GroupHint >= Vcb->sbi.s_groups_count) {
1039 DbgBreak();
1040 GroupHint = Vcb->sbi.s_groups_count - 1;
1041 }
1042
1043 if (BlockHint != 0) {
1044 GroupHint = (BlockHint - EXT2_FIRST_DATA_BLOCK) / BLOCKS_PER_GROUP;
1045 dwHint = (BlockHint - EXT2_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1046 }
1047
1048 Group = GroupHint;
1049
1050Again:
1051
1052 if (bh)
1053 fini_bh(&bh);
1054
1055 if (gb)
1056 fini_bh(&gb);
1057
1058 gd = ext4_get_group_desc(sb, Group, &gb);
1059 if (!gd) {
1060 DbgBreak();
1062 goto errorout;
1063 }
1064
1065 bitmap_blk = ext4_block_bitmap(sb, gd);
1066
1067 if (gd->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
1068 bh = sb_getblk_zero(sb, bitmap_blk);
1069 if (!bh) {
1070 DbgBreak();
1072 goto errorout;
1073 }
1074 gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1076 set_buffer_uptodate(bh);
1077 gd->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
1078 Ext2SaveGroup(IrpContext, Vcb, Group);
1079 } else {
1080 bh = sb_getblk(sb, bitmap_blk);
1081 if (!bh) {
1082 DbgBreak();
1084 goto errorout;
1085 }
1086 }
1087
1088 if (!buffer_uptodate(bh)) {
1089 int err = bh_submit_read(bh);
1090 if (err < 0) {
1091 DbgPrint("bh_submit_read error! err: %d\n", err);
1093 goto errorout;
1094 }
1095 }
1096
1097 if (ext4_free_blks_count(sb, gd)) {
1098
1099 if (Group == Vcb->sbi.s_groups_count - 1) {
1100
1102
1103 /* s_blocks_count is integer multiple of s_blocks_per_group */
1104 if (Length == 0) {
1106 }
1107 } else {
1109 }
1110
1111 /* initialize bitmap buffer */
1112 RtlInitializeBitMap(&BlockBitmap, (PULONG)bh->b_data, Length);
1113
1114 /* try to find a clear bit range */
1115 Index = RtlFindClearBits(&BlockBitmap, *Number, dwHint);
1116
1117 /* We could not get new block in the prefered group */
1118 if (Index == 0xFFFFFFFF) {
1119
1120 /* search clear bits from the hint block */
1121 Count = RtlFindNextForwardRunClear(&BlockBitmap, dwHint, &Index);
1122 if (dwHint != 0 && Count == 0) {
1123 /* search clear bits from the very beginning */
1124 Count = RtlFindNextForwardRunClear(&BlockBitmap, 0, &Index);
1125 }
1126
1127 if (Count == 0) {
1128
1129 RtlZeroMemory(&BlockBitmap, sizeof(RTL_BITMAP));
1130
1131 /* no blocks found: set bg_free_blocks_count to 0 */
1132 ext4_free_blks_set(sb, gd, 0);
1133 Ext2SaveGroup(IrpContext, Vcb, Group);
1134
1135 /* will try next group */
1136 goto Again;
1137
1138 } else {
1139
1140 /* we got free blocks */
1141 if (Count <= *Number) {
1142 *Number = Count;
1143 }
1144 }
1145 }
1146
1147 } else {
1148
1149 /* try next group */
1150 dwHint = 0;
1151 Group = (Group + 1) % Vcb->sbi.s_groups_count;
1152 if (Group != GroupHint) {
1153 goto Again;
1154 }
1155
1156 Index = 0xFFFFFFFF;
1157 }
1158
1159 if (Index < Length) {
1160
1161 /* mark block bits as allocated */
1162 RtlSetBits(&BlockBitmap, Index, *Number);
1163
1164 /* set block bitmap dirty in cache */
1166
1167 /* update group description */
1168 ext4_free_blks_set(sb, gd, RtlNumberOfClearBits(&BlockBitmap));
1169 Ext2SaveGroup(IrpContext, Vcb, Group);
1170
1171 /* update Vcb free blocks */
1172 Ext2UpdateVcbStat(IrpContext, Vcb);
1173
1174 /* validate the new allocated block number */
1176 if (*Block >= TOTAL_BLOCKS || *Block + *Number > TOTAL_BLOCKS) {
1177 DbgBreak();
1178 dwHint = 0;
1179 goto Again;
1180 }
1181
1182 if (ext4_block_bitmap(sb, gd) == *Block ||
1183 ext4_inode_bitmap(sb, gd) == *Block ||
1184 ext4_inode_table(sb, gd) == *Block ) {
1185 DbgBreak();
1186 dwHint = 0;
1187 goto Again;
1188 }
1189
1190 /* Always remove dirty MCB to prevent Volume's lazy writing.
1191 Metadata blocks will be re-added during modifications.*/
1192 if (Ext2RemoveBlockExtent(Vcb, NULL, *Block, *Number)) {
1193 } else {
1194 DbgBreak();
1196 }
1197
1198 DEBUG(DL_INF, ("Ext2NewBlock: Block %xh - %x allocated.\n",
1199 *Block, *Block + *Number));
1201 }
1202
1203errorout:
1204
1205 ExReleaseResourceLite(&Vcb->MetaBlock);
1206
1207 if (bh)
1208 fini_bh(&bh);
1209
1210 if (gb)
1211 fini_bh(&gb);
1212
1213 return Status;
1214}
#define EXT4_BG_BLOCK_UNINIT
Definition: ext3_fs.h:734
__le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2619
__u32 ext4_free_blks_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2483
unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, ext4_group_t block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2877
NTSYSAPI ULONG WINAPI RtlFindClearBits(PCRTL_BITMAP, ULONG, ULONG)
NTSYSAPI ULONG WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP, ULONG, PULONG)
static struct buffer_head * sb_getblk_zero(struct super_block *sb, sector_t block)
Definition: module.h:982
#define cpu_to_le16
Definition: module.h:150
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155

Referenced by Ext2ExpandLast(), and ext4_new_meta_blocks().

◆ Ext2NewInode()

NTSTATUS Ext2NewInode ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  GroupHint,
IN ULONG  Type,
OUT PULONG  Inode 
)

Definition at line 1366 of file generic.c.

1373{
1374 struct super_block *sb = &Vcb->sb;
1376 struct buffer_head *gb = NULL;
1377 struct buffer_head *bh = NULL;
1378 ext4_fsblk_t bitmap_blk;
1379
1380 RTL_BITMAP InodeBitmap;
1381
1382 ULONG Group, i, j;
1383 ULONG Average, Length;
1384
1385 ULONG dwInode;
1386
1388
1389 *Inode = dwInode = 0XFFFFFFFF;
1390
1392
1393 if (GroupHint >= Vcb->sbi.s_groups_count)
1394 GroupHint = GroupHint % Vcb->sbi.s_groups_count;
1395
1396repeat:
1397
1398 if (bh)
1399 fini_bh(&bh);
1400
1401 if (gb)
1402 fini_bh(&gb);
1403
1404 Group = i = 0;
1405 gd = NULL;
1406
1407 if (Type == EXT2_FT_DIR) {
1408
1409 Average = Vcb->SuperBlock->s_free_inodes_count / Vcb->sbi.s_groups_count;
1410
1411 for (j = 0; j < Vcb->sbi.s_groups_count; j++) {
1412
1413 i = (j + GroupHint) % (Vcb->sbi.s_groups_count);
1414 gd = ext4_get_group_desc(sb, i, &gb);
1415 if (!gd) {
1416 DbgBreak();
1418 goto errorout;
1419 }
1420
1421 if ((gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) ||
1422 (ext4_used_dirs_count(sb, gd) << 8 <
1423 ext4_free_inodes_count(sb, gd)) ) {
1424 Group = i + 1;
1425 break;
1426 }
1427 fini_bh(&gb);
1428 }
1429
1430 if (!Group) {
1431
1433
1434 gd = NULL;
1435
1436 /* get the group with the biggest vacancy */
1437 for (j = 0; j < Vcb->sbi.s_groups_count; j++) {
1438
1439 struct buffer_head *gt = NULL;
1440 desc = ext4_get_group_desc(sb, j, &gt);
1441 if (!desc) {
1442 DbgBreak();
1444 goto errorout;
1445 }
1446
1447 /* return the group if it's not initialized yet */
1448 if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1449 Group = j + 1;
1450 gd = desc;
1451
1452 if (gb)
1453 fini_bh(&gb);
1454 gb = gt;
1455 gt = NULL;
1456 break;
1457 }
1458
1459 if (!gd) {
1460 if (ext4_free_inodes_count(sb, desc) > 0) {
1461 Group = j + 1;
1462 gd = desc;
1463 if (gb)
1464 fini_bh(&gb);
1465 gb = gt;
1466 gt = NULL;
1467 }
1468 } else {
1471 Group = j + 1;
1472 gd = desc;
1473 if (gb)
1474 fini_bh(&gb);
1475 gb = gt;
1476 gt = NULL;
1477 break;
1478 }
1479 }
1480 if (gt)
1481 fini_bh(&gt);
1482 }
1483 }
1484
1485 } else {
1486
1487 /*
1488 * Try to place the inode in its parent directory (GroupHint)
1489 */
1490
1491 gd = ext4_get_group_desc(sb, GroupHint, &gb);
1492 if (!gb) {
1493 DbgBreak();
1495 goto errorout;
1496 }
1497
1498 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1500
1501 Group = GroupHint + 1;
1502
1503 } else {
1504
1505 /* this group is 100% cocucpied */
1506 fini_bh(&gb);
1507
1508 i = GroupHint;
1509
1510 /*
1511 * Use a quadratic hash to find a group with a free inode
1512 */
1513
1514 for (j = 1; j < Vcb->sbi.s_groups_count; j <<= 1) {
1515
1516
1517 i = (i + j) % Vcb->sbi.s_groups_count;
1518 gd = ext4_get_group_desc(sb, i, &gb);
1519 if (!gd) {
1520 DbgBreak();
1522 goto errorout;
1523 }
1524
1525 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1527 Group = i + 1;
1528 break;
1529 }
1530
1531 fini_bh(&gb);
1532 }
1533 }
1534
1535 if (!Group) {
1536 /*
1537 * That failed: try linear search for a free inode
1538 */
1539 i = GroupHint;
1540 for (j = 2; j < Vcb->sbi.s_groups_count; j++) {
1541
1542 i = (i + 1) % Vcb->sbi.s_groups_count;
1543 gd = ext4_get_group_desc(sb, i, &gb);
1544 if (!gd) {
1545 DbgBreak();
1547 goto errorout;
1548 }
1549
1550 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1552 Group = i + 1;
1553 break;
1554 }
1555
1556 fini_bh(&gb);
1557 }
1558 }
1559 }
1560
1561 if (gd == NULL || Group == 0) {
1562 goto errorout;
1563 }
1564
1565 /* finally we got the group, but is it valid ? */
1566 if (Group > Vcb->sbi.s_groups_count) {
1567 DbgBreak();
1568 goto errorout;
1569 }
1570
1571 /* valid group number starts from 1, not 0 */
1572 Group -= 1;
1573
1574 ASSERT(gd);
1575 bitmap_blk = ext4_inode_bitmap(sb, gd);
1576 /* check the block is valid or not */
1577 if (bitmap_blk == 0 || bitmap_blk >= TOTAL_BLOCKS) {
1578 DbgBreak();
1580 goto errorout;
1581 }
1582
1583 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1584 bh = sb_getblk_zero(sb, bitmap_blk);
1585 if (!bh) {
1586 DbgBreak();
1588 goto errorout;
1589 }
1590 gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1592 set_buffer_uptodate(bh);
1593 gd->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
1594 Ext2SaveGroup(IrpContext, Vcb, Group);
1595 } else {
1596 bh = sb_getblk(sb, bitmap_blk);
1597 if (!bh) {
1598 DbgBreak();
1600 goto errorout;
1601 }
1602 }
1603
1604 if (!buffer_uptodate(bh)) {
1605 int err = bh_submit_read(bh);
1606 if (err < 0) {
1607 DbgPrint("bh_submit_read error! err: %d\n", err);
1609 goto errorout;
1610 }
1611 }
1612
1613 if (Vcb->sbi.s_groups_count == 1) {
1615 } else {
1616 if (Group + 1 == Vcb->sbi.s_groups_count) {
1618 if (!Length) {
1619 /* INODES_COUNT is integer multiple of INODES_PER_GROUP */
1621 }
1622 } else {
1624 }
1625 }
1626
1627 RtlInitializeBitMap(&InodeBitmap, (PULONG)bh->b_data, Length);
1628 dwInode = RtlFindClearBits(&InodeBitmap, 1, 0);
1629
1630 if (dwInode == 0xFFFFFFFF || dwInode >= Length) {
1631
1632 RtlZeroMemory(&InodeBitmap, sizeof(RTL_BITMAP));
1633 if (ext4_free_inodes_count(sb, gd) > 0) {
1634 ext4_free_inodes_set(sb, gd, 0);
1635 Ext2SaveGroup(IrpContext, Vcb, Group);
1636 }
1637 goto repeat;
1638
1639 } else {
1640
1641 __u32 count = 0;
1642
1643 /* update unused inodes count */
1644 count = ext4_free_inodes_count(sb, gd) - 1;
1646
1647 RtlSetBits(&InodeBitmap, dwInode, 1);
1648
1649 /* set block bitmap dirty in cache */
1651
1652 /* If we didn't allocate from within the initialized part of the inode
1653 * table then we need to initialize up to this inode. */
1655
1656 __u32 free;
1657
1658 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1659 gd->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
1660 /* When marking the block group with
1661 * ~EXT4_BG_INODE_UNINIT we don't want to depend
1662 * on the value of bg_itable_unused even though
1663 * mke2fs could have initialized the same for us.
1664 * Instead we calculated the value below
1665 */
1666
1667 free = 0;
1668 } else {
1670 }
1671
1672 /*
1673 * Check the relative inode number against the last used
1674 * relative inode number in this group. if it is greater
1675 * we need to update the bg_itable_unused count
1676 *
1677 */
1678 if (dwInode + 1 > free) {
1680 (EXT3_INODES_PER_GROUP(sb) - 1 - dwInode));
1681 }
1682
1683 /* We may have to initialize the block bitmap if it isn't already */
1684 if (gd->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
1685
1686 struct buffer_head *block_bitmap_bh = NULL;
1687
1688 /* recheck and clear flag under lock if we still need to */
1689 block_bitmap_bh = sb_getblk_zero(sb, ext4_block_bitmap(sb, gd));
1690 if (block_bitmap_bh) {
1691 gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1692 free = ext4_init_block_bitmap(sb, block_bitmap_bh, Group, gd);
1693 set_buffer_uptodate(block_bitmap_bh);
1694 brelse(block_bitmap_bh);
1695 gd->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
1697 Ext2SaveGroup(IrpContext, Vcb, Group);
1698 }
1699 }
1700 }
1701
1702 *Inode = dwInode + 1 + Group * INODES_PER_GROUP;
1703
1704 /* update group_desc / super_block */
1705 if (Type == EXT2_FT_DIR) {
1707 }
1708 Ext2SaveGroup(IrpContext, Vcb, Group);
1709 Ext2UpdateVcbStat(IrpContext, Vcb);
1711 }
1712
1713errorout:
1714
1715 ExReleaseResourceLite(&Vcb->MetaInode);
1716
1717 if (bh)
1718 fini_bh(&bh);
1719
1720 if (gb)
1721 fini_bh(&gb);
1722
1723
1724 return Status;
1725}
u32 __u32
Definition: btrfs.h:19
#define free
Definition: debug_ros.c:5
#define EXT3_INODES_PER_GROUP(s)
Definition: ext3_fs.h:191
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM
Definition: ext3_fs.h:700
#define EXT4_BG_INODE_UNINIT
Definition: ext3_fs.h:733
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
__u32 ext4_free_inodes_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2491
__u32 ext4_itable_unused_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2507
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2563
unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh, ext4_group_t block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2786
static void brelse(struct buffer_head *bh)
Definition: module.h:955
static const WCHAR desc[]
Definition: protectdata.c:36
static int repeat
Definition: xmllint.c:137

Referenced by Ext2CreateInode().

◆ Ext2NoOpAcquire()

BOOLEAN Ext2NoOpAcquire ( IN PVOID  Fcb,
IN BOOLEAN  Wait 
)

Definition at line 138 of file cmcb.c.

Referenced by DriverEntry().

◆ Ext2NoOpRelease()

VOID Ext2NoOpRelease ( IN PVOID  Fcb)

Definition at line 153 of file cmcb.c.

156{
159
160 return;
161}

Referenced by DriverEntry().

◆ Ext2NotifyChangeDirectory()

NTSTATUS Ext2NotifyChangeDirectory ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1029 of file dirctl.c.

1032{
1036 PEXT2_VCB Vcb = NULL;
1037 PEXT2_FCB Fcb = NULL;
1038 PEXT2_CCB Ccb = NULL;
1039 PIRP Irp = NULL;
1044
1045 BOOLEAN bFcbAcquired = FALSE;
1046
1047 _SEH2_TRY {
1048
1049 ASSERT(IrpContext);
1050 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
1051 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
1052
1053 //
1054 // Always set the wait flag in the Irp context for the original request.
1055 //
1056
1057 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT );
1058
1059 DeviceObject = IrpContext->DeviceObject;
1060
1064 }
1065
1066 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
1067
1068 ASSERT(Vcb != NULL);
1069 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
1070 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
1071
1072 FileObject = IrpContext->FileObject;
1073 Fcb = (PEXT2_FCB) FileObject->FsContext;
1074 ASSERT(Fcb);
1075 if (Fcb->Identifier.Type == EXT2VCB) {
1076 DbgBreak();
1079 }
1081 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
1082
1083 Ccb = (PEXT2_CCB) FileObject->FsContext2;
1084 ASSERT(Ccb);
1086 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
1087
1088 /* do nothing if target fie was deleted */
1092 }
1093
1094 if (!IsDirectory(Fcb)) {
1095 DbgBreak();
1098 }
1099
1101 &Fcb->MainResource,
1102 TRUE )) {
1103 bFcbAcquired = TRUE;
1104 } else {
1107 }
1108
1109 Irp = IrpContext->Irp;
1110
1112
1113#ifndef _GNU_NTIFS_
1114
1116 IrpSp->Parameters.NotifyDirectory.CompletionFilter;
1117
1118#else // _GNU_NTIFS_
1119
1121 IrpSp)->Parameters.NotifyDirectory.CompletionFilter;
1122
1123#endif // _GNU_NTIFS_
1124
1126
1130 }
1131
1133 &Vcb->NotifyList,
1134 FileObject->FsContext2,
1135 (PSTRING)(&Fcb->Mcb->FullName),
1136 WatchTree,
1137 FALSE,
1139 Irp,
1140 NULL,
1141 NULL );
1142
1144
1146
1147 /*
1148 Currently the driver is read-only but here is an example on how to use the
1149 FsRtl-functions to report a change:
1150
1151 ANSI_STRING TestString;
1152 USHORT FileNamePartLength;
1153
1154 RtlInitAnsiString(&TestString, "\\ntifs.h");
1155
1156 FileNamePartLength = 7;
1157
1158 FsRtlNotifyReportChange(
1159 Vcb->NotifySync, // PNOTIFY_SYNC NotifySync
1160 &Vcb->NotifyList, // PLIST_ENTRY NotifyList
1161 &TestString, // PSTRING FullTargetName
1162 &FileNamePartLength, // PUSHORT FileNamePartLength
1163 FILE_NOTIFY_CHANGE_NAME // ULONG FilterMatch
1164 );
1165
1166 or
1167
1168 ANSI_STRING TestString;
1169
1170 RtlInitAnsiString(&TestString, "\\ntifs.h");
1171
1172 FsRtlNotifyFullReportChange(
1173 Vcb->NotifySync, // PNOTIFY_SYNC NotifySync
1174 &Vcb->NotifyList, // PLIST_ENTRY NotifyList
1175 &TestString, // PSTRING FullTargetName
1176 1, // USHORT TargetNameOffset
1177 NULL, // PSTRING StreamName OPTIONAL
1178 NULL, // PSTRING NormalizedParentName OPTIONAL
1179 FILE_NOTIFY_CHANGE_NAME, // ULONG FilterMatch
1180 0, // ULONG Action
1181 NULL // PVOID TargetContext
1182 );
1183 */
1184
1185 } _SEH2_FINALLY {
1186
1187 if (bFcbAcquired) {
1189 }
1190
1191 if (!IrpContext->ExceptionInProgress) {
1192 if (CompleteRequest) {
1193 if (Status == STATUS_PENDING) {
1194 Ext2QueueRequest(IrpContext);
1195 } else {
1196 Ext2CompleteIrpContext(IrpContext, Status);
1197 }
1198 } else {
1199 IrpContext->Irp = NULL;
1200 Ext2CompleteIrpContext(IrpContext, Status);
1201 }
1202 }
1203 } _SEH2_END;
1204
1205 return Status;
1206}
_Inout_ PLIST_ENTRY _In_ PVOID _In_ PSTRING _In_ BOOLEAN _In_ BOOLEAN _In_ ULONG CompletionFilter
Definition: fltkernel.h:2243
_Inout_ PLIST_ENTRY _In_ PVOID _In_ PSTRING _In_ BOOLEAN WatchTree
Definition: fltkernel.h:2241
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:322
#define SL_WATCH_TREE
Definition: iotypes.h:1839

Referenced by Ext2DirectoryControl().

◆ Ext2NotifyReportChange()

VOID Ext2NotifyReportChange ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Filter,
IN ULONG  Action 
)

Definition at line 1209 of file dirctl.c.

1215{
1216 USHORT Offset;
1217
1218 Offset = (USHORT) ( Mcb->FullName.Length -
1219 Mcb->ShortName.Length);
1220
1221 FsRtlNotifyFullReportChange( Vcb->NotifySync,
1222 &(Vcb->NotifyList),
1223 (PSTRING) (&Mcb->FullName),
1224 (USHORT) Offset,
1225 (PSTRING)NULL,
1226 (PSTRING) NULL,
1227 (ULONG) Filter,
1228 (ULONG) Action,
1229 (PVOID) NULL );
1230
1231 // ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
1232}
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
VOID NTAPI FsRtlNotifyFullReportChange(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PSTRING FullTargetName, IN USHORT TargetNameOffset, IN PSTRING StreamName OPTIONAL, IN PSTRING NormalizedParentName OPTIONAL, IN ULONG FilterMatch, IN ULONG Action, IN PVOID TargetContext)
Definition: notify.c:1552
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Referenced by Ext2Cleanup(), Ext2CreateFile(), Ext2DeleteReparsePoint(), Ext2QueryEa(), Ext2SetEa(), Ext2SetFileInformation(), Ext2SetLinkInfo(), Ext2SetRenameInfo(), Ext2SetReparsePoint(), and Ext2WriteFile().

◆ Ext2NtStatusToString()

◆ Ext2NtTime()

LARGE_INTEGER Ext2NtTime ( IN ULONG  i_time)

Definition at line 40 of file misc.c.

41{
42 LARGE_INTEGER SysTime;
43
44 SysTime.QuadPart = 0;
45 RtlSecondsSince1970ToTime(i_time, &SysTime);
46
47 return SysTime;
48}
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)

Referenced by Ext2Cleanup(), Ext2FlushFile(), Ext2InitializeVcb(), Ext2LookupFile(), Ext2ProcessEntry(), Ext2RefreshSuper(), and Ext2SetFileInformation().

◆ Ext2OEMToUnicode()

NTSTATUS Ext2OEMToUnicode ( IN PEXT2_VCB  Vcb,
IN OUT PUNICODE_STRING  Oem,
IN POEM_STRING  Unicode 
)

Definition at line 206 of file misc.c.

211{
213
214
215 if (Vcb->Codepage.PageTable) {
216 Status = Ext2MbsToUnicode(Vcb->Codepage.PageTable,
217 Unicode, Oem);
218
219 if (Status >0 && Status == Unicode->Length) {
221 goto errorout;
222 }
223 }
224
226 Unicode, Oem, FALSE );
227
228 if (!NT_SUCCESS(Status)) {
229 DbgBreak();
230 goto errorout;
231 }
232
233errorout:
234
235 return Status;
236}
ULONG Ext2MbsToUnicode(struct nls_table *PageTable, IN OUT PUNICODE_STRING Unicode, IN PANSI_STRING Mbs)
Definition: misc.c:66
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)

Referenced by Ext2FillEntry(), Ext2FollowLink(), Ext2GetReparsePoint(), Ext2InitializeLabel(), and Ext2QueryDirectory().

◆ Ext2OEMToUnicodeSize()

ULONG Ext2OEMToUnicodeSize ( IN PEXT2_VCB  Vcb,
IN PANSI_STRING  Oem 
)

Definition at line 183 of file misc.c.

187{
188 ULONG Length = 0;
189
190 if (Vcb->Codepage.PageTable) {
191 Length = Ext2MbsToUnicode(Vcb->Codepage.PageTable, NULL, Oem);
192 if (Length > 0) {
193 goto errorout;
194 }
195 }
196
198
199errorout:
200
201 return Length;
202}
#define RtlOemStringToCountedUnicodeSize(STRING)

Referenced by Ext2FillEntry(), Ext2FollowLink(), Ext2GetReparsePoint(), and Ext2QueryDirectory().

◆ Ext2OplockComplete()

VOID Ext2OplockComplete ( IN PVOID  Context,
IN PIRP  Irp 
)

Definition at line 45 of file dispatch.c.

49{
50 //
51 // Check on the return value in the Irp.
52 //
53
54 if (Irp->IoStatus.Status == STATUS_SUCCESS) {
55
56 //
57 // queue the Irp context in the workqueue.
58 //
59
61
62 } else {
63
64 //
65 // complete the request in case of failure
66 //
67
69 Irp->IoStatus.Status );
70 }
71
72 return;
73}
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:158

Referenced by Ext2CreateFile(), Ext2LockControl(), Ext2ReadFile(), and Ext2WriteFile().

◆ Ext2OplockRequest()

NTSTATUS Ext2OplockRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 451 of file fsctl.c.

454{
456
457 ULONG FsCtrlCode;
460
461 PIRP Irp = NULL;
464
468
469 ULONG OplockCount = 0;
470
471 BOOLEAN VcbResourceAcquired = FALSE;
472 BOOLEAN FcbResourceAcquired = FALSE;
473
474 ASSERT(IrpContext);
475
476 _SEH2_TRY {
477
478 Irp = IrpContext->Irp;
479 ASSERT(Irp);
480
482 ASSERT(IrpSp);
484
485 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
486 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
487
488 DeviceObject = IrpContext->DeviceObject;
489
490 //
491 // This request is not allowed on the main device object
492 //
496 }
497
498 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
499
500 ASSERT(Vcb != NULL);
501
502 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
503 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
504
506
507 FileObject = IrpContext->FileObject;
508
509 Fcb = (PEXT2_FCB) FileObject->FsContext;
510
511 //
512 // This request is not allowed on volumes
513 //
514
515 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
518 }
519
521 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
522
523 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
526 }
527
528 Ccb = (PEXT2_CCB) FileObject->FsContext2;
529 if (Ccb == NULL) {
532 }
533
534
536 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
537
538 FsCtrlCode = EIrpSp->Parameters.FileSystemControl.FsControlCode;
539
540 switch (FsCtrlCode) {
541
545
546 VcbResourceAcquired =
548 &Vcb->MainResource,
549 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) );
550
551 ClearFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
552
553 FcbResourceAcquired =
556 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT));
557
558 if (FsCtrlCode == FSCTL_REQUEST_OPLOCK_LEVEL_2) {
559 OplockCount = (ULONG) FsRtlAreThereCurrentFileLocks(&Fcb->FileLockAnchor);
560 } else {
561 OplockCount = Fcb->OpenHandleCount;
562 }
563
564 break;
565
570
571 FcbResourceAcquired =
574 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT));
575
576 break;
577
578 default:
579
580 Ext2BugCheck(EXT2_BUGCHK_FSCTL, FsCtrlCode, 0, 0);
581 }
582
583
584 //
585 // Call the FsRtl routine to grant/acknowledge oplock.
586 //
587
588 Status = FsRtlOplockFsctrl( &Fcb->Oplock,
589 Irp,
590 OplockCount );
591
592 //
593 // Set the flag indicating if Fast I/O is possible
594 //
595
596 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
597 IrpContext->Irp = NULL;
598
599 } _SEH2_FINALLY {
600
601 if (FcbResourceAcquired) {
603 }
604
605 if (VcbResourceAcquired) {
606 ExReleaseResourceLite(&Vcb->MainResource);
607 }
608
610 Ext2CompleteIrpContext(IrpContext, Status);
611 }
612 } _SEH2_END;
613
614 return Status;
615}
#define EXT2_BUGCHK_FSCTL
Definition: ext2fs.h:328
#define FSCTL_OPLOCK_BREAK_NOTIFY
Definition: nt_native.h:831
#define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE
Definition: nt_native.h:829
#define FSCTL_REQUEST_OPLOCK_LEVEL_1
Definition: nt_native.h:826
#define FSCTL_REQUEST_BATCH_OPLOCK
Definition: nt_native.h:828
#define FSCTL_OPBATCH_ACK_CLOSE_PENDING
Definition: nt_native.h:830
#define FSCTL_OPLOCK_BREAK_ACK_NO_2
Definition: nt_native.h:846
#define FSCTL_REQUEST_OPLOCK_LEVEL_2
Definition: nt_native.h:827
NTSTATUS NTAPI FsRtlOplockFsctrl(IN POPLOCK Oplock, IN PIRP Irp, IN ULONG OpenCount)
Definition: oplock.c:1430

Referenced by Ext2UserFsRequest().

◆ Ext2Pnp()

NTSTATUS Ext2Pnp ( IN PEXT2_IRP_CONTEXT  IrpContext)

Referenced by Ext2DispatchRequest().

◆ Ext2PnpCancelRemove()

NTSTATUS Ext2PnpCancelRemove ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

◆ Ext2PnpQueryRemove()

NTSTATUS Ext2PnpQueryRemove ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

◆ Ext2PnpRemove()

NTSTATUS Ext2PnpRemove ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

◆ Ext2PnpSurpriseRemove()

NTSTATUS Ext2PnpSurpriseRemove ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

◆ Ext2PreAcquireForCreateSection()

NTSTATUS Ext2PreAcquireForCreateSection ( IN PFS_FILTER_CALLBACK_DATA  cd,
OUT PVOID cc 
)

Definition at line 1178 of file fastio.c.

1182{
1183 PEXT2_FCB Fcb = (PEXT2_FCB)cd->FileObject->FsContext;
1185
1188 if (cd->Parameters.AcquireForSectionSynchronization.SyncType != SyncTypeCreateSection) {
1190 } else if (Fcb->ShareAccess.Writers == 0) {
1192 } else {
1194 }
1195
1196 return status;
1197}
InitDirComponents & cd
#define STATUS_FILE_LOCKED_WITH_ONLY_READERS
Definition: ntstatus.h:111
#define STATUS_FILE_LOCKED_WITH_WRITERS
Definition: ntstatus.h:112
#define STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY
Definition: ntstatus.h:110
ULONG Writers
Definition: iotypes.h:527
@ SyncTypeCreateSection
Definition: iotypes.h:7365
#define FS_FILTER_ACQUIRE_FOR_SECTION_SYNCHRONIZATION
Definition: iotypes.h:7398

Referenced by DriverEntry().

◆ Ext2PrepareToUnload()

NTSTATUS Ext2PrepareToUnload ( IN PEXT2_IRP_CONTEXT  IrpContext)

Referenced by Ext2DeviceControl().

◆ Ext2Printf()

VOID __cdecl Ext2Printf ( PCHAR  DebugMessage,
  ... 
)

◆ Ext2ProcessEntry()

NTSTATUS Ext2ProcessEntry ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Dcb,
IN FILE_INFORMATION_CLASS  FileInformationClass,
IN ULONG  in,
IN PVOID  Buffer,
IN ULONG  UsedLength,
IN ULONG  Length,
IN ULONG  FileIndex,
IN PUNICODE_STRING  pName,
OUT PULONG  EntrySize,
IN BOOLEAN  Single 
)

Definition at line 60 of file dirctl.c.

74{
78
81
83
86
88 struct inode Inode = { 0 };
89
90 ULONG InfoLength = 0;
91 ULONG NameLength = 0;
92#ifndef __REACTOS__
93 ULONG dwBytes = 0;
94#endif
98
99 BOOLEAN IsEntrySymlink = FALSE;
100
101 *EntrySize = 0;
102 NameLength = pName->Length;
103 ASSERT((UsedLength & 7) == 0);
104
106 if (InfoLength == 0) {
107 DEBUG(DL_ERR, ("Ext2ProcessDirEntry: Invalid Info Class %xh for %wZ in %wZ\n",
108 FileInformationClass, pName, &Dcb->Mcb->FullName ));
110 }
111
112 if (InfoLength + NameLength > Length) {
113 DEBUG(DL_INF, ( "Ext2PricessDirEntry: Buffer is not enough.\n"));
115 if (UsedLength || InfoLength > Length) {
116 DEBUG(DL_CP, ("Ext2ProcessDirEntry: Buffer overflows for %wZ in %wZ\n",
117 pName, &Dcb->Mcb->FullName ));
118 return Status;
119 }
120 }
121
122 DEBUG(DL_CP, ("Ext2ProcessDirEntry: %wZ in %wZ\n", pName, &Dcb->Mcb->FullName ));
123
124 Mcb = Ext2SearchMcb(Vcb, Dcb->Mcb, pName);
125 if (NULL != Mcb) {
126 if (S_ISLNK(Mcb->Inode.i_mode) && NULL == Mcb->Target) {
127 Ext2FollowLink( IrpContext, Vcb, Dcb->Mcb, Mcb, 0);
128 }
129
130 } else {
131
132 Inode.i_ino = in;
133 Inode.i_sb = &Vcb->sb;
134 if (!Ext2LoadInode(Vcb, &Inode)) {
135 DEBUG(DL_ERR, ("Ext2PricessDirEntry: Loading inode %xh (%wZ) error.\n",
136 in, pName ));
137 DbgBreak();
139 goto errorout;
140 }
141
142 if (S_ISDIR(Inode.i_mode) || S_ISREG(Inode.i_mode)) {
143 } else if (S_ISLNK(Inode.i_mode)) {
144 DEBUG(DL_RES, ("Ext2ProcessDirEntry: SymLink: %wZ\\%wZ\n",
145 &Dcb->Mcb->FullName, pName));
146 Ext2LookupFile(IrpContext, Vcb, pName, Dcb->Mcb, &Mcb,0);
147
148 if (Mcb && IsMcbSpecialFile(Mcb)) {
150 Mcb = NULL;
151 }
152 } else {
153 Inode.i_size = 0;
154 }
155 }
156
157 if (Mcb != NULL) {
158
159 FileAttributes = Mcb->FileAttr;
160 if (IsMcbSymLink(Mcb)) {
161 Target = Mcb->Target;
162 ASSERT(Target);
164 if (IsMcbDirectory(Target)) {
165 FileSize = 0;
167 } else {
168 FileSize = Target->Inode.i_size;
169 }
170 if (IsFileDeleted(Target)) {
172 FileSize = 0;
173 }
174 } else {
175 if (IsMcbDirectory(Mcb)) {
176 FileSize = 0;
177 } else {
178 FileSize = Mcb->Inode.i_size;
179 }
180 }
181
182 if (IsInodeSymLink(&Mcb->Inode)) {
183 IsEntrySymlink = TRUE;
184 }
185
186 } else {
187
188 if (S_ISDIR(Inode.i_mode)) {
189 FileSize = 0;
190 } else {
191 FileSize = Inode.i_size;
192 }
193
194 if (S_ISDIR(Inode.i_mode)) {
196 } else if (S_ISLNK(Inode.i_mode)) {
198 IsEntrySymlink = TRUE;
199 } else {
201 }
202
205 }
206 }
207
208 if (FileAttributes == 0)
210
212
213 /* process special files under root directory */
214 if (IsRoot(Dcb)) {
215 /* set hidden and system attributes for Recycled /
216 RECYCLER / pagefile.sys */
221 }
222 }
223
224 /* set hidden attribute for all entries starting with '.' */
225 if (( pName->Length >= 4 && pName->Buffer[0] == L'.') &&
226 ((pName->Length == 4 && pName->Buffer[1] != L'.') ||
227 pName->Length >= 6 )) {
229 }
230
231 switch (FileInformationClass) {
232
234 FIF = (PFILE_ID_FULL_DIR_INFORMATION) ((PUCHAR)Buffer + UsedLength);
236 FFI = (PFILE_FULL_DIR_INFORMATION) ((PUCHAR)Buffer + UsedLength);
238 FDI = (PFILE_DIRECTORY_INFORMATION) ((PUCHAR)Buffer + UsedLength);
239
240 if (!Single) {
241 FDI->NextEntryOffset = CEILING_ALIGNED(ULONG, InfoLength + NameLength, 8);
242 }
243
244 FDI->FileIndex = FileIndex;
245
246 if (Mcb) {
247
248 FDI->CreationTime = Mcb->CreationTime;
249 FDI->LastAccessTime = Mcb->LastAccessTime;
250 FDI->LastWriteTime = Mcb->LastWriteTime;
251 FDI->ChangeTime = Mcb->ChangeTime;
252
253 } else {
254
255 FDI->CreationTime = Ext2NtTime(Inode.i_ctime);
256 FDI->LastAccessTime = Ext2NtTime(Inode.i_atime);
257 FDI->LastWriteTime = Ext2NtTime(Inode.i_mtime);
258 FDI->ChangeTime = Ext2NtTime(Inode.i_mtime);
259 }
260
264
265 FDI->FileNameLength = NameLength;
266 if (InfoLength + NameLength > Length) {
267 NameLength = Length - InfoLength;
268 }
269
270 if (FIF) {
271 FIF->FileId.QuadPart = (LONGLONG) in;
272 if (IsEntrySymlink) {
274 }
275 RtlCopyMemory(&FIF->FileName[0], &pName->Buffer[0], NameLength);
276 } else if (FFI) {
277 if (IsEntrySymlink) {
279 }
280 RtlCopyMemory(&FFI->FileName[0], &pName->Buffer[0], NameLength);
281 } else {
282 RtlCopyMemory(&FDI->FileName[0], &pName->Buffer[0], NameLength);
283 }
284
285 *EntrySize = InfoLength + NameLength;
286 break;
287
288
290 FIB = (PFILE_ID_BOTH_DIR_INFORMATION)((PUCHAR)Buffer + UsedLength);
292 FBI = (PFILE_BOTH_DIR_INFORMATION) ((PUCHAR)Buffer + UsedLength);
293
294 if (!Single) {
295 FBI->NextEntryOffset = CEILING_ALIGNED(ULONG, InfoLength + NameLength, 8);
296 }
297
298 FBI->FileIndex = FileIndex;
301
302 if (Mcb) {
303
304 FBI->CreationTime = Mcb->CreationTime;
305 FBI->LastAccessTime = Mcb->LastAccessTime;
306 FBI->LastWriteTime = Mcb->LastWriteTime;
307 FBI->ChangeTime = Mcb->ChangeTime;
308
309 } else {
310
311 FBI->CreationTime = Ext2NtTime(Inode.i_ctime);
312 FBI->LastAccessTime = Ext2NtTime(Inode.i_atime);
313 FBI->LastWriteTime = Ext2NtTime(Inode.i_mtime);
314 FBI->ChangeTime = Ext2NtTime(Inode.i_mtime);
315 }
316
318
319 FBI->FileNameLength = NameLength;
320 if (InfoLength + NameLength > Length) {
321 NameLength = Length - InfoLength;
322 }
323
324 if (FIB) {
325 FIB->FileId.QuadPart = (LONGLONG)in;
326 if (IsEntrySymlink) {
328 }
329 RtlCopyMemory(&FIB->FileName[0], &pName->Buffer[0], NameLength);
330 } else {
331 RtlCopyMemory(&FBI->FileName[0], &pName->Buffer[0], NameLength);
332 }
333
334 *EntrySize = InfoLength + NameLength;
335 break;
336
338
339 FNI = (PFILE_NAMES_INFORMATION) ((PUCHAR)Buffer + UsedLength);
340 if (!Single) {
341 FNI->NextEntryOffset = CEILING_ALIGNED(ULONG, InfoLength + NameLength, 8);
342 }
343
344 FNI->FileNameLength = NameLength;
345 if (InfoLength + NameLength > Length) {
346 NameLength = Length - InfoLength;
347 }
348 RtlCopyMemory(&FNI->FileName[0], &pName->Buffer[0], NameLength);
349
350 *EntrySize = InfoLength + NameLength;
351 break;
352
353 default:
355 break;
356 }
357
358 if (Mcb) {
360 }
361
362errorout:
363
364 DEBUG(DL_CP, ("Ext2ProcessDirEntry: Status = %xh for %wZ in %wZ\n",
365 Status, pName, &Dcb->Mcb->FullName ));
366
367 return Status;
368}
BOOLEAN Ext2LookupFile(PEXT2_VOLUME_INFO Volume, PCSTR FileName, PEXT2_FILE_INFO Ext2FileInfo)
Definition: ext2.c:205
ULONG Ext2GetInfoLength(IN FILE_INFORMATION_CLASS FileInformationClass)
Definition: dirctl.c:30
#define IsRoot(Fcb)
Definition: ext2fs.h:287
BOOLEAN Ext2IsSpecialSystemFile(IN PUNICODE_STRING FileName, IN BOOLEAN bDirectory)
Definition: create.c:224
int Ext2CheckInodeAccess(PEXT2_VCB Vcb, struct inode *in, int attempt)
Definition: access.c:20
PEXT2_MCB Ext2SearchMcb(PEXT2_VCB Vcb, PEXT2_MCB Parent, PUNICODE_STRING FileName)
Definition: memory.c:1598
NTSTATUS Ext2FollowLink(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Parent, IN PEXT2_MCB Mcb, IN ULONG Linkdep)
Definition: create.c:67
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:322
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1236
struct _FILE_BOTH_DIR_INFORMATION * PFILE_BOTH_DIR_INFORMATION
struct _FILE_NAMES_INFORMATION * PFILE_NAMES_INFORMATION
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
@ Single
Definition: halhw.h:165
struct _FILE_FULL_DIRECTORY_INFORMATION * PFILE_FULL_DIR_INFORMATION
struct _FILE_DIRECTORY_INFORMATION * PFILE_DIRECTORY_INFORMATION
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
LARGE_INTEGER CreationTime
Definition: from_kernel.h:141
LARGE_INTEGER AllocationSize
Definition: from_kernel.h:146
LARGE_INTEGER LastAccessTime
Definition: from_kernel.h:142
LARGE_INTEGER LastWriteTime
Definition: from_kernel.h:143
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:524
LARGE_INTEGER ChangeTime
Definition: winternl.h:519
LARGE_INTEGER EndOfFile
Definition: winternl.h:520
LARGE_INTEGER CreationTime
Definition: winternl.h:516
LARGE_INTEGER LastWriteTime
Definition: winternl.h:518
LARGE_INTEGER LastAccessTime
Definition: winternl.h:517
LARGE_INTEGER AllocationSize
Definition: winternl.h:521
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:539
__u32 i_mtime
Definition: fs.h:83
loff_t i_size
Definition: fs.h:80
struct super_block * i_sb
Definition: fs.h:96
__u32 i_atime
Definition: fs.h:81
__u32 i_ctime
Definition: fs.h:82
_In_ UCHAR EntrySize
Definition: iofuncs.h:642
struct _FILE_ID_BOTH_DIR_INFORMATION * PFILE_ID_BOTH_DIR_INFORMATION
#define IO_REPARSE_TAG_SYMLINK
Definition: iotypes.h:7240
struct _FILE_ID_FULL_DIR_INFORMATION * PFILE_ID_FULL_DIR_INFORMATION

Referenced by Ext2FillEntry(), and Ext2QueryDirectory().

◆ Ext2ProcessGlobalProperty()

NTSTATUS Ext2ProcessGlobalProperty ( IN PDEVICE_OBJECT  DeviceObject,
IN PEXT2_VOLUME_PROPERTY3  Property,
IN ULONG  Length 
)

Definition at line 240 of file devctl.c.

245{
246 PEXT2_VOLUME_PROPERTY3 Property2 = (PVOID)Property3;
248 struct nls_table * PageTable = NULL;
249
251 BOOLEAN GlobalDataResourceAcquired = FALSE;
252
253 _SEH2_TRY {
254
255 if (Length < 8 || !IsFlagOn(Property->Flags, EXT2_FLAG_VP_SET_GLOBAL)) {
258 }
259
260 /* query Ext2Fsd's version and built date/time*/
261 if (Property->Command == APP_CMD_QUERY_VERSION) {
264
265 if (Length < sizeof(EXT2_VOLUME_PROPERTY_VERSION)) {
268 }
269
270 RtlZeroMemory(&PVPV->Date[0], 0x20);
271 RtlZeroMemory(&PVPV->Time[0], 0x20);
272 RtlZeroMemory(&PVPV->Version[0],0x1C);
273 strncpy(&PVPV->Version[0], gVersion, 0x1B);
274 strncpy(&PVPV->Date[0], gDate, 0x1F);
275 strncpy(&PVPV->Time[0], gTime, 0x1F);
277 }
278
279 /* must be property query/set commands */
280 if (Property->Command == APP_CMD_SET_PROPERTY) {
281 if (Length < sizeof(EXT2_VOLUME_PROPERTY)) {
284 }
285 } else if (Property->Command == APP_CMD_SET_PROPERTY2) {
286 if (Length < sizeof(EXT2_VOLUME_PROPERTY2)) {
289 }
290 } else if (Property->Command == APP_CMD_SET_PROPERTY3) {
291 if (Length < sizeof(EXT2_VOLUME_PROPERTY3)) {
294 }
295 } else {
298 }
299
301 GlobalDataResourceAcquired = TRUE;
302
303
304 switch (Property->Command) {
305
307
308 if (Property3->Flags2 & EXT2_VPROP3_AUTOMOUNT) {
309 if (Property3->AutoMount)
311 else
313 }
314
316
318 if ((Ext2Global->bHidingPrefix = Property2->bHidingPrefix)) {
320 Property2->sHidingPrefix,
321 HIDINGPAT_LEN - 1);
322 }
324 if ((Ext2Global->bHidingSuffix = Property2->bHidingSuffix)) {
326 Property2->sHidingSuffix,
327 HIDINGPAT_LEN - 1);
328 }
329
331
332 if (Property->bReadonly) {
335 } else {
337 if (Property->bExt3Writable) {
339 } else {
341 }
342 }
343
344 PageTable = load_nls(Property->Codepage);
345 if (PageTable) {
346 memcpy(Ext2Global->Codepage.AnsiName, Property->Codepage, CODEPAGE_MAXLEN);
347 Ext2Global->Codepage.PageTable = PageTable;
348 }
349
350 break;
351
352 default:
353 break;
354 }
355
356 } _SEH2_FINALLY {
357
358 if (GlobalDataResourceAcquired) {
360 }
361 } _SEH2_END;
362
363 return Status;
364}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define APP_CMD_QUERY_VERSION
Definition: common.h:150
#define HIDINGPAT_LEN
Definition: common.h:160
struct _EXT2_VOLUME_PROPERTY_VERSION * PEXT2_VOLUME_PROPERTY_VERSION
#define CODEPAGE_MAXLEN
Definition: common.h:159
#define APP_CMD_SET_PROPERTY2
Definition: common.h:155
#define EXT2_VPROP3_AUTOMOUNT
Definition: common.h:203
#define APP_CMD_SET_PROPERTY3
Definition: common.h:157
#define EXT2_FLAG_VP_SET_GLOBAL
Definition: common.h:148
#define APP_CMD_SET_PROPERTY
Definition: common.h:153
CHAR gDate[]
Definition: init.c:24
CHAR gVersion[]
Definition: init.c:22
CHAR gTime[]
Definition: init.c:23
#define EXT2_SUPPORT_WRITING
Definition: ext2fs.h:591
#define EXT2_AUTO_MOUNT
Definition: ext2fs.h:594
#define EXT3_FORCE_WRITING
Definition: ext2fs.h:592
struct nls_table * load_nls(char *)
Definition: nls_base.c:218
CHAR sHidingSuffix[HIDINGPAT_LEN]
Definition: ext2fs.h:574
BOOLEAN bHidingSuffix
Definition: ext2fs.h:573
BOOLEAN bHidingPrefix
Definition: ext2fs.h:571
struct _EXT2_GLOBAL::@687 Codepage
CHAR sHidingPrefix[HIDINGPAT_LEN]
Definition: ext2fs.h:572
static PMEM_HOOK PageTable[TOTAL_PAGES]
Definition: memory.c:43

Referenced by Ext2ProcessUserProperty().

◆ Ext2ProcessUserProperty()

NTSTATUS Ext2ProcessUserProperty ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VOLUME_PROPERTY3  Property,
IN ULONG  Length 
)

Definition at line 591 of file devctl.c.

596{
600
601 _SEH2_TRY {
602
603 ASSERT(IrpContext != NULL);
604 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
605 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
606
607 if (Property->Magic != EXT2_VOLUME_PROPERTY_MAGIC) {
610 }
611
612 DeviceObject = IrpContext->DeviceObject;
615 } else {
616 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
617 if (!((Vcb) && (Vcb->Identifier.Type == EXT2VCB) &&
618 (Vcb->Identifier.Size == sizeof(EXT2_VCB)))) {
621 }
623 }
624
625 if (NT_SUCCESS(Status)) {
626 IrpContext->Irp->IoStatus.Information = Length;
627 }
628
629 } _SEH2_FINALLY {
630
631 if (!IrpContext->ExceptionInProgress) {
632 Ext2CompleteIrpContext(IrpContext, Status);
633 }
634 } _SEH2_END;
635
636 return Status;
637}
#define EXT2_VOLUME_PROPERTY_MAGIC
Definition: common.h:146
NTSTATUS Ext2ProcessGlobalProperty(IN PDEVICE_OBJECT DeviceObject, IN PEXT2_VOLUME_PROPERTY3 Property3, IN ULONG Length)
Definition: devctl.c:240
NTSTATUS Ext2ProcessVolumeProperty(IN PEXT2_VCB Vcb, IN PEXT2_VOLUME_PROPERTY3 Property3, IN ULONG Length)
Definition: devctl.c:368

Referenced by Ext2DeviceControl().

◆ Ext2ProcessVolumeProperty()

NTSTATUS Ext2ProcessVolumeProperty ( IN PEXT2_VCB  Vcb,
IN PEXT2_VOLUME_PROPERTY3  Property,
IN ULONG  Length 
)

Definition at line 368 of file devctl.c.

373{
374 struct nls_table * PageTable = NULL;
375 PEXT2_VOLUME_PROPERTY2 Property2 = (PVOID)Property3;
378 BOOLEAN VcbResourceAcquired = FALSE;
379
380 _SEH2_TRY {
381
382 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
383 VcbResourceAcquired = TRUE;
384
385 if (Property->Command == APP_CMD_SET_PROPERTY ||
386 Property->Command == APP_CMD_QUERY_PROPERTY) {
387 if (Length < sizeof(EXT2_VOLUME_PROPERTY)) {
390 }
391 } else if (Property->Command == APP_CMD_SET_PROPERTY2 ||
392 Property->Command == APP_CMD_QUERY_PROPERTY2) {
393 if (Length < sizeof(EXT2_VOLUME_PROPERTY2)) {
396 }
397 } else if (Property->Command == APP_CMD_SET_PROPERTY3 ||
398 Property->Command == APP_CMD_QUERY_PROPERTY3) {
399 if (Length < sizeof(EXT2_VOLUME_PROPERTY3)) {
402 }
403 }
404
405 switch (Property->Command) {
406
408
409 if (Property3->Flags2 & EXT2_VPROP3_AUTOMOUNT) {
410 if (Property3->AutoMount)
412 else
414 }
415 if (Property3->Flags2 & EXT2_VPROP3_USERIDS) {
416 SetFlag(Vcb->Flags, VCB_USER_IDS);
417 Vcb->uid = Property3->uid;
418 Vcb->gid = Property3->gid;
419 if (Property3->EIDS) {
420 Vcb->euid = Property3->euid;
421 Vcb->egid = Property3->egid;
422 SetFlag(Vcb->Flags, VCB_USER_EIDS);
423 } else {
424 Vcb->euid = Vcb->egid = 0;
425 ClearFlag(Vcb->Flags, VCB_USER_EIDS);
426 }
427 } else {
428 ClearFlag(Vcb->Flags, VCB_USER_IDS);
429 ClearFlag(Vcb->Flags, VCB_USER_EIDS);
430 Vcb->uid = Vcb->gid = 0;
431 Vcb->euid = Vcb->egid = 0;
432 }
433
435
436 RtlZeroMemory(Vcb->sHidingPrefix, HIDINGPAT_LEN);
437#ifdef __REACTOS__
438 if (Vcb->bHidingPrefix == Property2->bHidingPrefix) {
439#else
440 if (Vcb->bHidingPrefix = Property2->bHidingPrefix) {
441#endif
442 RtlCopyMemory( Vcb->sHidingPrefix,
443 Property2->sHidingPrefix,
444 HIDINGPAT_LEN - 1);
445 }
446
447 RtlZeroMemory(Vcb->sHidingSuffix, HIDINGPAT_LEN);
448#ifdef __REACTOS__
449 if (Vcb->bHidingSuffix == Property2->bHidingSuffix) {
450#else
451 if (Vcb->bHidingSuffix = Property2->bHidingSuffix) {
452#endif
453 RtlCopyMemory( Vcb->sHidingSuffix,
454 Property2->sHidingSuffix,
455 HIDINGPAT_LEN - 1);
456 }
457 Vcb->DrvLetter = Property2->DrvLetter;
458
460
461 if (Property->bReadonly) {
462 if (IsFlagOn(Vcb->Flags, VCB_INITIALIZED)) {
465 }
467
468 } else {
469
470 if (Property->bExt3Writable) {
472 }
473
474 if (!Vcb->IsExt3fs) {
476 } else if (!Property->bExt3Writable) {
478 } else if (IsFlagOn(Vcb->Flags, VCB_JOURNAL_RECOVER)) {
481 if (IsFlagOn(Vcb->Flags, VCB_JOURNAL_RECOVER)) {
483 } else {
485 }
486 } else {
488 }
489 }
490
491 PageTable = load_nls(Property->Codepage);
492 memcpy(Vcb->Codepage.AnsiName, Property->Codepage, CODEPAGE_MAXLEN);
493 Vcb->Codepage.PageTable = PageTable;
494 if (Vcb->Codepage.PageTable) {
495 Ext2InitializeLabel(Vcb, Vcb->SuperBlock);
496 }
497
498 break;
499
501
503 SetFlag(Property3->Flags2, EXT2_VPROP3_AUTOMOUNT);
504 Property3->AutoMount = TRUE;
505 } else {
506 ClearFlag(Property3->Flags2, EXT2_VPROP3_AUTOMOUNT);
507 Property3->AutoMount = FALSE;
508 }
509
510 if (IsFlagOn(Vcb->Flags, VCB_USER_IDS)) {
511 SetFlag(Property3->Flags2, EXT2_VPROP3_USERIDS);
512 Property3->uid = Vcb->uid;
513 Property3->gid = Vcb->gid;
514 if (IsFlagOn(Vcb->Flags, VCB_USER_EIDS)) {
515 Property3->EIDS = TRUE;
516 Property3->euid = Vcb->euid;
517 Property3->egid = Vcb->egid;
518 } else {
519 Property3->EIDS = FALSE;
520 }
521 } else {
522 ClearFlag(Property3->Flags2, EXT2_VPROP3_USERIDS);
523 }
524
526
527 RtlCopyMemory(Property2->UUID, Vcb->SuperBlock->s_uuid, 16);
528 Property2->DrvLetter = Vcb->DrvLetter;
529
530#ifdef __REACTOS__
531 if (Property2->bHidingPrefix == Vcb->bHidingPrefix) {
532#else
533 if (Property2->bHidingPrefix = Vcb->bHidingPrefix) {
534#endif
535 RtlCopyMemory( Property2->sHidingPrefix,
536 Vcb->sHidingPrefix,
538 } else {
539 RtlZeroMemory( Property2->sHidingPrefix,
541 }
542
543#ifdef __REACTOS__
544 if (Property2->bHidingSuffix == Vcb->bHidingSuffix) {
545#else
546 if (Property2->bHidingSuffix = Vcb->bHidingSuffix) {
547#endif
548 RtlCopyMemory( Property2->sHidingSuffix,
549 Vcb->sHidingSuffix,
551 } else {
552 RtlZeroMemory( Property2->sHidingSuffix,
554 }
555
557
558 Property->bExt2 = TRUE;
559 Property->bExt3 = Vcb->IsExt3fs;
560 Property->bReadonly = IsFlagOn(Vcb->Flags, VCB_READ_ONLY);
561 if (!Property->bReadonly && Vcb->IsExt3fs) {
562 Property->bExt3Writable = TRUE;
563 } else {
564 Property->bExt3Writable = FALSE;
565 }
566
568 if (Vcb->Codepage.PageTable) {
569 strncpy(Property->Codepage, Vcb->Codepage.PageTable->charset, CODEPAGE_MAXLEN);
570 } else {
571 strncpy(Property->Codepage, "default", CODEPAGE_MAXLEN);
572 }
573 break;
574
575 default:
577 break;
578 }
579
580 } _SEH2_FINALLY {
581
582 if (VcbResourceAcquired) {
583 ExReleaseResourceLite(&Vcb->MainResource);
584 }
585 } _SEH2_END;
586
587 return Status;
588}
#define APP_CMD_QUERY_PROPERTY2
Definition: common.h:154
#define APP_CMD_QUERY_PROPERTY3
Definition: common.h:156
#define EXT2_VPROP3_USERIDS
Definition: common.h:204
#define APP_CMD_QUERY_PROPERTY
Definition: common.h:152
NTSTATUS Ext2InitializeLabel(IN PEXT2_VCB Vcb, IN PEXT2_SUPER_BLOCK Sb)
Definition: memory.c:2253
INT Ext2RecoverJournal(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
Definition: recover.c:95
#define VCB_FORCE_WRITING
Definition: ext2fs.h:799
#define VCB_USER_IDS
Definition: ext2fs.h:794
BOOLEAN bHidingPrefix
Definition: common.h:192
CHAR sHidingSuffix[HIDINGPAT_LEN]
Definition: common.h:195
BOOLEAN bHidingSuffix
Definition: common.h:193
CHAR sHidingPrefix[HIDINGPAT_LEN]
Definition: common.h:194

Referenced by Ext2PerformRegistryVolumeParams(), and Ext2ProcessUserProperty().

◆ Ext2PurgeFile()

NTSTATUS Ext2PurgeFile ( IN PEXT2_FCB  Fcb,
IN BOOLEAN  FlushBeforePurge 
)

Definition at line 2811 of file fsctl.c.

2813{
2815
2816 ASSERT(Fcb != NULL);
2817
2819 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
2820
2821
2822 if (!IsVcbReadOnly(Fcb->Vcb) && FlushBeforePurge) {
2823 DEBUG(DL_INF, ( "Ext2PurgeFile: CcFlushCache on %wZ.\n",
2824 &Fcb->Mcb->FullName));
2827 CcFlushCache(&Fcb->SectionObject, NULL, 0, &IoStatus);
2829 }
2830
2831 if (Fcb->SectionObject.ImageSectionObject) {
2832 DEBUG(DL_INF, ( "Ext2PurgeFile: MmFlushImageSection on %wZ.\n",
2833 &Fcb->Mcb->FullName));
2834 MmFlushImageSection(&Fcb->SectionObject, MmFlushForWrite);
2835 }
2836
2837 if (Fcb->SectionObject.DataSectionObject) {
2838 DEBUG(DL_INF, ( "Ext2PurgeFile: CcPurgeCacheSection on %wZ.\n",
2839 &Fcb->Mcb->FullName));
2840 CcPurgeCacheSection(&Fcb->SectionObject, NULL, 0, FALSE);
2841 }
2842
2843 return STATUS_SUCCESS;
2844}

Referenced by Ext2PurgeVolume().

◆ Ext2PurgeVolume()

NTSTATUS Ext2PurgeVolume ( IN PEXT2_VCB  Vcb,
IN BOOLEAN  FlushBeforePurge 
)

Definition at line 2704 of file fsctl.c.

2706{
2707 PEXT2_FCB Fcb;
2708 LIST_ENTRY List, *Next;
2709
2710 BOOLEAN VcbResourceAcquired = FALSE;
2711 BOOLEAN FcbResourceAcquired = FALSE;
2712 BOOLEAN gdResourceAcquired = FALSE;
2713
2714 _SEH2_TRY {
2715
2716 ASSERT(Vcb != NULL);
2717 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2718 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2719
2720 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
2721 VcbResourceAcquired = TRUE;
2722
2723 if (IsVcbReadOnly(Vcb)) {
2724 FlushBeforePurge = FALSE;
2725 }
2726
2728
2730 FcbResourceAcquired = TRUE;
2731
2732 while (!IsListEmpty(&Vcb->FcbList)) {
2733
2734 Next = RemoveHeadList(&Vcb->FcbList);
2735 Fcb = CONTAINING_RECORD(Next, EXT2_FCB, Next);
2736
2737 DEBUG(DL_INF, ( "Ext2PurgeVolume: %wZ refercount=%xh\n",
2738 &Fcb->Mcb->FullName, Fcb->ReferenceCount));
2739 InsertTailList(&List, &Fcb->Next);
2740 }
2741
2742 while (!IsListEmpty(&List)) {
2743
2744 Next = RemoveHeadList(&List);
2745 Fcb = CONTAINING_RECORD(Next, EXT2_FCB, Next);
2746
2748 &Fcb->MainResource,
2749 TRUE )) {
2750
2751 Ext2PurgeFile(Fcb, FlushBeforePurge);
2752
2753 if (Fcb->ReferenceCount <= 1) {
2754 Fcb->TsDrop.QuadPart = 0;
2755 InsertHeadList(&Vcb->FcbList, &Fcb->Next);
2756 } else {
2757 InsertTailList(&Vcb->FcbList, &Fcb->Next);
2758 }
2760 }
2761 }
2762
2763 if (FcbResourceAcquired) {
2764 ExReleaseResourceLite(&Vcb->FcbLock);
2765 FcbResourceAcquired = FALSE;
2766 }
2767
2768 /* acquire bd lock to avoid bh creation */
2769 ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
2770 gdResourceAcquired = TRUE;
2771
2772 /* discard buffer_headers for group_desc */
2773 Ext2DropBH(Vcb);
2774
2775 if (FlushBeforePurge) {
2776 ExAcquireSharedStarveExclusive(&Vcb->PagingIoResource, TRUE);
2777 ExReleaseResourceLite(&Vcb->PagingIoResource);
2778
2779 CcFlushCache(&Vcb->SectionObject, NULL, 0, NULL);
2780 }
2781
2782 if (Vcb->SectionObject.ImageSectionObject) {
2783 MmFlushImageSection(&Vcb->SectionObject, MmFlushForWrite);
2784 }
2785
2786 if (Vcb->SectionObject.DataSectionObject) {
2787 CcPurgeCacheSection(&Vcb->SectionObject, NULL, 0, FALSE);
2788 }
2789
2790 DEBUG(DL_INF, ( "Ext2PurgeVolume: Volume flushed and purged.\n"));
2791
2792 } _SEH2_FINALLY {
2793
2794 if (gdResourceAcquired) {
2795 ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
2796 }
2797
2798 if (FcbResourceAcquired) {
2799 ExReleaseResourceLite(&Vcb->FcbLock);
2800 }
2801
2802 if (VcbResourceAcquired) {
2803 ExReleaseResourceLite(&Vcb->MainResource);
2804 }
2805 } _SEH2_END;
2806
2807 return STATUS_SUCCESS;
2808}
NTSTATUS Ext2PurgeFile(IN PEXT2_FCB Fcb, IN BOOLEAN FlushBeforePurge)
Definition: fsctl.c:2811

Referenced by Ext2DismountVolume(), Ext2VerifyVolume(), and Ext2WriteVolume().

◆ Ext2PutGroup()

VOID Ext2PutGroup ( IN PEXT2_VCB  Vcb)

Definition at line 150 of file generic.c.

151{
152 struct ext3_sb_info *sbi = &Vcb->sbi;
153 unsigned long i;
154
155
156 if (NULL == Vcb->sbi.s_gd) {
157 return;
158 }
159
161
162 kfree(Vcb->sbi.s_gd);
163 Vcb->sbi.s_gd = NULL;
164
165 ClearFlag(Vcb->Flags, VCB_GD_LOADED);
166}
#define kfree(p)
Definition: module.h:1126

Referenced by Ext2InitializeVcb(), and Ext2LoadGroup().

◆ Ext2QueryDirectory()

NTSTATUS Ext2QueryDirectory ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 525 of file dirctl.c.

526{
534 PIRP Irp = NULL;
535 PIO_STACK_LOCATION IoStackLocation = NULL;
536
538 ULONG FileIndex;
541
544 BOOLEAN IndexSpecified;
545 BOOLEAN FirstQuery;
546 BOOLEAN FcbResourceAcquired = FALSE;
547
548 USHORT NameLen;
550
551 OEM_STRING Oem = { 0 };
552 UNICODE_STRING Unicode = { 0 };
553 PEXT2_DIR_ENTRY2 pDir = NULL;
554
556 ULONG RecLen = 0;
557 ULONG EntrySize = 0;
558
559 EXT2_FILLDIR_CONTEXT fc = { 0 };
560
561 _SEH2_TRY {
562
563 ASSERT(IrpContext);
564 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
565 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
566
567 DeviceObject = IrpContext->DeviceObject;
568
569 //
570 // This request is not allowed on the main device object
571 //
575 }
576
577 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
578 ASSERT(Vcb != NULL);
579 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
580 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
581
582 if (!IsMounted(Vcb)) {
585 }
586
587 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
590 }
591
592 FileObject = IrpContext->FileObject;
593 Fcb = (PEXT2_FCB) FileObject->FsContext;
594 if (Fcb == NULL) {
597 }
598 Mcb = Fcb->Mcb;
599 if (NULL == Mcb) {
602 }
604
605 //
606 // This request is not allowed on volumes
607 //
608 if (Fcb->Identifier.Type == EXT2VCB) {
611 }
612
614 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
615
616 if (!IsMcbDirectory(Mcb)) {
619 }
620
621 if (IsFileDeleted(Mcb)) {
624 }
625
626 Ccb = (PEXT2_CCB) FileObject->FsContext2;
627
628 ASSERT(Ccb);
630 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
631
632 Irp = IrpContext->Irp;
633 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
634
635#ifndef _GNU_NTIFS_
636
637 fi = IoStackLocation->Parameters.QueryDirectory.FileInformationClass;
638
639 Length = IoStackLocation->Parameters.QueryDirectory.Length;
640
641 FileName = (PUNICODE_STRING)IoStackLocation->Parameters.QueryDirectory.FileName;
642
643 FileIndex = IoStackLocation->Parameters.QueryDirectory.FileIndex;
644
645#else // _GNU_NTIFS_
646
648 IoStackLocation)->Parameters.QueryDirectory.FileInformationClass;
649
651 IoStackLocation)->Parameters.QueryDirectory.Length;
652
654 IoStackLocation)->Parameters.QueryDirectory.FileName;
655
656 FileIndex = ((PEXTENDED_IO_STACK_LOCATION)
657 IoStackLocation)->Parameters.QueryDirectory.FileIndex;
658
659#endif // _GNU_NTIFS_
660
662 IoStackLocation)->Flags, SL_RESTART_SCAN);
664 IoStackLocation)->Flags, SL_RETURN_SINGLE_ENTRY);
665 IndexSpecified = FlagOn(((PEXTENDED_IO_STACK_LOCATION)
666 IoStackLocation)->Flags, SL_INDEX_SPECIFIED);
667
669 if (Buffer == NULL) {
670 DbgBreak();
673 }
674
675 if (!IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT)) {
678 }
679
682 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) {
685 }
686 FcbResourceAcquired = TRUE;
687
688 if (FileName != NULL) {
689
690 if (Ccb->DirectorySearchPattern.Buffer != NULL) {
691
692 FirstQuery = FALSE;
693
694 } else {
695
696 FirstQuery = TRUE;
697
698 Ccb->DirectorySearchPattern.Length =
699 Ccb->DirectorySearchPattern.MaximumLength =
700 FileName->Length;
701
702 Ccb->DirectorySearchPattern.Buffer =
705
706 if (Ccb->DirectorySearchPattern.Buffer == NULL) {
707 DEBUG(DL_ERR, ( "Ex2QueryDirectory: failed to allocate SerarchPattern.\n"));
710 }
711
713 Ccb->DirectorySearchPattern.Buffer,
714 Ccb->DirectorySearchPattern.MaximumLength);
715
717 &(Ccb->DirectorySearchPattern),
718 FileName,
719 FALSE);
720
721 if (!NT_SUCCESS(Status)) {
723 }
724 }
725
726 } else if (Ccb->DirectorySearchPattern.Buffer != NULL) {
727
728 FirstQuery = FALSE;
729 FileName = &Ccb->DirectorySearchPattern;
730
731 } else {
732
733 FirstQuery = TRUE;
734
735 Ccb->DirectorySearchPattern.Length =
736 Ccb->DirectorySearchPattern.MaximumLength = 2;
737
738 Ccb->DirectorySearchPattern.Buffer =
740
741 if (Ccb->DirectorySearchPattern.Buffer == NULL) {
742 DEBUG(DL_ERR, ( "Ex2QueryDirectory: failed to allocate SerarchPattern (1st).\n"));
745 }
746
748 Ccb->DirectorySearchPattern.Buffer,
749 Ccb->DirectorySearchPattern.MaximumLength);
750
751 RtlZeroMemory(Ccb->DirectorySearchPattern.Buffer, 4);
753 Ccb->DirectorySearchPattern.Buffer,
754 L"*\0", 2);
755 }
756
757 if (IndexSpecified) {
758 Ccb->filp.f_pos = FileIndex;
759 } else {
760 if (RestartScan || FirstQuery) {
761 Ccb->filp.f_pos = FileIndex = 0;
762 } else {
763 FileIndex = (ULONG)Ccb->filp.f_pos;
764 }
765 }
766
768
769 fc.efc_irp = IrpContext;
770 fc.efc_buf = Buffer;
771 fc.efc_size = Length;
772 fc.efc_start = 0;
773 fc.efc_single = ReturnSingleEntry;
774 fc.efc_fi = fi;
775 fc.efc_status = STATUS_SUCCESS;
776
777#ifdef EXT2_HTREE_INDEX
778
779 if (EXT3_HAS_COMPAT_FEATURE(Mcb->Inode.i_sb,
781 ((EXT3_I(&Mcb->Inode)->i_flags & EXT3_INDEX_FL) ||
782 ((Mcb->Inode.i_size >> BLOCK_BITS) == 1)) ) {
783 int rc = ext3_dx_readdir(&Ccb->filp, Ext2FillEntry, &fc);
784 Status = fc.efc_status;
785 if (rc != ERR_BAD_DX_DIR) {
786 goto errorout;
787 }
788 /*
789 * We don't set the inode dirty flag since it's not
790 * critical that it get flushed back to the disk.
791 */
792 EXT3_I(&Mcb->Inode)->i_flags &= ~EXT3_INDEX_FL;
793 }
794#endif
795
796 if (Mcb->Inode.i_size <= Ccb->filp.f_pos) {
799 }
800
801 pDir = Ext2AllocatePool(
802 PagedPool,
803 sizeof(EXT2_DIR_ENTRY2),
805 );
806
807 if (!pDir) {
808 DEBUG(DL_ERR, ( "Ex2QueryDirectory: failed to allocate pDir.\n"));
811 }
812
814 ByteOffset = FileIndex;
815
816 DEBUG(DL_CP, ("Ex2QueryDirectory: Dir: %wZ Index=%xh Pattern : %wZ.\n",
817 &Fcb->Mcb->FullName, FileIndex, &Ccb->DirectorySearchPattern));
818
819 while ((ByteOffset < Mcb->Inode.i_size) &&
820 (CEILING_ALIGNED(ULONG, fc.efc_start, 8) < Length)) {
821
822 RtlZeroMemory(pDir, sizeof(EXT2_DIR_ENTRY2));
823
825 IrpContext,
826 Vcb,
827 Mcb,
829 (PVOID)pDir,
830 sizeof(EXT2_DIR_ENTRY2),
831 FALSE,
832 &EntrySize);
833
834 if (!NT_SUCCESS(Status)) {
835 DbgBreak();
837 }
838
839 if (pDir->rec_len == 0) {
840 RecLen = BLOCK_SIZE - (ByteOffset & (BLOCK_SIZE - 1));
841 } else {
842 RecLen = ext3_rec_len_from_disk(pDir->rec_len);
843 }
844
845 if (!pDir->inode || pDir->inode >= INODES_COUNT) {
846 goto ProcessNextEntry;
847 }
848
849 /* skip . and .. */
850 if ((pDir->name_len == 1 && pDir->name[0] == '.') ||
851 (pDir->name_len == 2 && pDir->name[0] == '.' && pDir->name[1] == '.' )) {
852 goto ProcessNextEntry;
853 }
854
855 Oem.Buffer = pDir->name;
856 Oem.Length = (pDir->name_len & 0xff);
857 Oem.MaximumLength = Oem.Length;
858
859 if (Ext2IsWearingCloak(Vcb, &Oem)) {
860 goto ProcessNextEntry;
861 }
862
863 NameLen = (USHORT) Ext2OEMToUnicodeSize(Vcb, &Oem);
864
865 if (NameLen <= 0) {
866 DEBUG(DL_CP, ("Ext2QueryDirectory: failed to count unicode length for inode: %xh\n",
867 pDir->inode));
869 break;
870 }
871
872 if ( Unicode.Buffer != NULL && Unicode.MaximumLength > NameLen) {
873 /* reuse buffer */
874 } else {
875 /* free and re-allocate it */
876 if (Unicode.Buffer) {
878 Unicode.Buffer,
879 Unicode.MaximumLength);
881 }
882 Unicode.MaximumLength = NameLen + 2;
883 Unicode.Buffer = Ext2AllocatePool(
884 PagedPool, Unicode.MaximumLength,
886 );
887 if (!Unicode.Buffer) {
888 DEBUG(DL_ERR, ( "Ex2QueryDirectory: failed to "
889 "allocate InodeFileName.\n"));
892 }
894 }
895
896 Unicode.Length = 0;
897 RtlZeroMemory(Unicode.Buffer, Unicode.MaximumLength);
898
899 Status = Ext2OEMToUnicode(Vcb, &Unicode, &Oem);
900 if (!NT_SUCCESS(Status)) {
901 DEBUG(DL_ERR, ( "Ex2QueryDirectory: Ext2OEMtoUnicode failed with %xh.\n", Status));
904 }
905
906 DEBUG(DL_CP, ( "Ex2QueryDirectory: process inode: %xh / %wZ (%d).\n",
907 pDir->inode, &Unicode, Unicode.Length));
908
910 &(Ccb->DirectorySearchPattern)) ?
912 &(Ccb->DirectorySearchPattern),
913 &Unicode,
914 TRUE,
915 NULL) :
917 &(Ccb->DirectorySearchPattern),
918 &Unicode,
919 TRUE) ) {
920
922 IrpContext,
923 Vcb,
924 Fcb,
925 fi,
926 pDir->inode,
927 Buffer,
928 CEILING_ALIGNED(ULONG, fc.efc_start, 8),
929 Length - CEILING_ALIGNED(ULONG, fc.efc_start, 8),
931 &Unicode,
932 &EntrySize,
934 );
935
936 if (NT_SUCCESS(Status)) {
937 if (EntrySize > 0) {
938 fc.efc_prev = CEILING_ALIGNED(ULONG, fc.efc_start, 8);
939 fc.efc_start = fc.efc_prev + EntrySize;
940 } else {
941 DbgBreak();
942 }
943 } else {
945 if (fc.efc_start == 0) {
946 fc.efc_start = EntrySize;
947 } else {
949 }
950 } else {
952 }
953 break;
954 }
955 }
956
957ProcessNextEntry:
958
959 ByteOffset += RecLen;
960 Ccb->filp.f_pos = ByteOffset;
961
962 if (fc.efc_start && ReturnSingleEntry) {
964 goto errorout;
965 }
966 }
967
968errorout:
969
970 ((PULONG)((PUCHAR)Buffer + fc.efc_prev))[0] = 0;
971 FileIndex = ByteOffset;
972
974 /* just return fc.efc_start/EntrySize bytes that we filled */
975 } else if (!fc.efc_start) {
976 if (NT_SUCCESS(Status)) {
977 if (FirstQuery) {
979 } else {
981 }
982 }
983 } else {
985 }
986
987 } _SEH2_FINALLY {
988
989 if (FcbResourceAcquired) {
991 }
992
993 if (pDir != NULL) {
996 }
997
998 if (Unicode.Buffer != NULL) {
1001 }
1002
1003 if (!IrpContext->ExceptionInProgress) {
1004
1005 if ( Status == STATUS_PENDING ||
1007
1009 IrpContext->Irp,
1010 Length,
1011 IoWriteAccess );
1012
1013 if (NT_SUCCESS(Status)) {
1014 Status = Ext2QueueRequest(IrpContext);
1015 } else {
1016 Ext2CompleteIrpContext(IrpContext, Status);
1017 }
1018 } else {
1019 IrpContext->Irp->IoStatus.Information = fc.efc_start;
1020 Ext2CompleteIrpContext(IrpContext, Status);
1021 }
1022 }
1023 } _SEH2_END;
1024
1025 return Status;
1026}
PFOR_CONTEXT fc
Definition: for.c:57
BOOLEAN Ext2ReadInode(PEXT2_VOLUME_INFO Volume, ULONG Inode, PEXT2_INODE InodeBuffer)
Definition: ext2.c:907
#define PS_INODE_NAME
Definition: common.h:26
#define PS_DIR_ENTRY
Definition: common.h:27
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
BOOLEAN Ext2IsWearingCloak(IN PEXT2_VCB Vcb, IN POEM_STRING OemName)
Definition: dirctl.c:372
static int Ext2FillEntry(void *context, const char *name, int namlen, ULONG offset, __u32 ino, unsigned int d_type)
Definition: dirctl.c:415
NTSTATUS Ext2ProcessEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG in, IN PVOID Buffer, IN ULONG UsedLength, IN ULONG Length, IN ULONG FileIndex, IN PUNICODE_STRING pName, OUT PULONG EntrySize, IN BOOLEAN Single)
Definition: dirctl.c:60
#define EXT2_INAME_MAGIC
Definition: ext2fs.h:297
int ext3_dx_readdir(struct file *filp, filldir_t filldir, void *context)
#define EXT2_DENTRY_MAGIC
Definition: ext2fs.h:300
#define EXT3_FEATURE_COMPAT_DIR_INDEX
Definition: ext3_fs.h:669
#define EXT3_HAS_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:645
#define EXT3_INDEX_FL
Definition: ext3_fs.h:220
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:731
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ BOOLEAN _In_ ULONG _In_opt_ PULONG _In_ BOOLEAN RestartScan
Definition: fltkernel.h:2299
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ BOOLEAN ReturnSingleEntry
Definition: fltkernel.h:2295
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
BOOLEAN NTAPI FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, IN BOOLEAN IgnoreCase, IN PWCHAR UpcaseTable OPTIONAL)
Definition: name.c:514
BOOLEAN NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
Definition: name.c:464
#define STATUS_NO_MORE_FILES
Definition: udferr_usr.h:128
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
#define SL_INDEX_SPECIFIED
Definition: iotypes.h:1837
#define SL_RETURN_SINGLE_ENTRY
Definition: iotypes.h:1836
#define SL_RESTART_SCAN
Definition: iotypes.h:1835

Referenced by Ext2DirectoryControl().

◆ Ext2QueryEa()

NTSTATUS Ext2QueryEa ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 94 of file ea.c.

97{
98 PIRP Irp = NULL;
100
102
107
108 PUCHAR UserEaList;
109 ULONG UserEaListLength;
110 ULONG UserEaIndex;
111
114 BOOLEAN IndexSpecified;
115
116 BOOLEAN MainResourceAcquired = FALSE;
117 BOOLEAN XattrRefAcquired = FALSE;
118
120
121 struct ext4_xattr_ref xattr_ref;
122 PCHAR UserBuffer;
123
124 ULONG UserBufferLength = 0;
125 ULONG RemainingUserBufferLength = 0;
126
127 PFILE_FULL_EA_INFORMATION FullEa, LastFullEa = NULL;
128
129 _SEH2_TRY {
130
131 Ccb = IrpContext->Ccb;
132 ASSERT(Ccb != NULL);
134 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
136 Vcb = (PEXT2_VCB)DeviceObject->DeviceExtension;
137 Fcb = IrpContext->Fcb;
138 Mcb = Fcb->Mcb;
139 Irp = IrpContext->Irp;
141
142 Irp->IoStatus.Information = 0;
143
144 //
145 // Receive input parameter from caller
146 //
147 UserBuffer = Ext2GetUserBuffer(Irp);
148 if (!UserBuffer) {
151 }
152 UserBufferLength = IrpSp->Parameters.QueryEa.Length;
153 RemainingUserBufferLength = UserBufferLength;
154 UserEaList = IrpSp->Parameters.QueryEa.EaList;
155 UserEaListLength = IrpSp->Parameters.QueryEa.EaListLength;
156 UserEaIndex = IrpSp->Parameters.QueryEa.EaIndex;
159 IndexSpecified = BooleanFlagOn(IrpSp->Flags, SL_INDEX_SPECIFIED);
160
161 if (!Mcb)
163
164 //
165 // We do not allow multiple instance gaining EA access to the same file
166 //
172 }
173 MainResourceAcquired = TRUE;
174
176 if (!NT_SUCCESS(Status)) {
177 DbgPrint("ext4_fs_get_xattr_ref() failed!\n");
179 }
180
181 FullEa = (PFILE_FULL_EA_INFORMATION)UserBuffer;
182
183 XattrRefAcquired = TRUE;
184
185 if (RemainingUserBufferLength)
186 RtlZeroMemory(FullEa, RemainingUserBufferLength);
187
188 if (UserEaList != NULL) {
189 int i = 0;
191 for (GetEa = (PFILE_GET_EA_INFORMATION)&UserEaList[0];
192 GetEa < (PFILE_GET_EA_INFORMATION)((PUCHAR)UserEaList
193 + UserEaListLength);
194 GetEa = (GetEa->NextEntryOffset == 0
197 + GetEa->NextEntryOffset))) {
198
199 size_t ItemSize;
201 ULONG EaEntrySize;
202 BOOL is_last = !GetEa->NextEntryOffset;
203
204 Str.MaximumLength = Str.Length = GetEa->EaNameLength;
205 Str.Buffer = &GetEa->EaName[0];
206
207 //
208 // At the moment we only need to know whether the item exists
209 // and its size.
210 //
213 Str.Buffer,
214 Str.Length,
215 NULL,
216 0,
217 &ItemSize));
218 if (!NT_SUCCESS(Status))
219 continue;
220
221 //
222 // We were not able to locate the name therefore we must
223 // dummy up a entry for the query. The needed Ea size is
224 // the size of the name + 4 (next entry offset) + 1 (flags)
225 // + 1 (name length) + 2 (value length) + the name length +
226 // 1 (null byte) + Data Size.
227 //
228 EaEntrySize = 4 + 1 + 1 + 2 + GetEa->EaNameLength + 1 + ItemSize;
229 if (!is_last)
230 EaEntrySize = ALIGN_UP(EaEntrySize, ULONG);
231
232 if (EaEntrySize > RemainingUserBufferLength) {
233
236 }
237 FullEa->NextEntryOffset = 0;
238 FullEa->Flags = 0;
239 FullEa->EaNameLength = GetEa->EaNameLength;
240 FullEa->EaValueLength = (USHORT)ItemSize;
241 RtlCopyMemory(&FullEa->EaName[0],
242 &GetEa->EaName[0],
243 GetEa->EaNameLength);
244
245 //
246 // This query must succeed, or is guarenteed to succeed
247 // since we are only looking up
248 // an EA entry in a in-memory tree structure.
249 // Otherwise that means someone might be operating on
250 // the xattr_ref without acquiring Inode lock.
251 //
253 ext4_fs_get_xattr(&xattr_ref,
255 Str.Buffer,
256 Str.Length,
257 &FullEa->EaName[0] + FullEa->EaNameLength + 1,
258 ItemSize,
259 &ItemSize
260 ))));
261 FullEa->EaValueLength = (USHORT)ItemSize;
262
263 // Link FullEa and LastFullEa together
264 if (LastFullEa)
265 LastFullEa->NextEntryOffset = (ULONG)((PCHAR)FullEa -
266 (PCHAR)LastFullEa);
267
268 LastFullEa = FullEa;
270 ((PCHAR)FullEa + EaEntrySize);
271 RemainingUserBufferLength -= EaEntrySize;
272 i++;
273 }
274 } else if (IndexSpecified) {
275 struct EaIterator EaIterator;
276 //
277 // The user supplied an index into the Ea list.
278 //
281
284 // In this case, return only an entry.
289 EaIterator.EaIndex = UserEaIndex;
291
292 xattr_ref.iter_arg = &EaIterator;
294
296
298
299 // It seems that the item isn't found
302
303 if (EaIterator.OverFlow) {
306 else
308 }
309
310 } else {
311 struct EaIterator EaIterator;
312 //
313 // Else perform a simple scan, taking into account the restart
314 // flag and the position of the next Ea stored in the Ccb.
315 //
316 if (RestartScan)
317 Ccb->EaIndex = 1;
318
321
328 EaIterator.EaIndex = Ccb->EaIndex;
330
331 xattr_ref.iter_arg = &EaIterator;
333
335
336 if (Ccb->EaIndex < EaIterator.EaIndexCounter)
337 Ccb->EaIndex = EaIterator.EaIndexCounter;
338
340
341 if (EaIterator.OverFlow) {
344 else
346 }
347
348 }
349 }
351
352 if (XattrRefAcquired) {
353 if (!NT_SUCCESS(Status)) {
354 xattr_ref.dirty = FALSE;
355 ext4_fs_put_xattr_ref(&xattr_ref);
356 }
357 else
359 }
360
361 if (MainResourceAcquired) {
363 }
364
365 if (NT_SUCCESS(Status)) {
367 IrpContext,
368 Vcb,
369 Mcb,
372 Irp->IoStatus.Information = UserBufferLength - RemainingUserBufferLength;
373 }
374
377 Status = Ext2QueueRequest(IrpContext);
378 }
379 else {
380 Ext2CompleteIrpContext(IrpContext, Status);
381 }
382 }
383 } _SEH2_END;
384
385 return Status;
386}
#define MAXUINT_PTR
Definition: basetsd.h:100
static int Ext2IterateAllEa(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item, BOOL is_last)
Definition: ea.c:46
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _FILE_FULL_EA_INFORMATION * PFILE_FULL_EA_INFORMATION
struct _FILE_GET_EA_INFORMATION * PFILE_GET_EA_INFORMATION
int ext4_fs_get_xattr(struct ext4_xattr_ref *ref, __u8 name_index, const char *name, size_t name_len, void *buf, size_t buf_size, size_t *data_size)
Definition: ext4_xattr.c:1078
void ext4_fs_xattr_iterate(struct ext4_xattr_ref *ref, int(*iter)(struct ext4_xattr_ref *ref, struct ext4_xattr_item *item, BOOL is_last))
Definition: ext4_xattr.c:978
#define EXT4_XATTR_INDEX_USER
Definition: ext4_xattr.h:52
int ext4_fs_put_xattr_ref(struct ext4_xattr_ref *ref)
Definition: ext4_xattr.c:1176
int ext4_fs_get_xattr_ref(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB fs, PEXT2_MCB inode_ref, struct ext4_xattr_ref *ref)
Definition: ext4_xattr.c:1105
#define PCHAR
Definition: match.c:90
#define STATUS_OBJECTID_NOT_FOUND
Definition: ntstatus.h:860
static UCHAR ItemSize[4]
Definition: parser.c:16
Definition: ea.c:22
PFILE_FULL_EA_INFORMATION FullEa
Definition: ea.c:30
ULONG RemainingUserBufferLength
Definition: ea.c:37
PFILE_FULL_EA_INFORMATION LastFullEa
Definition: ea.c:31
ULONG EaIndex
Definition: ea.c:40
ULONG EaIndexCounter
Definition: ea.c:43
BOOLEAN ReturnSingleEntry
Definition: ea.c:24
BOOL OverFlow
Definition: ea.c:27
ULONG UserBufferLength
Definition: ea.c:34
PEXT2_IRP_CONTEXT IrpContext
Definition: ext4_xattr.h:141
char * PCHAR
Definition: typedefs.h:51
#define ALIGN_UP(size, type)
Definition: umtypes.h:91
#define FILE_NOTIFY_CHANGE_EA

Referenced by Ext2DispatchRequest().

◆ Ext2QueryExtentMappings()

NTSTATUS Ext2QueryExtentMappings ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Fcb,
IN PLARGE_INTEGER  RequestVbn,
OUT PLARGE_INTEGER pMappedRuns 
)

Definition at line 670 of file fsctl.c.

677{
678 PLARGE_INTEGER MappedRuns = NULL;
679 PLARGE_INTEGER PartialRuns = NULL;
680
681 PEXT2_EXTENT Chain = NULL;
683
684 LONGLONG Vbn = 0;
685 ULONG Length = 0;
686 ULONG i = 0;
687
689
690 _SEH2_TRY {
691
692 /* now building all the request extents */
693 while (Vbn < RequestVbn->QuadPart) {
694
695 Length = 0x80000000; /* 2g bytes */
696 if (RequestVbn->QuadPart < Vbn + Length) {
697 Length = (ULONG)(RequestVbn->QuadPart - Vbn);
698 }
699
700 /* build extents for sub-range */
701 Extent = NULL;
703 IrpContext,
704 Vcb,
705 Fcb->Mcb,
706 Vbn,
707 Length,
708 FALSE,
709 &Extent);
710
711 if (!NT_SUCCESS(Status)) {
713 }
714
715 if (Chain) {
716 Ext2JointExtents(Chain, Extent);
717 } else {
718 Chain = Extent;
719 }
720
721 /* allocate extent array */
722 PartialRuns = Ext2AllocatePool(
724 (Ext2CountExtents(Chain) + 2) *
725 (2 * sizeof(LARGE_INTEGER)),
726 'RE2E');
727
728 if (PartialRuns == NULL) {
731 }
732 RtlZeroMemory( PartialRuns,
733 (Ext2CountExtents(Chain) + 2) *
734 (2 * sizeof(LARGE_INTEGER)));
735
736 if (MappedRuns) {
737 RtlMoveMemory(PartialRuns,
738 MappedRuns,
739 i * 2 * sizeof(LARGE_INTEGER));
740 Ext2FreePool(MappedRuns, 'RE2E');
741 }
742 MappedRuns = PartialRuns;
743
744 /* walk all the Mcb runs in Extent */
745 for (; Extent != NULL; Extent = Extent->Next) {
746 MappedRuns[i*2 + 0].QuadPart = Vbn + Extent->Offset;
747 MappedRuns[i*2 + 1].QuadPart = Extent->Lba;
748 i = i+1;
749 }
750
751 Vbn = Vbn + Length;
752 }
753
754 *pMappedRuns = MappedRuns;
755
756 } _SEH2_FINALLY {
757
759 if (MappedRuns) {
760 Ext2FreePool(MappedRuns, 'RE2E');
761 }
762 *pMappedRuns = NULL;
763 }
764
765 if (Chain) {
767 }
768 } _SEH2_END;
769
770 return Status;
771}
VOID Ext2JointExtents(IN PEXT2_EXTENT Chain, IN PEXT2_EXTENT Extent)
Definition: memory.c:527
ULONG Ext2CountExtents(IN PEXT2_EXTENT Chain)
Definition: memory.c:513
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by Ext2GetRetrievalPointers(), and Ext2QueryRetrievalPointers().

◆ Ext2QueryFileInformation()

NTSTATUS Ext2QueryFileInformation ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 48 of file fileinfo.c.

49{
57 PIRP Irp = NULL;
58 PIO_STACK_LOCATION IoStackLocation;
62 BOOLEAN FcbResourceAcquired = FALSE;
63
64 _SEH2_TRY {
65
66 ASSERT(IrpContext != NULL);
67 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
68 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
69
70 DeviceObject = IrpContext->DeviceObject;
71
72 //
73 // This request is not allowed on the main device object
74 //
78 }
79
80 FileObject = IrpContext->FileObject;
81 Fcb = (PEXT2_FCB) FileObject->FsContext;
82 if (Fcb == NULL) {
85 }
86
87 //
88 // This request is not allowed on volumes
89 //
90 if (Fcb->Identifier.Type == EXT2VCB) {
93 }
94
95 if (!((Fcb->Identifier.Type == EXT2FCB) &&
96 (Fcb->Identifier.Size == sizeof(EXT2_FCB)))) {
99 }
100
101 Vcb = Fcb->Vcb;
102
103 {
106 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT)
107 )) {
108
111 }
112
113 FcbResourceAcquired = TRUE;
114 }
115
116 Ccb = (PEXT2_CCB) FileObject->FsContext2;
117 ASSERT(Ccb != NULL);
119 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
120 Mcb = Ccb->SymLink;
121 if (!Mcb)
122 Mcb = Fcb->Mcb;
123
124 Irp = IrpContext->Irp;
125 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
127 IoStackLocation->Parameters.QueryFile.FileInformationClass;
128
129 Length = IoStackLocation->Parameters.QueryFile.Length;
130 Buffer = Irp->AssociatedIrp.SystemBuffer;
132
133 switch (FileInformationClass) {
134
136 {
138
139 if (Length < sizeof(FILE_BASIC_INFORMATION)) {
142 }
143
145
146 FileBasicInformation->CreationTime = Mcb->CreationTime;
147 FileBasicInformation->LastAccessTime = Mcb->LastAccessTime;
148 FileBasicInformation->LastWriteTime = Mcb->LastWriteTime;
149 FileBasicInformation->ChangeTime = Mcb->ChangeTime;
150
151 FileBasicInformation->FileAttributes = Mcb->FileAttr;
152 if (IsLinkInvalid(Mcb)) {
154 }
155 if (FileBasicInformation->FileAttributes == 0) {
157 }
158
159 Irp->IoStatus.Information = sizeof(FILE_BASIC_INFORMATION);
161 }
162 break;
163
165 {
167
168 if (Length < sizeof(FILE_STANDARD_INFORMATION)) {
171 }
172
174
175 FSI->NumberOfLinks = Mcb->Inode.i_nlink;
176
177 if (IsVcbReadOnly(Fcb->Vcb))
178 FSI->DeletePending = FALSE;
179 else
180 FSI->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
181
182 if (IsLinkInvalid(Mcb)) {
183 FSI->Directory = FALSE;
184 FSI->AllocationSize.QuadPart = 0;
185 FSI->EndOfFile.QuadPart = 0;
186 } else if (IsMcbDirectory(Mcb)) {
187 FSI->Directory = TRUE;
188 FSI->AllocationSize.QuadPart = 0;
189 FSI->EndOfFile.QuadPart = 0;
190 } else {
191 FSI->Directory = FALSE;
192 FSI->AllocationSize = Fcb->Header.AllocationSize;
193 FSI->EndOfFile = Fcb->Header.FileSize;
194 }
195
196 Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
198 }
199 break;
200
202 {
204
205 if (Length < sizeof(FILE_INTERNAL_INFORMATION)) {
208 }
209
211
212 /* we use the inode number as the internal index */
213 FileInternalInformation->IndexNumber.QuadPart = (LONGLONG)Mcb->Inode.i_ino;
214
215 Irp->IoStatus.Information = sizeof(FILE_INTERNAL_INFORMATION);
217 }
218 break;
219
220
222 {
223 struct ext4_xattr_ref xattr_ref;
225
226 if (Length < sizeof(FILE_EA_INFORMATION)) {
229 }
230
232 FileEaInformation->EaSize = 0;
233
235 if (!NT_SUCCESS(Status))
237
238 xattr_ref.iter_arg = &FileEaInformation->EaSize;
240 ext4_fs_put_xattr_ref(&xattr_ref);
241
242 if (FileEaInformation->EaSize)
243 FileEaInformation->EaSize += 4;
244
245 Irp->IoStatus.Information = sizeof(FILE_EA_INFORMATION);
247 }
248 break;
249
251 {
253 ULONG BytesToCopy = 0;
254
256 Mcb->FullName.Length) {
259 } else {
260 BytesToCopy = Mcb->FullName.Length;
262 }
263
265 FileNameInformation->FileNameLength = Mcb->FullName.Length;
266
268 FileNameInformation->FileName,
269 Mcb->FullName.Buffer,
270 BytesToCopy );
271
272 Irp->IoStatus.Information = BytesToCopy +
274 }
275 break;
276
278 {
280
281 if (Length < sizeof(FILE_POSITION_INFORMATION)) {
284 }
285
287 FilePositionInformation->CurrentByteOffset =
288 FileObject->CurrentByteOffset;
289
290 Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
292 }
293 break;
294
296 {
304
305 if (Length < sizeof(FILE_ALL_INFORMATION)) {
308 }
309
311
313 &FileAllInformation->BasicInformation;
314
315 FSI =
316 &FileAllInformation->StandardInformation;
317
319 &FileAllInformation->InternalInformation;
320
322 &FileAllInformation->EaInformation;
323
325 &FileAllInformation->PositionInformation;
326
328 &FileAllInformation->NameInformation;
329
330 FileBasicInformation->CreationTime = Mcb->CreationTime;
331 FileBasicInformation->LastAccessTime = Mcb->LastAccessTime;
332 FileBasicInformation->LastWriteTime = Mcb->LastWriteTime;
333 FileBasicInformation->ChangeTime = Mcb->ChangeTime;
334
335 FileBasicInformation->FileAttributes = Mcb->FileAttr;
336 if (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target)) {
338 }
339 if (FileBasicInformation->FileAttributes == 0) {
341 }
342
343 FSI->NumberOfLinks = Mcb->Inode.i_nlink;
344
345 if (IsVcbReadOnly(Fcb->Vcb))
346 FSI->DeletePending = FALSE;
347 else
348 FSI->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
349
350 if (IsLinkInvalid(Mcb)) {
351 FSI->Directory = FALSE;
352 FSI->AllocationSize.QuadPart = 0;
353 FSI->EndOfFile.QuadPart = 0;
354 } else if (IsDirectory(Fcb)) {
355 FSI->Directory = TRUE;
356 FSI->AllocationSize.QuadPart = 0;
357 FSI->EndOfFile.QuadPart = 0;
358 } else {
359 FSI->Directory = FALSE;
360 FSI->AllocationSize = Fcb->Header.AllocationSize;
361 FSI->EndOfFile = Fcb->Header.FileSize;
362 }
363
364 // The "inode number"
365 FileInternalInformation->IndexNumber.QuadPart = (LONGLONG)Mcb->Inode.i_ino;
366
367 // Romfs doesn't have any extended attributes
368 FileEaInformation->EaSize = 0;
369
370 FilePositionInformation->CurrentByteOffset =
371 FileObject->CurrentByteOffset;
372
373 FileNameInformation->FileNameLength = Mcb->ShortName.Length;
374
375 if (Length < sizeof(FILE_ALL_INFORMATION) +
376 Mcb->ShortName.Length - sizeof(WCHAR)) {
377 Irp->IoStatus.Information = sizeof(FILE_ALL_INFORMATION);
380 FileNameInformation->FileName,
381 Mcb->ShortName.Buffer,
383 NameInformation.FileName)
384 );
386 }
387
389 FileNameInformation->FileName,
390 Mcb->ShortName.Buffer,
391 Mcb->ShortName.Length
392 );
393
394 Irp->IoStatus.Information = sizeof(FILE_ALL_INFORMATION) +
395 Mcb->ShortName.Length - sizeof(WCHAR);
396#if 0
398 sizeof(FILE_MODE_INFORMATION) -
400#endif
401
403 }
404 break;
405
406 /*
407 case FileAlternateNameInformation:
408 {
409 // TODO: Handle FileAlternateNameInformation
410
411 // Here we would like to use RtlGenerate8dot3Name but I don't
412 // know how to use the argument PGENERATE_NAME_CONTEXT
413 }
414 */
415
417 {
419
423 }
424
426
427 PFNOI->FileAttributes = Mcb->FileAttr;
428 if (IsLinkInvalid(Mcb)) {
430 PFNOI->AllocationSize.QuadPart = 0;
431 PFNOI->EndOfFile.QuadPart = 0;
432 } else if (IsDirectory(Fcb)) {
433 PFNOI->AllocationSize.QuadPart = 0;
434 PFNOI->EndOfFile.QuadPart = 0;
435 } else {
436 PFNOI->AllocationSize = Fcb->Header.AllocationSize;
437 PFNOI->EndOfFile = Fcb->Header.FileSize;
438 }
439
440 if (PFNOI->FileAttributes == 0) {
442 }
443
444 PFNOI->CreationTime = Mcb->CreationTime;
445 PFNOI->LastAccessTime = Mcb->LastAccessTime;
446 PFNOI->LastWriteTime = Mcb->LastWriteTime;
447 PFNOI->ChangeTime = Mcb->ChangeTime;
448
449
450 Irp->IoStatus.Information =
453 }
454 break;
455
456#if (_WIN32_WINNT >= 0x0500)
457
459 {
461
465 }
466
468 FATI->FileAttributes = Mcb->FileAttr;
469 if (IsLinkInvalid(Mcb)) {
471 }
472 if (FATI->FileAttributes == 0) {
474 }
476 Irp->IoStatus.Information = sizeof(FILE_ATTRIBUTE_TAG_INFORMATION);
478 }
479 break;
480#endif // (_WIN32_WINNT >= 0x0500)
481
484 break;
485
486 default:
487 DEBUG(DL_WRN, ( "Ext2QueryInformation: invalid class: %d\n",
489 Status = STATUS_INVALID_PARAMETER; /* STATUS_INVALID_INFO_CLASS; */
490 break;
491 }
492
493 } _SEH2_FINALLY {
494
495 if (FcbResourceAcquired) {
497 }
498
500 if (Status == STATUS_PENDING ||
503 } else {
505 }
506 }
507 } _SEH2_END;
508
509 return Status;
510}
static int Ext2IterateAllEa(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item, BOOL is_last)
Definition: fileinfo.c:38
#define DL_WRN
Definition: ext2fs.h:1447
#define IsLinkInvalid(Mcb)
Definition: ext2fs.h:970
@ FilePositionInformation
Definition: from_kernel.h:75
@ FileAllInformation
Definition: from_kernel.h:79
@ FileInternalInformation
Definition: from_kernel.h:67
@ FileAttributeTagInformation
Definition: from_kernel.h:96
@ FileEaInformation
Definition: from_kernel.h:68
@ FileNameInformation
Definition: from_kernel.h:70
@ FileNetworkOpenInformation
Definition: from_kernel.h:95
@ FileStreamInformation
Definition: from_kernel.h:83
@ FileBasicInformation
Definition: from_kernel.h:65
struct _FILE_NETWORK_OPEN_INFORMATION FILE_NETWORK_OPEN_INFORMATION
struct _FILE_NETWORK_OPEN_INFORMATION * PFILE_NETWORK_OPEN_INFORMATION
struct _FILE_INTERNAL_INFORMATION * PFILE_INTERNAL_INFORMATION
struct _FILE_ATTRIBUTE_TAG_INFORMATION FILE_ATTRIBUTE_TAG_INFORMATION
struct _FILE_ALL_INFORMATION * PFILE_ALL_INFORMATION
struct _FILE_NAME_INFORMATION * PFILE_NAME_INFORMATION
struct _FILE_EA_INFORMATION * PFILE_EA_INFORMATION
struct _FILE_ATTRIBUTE_TAG_INFORMATION * PFILE_ATTRIBUTE_TAG_INFORMATION
struct _FILE_EA_INFORMATION FILE_EA_INFORMATION
struct _FILE_ALL_INFORMATION FILE_ALL_INFORMATION
@ FSI
Definition: bidi.c:98
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3168
struct _FILE_POSITION_INFORMATION FILE_POSITION_INFORMATION
struct _FILE_BASIC_INFORMATION * PFILE_BASIC_INFORMATION
struct _FILE_ALIGNMENT_INFORMATION FILE_ALIGNMENT_INFORMATION
struct _FILE_POSITION_INFORMATION * PFILE_POSITION_INFORMATION
struct _FILE_STANDARD_INFORMATION * PFILE_STANDARD_INFORMATION
struct _FILE_ACCESS_INFORMATION FILE_ACCESS_INFORMATION
#define FileStandardInformation
Definition: propsheet.cpp:61
#define IO_REPARSE_TAG_RESERVED_ZERO
Definition: iotypes.h:7216

Referenced by Ext2DispatchRequest().

◆ Ext2QueryGlobalParameters()

NTSTATUS Ext2QueryGlobalParameters ( IN PUNICODE_STRING  RegistryPath)

Definition at line 199 of file init.c.

200{
202 int i = 0;
204
206
207 /*
208 * 1 writing support
209 */
210 QueryTable[i].Flags = 0;
217 i++;
218
219 /*
220 * 2 checking bitmap
221 */
222 QueryTable[i].Flags = 0;
229 i++;
230
231 /*
232 * 3 force writing
233 */
234 QueryTable[i].Flags = 0;
241 i++;
242
243 /*
244 * 4 automount
245 */
246 QueryTable[i].Flags = 0;
253 i++;
254
255 /*
256 * 5 codepage
257 */
258 QueryTable[i].Flags = 0;
265 i++;
266
267 /*
268 * 6 hidden prefix
269 */
270 QueryTable[i].Flags = 0;
277 i++;
278
279
280 /*
281 * 7 hidden suffix
282 */
283 QueryTable[i].Flags = 0;
290 i++;
291
294 RegistryPath->Buffer,
295 &QueryTable[0],
296 NULL,
297 NULL
298 );
299
300 return NT_SUCCESS(Status);
301}
NTSTATUS Ext2RegistryQueryCallback(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: init.c:115
#define AUTO_MOUNT
Definition: ext2fs.h:152
#define HIDING_PREFIX
Definition: ext2fs.h:150
#define CHECKING_BITMAP
Definition: ext2fs.h:147
#define HIDING_SUFFIX
Definition: ext2fs.h:151
#define CODEPAGE_NAME
Definition: ext2fs.h:149
#define EXT3_FORCEWRITING
Definition: ext2fs.h:148
#define WRITING_SUPPORT
Definition: ext2fs.h:146
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4208
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
#define REG_NONE
Definition: nt_native.h:1492
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
Definition: nt_native.h:109
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215

Referenced by Ext2QueryRegistrySettings().

◆ Ext2QueryRegistrySettings()

BOOLEAN Ext2QueryRegistrySettings ( IN PUNICODE_STRING  RegistryPath)

Definition at line 305 of file init.c.

306{
307 UNICODE_STRING ParameterPath;
308 UNICODE_STRING UniName;
309 ANSI_STRING AnsiName;
310
311 ULONG WritingSupport = 0;
312 ULONG CheckingBitmap = 0;
313 ULONG Ext3ForceWriting = 0;
314 ULONG AutoMount = 0;
315
316 WCHAR UniBuffer[CODEPAGE_MAXLEN];
318
320
321 ParameterPath.Length = 0;
322 ParameterPath.MaximumLength =
323 RegistryPath->Length + sizeof(PARAMETERS_KEY) + sizeof(WCHAR);
324 ParameterPath.Buffer =
326 PagedPool,
327 ParameterPath.MaximumLength,
328 'LG2E'
329 );
330 if (!ParameterPath.Buffer) {
331 DbgBreak();
332 DEBUG(DL_ERR, ( "Ex2QueryParameters: failed to allocate Parameters...\n"));
333 return FALSE;
334 }
335
336 RtlCopyUnicodeString(&ParameterPath, RegistryPath);
338
339 /* enable automount of ext2/3/4 volumes */
341
342 /* query parameter settings from registry */
343 Ext2QueryGlobalParameters(&ParameterPath);
344
345 /* set global codepage settings */
346 if (wcslen(&Ext2Global->Codepage.PageName[0])) {
347 UniName.Length = sizeof(WCHAR) * wcslen(&Ext2Global->Codepage.PageName[0]);
348 UniName.MaximumLength = CODEPAGE_MAXLEN * sizeof(WCHAR);
349 UniName.Buffer = &Ext2Global->Codepage.PageName[0];
351 AnsiName.Length = 0;
352 AnsiName.Buffer = &Ext2Global->Codepage.AnsiName[0];
354 &AnsiName,
355 &UniName,
356 FALSE);
357 if (!NT_SUCCESS(Status)) {
358 DEBUG(DL_ERR, ( "Ext2QueryParameters: Wrong CodePage %wZ ...\n", &UniName));
359 RtlCopyMemory(&(Ext2Global->Codepage.AnsiName[0]),"default\0", 8);
360 }
361 } else {
362 DEBUG(DL_ERR, ( "Ext2QueryParameters: CodePage not specified.\n"));
363 RtlCopyMemory(&(Ext2Global->Codepage.AnsiName[0]),"default\0", 8);
364 }
365 Ext2Global->Codepage.AnsiName[CODEPAGE_MAXLEN - 1] = 0;
366
367
368 /* set global hidden prefix pattern */
369 if (wcslen(&Ext2Global->wHidingPrefix[0])) {
370 UniName.Length = sizeof(WCHAR) * wcslen(&Ext2Global->wHidingPrefix[0]);
371 UniName.MaximumLength = HIDINGPAT_LEN * sizeof(WCHAR);
372 UniName.Buffer = &Ext2Global->wHidingPrefix[0];
373 AnsiName.MaximumLength = HIDINGPAT_LEN;
374 AnsiName.Length = 0;
375 AnsiName.Buffer = &(Ext2Global->sHidingPrefix[0]);
376
378 &AnsiName,
379 &UniName,
380 FALSE);
381 if (NT_SUCCESS(Status)) {
383 } else {
384 DEBUG(DL_ERR, ( "Ext2QueryParameters: Wrong HidingPrefix ...\n"));
385 }
386 } else {
387 DEBUG(DL_ERR, ( "Ext2QueryParameters: HidingPrefix not specified.\n"));
388 }
390
391
392 /* set global hidden suffix pattern */
393 if (wcslen(&Ext2Global->wHidingSuffix[0])) {
394 UniName.Length = sizeof(WCHAR) * wcslen(&Ext2Global->wHidingSuffix[0]);
395 UniName.MaximumLength = HIDINGPAT_LEN * sizeof(WCHAR);
396 UniName.Buffer = &Ext2Global->wHidingSuffix[0];
397 AnsiName.MaximumLength = HIDINGPAT_LEN;
398 AnsiName.Length = 0;
399 AnsiName.Buffer = &(Ext2Global->sHidingSuffix[0]);
400
402 &AnsiName,
403 &UniName,
404 FALSE);
405 if (NT_SUCCESS(Status)) {
407 } else {
408 DEBUG(DL_ERR, ( "Ext2QueryParameters: Wrong HidingSuffix ...\n"));
409 }
410 } else {
411 DEBUG(DL_ERR, ( "Ext2QueryParameters: HidingSuffix not specified.\n"));
412 }
414
415 Ext2Global->RegistryPath.Buffer = ParameterPath.Buffer;
420
421 return TRUE;
422}
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
NTSTATUS Ext2QueryGlobalParameters(IN PUNICODE_STRING RegistryPath)
Definition: init.c:199
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define VOLUMES_KEY
Definition: ext2fs.h:143
#define PARAMETERS_KEY
Definition: ext2fs.h:142
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
USHORT MaximumLength
Definition: env_spec_w32.h:377
UNICODE_STRING RegistryPath
Definition: ext2fs.h:577
WCHAR wHidingSuffix[HIDINGPAT_LEN]
Definition: ext2fs.h:570
WCHAR wHidingPrefix[HIDINGPAT_LEN]
Definition: ext2fs.h:569

Referenced by DriverEntry().

◆ Ext2QueryRetrievalPointers()

NTSTATUS Ext2QueryRetrievalPointers ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 774 of file fsctl.c.

777{
778 PIRP Irp = NULL;
781
784
788
789 PLARGE_INTEGER RequestVbn;
790 PLARGE_INTEGER * pMappedRuns;
791
792 ULONG InputSize;
793 ULONG OutputSize;
794
796
797 BOOLEAN FcbResourceAcquired = FALSE;
798
799 _SEH2_TRY {
800
801 ASSERT(IrpContext);
802 Irp = IrpContext->Irp;
803 ASSERT(Irp);
804
807 ASSERT(IrpSp);
808
809 InputSize = EIrpSp->Parameters.FileSystemControl.InputBufferLength;
810 OutputSize = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
811
812 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
813 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
814
815 DeviceObject = IrpContext->DeviceObject;
816
817 DbgBreak();
818
819 /* This request is not allowed on the main device object */
823 }
824
825 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
826 ASSERT(Vcb != NULL);
827 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
828 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
830
831 FileObject = IrpContext->FileObject;
832 Fcb = (PEXT2_FCB) FileObject->FsContext;
833
834 /* check Fcb is valid or not */
835 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
838 }
839
841 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
842 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
845 }
846
847 Ccb = (PEXT2_CCB) FileObject->FsContext2;
848 if (Ccb == NULL) {
851 }
852
854 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
855
856 /* Is requstor in kernel and Fcb a paging file ? */
857 if (Irp->RequestorMode != KernelMode ||
859 InputSize != sizeof(LARGE_INTEGER) ||
860 OutputSize != sizeof(PVOID)) {
863 }
864
869 }
870 FcbResourceAcquired = TRUE;
871
872 RequestVbn = EIrpSp->Parameters.FileSystemControl.Type3InputBuffer;
873 pMappedRuns = Irp->UserBuffer;
874
875 DbgBreak();
876
877 /* request size beyonds whole file size */
878 if (RequestVbn->QuadPart >= Fcb->Header.AllocationSize.QuadPart) {
881 }
882
884 IrpContext,
885 Vcb,
886 Fcb,
887 RequestVbn,
888 pMappedRuns
889 );
890
891 } _SEH2_FINALLY {
892
893 if (FcbResourceAcquired) {
895 }
896
899 Status = Ext2QueueRequest(IrpContext);
900 } else {
901 Ext2CompleteIrpContext(IrpContext, Status);
902 }
903 }
904 } _SEH2_END;
905
906 return Status;
907}

Referenced by Ext2UserFsRequest().

◆ Ext2QueryVolumeInformation()

NTSTATUS Ext2QueryVolumeInformation ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 27 of file volinfo.c.

28{
31 PIRP Irp = NULL;
32 PIO_STACK_LOCATION IoStackLocation = NULL;
37 BOOLEAN VcbResourceAcquired = FALSE;
38
39 _SEH2_TRY {
40
41 ASSERT(IrpContext != NULL);
42 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
43 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
44
45 DeviceObject = IrpContext->DeviceObject;
46
47 //
48 // This request is not allowed on the main device object
49 //
53 }
54
55 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
56 ASSERT(Vcb != NULL);
57 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
58 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
59
60 if (!IsMounted(Vcb)) {
63 }
64
66 &Vcb->MainResource,
67 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT)
68 )) {
69
72 }
73 VcbResourceAcquired = TRUE;
74
75 Irp = IrpContext->Irp;
76 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
78 IoStackLocation->Parameters.QueryVolume.FsInformationClass;
79
80 Length = IoStackLocation->Parameters.QueryVolume.Length;
81 Buffer = Irp->AssociatedIrp.SystemBuffer;
82
84
85 switch (FsInformationClass) {
86
88 {
90 ULONG VolumeLabelLength;
92
93 if (Length < sizeof(FILE_FS_VOLUME_INFORMATION)) {
96 }
97
99 FsVolInfo->VolumeCreationTime.QuadPart = 0;
100 FsVolInfo->VolumeSerialNumber = Vcb->Vpb->SerialNumber;
101 VolumeLabelLength = Vcb->Vpb->VolumeLabelLength;
102 FsVolInfo->VolumeLabelLength = VolumeLabelLength;
103 /* We don't support ObjectId */
104 FsVolInfo->SupportsObjects = FALSE;
105
107 + VolumeLabelLength - sizeof(WCHAR);
108
109 if (Length < RequiredLength) {
110 Irp->IoStatus.Information =
114 }
115
116 RtlCopyMemory(FsVolInfo->VolumeLabel, Vcb->Vpb->VolumeLabel, Vcb->Vpb->VolumeLabelLength);
117
118 Irp->IoStatus.Information = RequiredLength;
120 }
121 break;
122
124 {
125 PFILE_FS_SIZE_INFORMATION FsSizeInfo;
126
127 if (Length < sizeof(FILE_FS_SIZE_INFORMATION)) {
130 }
131
132 FsSizeInfo = (PFILE_FS_SIZE_INFORMATION) Buffer;
133 FsSizeInfo->TotalAllocationUnits.QuadPart =
137 FsSizeInfo->SectorsPerAllocationUnit =
138 Vcb->BlockSize / Vcb->DiskGeometry.BytesPerSector;
139 FsSizeInfo->BytesPerSector =
140 Vcb->DiskGeometry.BytesPerSector;
141
142 Irp->IoStatus.Information = sizeof(FILE_FS_SIZE_INFORMATION);
144 }
145 break;
146
148 {
150
151 if (Length < sizeof(FILE_FS_DEVICE_INFORMATION)) {
154 }
155
157 FsDevInfo->DeviceType =
158 Vcb->TargetDeviceObject->DeviceType;
159
160 if (FsDevInfo->DeviceType != FILE_DEVICE_DISK) {
161 DbgBreak();
162 }
163
164 FsDevInfo->Characteristics =
165 Vcb->TargetDeviceObject->Characteristics;
166
167 if (IsVcbReadOnly(Vcb)) {
168 SetFlag( FsDevInfo->Characteristics,
170 }
171
172 Irp->IoStatus.Information = sizeof(FILE_FS_DEVICE_INFORMATION);
174 }
175 break;
176
178 {
181
185 }
186
187 FsAttrInfo =
192 if (IsVcbReadOnly(Vcb)) {
194 }
196 FsAttrInfo->FileSystemNameLength = 8;
197
199 8 - sizeof(WCHAR);
200
201 if (Length < RequiredLength) {
202 Irp->IoStatus.Information =
206 }
207
208 if (IsFlagOn(SUPER_BLOCK->s_feature_incompat, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
209 RtlCopyMemory(FsAttrInfo->FileSystemName, L"EXT4\0", 10);
210 } else if (Vcb->IsExt3fs) {
211 RtlCopyMemory(FsAttrInfo->FileSystemName, L"EXT3\0", 10);
212 } else {
213 RtlCopyMemory(FsAttrInfo->FileSystemName, L"EXT2\0", 10);
214 }
215
216 Irp->IoStatus.Information = RequiredLength;
218 }
219 break;
220
221#if (_WIN32_WINNT >= 0x0500)
222
224 {
226
230 }
231
233
234 /*
235 typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
236 LARGE_INTEGER TotalAllocationUnits;
237 LARGE_INTEGER CallerAvailableAllocationUnits;
238 LARGE_INTEGER ActualAvailableAllocationUnits;
239 ULONG SectorsPerAllocationUnit;
240 ULONG BytesPerSector;
241 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
242 */
243
244 {
247
250
251 /* - Vcb->SuperBlock->s_r_blocks_count; */
254 }
255
257 Vcb->BlockSize / Vcb->DiskGeometry.BytesPerSector;
258
259 PFFFSI->BytesPerSector = Vcb->DiskGeometry.BytesPerSector;
260
261 Irp->IoStatus.Information = sizeof(FILE_FS_FULL_SIZE_INFORMATION);
263 }
264 break;
265
266#endif // (_WIN32_WINNT >= 0x0500)
267
268 default:
270 break;
271 }
272
273 } _SEH2_FINALLY {
274
275 if (VcbResourceAcquired) {
276 ExReleaseResourceLite(&Vcb->MainResource);
277 }
278
279 if (!IrpContext->ExceptionInProgress) {
280 if (Status == STATUS_PENDING) {
281 Ext2QueueRequest(IrpContext);
282 } else {
283 Ext2CompleteIrpContext(IrpContext, Status);
284 }
285 }
286 } _SEH2_END;
287
288 return Status;
289}
#define EXT2_NAME_LEN
Definition: ext2.h:156
static ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1745
#define EXT4_FEATURE_INCOMPAT_EXTENTS
Definition: ext3_fs.h:709
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FS_INFORMATION_CLASS FsInformationClass
Definition: fltkernel.h:1330
#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES
Definition: from_kernel.h:250
#define FILE_SUPPORTS_REPARSE_POINTS
Definition: from_kernel.h:240
#define FILE_READ_ONLY_VOLUME
Definition: from_kernel.h:246
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
#define FILE_SUPPORTS_HARD_LINKS
Definition: from_kernel.h:249
@ FileFsDeviceInformation
Definition: from_kernel.h:222
@ FileFsAttributeInformation
Definition: from_kernel.h:223
@ FileFsVolumeInformation
Definition: from_kernel.h:219
@ FileFsSizeInformation
Definition: from_kernel.h:221
struct _FILE_FS_ATTRIBUTE_INFORMATION * PFILE_FS_ATTRIBUTE_INFORMATION
struct _FILE_FS_SIZE_INFORMATION FILE_FS_SIZE_INFORMATION
#define FILE_CASE_SENSITIVE_SEARCH
Definition: from_kernel.h:233
enum _FSINFOCLASS FS_INFORMATION_CLASS
struct _FILE_FS_FULL_SIZE_INFORMATION FILE_FS_FULL_SIZE_INFORMATION
struct _FILE_FS_FULL_SIZE_INFORMATION * PFILE_FS_FULL_SIZE_INFORMATION
#define FILE_CASE_PRESERVED_NAMES
Definition: from_kernel.h:234
struct _FILE_FS_SIZE_INFORMATION * PFILE_FS_SIZE_INFORMATION
struct _FILE_FS_DEVICE_INFORMATION * PFILE_FS_DEVICE_INFORMATION
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
#define FILE_READ_ONLY_DEVICE
Definition: nt_native.h:808
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
#define FILE_DEVICE_DISK
Definition: winioctl.h:113
struct _FILE_FS_VOLUME_INFORMATION * PFILE_FS_VOLUME_INFORMATION
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
LARGE_INTEGER ActualAvailableAllocationUnits
Definition: from_kernel.h:272
LARGE_INTEGER CallerAvailableAllocationUnits
Definition: from_kernel.h:271
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:270
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:263
LARGE_INTEGER AvailableAllocationUnits
Definition: from_kernel.h:264
LARGE_INTEGER VolumeCreationTime
Definition: winioctl.h:408
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:30

Referenced by Ext2DispatchRequest().

◆ Ext2QueueCloseRequest()

VOID Ext2QueueCloseRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 190 of file close.c.

191{
192 ASSERT(IrpContext);
193 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
194 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
195
196 if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_DELAY_CLOSE)) {
197
198 if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_FILE_BUSY)) {
199 Ext2Sleep(500); /* 0.5 sec*/
200 } else {
201 Ext2Sleep(50); /* 0.05 sec*/
202 }
203
204 } else {
205
206 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
207 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_DELAY_CLOSE);
208
209 IrpContext->Fcb = (PEXT2_FCB) IrpContext->FileObject->FsContext;
210 IrpContext->Ccb = (PEXT2_CCB) IrpContext->FileObject->FsContext2;
211 }
212
214 &IrpContext->WorkQueueItem,
216 IrpContext);
217
218 ExQueueWorkItem(&IrpContext->WorkQueueItem, DelayedWorkQueue);
219}
VOID NTAPI Ext2DeQueueCloseRequest(IN PVOID Context)
Definition: close.c:222
#define IRP_CONTEXT_FLAG_FILE_BUSY
Definition: ext2fs.h:1097
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:723
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
@ DelayedWorkQueue
Definition: extypes.h:190

Referenced by Ext2Close().

◆ Ext2QueueRequest()

NTSTATUS Ext2QueueRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 158 of file dispatch.c.

159{
160 ASSERT(IrpContext);
161
162 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
163 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
164
165 /* set the flags of "can wait" and "queued" */
166 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
167 SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_REQUEUED);
168
169 /* make sure the buffer is kept valid in system context */
170 Ext2LockIrp(IrpContext, IrpContext->Irp);
171
172 /* initialize workite*/
174 &IrpContext->WorkQueueItem,
176 IrpContext );
177
178 /* dispatch it */
179 ExQueueWorkItem(&IrpContext->WorkQueueItem, CriticalWorkQueue);
180
181 return STATUS_PENDING;
182}
VOID Ext2LockIrp(IN PVOID Context, IN PIRP Irp)
Definition: dispatch.c:94
VOID Ext2DeQueueRequest(IN PVOID Context)
Definition: dispatch.c:190
@ CriticalWorkQueue
Definition: extypes.h:189

Referenced by Ext2Cleanup(), Ext2Create(), Ext2DeferWrite(), Ext2DeleteReparsePoint(), Ext2ExceptionHandler(), Ext2GetReparsePoint(), Ext2GetRetrievalPointerBase(), Ext2GetRetrievalPointers(), Ext2NotifyChangeDirectory(), Ext2OplockComplete(), Ext2QueryDirectory(), Ext2QueryEa(), Ext2QueryFileInformation(), Ext2QueryRetrievalPointers(), Ext2QueryVolumeInformation(), Ext2ReadFile(), Ext2ReadVolume(), Ext2SetEa(), Ext2SetFileInformation(), Ext2SetReparsePoint(), Ext2SetVolumeInformation(), Ext2ShutDown(), Ext2WriteFile(), and Ext2WriteVolume().

◆ Ext2Read()

NTSTATUS Ext2Read ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 863 of file read.c.

864{
867 PEXT2_FCBVCB FcbOrVcb;
870 BOOLEAN bCompleteRequest;
871
872 ASSERT(IrpContext);
873
874 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
875 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
876
877 _SEH2_TRY {
878
879 if (FlagOn(IrpContext->MinorFunction, IRP_MN_COMPLETE)) {
880
881 Status = Ext2ReadComplete(IrpContext);
882 bCompleteRequest = FALSE;
883
884 } else {
885
886 DeviceObject = IrpContext->DeviceObject;
887
890 bCompleteRequest = TRUE;
892 }
893
894 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
895 if (Vcb->Identifier.Type != EXT2VCB ||
896 Vcb->Identifier.Size != sizeof(EXT2_VCB) ) {
898 bCompleteRequest = TRUE;
899
901 }
902
903 FileObject = IrpContext->FileObject;
904
905 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED) &&
906 Vcb->LockFile != FileObject ) {
908#ifdef __REACTOS__
909 bCompleteRequest = TRUE;
910#endif
912 }
913
914 FcbOrVcb = (PEXT2_FCBVCB) FileObject->FsContext;
915
916 if (FcbOrVcb->Identifier.Type == EXT2VCB) {
917
918 Status = Ext2ReadVolume(IrpContext);
919 bCompleteRequest = FALSE;
920
921 } else if (FcbOrVcb->Identifier.Type == EXT2FCB) {
922
923 if (IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
925 bCompleteRequest = TRUE;
927 }
928
929 Status = Ext2ReadFile(IrpContext);
930 bCompleteRequest = FALSE;
931 } else {
932 DEBUG(DL_ERR, ( "Ext2Read: Inavlid FileObject (Vcb or Fcb corrupted)\n"));
933 DbgBreak();
934
936 bCompleteRequest = TRUE;
937 }
938 }
939
940 } _SEH2_FINALLY {
941 if (bCompleteRequest) {
942 Ext2CompleteIrpContext(IrpContext, Status);
943 }
944 } _SEH2_END;
945
946 return Status;
947}
NTSTATUS Ext2ReadComplete(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: read.c:832
NTSTATUS Ext2ReadFile(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: read.c:471
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
NTSTATUS Ext2ReadVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: read.c:64
#define STATUS_TOO_LATE
Definition: ntstatus.h:626
#define IRP_MN_COMPLETE
Definition: iotypes.h:4420

◆ Ext2ReadDisk()

NTSTATUS Ext2ReadDisk ( IN PEXT2_VCB  Vcb,
IN ULONGLONG  Offset,
IN ULONG  Size,
IN PVOID  Buffer,
IN BOOLEAN  bVerify 
)

Definition at line 559 of file block.c.

565{
567 PUCHAR Buf;
569 ULONGLONG Lba;
570
571 Lba = Offset & (~((ULONGLONG)SECTOR_SIZE - 1));
572 Length = (ULONG)(Size + Offset + SECTOR_SIZE - 1 - Lba) &
573 (~((ULONG)SECTOR_SIZE - 1));
574
576 if (!Buf) {
577 DEBUG(DL_ERR, ( "Ext2ReadDisk: failed to allocate Buffer.\n"));
579
580 goto errorout;
581 }
583
585 Lba,
586 Length,
587 Buf,
588 FALSE );
589
590 if (!NT_SUCCESS(Status)) {
591 DEBUG(DL_ERR, ("Ext2ReadDisk: disk i/o error: %xh.\n", Status));
592 goto errorout;
593 }
594
595 RtlCopyMemory(Buffer, &Buf[Offset - Lba], Size);
596
597errorout:
598
599 if (Buf) {
602 }
603
604 return Status;
605}
NTSTATUS Ext2ReadSync(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Length, OUT PVOID Buffer, BOOLEAN bVerify)
Definition: block.c:480
#define PS_DISK_BUFFER
Definition: common.h:30
#define EXT2_DATA_MAGIC
Definition: ext2fs.h:296

Referenced by ext2_load_inode(), ext2_read_block(), ext2_read_inode(), Ext2LoadSuper(), read_bitmaps(), and zap_sector().

◆ Ext2ReadInode()

NTSTATUS Ext2ReadInode ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONGLONG  Offset,
IN PVOID  Buffer,
IN ULONG  Size,
IN BOOLEAN  bDirectIo,
OUT PULONG  dwReturn 
)

Definition at line 311 of file read.c.

321{
322 PEXT2_EXTENT Chain = NULL;
323 PEXT2_EXTENT Extent = NULL, Prev = NULL;
324
327 ULONG RealSize ;
328
329 if (BytesRead) {
330 *BytesRead = 0;
331 }
332
333 _SEH2_TRY {
334
336
337 ASSERT((Mcb->Identifier.Type == EXT2MCB) &&
338 (Mcb->Identifier.Size == sizeof(EXT2_MCB)));
339
340 if ((Mcb->Identifier.Type != EXT2MCB) ||
341 (Mcb->Identifier.Size != sizeof(EXT2_MCB))) {
343 }
344
345 if (Buffer == NULL && IrpContext != NULL)
346 Buffer = Ext2GetUserBuffer(IrpContext->Irp);
347
348
349 /* handle fast symlinks */
350 if (S_ISLNK(Mcb->Inode.i_mode) && 0 == Mcb->Inode.i_blocks) {
351
352 PUCHAR Data = (PUCHAR) (&Mcb->Inode.i_block[0]);
353 if (!Buffer) {
356 }
357
363 } else {
365 }
367 }
368
369 //
370 // Build the scatterred block ranges to be read
371 //
372
373 if (bDirectIo) {
374 RealSize = CEILING_ALIGNED(ULONG, Size, SECTOR_SIZE - 1);
375 } else {
376 RealSize = Size;
377 }
378
380 IrpContext,
381 Vcb,
382 Mcb,
383 Offset,
384 RealSize,
385 FALSE,
386 &Chain
387 );
388
389 if (!NT_SUCCESS(Status)) {
391 }
392
393 if (Chain == NULL) {
397 }
398
399 /* for sparse file, we need zero the gaps */
400 for (Extent = Chain; Buffer != NULL && Extent != NULL; Extent = Extent->Next) {
401 if (NULL == Prev) {
402 ASSERT(Extent == Chain);
403 if (Extent->Offset) {
405 }
406 } else if (Extent->Offset > (Prev->Offset + Prev->Length)) {
407 SafeZeroMemory((PCHAR)Buffer + Prev->Offset + Prev->Length,
408 Extent->Offset - Prev->Offset - Prev->Length);
409 }
410 if (NULL == Extent->Next) {
411 if (Extent->Offset + Extent->Length < Size) {
413 Size - Extent->Offset - Extent->Length);
414 }
415 }
416 Prev = Extent;
417 }
418
419 if (bDirectIo) {
420
421 ASSERT(IrpContext != NULL);
422
423 // Offset should be SECTOR_SIZE aligned ...
425 IrpContext,
426 Vcb,
427 Chain,
428 Size
429 );
430 } else {
431
432 for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
433
434 if (!CcCopyRead(
435 Vcb->Volume,
436 (PLARGE_INTEGER)(&(Extent->Lba)),
437 Extent->Length,
438 PIN_WAIT,
439 (PVOID)((PUCHAR)Buffer + Extent->Offset),
440 &IoStatus
441 )) {
443 } else {
444 Status = IoStatus.Status;
445 }
446
447 if (!NT_SUCCESS(Status)) {
448 break;
449 }
450 }
451 }
452
453 } _SEH2_FINALLY {
454
455 if (Chain) {
457 }
458
460 } _SEH2_END;
461
462 if (NT_SUCCESS(Status)) {
463 if (BytesRead)
464 *BytesRead = Size;
465 }
466
467 return Status;
468}
NTSTATUS Ext2ReadWriteBlocks(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_EXTENT Extent, IN ULONG Length)
Definition: block.c:260
#define SafeZeroMemory(AT, BYTE_COUNT)
Definition: read.c:301
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by Ext2ReadFile().

◆ Ext2ReadSymlink()

NTSTATUS Ext2ReadSymlink ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN PVOID  Buffer,
IN ULONG  Size,
OUT PULONG  BytesRead 
)

Definition at line 1364 of file fsctl.c.

1372{
1373 return Ext2ReadInode ( IrpContext,
1374 Vcb,
1375 Mcb,
1376 0,
1377 Buffer,
1378 Size,
1379 FALSE,
1380 BytesRead);
1381}

Referenced by Ext2FollowLink(), and Ext2GetReparsePoint().

◆ Ext2ReadSync()

NTSTATUS Ext2ReadSync ( IN PEXT2_VCB  Vcb,
IN ULONGLONG  Offset,
IN ULONG  Length,
OUT PVOID  Buffer,
IN BOOLEAN  bVerify 
)

◆ Ext2ReadWriteBlocks()

NTSTATUS Ext2ReadWriteBlocks ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_EXTENT  Extent,
IN ULONG  Length 
)

Definition at line 260 of file block.c.

266{
267 PIRP Irp;
268 PIRP MasterIrp = IrpContext->Irp;
270 PMDL Mdl;
271 PEXT2_RW_CONTEXT pContext = NULL;
273 KEVENT Wait;
275 BOOLEAN bMasterCompleted = FALSE;
276 BOOLEAN bBugCheck = FALSE;
277
278 ASSERT(MasterIrp);
279
280 _SEH2_TRY {
281
283
284 if (!pContext) {
285 DEBUG(DL_ERR, ( "Ex2ReadWriteBlocks: failed to allocate pContext.\n"));
288 }
289
290 INC_MEM_COUNT(PS_RW_CONTEXT, pContext, sizeof(EXT2_RW_CONTEXT));
291 RtlZeroMemory(pContext, sizeof(EXT2_RW_CONTEXT));
292 pContext->Wait = Ext2CanIWait();
293 pContext->MasterIrp = MasterIrp;
294 pContext->Length = Length;
295
296 if (IrpContext->MajorFunction == IRP_MJ_WRITE) {
298 }
299
300 if (pContext->Wait) {
301
303
304 } else if (IrpContext->Fcb->Identifier.Type == EXT2FCB) {
305
306 if (IsFlagOn(MasterIrp->Flags, IRP_PAGING_IO)) {
307 pContext->Resource = &IrpContext->Fcb->PagingIoResource;
308 } else {
309 pContext->Resource = &IrpContext->Fcb->MainResource;
310 }
311
312 pContext->FileObject = IrpContext->FileObject;
314 }
315
316
317 if (NULL == Chain->Next && 0 == Chain->Offset) {
318
319 /* we get only 1 extent to dispatch, then don't bother allocating new irps */
320
321 /* setup the Stack location to do a read from the disk driver. */
322 IrpSp = IoGetNextIrpStackLocation(MasterIrp);
323 IrpSp->MajorFunction = IrpContext->MajorFunction;
324 IrpSp->Parameters.Read.Length = Chain->Length;
325 IrpSp->Parameters.Read.ByteOffset.QuadPart = Chain->Lba;
326 if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WRITE_THROUGH)) {
328 }
329 if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_VERIFY_READ)) {
331 }
332
334 MasterIrp,
335 Ext2CanIWait() ?
338 (PVOID) pContext,
339 TRUE,
340 TRUE,
341 TRUE );
342
343 /* intialize context block */
344 Chain->Irp = MasterIrp;
345 pContext->Blocks = 1;
346
347 } else {
348
349 for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
350
352 MasterIrp,
353 (CCHAR)(Vcb->TargetDeviceObject->StackSize + 1) );
354
355 if (!Irp) {
358 }
359
360 Mdl = IoAllocateMdl( (PCHAR)MasterIrp->UserBuffer +
361 Extent->Offset,
362 Extent->Length,
363 FALSE,
364 FALSE,
365 Irp );
366
367 if (!Mdl) {
370 }
371
372 IoBuildPartialMdl( MasterIrp->MdlAddress,
373 Mdl,
374 (PCHAR)MasterIrp->UserBuffer+Extent->Offset,
375 Extent->Length );
376
379
380 IrpSp->MajorFunction = IrpContext->MajorFunction;
381 IrpSp->Parameters.Read.Length = Extent->Length;
382 IrpSp->Parameters.Read.ByteOffset.QuadPart = Extent->Lba;
383
385 Irp,
386 Ext2CanIWait() ?
389 (PVOID) pContext,
390 TRUE,
391 TRUE,
392 TRUE );
393
395
396 IrpSp->MajorFunction = IrpContext->MajorFunction;
397 IrpSp->Parameters.Read.Length =Extent->Length;
398 IrpSp->Parameters.Read.ByteOffset.QuadPart = Extent->Lba;
399
400 /* set write through flag */
401 if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WRITE_THROUGH)) {
403 }
404
405 /* set verify flag */
406 if (IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_VERIFY_READ)) {
408 }
409
410 Extent->Irp = Irp;
411 pContext->Blocks += 1;
412 }
413
414 MasterIrp->AssociatedIrp.IrpCount = pContext->Blocks;
415 if (Ext2CanIWait()) {
416 MasterIrp->AssociatedIrp.IrpCount += 1;
417 }
418 }
419 if (!Ext2CanIWait()) {
420 /* mark MasterIrp pending */
421 IoMarkIrpPending(pContext->MasterIrp);
422 }
423
424 bBugCheck = TRUE;
425
426 for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
427 Status = IoCallDriver ( Vcb->TargetDeviceObject,
428 Extent->Irp);
429 Extent->Irp = NULL;
430 }
431
432 if (Ext2CanIWait()) {
433 KeWaitForSingleObject( &(pContext->Event),
435 KeClearEvent( &(pContext->Event) );
436 } else {
437 bMasterCompleted = TRUE;
438 }
439
440 } _SEH2_FINALLY {
441
442 for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
443 if (Extent->Irp != NULL ) {
444 if (Extent->Irp->MdlAddress != NULL) {
445 IoFreeMdl(Extent->Irp->MdlAddress );
446 }
447 IoFreeIrp(Extent->Irp);
448 }
449 }
450
451 if (IrpContext->ExceptionInProgress) {
452
453 if (bBugCheck) {
455 }
456
457 } else {
458
459 if (Ext2CanIWait()) {
460 if (MasterIrp) {
461 Status = MasterIrp->IoStatus.Status;
462 }
463 if (pContext) {
464 Ext2FreePool(pContext, EXT2_RWC_MAGIC);
465 DEC_MEM_COUNT(PS_RW_CONTEXT, pContext, sizeof(EXT2_RW_CONTEXT));
466 }
467 } else {
468 if (bMasterCompleted) {
469 IrpContext->Irp = NULL;
471 }
472 }
473 }
474 } _SEH2_END;
475
476 return Status;
477}
NTSTATUS Ext2ReadWriteBlockSyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: block.c:168
NTSTATUS Ext2ReadWriteBlockAsyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: block.c:205
#define PS_RW_CONTEXT
Definition: common.h:22
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define EXT2_RW_CONTEXT_WRITE
Definition: ext2fs.h:3215
#define EXT2_RWC_MAGIC
Definition: ext2fs.h:306
#define EXT2_BUGCHK_BLOCK
Definition: ext2fs.h:314
VOID NTAPI IoBuildPartialMdl(IN PMDL SourceMdl, IN PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
Definition: iomdl.c:96
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
PIRP NTAPI IoMakeAssociatedIrp(IN PIRP Irp, IN CCHAR StackSize)
Definition: irp.c:1925
PERESOURCE Resource
Definition: ext2fs.h:3207
KEVENT Event
Definition: ext2fs.h:3204
BOOLEAN Wait
Definition: ext2fs.h:3211
ERESOURCE_THREAD ThreadId
Definition: ext2fs.h:3208
PFILE_OBJECT FileObject
Definition: ext2fs.h:3209
IO_STATUS_BLOCK IoStatus
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2680

Referenced by Ext2ReadInode(), Ext2ReadVolume(), Ext2WriteInode(), and Ext2WriteVolume().

◆ Ext2ReaperThread()

VOID Ext2ReaperThread ( PVOID  Context)

◆ Ext2RecoverJournal()

INT Ext2RecoverJournal ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

Definition at line 95 of file recover.c.

99{
100 INT rc = 0;
101 ULONG jNo = 0;
102 PEXT2_MCB jcb = NULL;
103 struct block_device * bd = &Vcb->bd;
104#ifndef __REACTOS__
105 struct super_block * sb = &Vcb->sb;
106#endif
107 struct inode * ji = NULL;
108 journal_t * journal = NULL;
109 struct ext3_super_block *esb;
110
111 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
112
113 /* check journal inode number */
114 if (!Ext2CheckJournal(Vcb, &jNo)) {
115 rc = -1;
116 goto errorout;
117 }
118
119 /* allocate journal Mcb */
120 jcb = Ext2LoadInternalJournal(Vcb, jNo);
121 if (!jcb) {
122 rc = -6;
123 goto errorout;
124 }
125
126 /* allocate journal inode */
127 ji = &jcb->Inode;
128
129 /* initialize journal file from inode */
130 journal = journal_init_inode(ji);
131
132 /* initialzation succeeds ? */
133 if (!journal) {
134 iput(ji);
135 rc = -8;
136 goto errorout;
137 }
138
139 /* start journal recovery */
140 rc = journal_load(journal);
141 if (0 != rc) {
142 rc = -9;
143 DbgPrint("Ext2Fsd: recover_journal: failed "
144 "to recover journal data.\n");
145 }
146
147 /* reload super_block and group_description */
148 Ext2RefreshSuper(IrpContext, Vcb);
149 Ext2RefreshGroup(IrpContext, Vcb);
150
151 /* wipe journal data and clear recover flag in sb */
152 if (rc == 0) {
153 journal_wipe_recovery(journal);
155 Vcb->SuperBlock->s_feature_incompat,
157 Ext2SaveSuper(IrpContext, Vcb);
158 sync_blockdev(bd);
160 }
161
162errorout:
163
164 /* destroy journal structure */
165 if (journal) {
166 journal_destroy(journal);
167 }
168
169 /* destory journal Mcb */
170 if (jcb) {
171 Ext2FreeMcb(Vcb, jcb);
172 }
173
174 ExReleaseResourceLite(&Vcb->MainResource);
175
176 return rc;
177}
void iput(struct inode *inode)
Definition: linux.c:992
INT Ext2CheckJournal(PEXT2_VCB Vcb, PULONG jNo)
Definition: recover.c:55
PEXT2_MCB Ext2LoadInternalJournal(PEXT2_VCB Vcb, ULONG jNo)
Definition: recover.c:29
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:67
BOOLEAN Ext2RefreshGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:409
BOOLEAN Ext2RefreshSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:92
int sync_blockdev(struct block_device *bdev)
Definition: linux.c:919
int journal_load(journal_t *journal)
Definition: replay.c:1121
journal_t * journal_init_inode(struct inode *inode)
Definition: replay.c:592
void journal_wipe_recovery(journal_t *journal)
Definition: replay.c:659
void journal_destroy(journal_t *journal)
Definition: replay.c:678
int32_t INT
Definition: typedefs.h:58

Referenced by Ext2InitializeVcb(), and Ext2ProcessVolumeProperty().

◆ Ext2RefreshGroup()

BOOLEAN Ext2RefreshGroup ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 409 of file generic.c.

413{
414 return TRUE;
415}

Referenced by Ext2RecoverJournal().

◆ Ext2RefreshSuper()

BOOLEAN Ext2RefreshSuper ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 92 of file generic.c.

96{
99
101 if (!CcCopyRead(
102 Vcb->Volume,
105 TRUE,
106 (PVOID)Vcb->SuperBlock,
107 &iosb )) {
108 return FALSE;
109 }
110
111 if (!NT_SUCCESS(iosb.Status)) {
112 return FALSE;
113 }
114
115 /* reload root inode */
116 if (Vcb->McbTree) {
117
118 if (!Ext2LoadInode(Vcb, &Vcb->McbTree->Inode))
119 return FALSE;
120
121 /* initializeroot node */
122 Vcb->McbTree->CreationTime = Ext2NtTime(Vcb->McbTree->Inode.i_ctime);
123 Vcb->McbTree->LastAccessTime = Ext2NtTime(Vcb->McbTree->Inode.i_atime);
124 Vcb->McbTree->LastWriteTime = Ext2NtTime(Vcb->McbTree->Inode.i_mtime);
125 Vcb->McbTree->ChangeTime = Ext2NtTime(Vcb->McbTree->Inode.i_mtime);
126 }
127
128 return TRUE;
129}
BOOLEAN Ext2LoadInode(IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:508
static PIO_STATUS_BLOCK iosb
Definition: file.c:98

Referenced by Ext2RecoverJournal().

◆ Ext2ReleaseFcb()

VOID Ext2ReleaseFcb ( IN PEXT2_FCB  Fcb)

Definition at line 276 of file memory.c.

277{
278 PEXT2_VCB Vcb = Fcb->Vcb;
280
281 if (0 != Ext2DerefXcb(&Fcb->ReferenceCount))
282 return;
283
286
287 Mcb = Fcb->Mcb;
288 RemoveEntryList(&Fcb->Next);
289
291 NULL == Mcb || IsFileDeleted(Mcb)) {
292 InsertHeadList(&Vcb->FcbList, &Fcb->Next);
293 Fcb->TsDrop.QuadPart = 0;
294 } else {
295 InsertTailList(&Vcb->FcbList, &Fcb->Next);
296 KeQuerySystemTime(&Fcb->TsDrop);
297 }
299 ExReleaseResourceLite(&Vcb->FcbLock);
300
301 if ((Vcb->FcbCount >> 6) > (ULONG)(Ext2Global->MaxDepth)) {
303 }
304}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
EXT2_REAPER FcbReaper
Definition: ext2fs.h:548

Referenced by Ext2CreateFile(), Ext2DeleteFile(), Ext2DeleteReparsePoint(), Ext2SetLinkInfo(), Ext2SetRenameInfo(), and Ext2SetReparsePoint().

◆ Ext2ReleaseFileForCcFlush()

NTSTATUS Ext2ReleaseFileForCcFlush ( IN PFILE_OBJECT  FileObject,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 1156 of file fastio.c.

1160{
1161 PEXT2_FCB Fcb = FileObject->FsContext;
1162
1163 DEBUG(FASTIO_DEBUG_LEVEL, ("Ext2ReleaseFileForCcFlush: Fcb=%p\n", Fcb));
1164
1165 if (Fcb->Header.Resource != NULL) {
1166 ExReleaseResourceLite(Fcb->Header.Resource);
1167 }
1168
1169 return STATUS_SUCCESS;
1170}

Referenced by DriverEntry().

◆ Ext2ReleaseFileForModWrite()

NTSTATUS Ext2ReleaseFileForModWrite ( IN PFILE_OBJECT  FileObject,
IN PERESOURCE  ResourceToRelease,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 1110 of file fastio.c.

1115{
1116 PEXT2_FCB Fcb = FileObject->FsContext;
1117
1118 DEBUG(FASTIO_DEBUG_LEVEL, ("Ext2ReleaseFileForModWrite: Fcb=%p\n", Fcb));
1119
1120 if (ResourceToRelease != NULL) {
1121 ASSERT(ResourceToRelease == Fcb->Header.Resource);
1123 } else {
1124 DbgBreak();
1125 }
1126
1127 return STATUS_SUCCESS;
1128}

Referenced by DriverEntry().

◆ Ext2ReleaseForCreateSection()

VOID Ext2ReleaseForCreateSection ( IN PFILE_OBJECT  FileObject)

Definition at line 1062 of file fastio.c.

1065{
1066 PEXT2_FCB Fcb = FileObject->FsContext;
1067
1068 DEBUG(FASTIO_DEBUG_LEVEL, ("Ext2ReleaseForCreateSection: Fcb=%p\n", Fcb));
1069
1070 if (Fcb->Header.Resource != NULL) {
1071 ExReleaseResourceLite(Fcb->Header.Resource);
1072 }
1073}

Referenced by DriverEntry().

◆ Ext2ReleaseFromLazyWrite()

VOID Ext2ReleaseFromLazyWrite ( IN PVOID  Context)

Definition at line 63 of file cmcb.c.

64{
65 //
66 // On a readonly filesystem this function still has to exist but it
67 // doesn't need to do anything.
69
70 ASSERT(Fcb != NULL);
71
73 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
74#if EXT2_DEBUG
75 DEBUG(CMCB_DEBUG_LEVEL, ( "Ext2ReleaseFromLazyWrite: %s %s Fcb=%p\n",
76 Ext2GetCurrentProcessName(), "RELEASE_FROM_LAZY_WRITE", Fcb));
77#endif
78 ASSERT(Fcb->LazyWriterThread == PsGetCurrentThread());
79 Fcb->LazyWriterThread = NULL;
80
82
85}

Referenced by DriverEntry().

◆ Ext2ReleaseFromReadAhead()

VOID Ext2ReleaseFromReadAhead ( IN PVOID  Context)

Definition at line 117 of file cmcb.c.

118{
120
121 ASSERT(Fcb != NULL);
122
124 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
125
126 DEBUG(CMCB_DEBUG_LEVEL, ("Ext2ReleaseFromReadAhead: i=%xh Fcb=%p\n",
127 Fcb->Mcb->Inode.i_ino, Fcb));
128
131}

Referenced by DriverEntry().

◆ Ext2RemoveBlockExtent()

BOOLEAN Ext2RemoveBlockExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Start,
IN ULONG  Number 
)

Definition at line 1097 of file memory.c.

1103{
1104 LONGLONG Vbn = 0;
1105 LONGLONG Length = 0;
1106 BOOLEAN rc;
1107
1108 Vbn = ((LONGLONG) Start) << BLOCK_BITS;
1110
1111 if (Mcb) {
1113 } else {
1115 }
1116
1117 return rc;
1118}
BOOLEAN Ext2RemoveMcbExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Length)
Definition: memory.c:848
BOOLEAN Ext2RemoveVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
Definition: memory.c:700

Referenced by Ext2FreeBlock(), Ext2NewBlock(), Ext2TruncateBlock(), and Ext2TruncateExtent().

◆ Ext2RemoveEntry()

NTSTATUS Ext2RemoveEntry ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Dcb,
IN PEXT2_MCB  Mcb 
)

Definition at line 2021 of file generic.c.

2027{
2028 struct inode *dir = Dcb->Inode;
2029 struct buffer_head *bh = NULL;
2030 struct ext3_dir_entry_2 *de;
2031 struct inode *inode;
2032 int rc = -ENOENT;
2034 BOOLEAN MainResourceAcquired = FALSE;
2035
2036 if (!IsDirectory(Dcb)) {
2038 }
2039
2040 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
2041 MainResourceAcquired = TRUE;
2042
2043 _SEH2_TRY {
2044
2045 Ext2ReferXcb(&Dcb->ReferenceCount);
2046
2047 bh = ext3_find_entry(IrpContext, Mcb->de, &de);
2048 if (!bh)
2050
2051 inode = &Mcb->Inode;
2052 if (le32_to_cpu(de->inode) != inode->i_ino)
2054
2055 if (!inode->i_nlink) {
2056 ext3_warning (inode->i_sb, "ext3_unlink",
2057 "Deleting nonexistent file (%lu), %d",
2059 inode->i_nlink = 1;
2060 }
2061 rc = ext3_delete_entry(IrpContext, dir, de, bh);
2062 if (rc) {
2063 Status = Ext2WinntError(rc);
2065 }
2066 /*
2067 if (!inode->i_nlink)
2068 ext3_orphan_add(handle, inode);
2069 */
2070 inode->i_ctime = dir->i_ctime = dir->i_mtime = ext3_current_time(dir);
2072 ext3_mark_inode_dirty(IrpContext, inode);
2073
2074 /* decrease dir inode's nlink for .. */
2075 if (S_ISDIR(inode->i_mode)) {
2078 ext3_mark_inode_dirty(IrpContext, dir);
2079 }
2080
2082
2083 } _SEH2_FINALLY {
2084
2085 Ext2DerefXcb(&Dcb->ReferenceCount);
2086
2087 if (MainResourceAcquired)
2088 ExReleaseResourceLite(&Dcb->MainResource);
2089
2090 if (bh)
2091 brelse(bh);
2092 } _SEH2_END;
2093
2094 return Status;
2095}
#define ENOENT
Definition: acclib.h:79
__u32 ext3_current_time(struct inode *in)
Definition: htree.c:204
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
struct buffer_head * ext3_find_entry(struct ext2_icb *icb, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir)
Definition: htree.c:2166
void ext3_warning(struct super_block *sb, const char *function, char *fmt,...)
Definition: htree.c:212
void ext3_dec_count(struct inode *inode)
Definition: htree.c:312
int ext3_delete_entry(struct ext2_icb *icb, struct inode *dir, struct ext3_dir_entry_2 *de_del, struct buffer_head *bh)
Definition: htree.c:2005
void ext3_update_dx_flag(struct inode *inode)
Definition: htree.c:368
__u16 i_nlink
Definition: fs.h:91

Referenced by Ext2DeleteFile(), and Ext2SetRenameInfo().

◆ Ext2RemoveMcb()

BOOLEAN Ext2RemoveMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb 
)

Definition at line 1746 of file memory.c.

1750{
1751 PEXT2_MCB TmpMcb = NULL;
1752 BOOLEAN LockAcquired = FALSE;
1753 BOOLEAN bLinked = FALSE;
1754
1755 _SEH2_TRY {
1756
1758 LockAcquired = TRUE;
1759
1760 if (Mcb->Parent) {
1761
1762 if (Mcb->Parent->Child == Mcb) {
1763 Mcb->Parent->Child = Mcb->Next;
1764 bLinked = TRUE;
1765 } else {
1766 TmpMcb = Mcb->Parent->Child;
1767
1768 while (TmpMcb && TmpMcb->Next != Mcb) {
1769 TmpMcb = TmpMcb->Next;
1770 }
1771
1772 if (TmpMcb) {
1773 TmpMcb->Next = Mcb->Next;
1774 bLinked = TRUE;
1775 } else {
1776 /* we got errors: link broken */
1777 }
1778 }
1779
1780 if (bLinked) {
1781 if (IsFlagOn(Mcb->Flags, MCB_ENTRY_TREE)) {
1782 DEBUG(DL_RES, ("Mcb %p %wZ removed from Mcb %p %wZ\n", Mcb,
1783 &Mcb->FullName, Mcb->Parent, &Mcb->Parent->FullName));
1784 Ext2DerefMcb(Mcb->Parent);
1786 } else {
1787 DbgBreak();
1788 }
1789 } else {
1790 if (IsFlagOn(Mcb->Flags, MCB_ENTRY_TREE)) {
1792 }
1793 DbgBreak();
1794 }
1795 Mcb->Parent = NULL;
1796 Mcb->de->d_parent = NULL;
1797 }
1798
1799 } _SEH2_FINALLY {
1800
1801 if (LockAcquired) {
1802 ExReleaseResourceLite(&Vcb->McbLock);
1803 }
1804 } _SEH2_END;
1805
1806 return TRUE;
1807}

Referenced by Ext2DeleteFile(), Ext2FirstUnusedMcb(), Ext2SetRenameInfo(), and Ext2UnlinkFcb().

◆ Ext2RemoveMcbExtent()

BOOLEAN Ext2RemoveMcbExtent ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN LONGLONG  Vbn,
IN LONGLONG  Length 
)

Definition at line 848 of file memory.c.

854{
855 ULONG TriedTimes = 0;
856 LONGLONG Base = 0;
857 UCHAR Bits = 0;
858 BOOLEAN rc = TRUE;
859
861 Bits = (UCHAR)BLOCK_BITS;
862
863 ASSERT ((Vbn & (Base - 1)) == 0);
864 ASSERT ((Length & (Base - 1)) == 0);
865
866 Vbn = (Vbn >> Bits) + 1;
867 Length = (Length >> Bits);
868
869Again:
870
871 _SEH2_TRY {
873 &Mcb->Extents,
874 Vbn,
875 Length
876 );
878 DbgBreak();
879 rc = FALSE;
880 } _SEH2_END;
881
882 if (!rc && ++TriedTimes < 10) {
883 Ext2Sleep(TriedTimes * 100);
884 goto Again;
885 }
886
887 DEBUG(DL_EXT, ("Ext2RemoveMcbExtent: Vbn=%I64xh Length=%I64xh Runs=%u\n",
889 if (rc) {
890 Ext2CheckExtent(&Mcb->Extents, Vbn, 0, Length, FALSE);
891 }
892
893 return rc;
894}
VOID NTAPI FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG SectorCount)
Definition: largemcb.c:905

Referenced by Ext2RemoveBlockExtent().

◆ Ext2RemoveMcbMetaExts()

BOOLEAN Ext2RemoveMcbMetaExts ( IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Block,
IN ULONG  Length 
)

Definition at line 985 of file memory.c.

991{
992 ULONG TriedTimes = 0;
993 LONGLONG Lbn = Block + 1;
994 BOOLEAN rc = TRUE;
995
996Again:
997
998 _SEH2_TRY {
999
1001 &Mcb->MetaExts,
1002 Lbn,
1003 Length
1004 );
1005
1007 DbgBreak();
1008 rc = FALSE;
1009 } _SEH2_END;
1010
1011 if (!rc && ++TriedTimes < 10) {
1012 Ext2Sleep(TriedTimes * 100);
1013 goto Again;
1014 }
1015
1016 DEBUG(DL_EXT, ("Ext2RemoveMcbMetaExts: Block: %xh-%xhh Runs=%u\n", Block,
1017 Length, FsRtlNumberOfRunsInLargeMcb(&Mcb->MetaExts)));
1018 if (rc) {
1019 Ext2CheckExtent(&Mcb->MetaExts, Lbn, 0, Length, FALSE);
1020 }
1021
1022 return rc;
1023}

Referenced by Ext2TruncateBlock().

◆ Ext2RemoveVcb()

VOID Ext2RemoveVcb ( PEXT2_VCB  Vcb)

Definition at line 1943 of file memory.c.

1944{
1945 RemoveEntryList(&Vcb->Next);
1946 InitializeListHead(&Vcb->Next);
1947}

Referenced by Ext2CheckDismount().

◆ Ext2RemoveVcbExtent()

BOOLEAN Ext2RemoveVcbExtent ( IN PEXT2_VCB  Vcb,
IN LONGLONG  Vbn,
IN LONGLONG  Length 
)

Definition at line 700 of file memory.c.

705{
706 ULONG TriedTimes = 0;
707 LONGLONG Offset = 0;
708 BOOLEAN rc = TRUE;
709
710 Offset = Vbn & (~(Vcb->IoUnitSize - 1));
711 Length = (Length + Vbn - Offset + Vcb->IoUnitSize - 1) & (~(Vcb->IoUnitSize - 1));
712
713 ASSERT ((Offset & (Vcb->IoUnitSize - 1)) == 0);
714 ASSERT ((Length & (Vcb->IoUnitSize - 1)) == 0);
715
716 Offset = (Offset >> Vcb->IoUnitBits) + 1;
717 Length = (Length >> Vcb->IoUnitBits);
718
719Again:
720
721 _SEH2_TRY {
723 &Vcb->Extents,
724 Offset,
725 Length
726 );
728 DbgBreak();
729 rc = FALSE;
730 } _SEH2_END;
731
732 if (!rc && ++TriedTimes < 10) {
733 Ext2Sleep(TriedTimes * 100);
734 goto Again;
735 }
736
737 DEBUG(DL_EXT, ("Ext2RemoveVcbExtent: Vbn=%I64xh Length=%I64xh Runs=%u\n",
739 if (rc) {
740 Ext2CheckExtent(&Vcb->Extents, Offset, 0, Length, FALSE);
741 }
742
743 return rc;
744}

Referenced by Ext2RemoveBlockExtent(), and Ext2WriteVolume().

◆ Ext2SaveBlock()

BOOLEAN Ext2SaveBlock ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  dwBlk,
IN PVOID  Buf 
)

Definition at line 698 of file generic.c.

702{
703 struct buffer_head *bh = NULL;
704 BOOLEAN rc = 0;
705
706 _SEH2_TRY {
707
708 bh = sb_getblk_zero(&Vcb->sb, (sector_t)Index);
709
710 if (!bh) {
711 DEBUG(DL_ERR, ("Ext2Saveblock: can't load block %u\n", Index));
712 DbgBreak();
714 }
715
716 if (!buffer_uptodate(bh)) {
717 }
718
721 rc = TRUE;
722
723 } _SEH2_FINALLY {
724
725 if (bh)
726 fini_bh(&bh);
727 } _SEH2_END;
728
729 return rc;
730}

Referenced by Ext2ExpandBlock(), and Ext2ExpandLast().

◆ Ext2SaveBuffer()

BOOLEAN Ext2SaveBuffer ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN LONGLONG  Offset,
IN ULONG  Size,
IN PVOID  Buf 
)

Definition at line 928 of file generic.c.

933{
934 struct buffer_head *bh = NULL;
935 BOOLEAN rc = 0;
936
937 __try {
938
939 while (size) {
940
942 ULONG len = 0, delta = 0;
943
945 delta = (ULONG)offset & (BLOCK_SIZE - 1);
946 len = BLOCK_SIZE - delta;
947 if (size < len)
948 len = size;
949
950 if (delta == 0 && len >= BLOCK_SIZE) {
951 bh = sb_getblk_zero(&Vcb->sb, block);
952 } else {
953 bh = sb_getblk(&Vcb->sb, block);
954 }
955
956 if (!bh) {
957 DEBUG(DL_ERR, ("Ext2SaveBuffer: can't load block %I64u\n", block));
958 DbgBreak();
959 __leave;
960 }
961
962 if (!buffer_uptodate(bh)) {
963 int err = bh_submit_read(bh);
964 if (err < 0) {
965 DEBUG(DL_ERR, ("Ext2SaveBuffer: bh_submit_read failed: %d\n", err));
966 __leave;
967 }
968 }
969
970 __try {
971 RtlCopyMemory(bh->b_data + delta, buf, len);
973 } __finally {
974 fini_bh(&bh);
975 }
976
977 buf = (PUCHAR)buf + len;
978 offset = offset + len;
979 size = size - len;
980 }
981
982 rc = TRUE;
983
984 } __finally {
985
986 if (bh)
987 fini_bh(&bh);
988
989 }
990
991 return rc;
992}

Referenced by Ext2SaveInode(), Ext2SaveInodeXattr(), Ext2SaveSuper(), and Ext2WriteInode().

◆ Ext2SaveGroup()

BOOLEAN Ext2SaveGroup ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  Group 
)

Definition at line 386 of file generic.c.

391{
392 struct ext4_group_desc *gd;
393 struct buffer_head *gb = NULL;
394 unsigned long i;
395
396 gd = ext4_get_group_desc(&Vcb->sb, Group, &gb);
397 if (!gd)
398 return 0;
399
400 gd->bg_checksum = ext4_group_desc_csum(&Vcb->sbi, Group, gd);
402 fini_bh(&gb);
403
404 return TRUE;
405}
__le16 bg_checksum
Definition: ext3_fs.h:145

Referenced by Ext2FreeBlock(), Ext2FreeInode(), Ext2NewBlock(), Ext2NewInode(), and Ext2UpdateGroupDirStat().

◆ Ext2SaveInode()

BOOLEAN Ext2SaveInode ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN struct inode Inode 
)

Definition at line 552 of file generic.c.

555{
556 struct ext3_inode ext3i = {0};
557
558 LONGLONG Offset = 0;
559 ULONG InodeSize = sizeof(ext3i);
560 BOOLEAN rc = 0;
561
562 DEBUG(DL_INF, ( "Ext2SaveInode: Saving Inode %xh: Mode=%xh Size=%xh\n",
563 Inode->i_ino, Inode->i_mode, Inode->i_size));
564 rc = Ext2GetInodeLba(Vcb, Inode->i_ino, &Offset);
565 if (!rc) {
566 DEBUG(DL_ERR, ( "Ext2SaveInode: failed inode %u.\n", Inode->i_ino));
567 goto errorout;
568 }
569
570 rc = Ext2LoadBuffer(NULL, Vcb, Offset, InodeSize, &ext3i);
571 if (!rc) {
572 DEBUG(DL_ERR, ( "Ext2SaveInode: failed reading inode %u.\n", Inode->i_ino));
573 goto errorout;;
574 }
575
576 Ext2EncodeInode(&ext3i, Inode);
577 if (InodeSize > Vcb->InodeSize)
578 InodeSize = Vcb->InodeSize;
579 rc = Ext2SaveBuffer(IrpContext, Vcb, Offset, InodeSize, &ext3i);
580
581 if (rc && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
583 }
584
585errorout:
586 return rc;
587}
VOID Ext2StartFloppyFlushDpc(PEXT2_VCB Vcb, PEXT2_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:139
BOOLEAN Ext2SaveBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:928

Referenced by Ext2Cleanup(), Ext2CreateInode(), Ext2DeleteFile(), Ext2DoExtentExpand(), Ext2ExpandExtent(), Ext2ExpandIndirect(), Ext2FlushFile(), Ext2GetBlock(), Ext2MapExtent(), Ext2MapIndirect(), Ext2SetFileInformation(), Ext2SetReparsePoint(), Ext2SupersedeOrOverWriteFile(), Ext2TruncateExtent(), Ext2TruncateIndirect(), Ext2TruncateSymlink(), Ext2WriteFile(), Ext2WriteSymlink(), ext3_append(), ext3_mark_inode_dirty(), and ext4_fs_put_xattr_ref().

◆ Ext2SaveInodeXattr()

BOOLEAN Ext2SaveInodeXattr ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN struct inode Inode,
IN PEXT2_INODE  InodeXattr 
)

Definition at line 621 of file generic.c.

625{
627 LONGLONG Offset = 0;
628 ULONG InodeSize = Vcb->InodeSize;
629 BOOLEAN rc = 0;
630
631 /* There is no way to put EA information in such a small inode */
632 if (InodeSize == EXT2_GOOD_OLD_INODE_SIZE)
633 return FALSE;
634
635 DEBUG(DL_INF, ("Ext2SaveInodeXattr: Saving Inode %xh: Mode=%xh Size=%xh\n",
636 Inode->i_ino, Inode->i_mode, Inode->i_size));
637 rc = Ext2GetInodeLba(Vcb, Inode->i_ino, &Offset);
638 if (!rc) {
639 DEBUG(DL_ERR, ("Ext2SaveInodeXattr: error get inode(%xh)'s addr.\n", Inode->i_ino));
640 goto errorout;
641 }
642
643 rc = Ext2SaveBuffer(IrpContext,
644 Vcb,
645 Offset + EXT2_GOOD_OLD_INODE_SIZE + Inode->i_extra_isize,
646 InodeSize - EXT2_GOOD_OLD_INODE_SIZE - Inode->i_extra_isize,
647 (char *)InodeXattr + EXT2_GOOD_OLD_INODE_SIZE + Inode->i_extra_isize);
648
649 if (rc && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
651 }
652
653errorout:
654 return rc;
655}
#define EXT2_GOOD_OLD_INODE_SIZE
Definition: ext2.h:54

Referenced by ext4_fs_put_xattr_ref().

◆ Ext2SaveSuper()

BOOLEAN Ext2SaveSuper ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 67 of file generic.c.

71{
73 BOOLEAN rc;
74
76 rc = Ext2SaveBuffer( IrpContext,
77 Vcb,
78 offset,
80 Vcb->SuperBlock
81 );
82
83 if (IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
85 }
86
87 return rc;
88}

Referenced by Ext2RecoverJournal(), Ext2SetFileInformation(), Ext2SetVolumeInformation(), Ext2ShutDown(), Ext2UpdateVcbStat(), Ext2WriteFile(), and ext3_inode_blocks_set().

◆ Ext2ScanDir()

NTSTATUS Ext2ScanDir ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Parent,
IN PUNICODE_STRING  FileName,
OUT PULONG  Inode,
struct dentry **  dentry 
)

◆ Ext2SearchMcb()

PEXT2_MCB Ext2SearchMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Parent,
PUNICODE_STRING  FileName 
)

Definition at line 1598 of file memory.c.

1603{
1604 BOOLEAN LockAcquired = FALSE;
1605 PEXT2_MCB Mcb = NULL;
1606
1607 _SEH2_TRY {
1609 LockAcquired = TRUE;
1611 } _SEH2_FINALLY {
1612 if (LockAcquired) {
1613 ExReleaseResourceLite(&Vcb->McbLock);
1614 }
1615 } _SEH2_END;
1616
1617 return Mcb;
1618}
PEXT2_MCB Ext2SearchMcbWithoutLock(PEXT2_MCB Parent, PUNICODE_STRING FileName)
Definition: memory.c:1622

Referenced by Ext2ProcessEntry().

◆ Ext2SearchMcbWithoutLock()

PEXT2_MCB Ext2SearchMcbWithoutLock ( PEXT2_MCB  Parent,
PUNICODE_STRING  FileName 
)

Definition at line 1622 of file memory.c.

1626{
1627 PEXT2_MCB TmpMcb = NULL;
1628
1629 DEBUG(DL_RES, ("Ext2SearchMcb: %wZ\n", FileName));
1630
1631 _SEH2_TRY {
1632
1634
1635 if (Ext2IsDot(FileName)) {
1636 TmpMcb = Parent;
1639 }
1640
1641 if (Ext2IsDotDot(FileName)) {
1642 if (IsMcbRoot(Parent)) {
1643 TmpMcb = Parent;
1644 } else {
1645 TmpMcb = Parent->Parent;
1646 }
1647 if (TmpMcb) {
1648 Ext2ReferMcb(TmpMcb);
1649 }
1651 }
1652
1653 if (IsMcbSymLink(Parent)) {
1654 if (Parent->Target) {
1655 TmpMcb = Parent->Target->Child;
1656 ASSERT(!IsMcbSymLink(Parent->Target));
1657 } else {
1658 TmpMcb = NULL;
1660 }
1661 } else {
1662 TmpMcb = Parent->Child;
1663 }
1664
1665 while (TmpMcb) {
1666
1668 &(TmpMcb->ShortName),
1669 FileName, TRUE )) {
1670 Ext2ReferMcb(TmpMcb);
1671 break;
1672 }
1673
1674 TmpMcb = TmpMcb->Next;
1675 }
1676
1677 } _SEH2_FINALLY {
1678
1680 } _SEH2_END;
1681
1682 return TmpMcb;
1683}
BOOLEAN Ext2IsDotDot(PUNICODE_STRING name)
Definition: misc.c:529
BOOLEAN Ext2IsDot(PUNICODE_STRING name)
Definition: misc.c:524
UNICODE_STRING ShortName
Definition: ext2fs.h:917

Referenced by Ext2LookupFile(), and Ext2SearchMcb().

◆ Ext2SetDispositionInfo()

NTSTATUS Ext2SetDispositionInfo ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_FCB  Fcb,
PEXT2_CCB  Ccb,
BOOLEAN  bDelete 
)

Definition at line 1282 of file fileinfo.c.

1289{
1290 PIRP Irp = IrpContext->Irp;
1293 PEXT2_MCB Mcb = Fcb->Mcb;
1294
1296
1297 DEBUG(DL_INF, ( "Ext2SetDispositionInfo: bDelete=%x\n", bDelete));
1298
1299 if (bDelete) {
1300
1301 DEBUG(DL_INF, ( "Ext2SetDispositionInformation: Removing %wZ.\n",
1302 &Mcb->FullName));
1303
1304 if (Ccb->SymLink || IsInodeSymLink(&Mcb->Inode)) {
1305 /* always allow deleting on symlinks */
1306 } else {
1307 status = Ext2IsFileRemovable(IrpContext, Vcb, Fcb, Ccb);
1308 }
1309
1310 if (NT_SUCCESS(status)) {
1312 IrpSp->FileObject->DeletePending = TRUE;
1313 }
1314
1315 } else {
1316
1318 IrpSp->FileObject->DeletePending = FALSE;
1319 }
1320
1321 return status;
1322}
NTSTATUS Ext2IsFileRemovable(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PEXT2_CCB Ccb)
Definition: fileinfo.c:1239

Referenced by Ext2SetFileInformation().

◆ Ext2SetEa()

NTSTATUS Ext2SetEa ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 436 of file ea.c.

439{
440 PIRP Irp = NULL;
442
444
449
450 BOOLEAN MainResourceAcquired = FALSE;
451 BOOLEAN FcbLockAcquired = FALSE;
452 BOOLEAN XattrRefAcquired = FALSE;
453
455
456 struct ext4_xattr_ref xattr_ref;
457 PCHAR UserBuffer;
458 ULONG UserBufferLength;
459
461
462 _SEH2_TRY {
463
464 Ccb = IrpContext->Ccb;
465 ASSERT(Ccb != NULL);
467 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
469 Vcb = (PEXT2_VCB)DeviceObject->DeviceExtension;
470 Fcb = IrpContext->Fcb;
471 Mcb = Fcb->Mcb;
472 Irp = IrpContext->Irp;
474
475 Irp->IoStatus.Information = 0;
476
477 //
478 // Receive input parameter from caller
479 //
480 UserBufferLength = IrpSp->Parameters.SetEa.Length;
481 UserBuffer = Irp->UserBuffer;
482
483 // Check if the EA buffer provided is valid
485 UserBufferLength,
486 (PULONG)&Irp->IoStatus.Information);
487 if (!NT_SUCCESS(Status))
489
491 FcbLockAcquired = TRUE;
492
493 if (!Mcb)
495
496 //
497 // We do not allow multiple instance gaining EA access to the same file
498 //
504 }
505 MainResourceAcquired = TRUE;
506
508 if (!NT_SUCCESS(Status)) {
509 DbgPrint("ext4_fs_get_xattr_ref() failed!\n");
511 }
512
513 XattrRefAcquired = TRUE;
514
515 //
516 // Remove all existing EA entries.
517 //
518 ext4_xattr_purge_items(&xattr_ref);
519 xattr_ref.dirty = TRUE;
521
522 // Iterate the whole EA buffer to do inspection
523 for (FullEa = (PFILE_FULL_EA_INFORMATION)UserBuffer;
524 FullEa < (PFILE_FULL_EA_INFORMATION)&UserBuffer[UserBufferLength];
525 FullEa = (PFILE_FULL_EA_INFORMATION)(FullEa->NextEntryOffset == 0 ?
526 &UserBuffer[UserBufferLength] :
527 (PCHAR)FullEa + FullEa->NextEntryOffset)) {
528
529 OEM_STRING EaName;
530
531 EaName.MaximumLength = EaName.Length = FullEa->EaNameLength;
532 EaName.Buffer = &FullEa->EaName[0];
533
534 // Check if EA's name is valid
535 if (!Ext2IsEaNameValid(EaName)) {
536 Irp->IoStatus.Information = (PCHAR)FullEa - UserBuffer;
539 }
540 }
541
542 // Now add EA entries to the inode
543 for (FullEa = (PFILE_FULL_EA_INFORMATION)UserBuffer;
544 FullEa < (PFILE_FULL_EA_INFORMATION)&UserBuffer[UserBufferLength];
545 FullEa = (PFILE_FULL_EA_INFORMATION)(FullEa->NextEntryOffset == 0 ?
546 &UserBuffer[UserBufferLength] :
547 (PCHAR)FullEa + FullEa->NextEntryOffset)) {
548
549 int ret;
550 OEM_STRING EaName;
551
552 EaName.MaximumLength = EaName.Length = FullEa->EaNameLength;
553 EaName.Buffer = &FullEa->EaName[0];
554
556 ext4_fs_set_xattr_ordered(&xattr_ref,
558 EaName.Buffer,
559 EaName.Length,
560 &FullEa->EaName[0] + FullEa->EaNameLength + 1,
561 FullEa->EaValueLength));
562 if (!NT_SUCCESS(Status))
564
565 }
566 } _SEH2_FINALLY {
567
568 if (XattrRefAcquired) {
569 if (!NT_SUCCESS(Status)) {
570 xattr_ref.dirty = FALSE;
571 ext4_fs_put_xattr_ref(&xattr_ref);
572 } else
574 }
575
576 if (FcbLockAcquired) {
577 ExReleaseResourceLite(&Vcb->FcbLock);
578 FcbLockAcquired = FALSE;
579 }
580
581 if (MainResourceAcquired) {
583 }
584
585 if (NT_SUCCESS(Status)) {
588 Vcb,
589 Mcb,
592 }
593
597 }
598 else {
600 }
601 }
602 } _SEH2_END;
603 return Status;
604}
BOOLEAN Ext2IsEaNameValid(IN OEM_STRING Name)
Definition: ea.c:389
int ext4_fs_set_xattr_ordered(struct ext4_xattr_ref *ref, __u8 name_index, const char *name, size_t name_len, const void *data, size_t data_size)
Definition: ext4_xattr.c:1055
void ext4_xattr_purge_items(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:736
NTSTATUS NTAPI IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: util.c:191
#define STATUS_INVALID_EA_NAME
Definition: ntstatus.h:199
int ret

Referenced by Ext2DispatchRequest().

◆ Ext2SetFileInformation()

NTSTATUS Ext2SetFileInformation ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 514 of file fileinfo.c.

515{
523 PIRP Irp = NULL;
524 PIO_STACK_LOCATION IoStackLocation = NULL;
526
528
531
532 BOOLEAN FcbMainResourceAcquired = FALSE;
533 BOOLEAN FcbPagingIoResourceAcquired = FALSE;
534
535 _SEH2_TRY {
536
537 ASSERT(IrpContext != NULL);
538
539 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
540 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
541 DeviceObject = IrpContext->DeviceObject;
542
543 //
544 // This request is not allowed on the main device object
545 //
549 }
550
551 /* check io stack location of irp stack */
552 Irp = IrpContext->Irp;
553 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
555 IoStackLocation->Parameters.SetFile.FileInformationClass;
556 Length = IoStackLocation->Parameters.SetFile.Length;
557 Buffer = Irp->AssociatedIrp.SystemBuffer;
558
559 /* check Vcb */
560 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
561 ASSERT(Vcb != NULL);
562 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
563 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
564 if (!IsMounted(Vcb)) {
567 }
568
569 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
572 }
573
574 FileObject = IrpContext->FileObject;
575 Fcb = (PEXT2_FCB) FileObject->FsContext;
576
577 // This request is issued to volumes, just return success
578 if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
581 }
583 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
584
585 if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
588 }
589
590 Ccb = (PEXT2_CCB) FileObject->FsContext2;
591 ASSERT(Ccb != NULL);
593 (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
594 Mcb = Ccb->SymLink;
595 if (Mcb) {
596 if (IsFlagOn(Mcb->Flags, MCB_FILE_DELETED)) {
599 }
600 } else {
601 Mcb = Fcb->Mcb;
602 }
603
605 if (IsVcbReadOnly(Vcb)) {
608 }
612 }
613 }
614
619
620 Status = FsRtlCheckOplock( &Fcb->Oplock,
621 Irp,
622 IrpContext,
623 NULL,
624 NULL );
625
626 if (Status != STATUS_SUCCESS) {
628 }
629
630 //
631 // Set the flag indicating if Fast I/O is possible
632 //
633
634 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
635 }
636
637 /* for renaming or set link, we must not grab any Fcb locks,
638 and later we will get Dcb or Fcb resources exclusively. */
642
645 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) {
648 }
649
650 FcbMainResourceAcquired = TRUE;
651
655
658 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) {
660 DbgBreak();
662 }
663 FcbPagingIoResourceAcquired = TRUE;
664 }
665 }
666
667 switch (FileInformationClass) {
668
670 {
672 struct inode *Inode = &Mcb->Inode;
673
674 if (FBI->CreationTime.QuadPart != 0 && FBI->CreationTime.QuadPart != -1) {
675 Inode->i_ctime = Ext2LinuxTime(FBI->CreationTime);
676 Mcb->CreationTime = Ext2NtTime(Inode->i_ctime);
678 }
679
680 if (FBI->LastAccessTime.QuadPart != 0 && FBI->LastAccessTime.QuadPart != -1) {
681 Inode->i_atime = Ext2LinuxTime(FBI->LastAccessTime);
682 Mcb->LastAccessTime = Ext2NtTime(Inode->i_atime);
684 }
685
686 if (FBI->LastWriteTime.QuadPart != 0 && FBI->LastWriteTime.QuadPart != -1) {
687 Inode->i_mtime = Ext2LinuxTime(FBI->LastWriteTime);
688 Mcb->LastWriteTime = Ext2NtTime(Inode->i_mtime);
691 }
692
693 if (FBI->ChangeTime.QuadPart !=0 && FBI->ChangeTime.QuadPart != -1) {
694 Mcb->ChangeTime = FBI->ChangeTime;
695 }
696
697 if (FBI->FileAttributes != 0) {
698
699 BOOLEAN bIsDirectory = IsDirectory(Fcb);
701
704 } else {
706 }
707
710 } else {
712 }
713
714 Mcb->FileAttr = FBI->FileAttributes;
715 if (bIsDirectory) {
718 }
719 }
720
721 if (NotifyFilter != 0) {
722 if (Ext2SaveInode(IrpContext, Vcb, Inode)) {
724 }
725 }
726
729 }
730
731 break;
732
734 {
737
741 } else {
743 }
744
745 /* set Mcb to it's target */
746 if (IsMcbSymLink(Mcb)) {
747 ASSERT(Fcb->Mcb == Mcb->Target);
748 }
749 Mcb = Fcb->Mcb;
750
751 /* get user specified allocationsize aligned with BLOCK_SIZE */
755
756 if (AllocationSize.QuadPart > Fcb->Header.AllocationSize.QuadPart) {
757
758 Status = Ext2ExpandFile(IrpContext, Vcb, Mcb, &AllocationSize);
759 Fcb->Header.AllocationSize = AllocationSize;
762
763 } else if (AllocationSize.QuadPart < Fcb->Header.AllocationSize.QuadPart) {
764
765 if (MmCanFileBeTruncated(&(Fcb->SectionObject), &AllocationSize)) {
766
767 /* truncate file blocks */
768 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &AllocationSize);
769
770 if (NT_SUCCESS(Status)) {
772 }
773
775 Fcb->Header.AllocationSize.QuadPart = AllocationSize.QuadPart;
776 if (Mcb->Inode.i_size > (loff_t)AllocationSize.QuadPart) {
777 Mcb->Inode.i_size = AllocationSize.QuadPart;
778 }
779 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
780 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
781 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
782 }
783
784 } else {
785
787 DbgBreak();
789 }
790 }
791
792 if (NotifyFilter) {
793
796 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
798 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
799 }
800 }
801
802 DEBUG(DL_IO, ("Ext2SetInformation: %wZ NewSize=%I64xh AllocationSize=%I64xh "
803 "FileSize=%I64xh VDL=%I64xh i_size=%I64xh status = %xh\n",
804 &Fcb->Mcb->ShortName, AllocationSize.QuadPart,
805 Fcb->Header.AllocationSize.QuadPart,
806 Fcb->Header.FileSize.QuadPart, Fcb->Header.ValidDataLength.QuadPart,
807 Mcb->Inode.i_size, Status));
808 }
809
810 break;
811
813 {
815 LARGE_INTEGER NewSize, OldSize, EndOfFile;
816
820 } else {
822 }
823
824 /* set Mcb to it's target */
825 if (IsMcbSymLink(Mcb)) {
826 ASSERT(Fcb->Mcb == Mcb->Target);
827 }
828 Mcb = Fcb->Mcb;
829
830 OldSize = Fcb->Header.AllocationSize;
831 EndOfFile = FEOFI->EndOfFile;
832
833 if (IoStackLocation->Parameters.SetFile.AdvanceOnly) {
834
837 }
838
839 if (EndOfFile.QuadPart > Fcb->Header.FileSize.QuadPart) {
840 EndOfFile.QuadPart = Fcb->Header.FileSize.QuadPart;
841 }
842
843 if (EndOfFile.QuadPart > Fcb->Header.ValidDataLength.QuadPart) {
844 Fcb->Header.ValidDataLength.QuadPart = EndOfFile.QuadPart;
846 }
847
849 }
850
852 EndOfFile.QuadPart, BLOCK_SIZE);
853
854 if (NewSize.QuadPart > OldSize.QuadPart) {
855
856 Fcb->Header.AllocationSize = NewSize;
858 IrpContext,
859 Vcb,
860 Mcb,
861 &(Fcb->Header.AllocationSize)
862 );
865
866
867 } else if (NewSize.QuadPart == OldSize.QuadPart) {
868
869 /* we are luck ;) */
871
872 } else {
873
874 /* don't truncate file data since it's still being written */
876
878
879 } else {
880
881 if (!MmCanFileBeTruncated(&(Fcb->SectionObject), &NewSize)) {
883 DbgBreak();
885 }
886
887 /* truncate file blocks */
888 Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &NewSize);
889
890 /* restore original file size */
891 if (NT_SUCCESS(Status)) {
893 }
894
895 /* update file allocateion size */
896 Fcb->Header.AllocationSize.QuadPart = NewSize.QuadPart;
897
898 ASSERT((loff_t)NewSize.QuadPart >= Mcb->Inode.i_size);
899 if ((loff_t)Fcb->Header.FileSize.QuadPart < Mcb->Inode.i_size) {
900 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size;
901 }
902 if (Fcb->Header.ValidDataLength.QuadPart > Fcb->Header.FileSize.QuadPart) {
903 Fcb->Header.ValidDataLength.QuadPart = Fcb->Header.FileSize.QuadPart;
904 }
905
908 }
909
911 }
912
913 if (NT_SUCCESS(Status)) {
914
915 Fcb->Header.FileSize.QuadPart = Mcb->Inode.i_size = EndOfFile.QuadPart;
917 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
918 }
919
920 if (Fcb->Header.FileSize.QuadPart >= 0x80000000 &&
923 Ext2SaveSuper(IrpContext, Vcb);
924 }
925
929 }
930
931
932 Ext2SaveInode( IrpContext, Vcb, &Mcb->Inode);
933
934 DEBUG(DL_IO, ("Ext2SetInformation: FileEndOfFileInformation %wZ EndofFile=%I64xh "
935 "AllocatieonSize=%I64xh FileSize=%I64xh VDL=%I64xh i_size=%I64xh status = %xh\n",
936 &Fcb->Mcb->ShortName, EndOfFile.QuadPart, Fcb->Header.AllocationSize.QuadPart,
937 Fcb->Header.FileSize.QuadPart, Fcb->Header.ValidDataLength.QuadPart,
938 Mcb->Inode.i_size, Status));
939 }
940
941 break;
942
944 {
946 LARGE_INTEGER NewVDL;
947
951 } else {
953 }
954
955 NewVDL = FVDL->ValidDataLength;
956 if ((NewVDL.QuadPart < Fcb->Header.ValidDataLength.QuadPart)) {
959 }
960 if (NewVDL.QuadPart > Fcb->Header.FileSize.QuadPart)
961 NewVDL = Fcb->Header.FileSize;
962
963 if (!MmCanFileBeTruncated(FileObject->SectionObjectPointer,
964 &NewVDL)) {
967 }
968
969 Fcb->Header.ValidDataLength = NewVDL;
972 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)(&(Fcb->Header.AllocationSize)));
973 }
974 }
975
976 break;
977
979 {
981
982 Status = Ext2SetDispositionInfo(IrpContext, Vcb, Fcb, Ccb, FDI->DeleteFile);
983
984 DEBUG(DL_INF, ( "Ext2SetInformation: SetDispositionInformation: DeleteFile=%d %wZ status = %xh\n",
985 FDI->DeleteFile, &Mcb->ShortName, Status));
986 }
987
988 break;
989
991 {
992 Status = Ext2SetRenameInfo(IrpContext, Vcb, Fcb, Ccb);
993 }
994
995 break;
996
997
999 {
1000 Status = Ext2SetLinkInfo(IrpContext, Vcb, Fcb, Ccb);
1001 }
1002
1003 break;
1004
1005 //
1006 // This is the only set file information request supported on read
1007 // only file systems
1008 //
1010 {
1012
1013 if (Length < sizeof(FILE_POSITION_INFORMATION)) {
1016 }
1017
1019
1021 (FilePositionInformation->CurrentByteOffset.LowPart &
1022 DeviceObject->AlignmentRequirement) ) {
1025 }
1026
1027 FileObject->CurrentByteOffset =
1028 FilePositionInformation->CurrentByteOffset;
1029
1032 }
1033
1034 break;
1035
1036 default:
1037 DEBUG(DL_WRN, ( "Ext2SetInformation: invalid class: %d\n",
1039 Status = STATUS_INVALID_PARAMETER;/* STATUS_INVALID_INFO_CLASS; */
1040 }
1041
1042 } _SEH2_FINALLY {
1043
1044 if (FcbPagingIoResourceAcquired) {
1046 }
1047
1048 if (NT_SUCCESS(Status) && (NotifyFilter != 0)) {
1050 IrpContext,
1051 Vcb,
1052 Mcb,
1055
1056 }
1057
1058 if (FcbMainResourceAcquired) {
1060 }
1061
1062 if (!IrpContext->ExceptionInProgress) {
1063 if (Status == STATUS_PENDING ||
1065 DbgBreak();
1066 Status = Ext2QueueRequest(IrpContext);
1067 } else {
1068 Ext2CompleteIrpContext(IrpContext, Status);
1069 }
1070 }
1071 } _SEH2_END;
1072
1073 return Status;
1074}
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE
Definition: ext2_fs.h:466
NTSTATUS Ext2SetLinkInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
Definition: fileinfo.c:1665
NTSTATUS Ext2SetRenameInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb)
Definition: fileinfo.c:1325
NTSTATUS Ext2SetDispositionInfo(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_CCB Ccb, BOOLEAN bDelete)
Definition: fileinfo.c:1282
NTSTATUS Ext2ExpandFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1152
#define Ext2SetOwnerWritable(m)
Definition: ext2fs.h:413
#define Ext2SetOwnerReadOnly(m)
Definition: ext2fs.h:414
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
@ FileEndOfFileInformation
Definition: from_kernel.h:81
@ FileRenameInformation
Definition: from_kernel.h:71
@ FileLinkInformation
Definition: from_kernel.h:72
@ FileValidDataLengthInformation
Definition: from_kernel.h:100
@ FileAllocationInformation
Definition: from_kernel.h:80
@ FileDispositionInformation
Definition: from_kernel.h:74
struct _FILE_ALLOCATION_INFORMATION * PFILE_ALLOCATION_INFORMATION
struct _FILE_END_OF_FILE_INFORMATION * PFILE_END_OF_FILE_INFORMATION
struct _FILE_DISPOSITION_INFORMATION * PFILE_DISPOSITION_INFORMATION
#define FILE_ATTRIBUTE_TEMPORARY
Definition: nt_native.h:708
#define STATUS_USER_MAPPED_FILE
Definition: ntstatus.h:711
BOOLEAN NTAPI MmCanFileBeTruncated(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER NewFileSize)
Definition: section.c:4255
LARGE_INTEGER AllocationSize
Definition: winternl.h:688
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
LARGE_INTEGER ChangeTime
Definition: nt_native.h:942
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
#define FILE_NOTIFY_CHANGE_SIZE
#define FO_TEMPORARY_FILE
Definition: iotypes.h:1791
struct _FILE_VALID_DATA_LENGTH_INFORMATION * PFILE_VALID_DATA_LENGTH_INFORMATION
#define FO_NO_INTERMEDIATE_BUFFERING
Definition: iotypes.h:1778
#define FILE_NOTIFY_CHANGE_CREATION
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID _Out_ PIO_STATUS_BLOCK _In_ ULONG NotifyFilter
Definition: zwfuncs.h:504

Referenced by Ext2DispatchRequest().

◆ Ext2SetFileType()

NTSTATUS Ext2SetFileType ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Dcb,
IN PEXT2_MCB  Mcb,
IN umode_t  mode 
)

Definition at line 1951 of file generic.c.

1958{
1959 struct inode *dir = Dcb->Inode;
1960 struct buffer_head *bh = NULL;
1961 struct ext3_dir_entry_2 *de;
1962 struct inode *inode;
1964 BOOLEAN MainResourceAcquired = FALSE;
1965
1967 return STATUS_SUCCESS;
1968 }
1969
1970 if (!IsDirectory(Dcb)) {
1972 }
1973
1974 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1975 MainResourceAcquired = TRUE;
1976
1977 _SEH2_TRY {
1978
1979 Ext2ReferXcb(&Dcb->ReferenceCount);
1980
1981 bh = ext3_find_entry(IrpContext, Mcb->de, &de);
1982 if (!bh)
1984
1985 inode = &Mcb->Inode;
1986 if (le32_to_cpu(de->inode) != inode->i_ino)
1988
1991
1992 if (S_ISDIR(inode->i_mode) == S_ISDIR(mode)) {
1993 } else if (S_ISDIR(inode->i_mode)) {
1995 } else if (S_ISDIR(mode)) {
1997 }
1998 dir->i_ctime = dir->i_mtime = ext3_current_time(dir);
1999 ext3_mark_inode_dirty(IrpContext, dir);
2000
2001 inode->i_mode = mode;
2002 ext3_mark_inode_dirty(IrpContext, inode);
2003
2005
2006 } _SEH2_FINALLY {
2007
2008 Ext2DerefXcb(&Dcb->ReferenceCount);
2009
2010 if (MainResourceAcquired)
2011 ExReleaseResourceLite(&Dcb->MainResource);
2012
2013 if (bh)
2014 brelse(bh);
2015 } _SEH2_END;
2016
2017 return Status;
2018}
void ext3_set_de_type(struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
Definition: htree.c:347
void ext3_inc_count(struct inode *inode)
Definition: htree.c:307
#define EXT3_FEATURE_INCOMPAT_FILETYPE
Definition: ext3_fs.h:679
GLenum mode
Definition: glext.h:6217

Referenced by Ext2SetReparsePoint().

◆ Ext2SetLinkInfo()

NTSTATUS Ext2SetLinkInfo ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_FCB  Fcb,
PEXT2_CCB  Ccb 
)

Definition at line 1665 of file fileinfo.c.

1671{
1672 PEXT2_MCB Mcb = Fcb->Mcb;
1673
1674 PEXT2_FCB TargetDcb = NULL; /* Dcb of target directory */
1675 PEXT2_MCB TargetMcb = NULL;
1676 PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1677 PEXT2_MCB ParentMcb = NULL;
1678
1679 PEXT2_FCB ExistingFcb = NULL; /* Target file Fcb if it exists*/
1680 PEXT2_MCB ExistingMcb = NULL;
1681 PEXT2_MCB LinkMcb = NULL; /* Mcb for new hardlink */
1682
1684
1686
1687 PIRP Irp;
1689
1691 PFILE_OBJECT TargetObject;
1692
1693 BOOLEAN ReplaceIfExists;
1694 BOOLEAN bTargetRemoved = FALSE;
1695
1696 BOOLEAN bFcbLockAcquired = FALSE;
1697
1699
1700 if (Ccb->SymLink) {
1701 Mcb = Ccb->SymLink;
1702 }
1703
1704 if (IsMcbDirectory(Mcb)) {
1706 goto errorout;
1707 }
1708
1709 Irp = IrpContext->Irp;
1711
1713 TargetObject = IrpSp->Parameters.SetFile.FileObject;
1714 ReplaceIfExists = IrpSp->Parameters.SetFile.ReplaceIfExists;
1715
1716 FLI = (PFILE_LINK_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1717
1718 if (TargetObject == NULL) {
1719
1721
1722 NewName.Buffer = FLI->FileName;
1724
1725 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] == L'\\') {
1726 NewName.Buffer[NewName.Length/2 - 1] = 0;
1727 NewName.Length -= 2;
1728 }
1729
1730 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] != L'\\') {
1731 NewName.Length -= 2;
1732 }
1733
1736
1737 FileName = NewName;
1738
1739 TargetMcb = Mcb->Parent;
1740 if (IsMcbSymLink(TargetMcb)) {
1741 TargetMcb = TargetMcb->Target;
1742 ASSERT(!IsMcbSymLink(TargetMcb));
1743 }
1744
1745 if (TargetMcb == NULL || FileName.Length >= EXT2_NAME_LEN*2) {
1747 goto errorout;
1748 }
1749
1750 } else {
1751
1752 TargetDcb = (PEXT2_FCB)(TargetObject->FsContext);
1753 if (!TargetDcb || TargetDcb->Vcb != Vcb) {
1754 DbgBreak();
1756 goto errorout;
1757 }
1758
1759 TargetMcb = TargetDcb->Mcb;
1760 FileName = TargetObject->FileName;
1761 }
1762
1765 goto errorout;
1766 }
1767
1768 if (TargetMcb->Inode.i_ino == Mcb->Parent->Inode.i_ino) {
1770 &(Mcb->ShortName),
1771 FALSE,
1772 NULL )) {
1774 goto errorout;
1775 }
1776 }
1777
1779 bFcbLockAcquired = TRUE;
1780
1781 TargetDcb = TargetMcb->Fcb;
1782 if (TargetDcb == NULL) {
1783 TargetDcb = Ext2AllocateFcb(Vcb, TargetMcb);
1784 }
1785 if (TargetDcb) {
1786 Ext2ReferXcb(&TargetDcb->ReferenceCount);
1787 }
1788
1789 ParentMcb = Mcb->Parent;
1790 ParentDcb = ParentMcb->Fcb;
1791
1792 if ((TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino)) {
1793
1794 if (ParentDcb == NULL) {
1795 ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1796 }
1797 }
1798 if (ParentDcb) {
1799 Ext2ReferXcb(&ParentDcb->ReferenceCount);
1800 }
1801
1802 if (bFcbLockAcquired) {
1803 ExReleaseResourceLite(&Vcb->FcbLock);
1804 bFcbLockAcquired = FALSE;
1805 }
1806
1807 if (!TargetDcb || !ParentDcb) {
1809 goto errorout;
1810 }
1811
1812 DEBUG(DL_RES, ("Ext2SetLinkInfo: %wZ\\%wZ -> %wZ\n",
1813 &TargetMcb->FullName, &FileName, &Mcb->FullName));
1814
1815 Status = Ext2LookupFile(IrpContext, Vcb, &FileName,
1816 TargetMcb, &ExistingMcb, 0);
1817 if (NT_SUCCESS(Status) && ExistingMcb != Mcb) {
1818
1819 if (!ReplaceIfExists) {
1820
1822 DEBUG(DL_RES, ("Ext2SetRenameInfo: Target file %wZ exists\n",
1823 &ExistingMcb->FullName));
1824 goto errorout;
1825
1826 } else {
1827
1828 if ( (ExistingFcb = ExistingMcb->Fcb) && !IsMcbSymLink(ExistingMcb) ) {
1829 Status = Ext2IsFileRemovable(IrpContext, Vcb, ExistingFcb, Ccb);
1830 if (!NT_SUCCESS(Status)) {
1831 DEBUG(DL_REN, ("Ext2SetRenameInfo: Target file %wZ cannot be removed.\n",
1832 &ExistingMcb->FullName));
1833 goto errorout;
1834 }
1835 }
1836
1837 Status = Ext2DeleteFile(IrpContext, Vcb, ExistingFcb, ExistingMcb);
1838 if (!NT_SUCCESS(Status)) {
1839 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to delete %wZ with status: %xh.\n",
1840 &FileName, Status));
1841
1842 goto errorout;
1843 }
1844 bTargetRemoved = TRUE;
1845 }
1846 }
1847
1848 /* add new entry for new target name */
1849 Status = Ext2AddEntry(IrpContext, Vcb, TargetDcb, &Mcb->Inode, &FileName, NULL);
1850 if (!NT_SUCCESS(Status)) {
1851 DEBUG(DL_REN, ("Ext2SetLinkInfo: Failed to add entry for %wZ with status: %xh.\n",
1852 &FileName, Status));
1853 goto errorout;
1854 }
1855
1856 if (bTargetRemoved) {
1858 IrpContext,
1859 Vcb,
1860 ExistingMcb,
1861 (IsMcbDirectory(ExistingMcb) ?
1865 }
1866
1867 if (NT_SUCCESS(Status)) {
1868
1869 Ext2LookupFile(IrpContext, Vcb, &FileName, TargetMcb, &LinkMcb, 0);
1870 if (!LinkMcb)
1871 goto errorout;
1872
1874 IrpContext,
1875 Vcb,
1876 LinkMcb,
1879 }
1880
1881errorout:
1882
1883 if (bFcbLockAcquired) {
1884 ExReleaseResourceLite(&Vcb->FcbLock);
1885 bFcbLockAcquired = FALSE;
1886 }
1887
1888 if (TargetDcb) {
1890 }
1891
1892 if (ParentDcb) {
1894 }
1895
1896 if (ExistingMcb)
1897 Ext2DerefMcb(ExistingMcb);
1898
1899 if (LinkMcb)
1900 Ext2DerefMcb(LinkMcb);
1901
1902 return Status;
1903}
NTSTATUS Ext2DeleteFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PEXT2_MCB Mcb)
Definition: fileinfo.c:1920
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB ParentDcb
Definition: create.c:4141
#define DL_REN
Definition: ext2fs.h:1439
NTSTATUS Ext2AddEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN struct inode *Inode, IN PUNICODE_STRING FileName, OUT struct dentry **dentry)
IN PDCB TargetDcb
Definition: fatprocs.h:788
struct _FILE_LINK_INFORMATION * PFILE_LINK_INFORMATION
BOOLEAN NTAPI FsRtlAreNamesEqual(IN PCUNICODE_STRING Name1, IN PCUNICODE_STRING Name2, IN BOOLEAN IgnoreCase, IN PCWCH UpcaseTable OPTIONAL)
Definition: name.c:296
PEXT2_FCB Fcb
Definition: ext2fs.h:914
PEXT2_MCB Target
Definition: ext2fs.h:908
UNICODE_STRING FullName
Definition: ext2fs.h:920
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define FILE_ACTION_ADDED
_In_ PUNICODE_STRING NewName
Definition: zwfuncs.h:1203

Referenced by Ext2SetFileInformation().

◆ Ext2SetParentEntry()

NTSTATUS Ext2SetParentEntry ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Dcb,
IN ULONG  OldParent,
IN ULONG  NewParent 
)

Definition at line 2098 of file generic.c.

2104{
2106
2107 PEXT2_DIR_ENTRY2 pSelf = NULL;
2109
2110 ULONG dwBytes = 0;
2111
2112 BOOLEAN MainResourceAcquired = FALSE;
2113
2114 ULONG Offset = 0;
2115
2116 if (!IsDirectory(Dcb)) {
2118 }
2119
2120 if (OldParent == NewParent) {
2121 return STATUS_SUCCESS;
2122 }
2123
2124 MainResourceAcquired =
2125 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
2126
2127 _SEH2_TRY {
2128
2129 Ext2ReferXcb(&Dcb->ReferenceCount);
2130
2131 pSelf = (PEXT2_DIR_ENTRY2)
2133 PagedPool,
2136 );
2137 if (!pSelf) {
2138 DEBUG(DL_ERR, ( "Ex2SetParentEntry: failed to allocate pSelf.\n"));
2141 }
2142
2143 dwBytes = 0;
2144
2145 //
2146 // Reading the DCB contents
2147 //
2148
2150 IrpContext,
2151 Vcb,
2152 Dcb->Mcb,
2154 (PVOID)pSelf,
2156 FALSE,
2157 &dwBytes );
2158
2159 if (!NT_SUCCESS(Status)) {
2160 DEBUG(DL_ERR, ( "Ext2SetParentEntry: failed to read directory.\n"));
2162 }
2163
2164 ASSERT(dwBytes == EXT2_DIR_REC_LEN(1) + EXT2_DIR_REC_LEN(2));
2165
2166 pParent = (PEXT2_DIR_ENTRY2)((PUCHAR)pSelf + pSelf->rec_len);
2167
2168 if (pSelf->name_len == 1 && pSelf->name[0] == '.' &&
2169 pParent->name_len == 2 && pParent->name[0] == '.' &&
2170 pParent->name[1] == '.') {
2171
2172 if (pParent->inode != OldParent) {
2173 DbgBreak();
2174 }
2175 pParent->inode = NewParent;
2176
2178 IrpContext,
2179 Vcb,
2180 Dcb->Mcb,
2182 pSelf,
2183 dwBytes,
2184 FALSE,
2185 &dwBytes );
2186 } else {
2187 DbgBreak();
2188 }
2189
2190 } _SEH2_FINALLY {
2191
2192
2193 if (Ext2DerefXcb(&Dcb->ReferenceCount) == 0) {
2194 DEBUG(DL_ERR, ( "Ext2SetParentEntry: Dcb reference goes to ZERO.\n"));
2195 }
2196
2197 if (MainResourceAcquired) {
2198 ExReleaseResourceLite(&Dcb->MainResource);
2199 }
2200
2201 if (pSelf) {
2203 }
2204 } _SEH2_END;
2205
2206 return Status;
2207}
#define EXT2_DIR_REC_LEN(name_len)
Definition: ext2_fs.h:536
struct ext3_dir_entry_2 * PEXT2_DIR_ENTRY2
Definition: ext2fs.h:109
NTSTATUS Ext2WriteInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN PVOID Buffer, IN ULONG Size, IN BOOLEAN bDirectIo, OUT PULONG dwReturn)
Definition: write.c:668
FxObject * pParent
Definition: fxdpcapi.cpp:86

Referenced by Ext2SetRenameInfo().

◆ Ext2SetRenameInfo()

NTSTATUS Ext2SetRenameInfo ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_FCB  Fcb,
PEXT2_CCB  Ccb 
)

Definition at line 1325 of file fileinfo.c.

1331{
1332 PEXT2_MCB Mcb = Fcb->Mcb;
1333
1334 PEXT2_FCB TargetDcb = NULL; /* Dcb of target directory */
1335 PEXT2_MCB TargetMcb = NULL;
1336 PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1337 PEXT2_MCB ParentMcb = NULL;
1338
1339 PEXT2_FCB ExistingFcb = NULL; /* Target file Fcb if it exists*/
1340 PEXT2_MCB ExistingMcb = NULL;
1341
1343
1345
1346 PIRP Irp;
1348
1350 PFILE_OBJECT TargetObject;
1351
1352 struct dentry *NewEntry = NULL;
1353
1354 BOOLEAN ReplaceIfExists;
1355 BOOLEAN bMove = FALSE;
1356 BOOLEAN bTargetRemoved = FALSE;
1357
1358 BOOLEAN bFcbLockAcquired = FALSE;
1359
1361
1362 if (Ccb->SymLink) {
1363 Mcb = Ccb->SymLink;
1364 }
1365
1366 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
1368 goto errorout;
1369 }
1370
1371 Irp = IrpContext->Irp;
1373
1375 TargetObject = IrpSp->Parameters.SetFile.FileObject;
1376 ReplaceIfExists = IrpSp->Parameters.SetFile.ReplaceIfExists;
1377
1378 FRI = (PFILE_RENAME_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
1379
1380 if (TargetObject == NULL) {
1381
1383
1384 NewName.Buffer = FRI->FileName;
1386
1387 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] == L'\\') {
1388 NewName.Buffer[NewName.Length/2 - 1] = 0;
1389 NewName.Length -= 2;
1390 }
1391
1392 while (NewName.Length > 0 && NewName.Buffer[NewName.Length/2 - 1] != L'\\') {
1393 NewName.Length -= 2;
1394 }
1395
1398
1399 FileName = NewName;
1400
1401 TargetMcb = Mcb->Parent;
1402 if (IsMcbSymLink(TargetMcb)) {
1403 TargetMcb = TargetMcb->Target;
1404 ASSERT(!IsMcbSymLink(TargetMcb));
1405 }
1406
1407 if (TargetMcb == NULL || FileName.Length >= EXT2_NAME_LEN*2) {
1409 goto errorout;
1410 }
1411
1412 } else {
1413
1414 TargetDcb = (PEXT2_FCB)(TargetObject->FsContext);
1415
1416 if (!TargetDcb || TargetDcb->Vcb != Vcb) {
1417
1418 DbgBreak();
1419
1421 goto errorout;
1422 }
1423
1424 TargetMcb = TargetDcb->Mcb;
1425 FileName = TargetObject->FileName;
1426 }
1427
1430 goto errorout;
1431 }
1432
1433 if (TargetMcb->Inode.i_ino == Mcb->Parent->Inode.i_ino) {
1435 &(Mcb->ShortName),
1436 FALSE,
1437 NULL )) {
1439 goto errorout;
1440 }
1441 } else {
1442 bMove = TRUE;
1443 }
1444
1445 if (!bFcbLockAcquired) {
1447 bFcbLockAcquired = TRUE;
1448 }
1449
1450 TargetDcb = TargetMcb->Fcb;
1451 if (TargetDcb == NULL) {
1452 TargetDcb = Ext2AllocateFcb(Vcb, TargetMcb);
1453 }
1454 if (TargetDcb) {
1455 Ext2ReferXcb(&TargetDcb->ReferenceCount);
1456 }
1457
1458 ParentMcb = Mcb->Parent;
1459 ParentDcb = ParentMcb->Fcb;
1460
1461 if ((TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino)) {
1462
1463 if (ParentDcb == NULL) {
1464 ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1465 }
1466 }
1467 if (ParentDcb) {
1468 Ext2ReferXcb(&ParentDcb->ReferenceCount);
1469 }
1470
1471 if (bFcbLockAcquired) {
1472 ExReleaseResourceLite(&Vcb->FcbLock);
1473 bFcbLockAcquired = FALSE;
1474 }
1475
1476 if (!TargetDcb || !ParentDcb) {
1478 goto errorout;
1479 }
1480
1481 DEBUG(DL_RES, ("Ext2SetRenameInfo: rename %wZ to %wZ\\%wZ\n",
1482 &Mcb->FullName, &TargetMcb->FullName, &FileName));
1483
1485 IrpContext,
1486 Vcb,
1487 &FileName,
1488 TargetMcb,
1489 &ExistingMcb,
1490 0
1491 );
1492
1493 if (NT_SUCCESS(Status) && ExistingMcb != Mcb) {
1494
1495 if (!ReplaceIfExists) {
1496
1498 DEBUG(DL_RES, ("Ext2SetRenameInfo: Target file %wZ exists\n",
1499 &ExistingMcb->FullName));
1500 goto errorout;
1501
1502 } else {
1503
1504 if ( (ExistingFcb = ExistingMcb->Fcb) && !IsMcbSymLink(ExistingMcb) ) {
1505
1506 Status = Ext2IsFileRemovable(IrpContext, Vcb, ExistingFcb, Ccb);
1507 if (!NT_SUCCESS(Status)) {
1508 DEBUG(DL_REN, ("Ext2SetRenameInfo: Target file %wZ cannot be removed.\n",
1509 &ExistingMcb->FullName));
1510 goto errorout;
1511 }
1512 }
1513
1514 Status = Ext2DeleteFile(IrpContext, Vcb, ExistingFcb, ExistingMcb);
1515 if (!NT_SUCCESS(Status)) {
1516 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to delete %wZ with status: %xh.\n",
1517 &FileName, Status));
1518
1519 goto errorout;
1520 }
1521
1522 bTargetRemoved = TRUE;
1523 }
1524 }
1525
1526 /* remove directory entry of old name */
1527 Status = Ext2RemoveEntry(IrpContext, Vcb, ParentDcb, Mcb);
1528 if (!NT_SUCCESS(Status)) {
1529 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to remove entry %wZ with status %xh.\n",
1530 &Mcb->FullName, Status));
1531 DbgBreak();
1532 goto errorout;
1533 }
1534
1535 /* add new entry for new target name */
1536 Status = Ext2AddEntry(IrpContext, Vcb, TargetDcb, &Mcb->Inode, &FileName, &NewEntry);
1537 if (!NT_SUCCESS(Status)) {
1538 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to add entry for %wZ with status: %xh.\n",
1539 &FileName, Status));
1540 Ext2AddEntry(IrpContext, Vcb, ParentDcb, &Mcb->Inode, &Mcb->ShortName, &NewEntry);
1541 goto errorout;
1542 }
1543
1544 /* correct the inode number in .. entry */
1545 if (IsMcbDirectory(Mcb)) {
1547 IrpContext, Vcb, Fcb,
1548 ParentMcb->Inode.i_ino,
1549 TargetMcb->Inode.i_ino );
1550 if (!NT_SUCCESS(Status)) {
1551 DEBUG(DL_REN, ("Ext2SetRenameInfo: Failed to set parent refer of %wZ with %xh.\n",
1552 &Mcb->FullName, Status));
1553 DbgBreak();
1554 goto errorout;
1555 }
1556 }
1557
1558 /* Update current dentry from the newly created one. We need keep the original
1559 dentry to assure children's links are valid if current entry is a directory */
1560 if (Mcb->de) {
1561 char *np = Mcb->de->d_name.name;
1562 *(Mcb->de) = *NewEntry;
1563 NewEntry->d_name.name = np;
1564 }
1565
1566 if (bTargetRemoved) {
1568 IrpContext,
1569 Vcb,
1570 ExistingMcb,
1571 (IsMcbDirectory(ExistingMcb) ?
1575 }
1576
1577 if (NT_SUCCESS(Status)) {
1578
1579 if (bMove) {
1581 IrpContext,
1582 Vcb,
1583 Mcb,
1584 (IsDirectory(Fcb) ?
1588
1589 } else {
1591 IrpContext,
1592 Vcb,
1593 Mcb,
1594 (IsDirectory(Fcb) ?
1598
1599 }
1600
1601 if (TargetMcb->Inode.i_ino != ParentMcb->Inode.i_ino) {
1603 Ext2InsertMcb(Vcb, TargetMcb, Mcb);
1604 }
1605
1606 if (!Ext2BuildName( &Mcb->ShortName,
1607 &FileName, NULL )) {
1609 goto errorout;
1610 }
1611
1612 if (!Ext2BuildName( &Mcb->FullName,
1613 &FileName,
1614 &TargetMcb->FullName)) {
1616 goto errorout;
1617 }
1618
1619 if (bMove) {
1621 IrpContext,
1622 Vcb,
1623 Mcb,
1624 (IsDirectory(Fcb) ?
1628 } else {
1630 IrpContext,
1631 Vcb,
1632 Mcb,
1633 (IsDirectory(Fcb) ?
1637 }
1638 }
1639
1640errorout:
1641
1642 if (bFcbLockAcquired) {
1643 ExReleaseResourceLite(&Vcb->FcbLock);
1644 bFcbLockAcquired = FALSE;
1645 }
1646
1647 if (NewEntry)
1648 Ext2FreeEntry(NewEntry);
1649
1650 if (TargetDcb) {
1652 }
1653
1654 if (ParentDcb) {
1656 }
1657
1658 if (ExistingMcb)
1659 Ext2DerefMcb(ExistingMcb);
1660
1661 return Status;
1662}
NTSTATUS Ext2SetParentEntry(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN ULONG OldParent, IN ULONG NewParent)
Definition: generic.c:2098
BOOLEAN Ext2BuildName(IN OUT PUNICODE_STRING Target, IN PUNICODE_STRING File, IN PUNICODE_STRING Parent)
Definition: memory.c:1361
struct _FILE_RENAME_INFORMATION * PFILE_RENAME_INFORMATION
#define FILE_ACTION_RENAMED_OLD_NAME
#define FILE_ACTION_RENAMED_NEW_NAME

Referenced by Ext2SetFileInformation().

◆ Ext2SetVolumeInformation()

NTSTATUS Ext2SetVolumeInformation ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 292 of file volinfo.c.

293{
297 PIRP Irp;
298 PIO_STACK_LOCATION IoStackLocation;
300 BOOLEAN VcbResourceAcquired = FALSE;
301
302 _SEH2_TRY {
303
304 ASSERT(IrpContext != NULL);
305
306 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
307 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
308
309 DeviceObject = IrpContext->DeviceObject;
310
311 //
312 // This request is not allowed on the main device object
313 //
317 }
318
319 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
320 ASSERT(Vcb != NULL);
321 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
322 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
324
325 if (IsVcbReadOnly(Vcb)) {
328 }
329
331 &Vcb->MainResource, TRUE)) {
334 }
335 VcbResourceAcquired = TRUE;
336
337 Ext2VerifyVcb(IrpContext, Vcb);
338
339 Irp = IrpContext->Irp;
340 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
341
342 //Notes: SetVolume is not defined in ntddk.h of win2k ddk,
343 // But it's same to QueryVolume ....
345 IoStackLocation->Parameters./*SetVolume*/QueryVolume.FsInformationClass;
346
347 switch (FsInformationClass) {
348
350 {
351 PFILE_FS_LABEL_INFORMATION VolLabelInfo = NULL;
352 ULONG VolLabelLen;
354
356
357 VolLabelInfo = (PFILE_FS_LABEL_INFORMATION) Irp->AssociatedIrp.SystemBuffer;
358 VolLabelLen = VolLabelInfo->VolumeLabelLength;
359
360 if (VolLabelLen > (16 * sizeof(WCHAR))) {
363 }
364
365 RtlCopyMemory( Vcb->Vpb->VolumeLabel,
366 VolLabelInfo->VolumeLabel,
367 VolLabelLen );
368
369 RtlZeroMemory(Vcb->SuperBlock->s_volume_name, 16);
370 LabelName.Buffer = VolLabelInfo->VolumeLabel;
371 LabelName.MaximumLength = (USHORT)16 * sizeof(WCHAR);
372 LabelName.Length = (USHORT)VolLabelLen;
373
374 OemName.Buffer = SUPER_BLOCK->s_volume_name;
375 OemName.Length = 0;
376 OemName.MaximumLength = 16;
377
379 Vcb->Vpb->VolumeLabelLength = (USHORT) VolLabelLen;
380
381 if (Ext2SaveSuper(IrpContext, Vcb)) {
383 }
384
385 Irp->IoStatus.Information = 0;
386 }
387 break;
388
389 default:
391 }
392
393 } _SEH2_FINALLY {
394
395 if (VcbResourceAcquired) {
396 ExReleaseResourceLite(&Vcb->MainResource);
397 }
398
399 if (!IrpContext->ExceptionInProgress) {
400 if (Status == STATUS_PENDING) {
401 Ext2QueueRequest(IrpContext);
402 } else {
403 Ext2CompleteIrpContext(IrpContext, Status);
404 }
405 }
406 } _SEH2_END;
407
408 return Status;
409}
@ LabelName
Definition: asmpp.cpp:94
@ FileFsLabelInformation
Definition: from_kernel.h:220
#define STATUS_INVALID_VOLUME_LABEL
Definition: udferr_usr.h:156
struct _FILE_FS_LABEL_INFORMATION * PFILE_FS_LABEL_INFORMATION

Referenced by Ext2DispatchRequest().

◆ Ext2SetVpbFlag()

VOID Ext2SetVpbFlag ( IN PVPB  Vpb,
IN USHORT  Flag 
)

Definition at line 44 of file fsctl.c.

47{
49
51 Vpb->Flags |= Flag;
53}

Referenced by Ext2LockVcb().

◆ Ext2ShutDown()

NTSTATUS Ext2ShutDown ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 25 of file shutdown.c.

26{
28
29 PIRP Irp;
30
32 PLIST_ENTRY ListEntry;
33
34 BOOLEAN GlobalResourceAcquired = FALSE;
35
36 _SEH2_TRY {
37
39
40 ASSERT(IrpContext);
41 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
42 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
43
44 Irp = IrpContext->Irp;
45
48 IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) {
51 }
52
53 GlobalResourceAcquired = TRUE;
54
55 for (ListEntry = Ext2Global->VcbList.Flink;
56 ListEntry != &(Ext2Global->VcbList);
57 ListEntry = ListEntry->Flink ) {
58
59 Vcb = CONTAINING_RECORD(ListEntry, EXT2_VCB, Next);
60
62 &Vcb->MainResource,
63 TRUE )) {
64
65 if (IsMounted(Vcb)) {
66
67 /* update mount count */
68 Vcb->SuperBlock->s_mnt_count++;
69 if (Vcb->SuperBlock->s_mnt_count >
70 Vcb->SuperBlock->s_max_mnt_count ) {
71 Vcb->SuperBlock->s_mnt_count =
72 Vcb->SuperBlock->s_max_mnt_count;
73 }
74 Ext2SaveSuper(IrpContext, Vcb);
75
76 /* flush dirty cache for all files */
77 Status = Ext2FlushFiles(IrpContext, Vcb, TRUE);
78 if (!NT_SUCCESS(Status)) {
79 DbgBreak();
80 }
81
82 /* flush volume stream's cache to disk */
83 Status = Ext2FlushVolume(IrpContext, Vcb, TRUE);
84
86 DbgBreak();
87 }
88
89 /* send shutdown request to underlying disk */
91 }
92
93 ExReleaseResourceLite(&Vcb->MainResource);
94 }
95 }
96
97 /*
98 IoUnregisterFileSystem(Ext2Global->DiskdevObject);
99 IoUnregisterFileSystem(Ext2Global->CdromdevObject);
100 */
101
102 } _SEH2_FINALLY {
103
104 if (GlobalResourceAcquired) {
106 }
107
108 if (!IrpContext->ExceptionInProgress) {
109 if (Status == STATUS_PENDING) {
110 Ext2QueueRequest(IrpContext);
111 } else {
112 Ext2CompleteIrpContext(IrpContext, Status);
113 }
114 }
115 } _SEH2_END;
116
117 return Status;
118}
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
NTSTATUS Ext2DiskShutDown(PEXT2_VCB Vcb)
Definition: block.c:748

Referenced by Ext2DispatchRequest().

◆ Ext2Sleep()

◆ Ext2StartFloppyFlushDpc()

VOID Ext2StartFloppyFlushDpc ( PEXT2_VCB  Vcb,
PEXT2_FCB  Fcb,
PFILE_OBJECT  FileObject 
)

Definition at line 139 of file write.c.

143{
144 LARGE_INTEGER OneSecond;
146
148
151 sizeof(EXT2_FLPFLUSH_CONTEXT),
153 );
154
155 if (!Context) {
156 DEBUG(DL_ERR, ( "Ex2StartFloppy...: failed to allocate Context\n"));
157 DbgBreak();
158 return;
159 }
160
161 KeInitializeTimer(&Context->Timer);
162
165 Context );
166
169 Context );
170
171 Context->Vcb = Vcb;
172 Context->Fcb = Fcb;
173 Context->FileObject = FileObject;
174
175 if (FileObject) {
177 }
178
179 OneSecond.QuadPart = (LONGLONG)-1*1000*1000*10;
180 KeSetTimer( &Context->Timer,
181 OneSecond,
182 &Context->Dpc );
183}
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
#define EXT2_FLPFLUSH_MAGIC
Definition: write.c:22
VOID Ext2FloppyFlushDpc(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: write.c:122
VOID Ext2FloppyFlush(IN PVOID Parameter)
Definition: write.c:75
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by Ext2SaveInode(), Ext2SaveInodeXattr(), Ext2SaveSuper(), Ext2WriteFile(), and Ext2WriteInode().

◆ Ext2StartReaper()

NTSTATUS Ext2StartReaper ( PEXT2_REAPER  Reaper,
EXT2_REAPER_RELEASE  Free 
)

Definition at line 3478 of file memory.c.

3479{
3482 HANDLE handle = 0;
3484
3485 Reaper->Free = Free;
3486
3487 /* initialize wait event */
3489 &Reaper->Wait,
3491 );
3492
3493 /* Reaper thread engine event */
3495 &Reaper->Engine,
3497 );
3498
3499 /* initialize oa */
3501 &oa,
3502 NULL,
3505 NULL,
3506 NULL
3507 );
3508
3509 /* start a new system thread */
3511 &handle,
3512 0,
3513 &oa,
3514 NULL,
3515 NULL,
3516 Free,
3517 (PVOID)Reaper
3518 );
3519
3520 if (NT_SUCCESS(status)) {
3521 ZwClose(handle);
3522
3523 /* make sure Reaperthread is started */
3524 timeout.QuadPart = (LONGLONG)-10*1000*1000*2; /* 2 seconds */
3526 &Reaper->Engine,
3527 Executive,
3528 KernelMode,
3529 FALSE,
3530 &timeout
3531 );
3532 if (status != STATUS_SUCCESS) {
3534 }
3535 }
3536
3537 return status;
3538}
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ SynchronizationEvent
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
EXT2_REAPER_RELEASE Free
Definition: ext2fs.h:507
Definition: dhcpd.h:245
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815

Referenced by DriverEntry().

◆ Ext2StopReaper()

VOID Ext2StopReaper ( PEXT2_REAPER  Reaper)

Definition at line 3546 of file memory.c.

3547{
3549
3550 Reaper->Flags |= EXT2_REAPER_FLAG_STOP;
3551 KeSetEvent(&Reaper->Wait, 0, FALSE);
3552
3553 /* make sure Reaperthread is started */
3554 timeout.QuadPart = (LONGLONG)-10*1000*1000*2; /* 2 seconds */
3556 &Reaper->Engine,
3557 Executive,
3558 KernelMode,
3559 FALSE,
3560 &timeout);
3561}

Referenced by DriverEntry().

◆ Ext2SupersedeOrOverWriteFile()

NTSTATUS Ext2SupersedeOrOverWriteFile ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PFILE_OBJECT  FileObject,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Fcb,
IN PLARGE_INTEGER  AllocationSize,
IN ULONG  Disposition 
)

Definition at line 2137 of file create.c.

2145{
2146 LARGE_INTEGER CurrentTime;
2148
2149 KeQuerySystemTime(&CurrentTime);
2150
2151 Size.QuadPart = 0;
2152 if (!MmCanFileBeTruncated(&(Fcb->SectionObject), &(Size))) {
2154 }
2155
2156 /* purge all file cache and shrink cache windows size */
2157 CcPurgeCacheSection(&Fcb->SectionObject, NULL, 0, FALSE);
2158 Fcb->Header.AllocationSize.QuadPart =
2159 Fcb->Header.FileSize.QuadPart =
2160 Fcb->Header.ValidDataLength.QuadPart = 0;
2162 (PCC_FILE_SIZES)&Fcb->Header.AllocationSize);
2163
2164 Size.QuadPart = CEILING_ALIGNED(ULONGLONG,
2165 (ULONGLONG)AllocationSize->QuadPart,
2167
2168 if ((loff_t)Size.QuadPart > Fcb->Inode->i_size) {
2169 Ext2ExpandFile(IrpContext, Vcb, Fcb->Mcb, &Size);
2170 } else {
2171 Ext2TruncateFile(IrpContext, Vcb, Fcb->Mcb, &Size);
2172 }
2173
2174 Fcb->Header.AllocationSize = Size;
2175 if (Fcb->Header.AllocationSize.QuadPart > 0) {
2178 (PCC_FILE_SIZES)&Fcb->Header.AllocationSize );
2179 }
2180
2181 /* remove all extent mappings */
2182 DEBUG(DL_EXT, ("Ext2SuperSede ...: %wZ\n", &Fcb->Mcb->FullName));
2183 Fcb->Inode->i_size = 0;
2184
2185 if (Disposition == FILE_SUPERSEDE) {
2186 Fcb->Inode->i_ctime = Ext2LinuxTime(CurrentTime);
2187 }
2188 Fcb->Inode->i_atime =
2189 Fcb->Inode->i_mtime = Ext2LinuxTime(CurrentTime);
2190 Ext2SaveInode(IrpContext, Vcb, Fcb->Inode);
2191
2192 // See if we need to overwrite EA of the file
2193 return Ext2OverwriteEa(IrpContext, Vcb, Fcb, &IrpContext->Irp->IoStatus);
2194}
NTSTATUS Ext2OverwriteEa(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_FCB Fcb, PIO_STATUS_BLOCK Iosb)
Definition: create.c:684
NTSTATUS Ext2ExpandFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1152
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56

Referenced by Ext2CreateFile().

◆ Ext2SyncUninitializeCacheMap()

VOID Ext2SyncUninitializeCacheMap ( IN PFILE_OBJECT  FileObject)

Definition at line 2883 of file memory.c.

2886{
2887 CACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent;
2888 NTSTATUS WaitStatus;
2889 LARGE_INTEGER Ext2LargeZero = {0,0};
2890
2891
2892 KeInitializeEvent( &UninitializeCompleteEvent.Event,
2894 FALSE);
2895
2897 &Ext2LargeZero,
2898 &UninitializeCompleteEvent );
2899
2900 WaitStatus = KeWaitForSingleObject( &UninitializeCompleteEvent.Event,
2901 Executive,
2902 KernelMode,
2903 FALSE,
2904 NULL);
2905
2906 ASSERT (NT_SUCCESS(WaitStatus));
2907}

Referenced by Ext2InitializeVcb(), and Ext2TearDownStream().

◆ Ext2TearDownStream()

VOID Ext2TearDownStream ( IN PEXT2_VCB  Vcb)

Definition at line 2798 of file memory.c.

2799{
2800 PFILE_OBJECT Stream = Vcb->Volume;
2802
2803 ASSERT(Vcb != NULL);
2804 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2805 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2806
2807 if (Stream) {
2808
2809 Vcb->Volume = NULL;
2810
2811 if (IsFlagOn(Stream->Flags, FO_FILE_MODIFIED)) {
2812 CcFlushCache(&(Vcb->SectionObject), NULL, 0, &IoStatus);
2814 }
2815
2816 if (Stream->PrivateCacheMap) {
2818 }
2819
2821 }
2822}
VOID Ext2SyncUninitializeCacheMap(IN PFILE_OBJECT FileObject)
Definition: memory.c:2883
static IStream Stream
Definition: htmldoc.c:1115

Referenced by Ext2CheckDismount(), and Ext2DestroyVcb().

◆ Ext2TotalBlocks()

ULONG Ext2TotalBlocks ( PEXT2_VCB  Vcb,
PLARGE_INTEGER  Size,
PULONG  pMeta 
)

Definition at line 1077 of file fileinfo.c.

1082{
1083 ULONG Blocks, Meta =0, Remain;
1084
1085 Blocks = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1086 if (Blocks <= EXT2_NDIR_BLOCKS)
1087 goto errorout;
1088 Blocks -= EXT2_NDIR_BLOCKS;
1089
1090 Meta += 1;
1091 if (Blocks <= Vcb->max_blocks_per_layer[1]) {
1092 goto errorout;
1093 }
1094 Blocks -= Vcb->max_blocks_per_layer[1];
1095
1096level2:
1097
1098 if (Blocks <= Vcb->max_blocks_per_layer[2]) {
1099 Meta += 1 + ((Blocks + BLOCK_SIZE/4 - 1) >> (BLOCK_BITS - 2));
1100 goto errorout;
1101 }
1102 Meta += 1 + BLOCK_SIZE/4;
1103 Blocks -= Vcb->max_blocks_per_layer[2];
1104
1105 if (Blocks > Vcb->max_blocks_per_layer[3]) {
1106 Blocks = Vcb->max_blocks_per_layer[3];
1107 }
1108
1109 ASSERT(Vcb->max_blocks_per_layer[2]);
1110 Remain = Blocks % Vcb->max_blocks_per_layer[2];
1111 Blocks = Blocks / Vcb->max_blocks_per_layer[2];
1112 Meta += 1 + Blocks * (1 + BLOCK_SIZE/4);
1113 if (Remain) {
1114 Blocks = Remain;
1115 goto level2;
1116 }
1117
1118errorout:
1119
1120 if (pMeta)
1121 *pMeta = Meta;
1122 Blocks = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1123 return (Blocks + Meta);
1124}

Referenced by Ext2CreateFile().

◆ Ext2TraceIrpContext()

__inline VOID Ext2TraceIrpContext ( BOOLEAN  _n,
PEXT2_IRP_CONTEXT  IrpContext 
)

Definition at line 1174 of file ext2fs.h.

1175{
1176 if (_n) {
1177 INC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
1178 InterlockedIncrement(&(Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Current));
1179 } else {
1180 DEC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
1181 InterlockedIncrement(&Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Processed);
1183 }
1184}
#define InterlockedIncrement
Definition: armddk.h:53
#define PS_IRP_CONTEXT
Definition: common.h:16

◆ Ext2TraceMemory()

__inline VOID Ext2TraceMemory ( BOOLEAN  _n,
int  _i,
PVOID  _p,
LONG  _s 
)

Definition at line 1157 of file ext2fs.h.

1158{
1159 if (_n) {
1163 } else {
1166 }
1167}
#define InterlockedExchangeAdd
Definition: interlocked.h:181
ULONG Slot[PS_MAX_TYPE_V2]
Definition: common.h:67

◆ Ext2TruncateBlock()

NTSTATUS Ext2TruncateBlock ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONG  Base,
IN ULONG  Start,
IN ULONG  Layer,
IN ULONG  SizeArray,
IN PULONG  BlockArray,
IN PULONG  Extra 
)

Definition at line 632 of file indirect.c.

643{
645 ULONG i = 0;
646 ULONG Slot = 0;
647 ULONG Skip = 0;
648
650 PBCB Bcb = NULL;
651 PULONG pData = NULL;
652
653 ASSERT(Mcb != NULL);
654
655 for (i = 0; i < SizeArray; i++) {
656
657 if (Layer == 0) {
658
659 ULONG Number = 1;
660
661 while (Extra && SizeArray > i + 1 && Number < *Extra) {
662
663 if (BlockArray[SizeArray - i - 1] ==
664 BlockArray[SizeArray - i - 2] + 1) {
665
666 BlockArray[SizeArray - i - 1] = 0;
667 Number++;
668 SizeArray--;
669
670 } else {
671 break;
672 }
673 }
674
675 if (BlockArray[SizeArray - i - 1]) {
676
677 Status = Ext2FreeBlock(IrpContext, Vcb, BlockArray[SizeArray - i - 1], Number);
678 if (NT_SUCCESS(Status)) {
679 ASSERT(Mcb->Inode.i_blocks >= (Number << (BLOCK_BITS - 9)));
680 if (Mcb->Inode.i_blocks < (Number << (BLOCK_BITS - 9))) {
681 Mcb->Inode.i_blocks = 0;
682 DbgBreak();
683 } else {
684 Mcb->Inode.i_blocks -= (Number << (BLOCK_BITS - 9));
685 }
686 BlockArray[SizeArray - i - 1] = 0;
687 }
688 }
689
690 if (Extra) {
691
692 /* dec blocks count */
693 ASSERT(*Extra >= Number);
694 *Extra = *Extra - Number;
695
696 /* remove block mapping frm Mcb Extents */
697 if (!Ext2RemoveBlockExtent(Vcb, Mcb, Base + SizeArray - 1 - i, Number)) {
698 DbgBreak();
700 Ext2ClearAllExtents(&Mcb->Extents);
701 }
702 }
703
704 } else {
705
706 ASSERT(Layer <= 3);
707
708 if (BlockArray[SizeArray - i - 1] >= TOTAL_BLOCKS) {
709 DbgBreak();
710 BlockArray[SizeArray - i - 1] = 0;
711 }
712
713 if (i == 0) {
714 if (Layer > 1) {
715 Slot = Start / Vcb->max_blocks_per_layer[Layer - 1];
716 Start = Start % Vcb->max_blocks_per_layer[Layer - 1];
717 } else {
718 Slot = Start;
719 Start = (BLOCK_SIZE / 4) - 1;
720 }
721 } else {
722 Slot = Start = (BLOCK_SIZE / 4) - 1;
723 }
724
725 Skip = (SizeArray - i - 1) * Vcb->max_blocks_per_layer[Layer];
726
727 if (BlockArray[SizeArray - i - 1]) {
728
729 Offset = (LONGLONG) (BlockArray[SizeArray - i - 1]);
731
732 if (!CcPinRead( Vcb->Volume,
735 PIN_WAIT,
736 &Bcb,
737#ifdef __REACTOS__
738 (void **)&pData )) {
739#else
740 &pData )) {
741#endif
742
743 DEBUG(DL_ERR, ( "Ext2TruncateBlock: PinLock failed on block %xh ...\n",
744 BlockArray[SizeArray - i - 1]));
746 DbgBreak();
747 goto errorout;
748 }
749
751 IrpContext,
752 Vcb,
753 Mcb,
754 Base + Skip,
755 Start,
756 Layer - 1,
757 Slot + 1,
758 &pData[0],
759 Extra
760 );
761
762 if (!NT_SUCCESS(Status)) {
763 break;
764 }
765
768
769 if (*Extra || Ext2IsBlockEmpty(pData, BLOCK_SIZE/4)) {
770
772 IrpContext,
773 Vcb,
774 Mcb,
775 Base + Skip, /* base */
776 0, /* start */
777 0, /* layer */
778 1,
779 &BlockArray[SizeArray - i - 1],
780 NULL
781 );
782
783 if (!Ext2RemoveMcbMetaExts(Vcb, Mcb, BlockArray[SizeArray - i - 1], 1)) {
784 DbgBreak();
785 Ext2Sleep(500);
786 Ext2RemoveMcbMetaExts(Vcb, Mcb, BlockArray[SizeArray - i - 1], 1);
787 }
788 }
789
790 if (pData) {
792 Bcb = NULL;
793 pData = NULL;
794 }
795
796 } else {
797
798 if (Layer > 1) {
799 if (*Extra > Slot * Vcb->max_blocks_per_layer[Layer - 1] + Start + 1) {
800 *Extra -= (Slot * Vcb->max_blocks_per_layer[Layer - 1] + Start + 1);
801 } else {
802 *Extra = 0;
803 }
804 } else {
805 if (*Extra > Slot + 1) {
806 *Extra -= (Slot + 1);
807 } else {
808 *Extra = 0;
809 }
810 }
811
812 if (!Ext2RemoveBlockExtent(Vcb, Mcb, Base + Skip, (Start + 1))) {
813 DbgBreak();
815 Ext2ClearAllExtents(&Mcb->Extents);
816 }
817 }
818 }
819
820 if (Extra && *Extra == 0) {
821 break;
822 }
823 }
824
825errorout:
826
827 if (pData) {
829 }
830
831 return Status;
832}
NTSTATUS Ext2FreeBlock(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Block, IN ULONG Number)
Definition: generic.c:1217
BOOLEAN Ext2RemoveMcbMetaExts(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Block, IN ULONG Length)
Definition: memory.c:985
NTSTATUS Ext2TruncateBlock(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Base, IN ULONG Start, IN ULONG Layer, IN ULONG SizeArray, IN PULONG BlockArray, IN PULONG Extra)
Definition: indirect.c:632
BOOLEAN Ext2IsBlockEmpty(PULONG BlockArray, ULONG SizeArray)
Definition: indirect.c:619

Referenced by Ext2TruncateBlock(), and Ext2TruncateIndirect().

◆ Ext2TruncateExtent()

NTSTATUS Ext2TruncateExtent ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
PLARGE_INTEGER  Size 
)

Definition at line 200 of file extents.c.

206{
208
209 ULONG Extra = 0;
210 ULONG Wanted = 0;
211 ULONG End;
213 int err;
214
215 /* translate file size to block */
216 End = Vcb->max_data_blocks;
217 Wanted = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
218
219 /* calculate blocks to be freed */
220 Extra = End - Wanted;
221
222 err = ext4_ext_truncate(IrpContext, &Mcb->Inode, Wanted);
223 if (err == 0) {
224 if (!Ext2RemoveBlockExtent(Vcb, Mcb, Wanted, Extra)) {
226 Ext2ClearAllExtents(&Mcb->Extents);
227 }
228 Extra = 0;
229 } else {
231 }
232
233 if (!NT_SUCCESS(Status)) {
234 Size->QuadPart += ((ULONGLONG)Extra << BLOCK_BITS);
235 }
236
237 if (Mcb->Inode.i_size > (loff_t)(Size->QuadPart))
238 Mcb->Inode.i_size = (loff_t)(Size->QuadPart);
239
240 /* Save modifications on i_blocks field and i_size field of the inode. */
241 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
242
243 return Status;
244}
int ext4_ext_truncate(void *icb, struct inode *inode, unsigned long start)
@ Removed
Definition: fbtusb.h:86

Referenced by Ext2TruncateFile().

◆ Ext2TruncateFile()

NTSTATUS Ext2TruncateFile ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
PLARGE_INTEGER  AllocationSize 
)

Definition at line 1204 of file fileinfo.c.

1210{
1212
1213 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
1214 status = Ext2TruncateExtent(IrpContext, Vcb, Mcb, Size);
1215 } else {
1216 status = Ext2TruncateIndirect(IrpContext, Vcb, Mcb, Size);
1217 }
1218
1219 /* check and clear data/meta mcb extents */
1220 if (Size->QuadPart == 0) {
1221
1222 /* check and remove all data extents */
1223 if (Ext2ListExtents(&Mcb->Extents)) {
1224 DbgBreak();
1225 }
1226 Ext2ClearAllExtents(&Mcb->Extents);
1227 /* check and remove all meta extents */
1228 if (Ext2ListExtents(&Mcb->MetaExts)) {
1229 DbgBreak();
1230 }
1231 Ext2ClearAllExtents(&Mcb->MetaExts);
1233 }
1234
1235 return status;
1236}
NTSTATUS Ext2TruncateExtent(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: extents.c:200
NTSTATUS Ext2TruncateIndirect(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: indirect.c:1099
BOOLEAN Ext2ListExtents(PLARGE_MCB Extents)
Definition: memory.c:558

Referenced by Ext2Cleanup(), Ext2CreateFile(), Ext2DeleteFile(), Ext2SetFileInformation(), Ext2SetReparsePoint(), Ext2SupersedeOrOverWriteFile(), Ext2TruncateSymlink(), and Ext2WriteSymlink().

◆ Ext2TruncateIndirect()

NTSTATUS Ext2TruncateIndirect ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
PLARGE_INTEGER  Size 
)

Definition at line 1099 of file indirect.c.

1105{
1107
1108 ULONG Layer = 0;
1109
1110 ULONG Extra = 0;
1111 ULONG Wanted = 0;
1112 ULONG End;
1113 ULONG Base;
1114
1115 ULONG SizeArray = 0;
1116 PULONG BlockArray = NULL;
1117
1118 /* translate file size to block */
1119 End = Base = Vcb->max_data_blocks;
1120 Wanted = (ULONG)((Size->QuadPart + BLOCK_SIZE - 1) >> BLOCK_BITS);
1121
1122 /* do fast deletion here */
1123 if (Wanted == 0) {
1124 Status = Ext2TruncateIndirectFast(IrpContext, Vcb, Mcb);
1125 if (NT_SUCCESS(Status))
1126 goto errorout;
1127 }
1128
1129 /* calculate blocks to be freed */
1130 Extra = End - Wanted;
1131
1132 for (Layer = EXT2_BLOCK_TYPES; Layer > 0 && Extra; Layer--) {
1133
1134 if (Vcb->max_blocks_per_layer[Layer - 1] == 0) {
1135 continue;
1136 }
1137
1138 Base -= Vcb->max_blocks_per_layer[Layer - 1];
1139
1140 if (Layer - 1 == 0) {
1141#ifdef __REACTOS__
1142 BlockArray = (PULONG)&Mcb->Inode.i_block[0];
1143#else
1144 BlockArray = &Mcb->Inode.i_block[0];
1145#endif
1146 SizeArray = End;
1147 ASSERT(End == EXT2_NDIR_BLOCKS && Base == 0);
1148 } else {
1149#ifdef __REACTOS__
1150 BlockArray = (PULONG)&Mcb->Inode.i_block[EXT2_NDIR_BLOCKS - 1 + Layer - 1];
1151#else
1152 BlockArray = &Mcb->Inode.i_block[EXT2_NDIR_BLOCKS - 1 + Layer - 1];
1153#endif
1154 SizeArray = 1;
1155 }
1156
1158 IrpContext,
1159 Vcb,
1160 Mcb,
1161 Base,
1162 End - Base - 1,
1163 Layer - 1,
1164 SizeArray,
1165 BlockArray,
1166 &Extra
1167 );
1168 if (!NT_SUCCESS(Status)) {
1169 break;
1170 }
1171
1172 End = Base;
1173 }
1174
1175errorout:
1176
1177 if (!NT_SUCCESS(Status)) {
1178 Size->QuadPart += ((ULONGLONG)Extra << BLOCK_BITS);
1179 }
1180
1181 /* save inode */
1182 if (Mcb->Inode.i_size > (loff_t)(Size->QuadPart))
1183 Mcb->Inode.i_size = (loff_t)(Size->QuadPart);
1184 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
1185
1186 return Status;
1187}
NTSTATUS Ext2TruncateIndirectFast(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb)
Definition: indirect.c:1035

Referenced by Ext2TruncateFile().

◆ Ext2TruncateSymlink()

NTSTATUS Ext2TruncateSymlink ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
ULONG  Size 
)

Definition at line 1751 of file fsctl.c.

1757{
1759 PUCHAR data = (PUCHAR)&Mcb->Inode.i_block;
1760 ULONG len = (ULONG)Mcb->Inode.i_size;
1762
1763 if (len < EXT2_LINKLEN_IN_INODE && !Mcb->Inode.i_blocks) {
1764
1766 Mcb->Inode.i_size = Size;
1767 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
1768
1769 } else {
1770 NewSize.QuadPart = Size;
1771 status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &NewSize);
1772 if (!NT_SUCCESS(status)) {
1773 goto out;
1774 }
1775 }
1776
1777out:
1778 return status;
1779}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static FILE * out
Definition: regtests2xml.c:44

Referenced by Ext2DeleteReparsePoint().

◆ Ext2UnicodeToOEM()

NTSTATUS Ext2UnicodeToOEM ( IN PEXT2_VCB  Vcb,
IN OUT POEM_STRING  Oem,
IN PUNICODE_STRING  Unicode 
)

Definition at line 261 of file misc.c.

265{
267
268 if (Vcb->Codepage.PageTable) {
269
270 Status = Ext2UnicodeToMbs(Vcb->Codepage.PageTable,
271 Oem, Unicode);
272 if (Status > 0 && Status == Oem->Length) {
274 } else {
276 DbgBreak();
277 }
278
279 goto errorout;
280 }
281
283 Oem, Unicode, FALSE );
284
285 if (!NT_SUCCESS(Status))
286 {
287 DbgBreak();
288 goto errorout;
289 }
290
291errorout:
292
293 return Status;
294}
ULONG Ext2UnicodeToMbs(struct nls_table *PageTable, IN OUT PANSI_STRING Mbs, IN PUNICODE_STRING Unicode)
Definition: misc.c:122
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)

Referenced by Ext2BuildEntry(), Ext2SetReparsePoint(), and Ext2SetVolumeInformation().

◆ Ext2UnicodeToOEMSize()

ULONG Ext2UnicodeToOEMSize ( IN PEXT2_VCB  Vcb,
IN PUNICODE_STRING  Unicode 
)

Definition at line 239 of file misc.c.

243{
244 ULONG Length = 0;
245
246 if (Vcb->Codepage.PageTable) {
247 Length = Ext2UnicodeToMbs(Vcb->Codepage.PageTable,
248 NULL, Unicode);
249 if (Length > 0) {
250 return Length;
251 }
252
253 DbgBreak();
254 }
255
256 return RtlxUnicodeStringToOemSize(Unicode);
257}
NTSYSAPI ULONG NTAPI RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString)
Definition: unicode.c:1091

Referenced by Ext2BuildEntry(), and Ext2SetReparsePoint().

◆ Ext2UnlinkFcb()

VOID Ext2UnlinkFcb ( IN PEXT2_FCB  Fcb)

Definition at line 202 of file memory.c.

203{
204 PEXT2_VCB Vcb = Fcb->Vcb;
206
208 Mcb = Fcb->Mcb;
209
210 DEBUG(DL_INF, ("Ext2FreeFcb: Fcb (%p) to be unlinked: %wZ.\n",
211 Fcb, Mcb ? &Mcb->FullName : NULL));
212
213 if ((Mcb != NULL) &&
214 (Mcb->Identifier.Type == EXT2MCB) &&
215 (Mcb->Identifier.Size == sizeof(EXT2_MCB))) {
216
217 ASSERT (Mcb->Fcb == Fcb);
218 if (IsMcbSpecialFile(Mcb) ||
220
221 ASSERT(!IsRoot(Fcb));
223 Mcb->Fcb = NULL;
224
228
229 } else {
230 Mcb->Fcb = NULL;
232 }
233 Fcb->Mcb = NULL;
234 }
235
236 ExReleaseResourceLite(&Vcb->McbLock);
237}

Referenced by Ext2QueryUnusedFcb().

◆ Ext2UnlinkMcb()

VOID Ext2UnlinkMcb ( PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb 
)

Definition at line 2957 of file memory.c.

2958{
2959 if (Mcb->Inode.i_ino == EXT2_ROOT_INO) {
2960 return;
2961 }
2962
2964
2965 if (IsFlagOn(Mcb->Flags, MCB_VCB_LINK)) {
2966 RemoveEntryList(&(Mcb->Link));
2968 Ext2DerefXcb(&Vcb->NumOfMcb);
2969 } else {
2970 DEBUG(DL_RES, ( "Ext2UnlinkMcb: %wZ already unlinked.\n",
2971 &Mcb->FullName));
2972 }
2973 ExReleaseResourceLite(&Vcb->McbLock);
2974}

Referenced by Ext2FreeCcb(), and Ext2UnlinkFcb().

◆ Ext2UnloadAllNls()

VOID Ext2UnloadAllNls ( )

Definition at line 181 of file nls.c.

182{
183
184#ifdef FULL_CODEPAGES_SUPPORT
185
223
224 /* unloading chinese codepages */
227
228#endif //FULL_CODEPAGES_SUPPORT
229
230 /* unloading nls of utf8 */
232}
#define UNLOAD_NLS
Definition: module.h:293
static void __exit exit_nls_cp1251(void)
Definition: nls_cp1251.c:295
static void __exit exit_nls_cp1255(void)
Definition: nls_cp1255.c:376
static void __exit exit_nls_cp437(void)
Definition: nls_cp437.c:381
static void __exit exit_nls_cp737(void)
Definition: nls_cp737.c:344
static void __exit exit_nls_cp775(void)
Definition: nls_cp775.c:313
static void __exit exit_nls_cp850(void)
Definition: nls_cp850.c:309
static void __exit exit_nls_cp852(void)
Definition: nls_cp852.c:331
static void __exit exit_nls_cp855(void)
Definition: nls_cp855.c:293
static void __exit exit_nls_cp857(void)
Definition: nls_cp857.c:295
static void __exit exit_nls_cp860(void)
Definition: nls_cp860.c:358
static void __exit exit_nls_cp861(void)
Definition: nls_cp861.c:381
static void __exit exit_nls_cp862(void)
Definition: nls_cp862.c:415
static void __exit exit_nls_cp863(void)
Definition: nls_cp863.c:375
static void __exit exit_nls_cp864(void)
Definition: nls_cp864.c:401
static void __exit exit_nls_cp865(void)
Definition: nls_cp865.c:381
static void __exit exit_nls_cp866(void)
Definition: nls_cp866.c:299
static void __exit exit_nls_cp869(void)
Definition: nls_cp869.c:309
static void __exit exit_nls_cp874(void)
Definition: nls_cp874.c:267
static void __exit exit_nls_cp932(void)
Definition: nls_cp932.c:7937
static void __exit exit_nls_cp936(void)
Definition: nls_cp936.c:11022
static void __exit exit_nls_cp949(void)
Definition: nls_cp949.c:13939
static void __exit exit_nls_cp950(void)
Definition: nls_cp950.c:9478
static void __exit exit_nls_euc_jp(void)
Definition: nls_euc-jp.c:578
static void __exit exit_nls_iso8859_13(void)
static void __exit exit_nls_iso8859_14(void)
static void __exit exit_nls_iso8859_15(void)
static void __exit exit_nls_iso8859_1(void)
static void __exit exit_nls_iso8859_2(void)
static void __exit exit_nls_iso8859_3(void)
static void __exit exit_nls_iso8859_4(void)
static void __exit exit_nls_iso8859_5(void)
static void __exit exit_nls_iso8859_6(void)
static void __exit exit_nls_iso8859_7(void)
static void __exit exit_nls_iso8859_9(void)
static void __exit exit_nls_koi8_r(void)
Definition: nls_koi8-r.c:317
static void __exit exit_nls_koi8_ru(void)
Definition: nls_koi8-ru.c:76
static void __exit exit_nls_koi8_u(void)
Definition: nls_koi8-u.c:324
static void __exit exit_nls_utf8(void)
Definition: nls_utf8.c:55

◆ Ext2UnlockVcb()

NTSTATUS Ext2UnlockVcb ( IN PEXT2_VCB  Vcb,
IN PFILE_OBJECT  FileObject 
)

Definition at line 206 of file fsctl.c.

208{
210
211 _SEH2_TRY {
212
213 if (FileObject && FileObject->FsContext != Vcb) {
216 }
217
218 if (!FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
219 DEBUG(DL_ERR, ( ": Ext2UnlockVcb: Volume is not locked.\n"));
222 }
223
224 if (Vcb->LockFile == FileObject) {
227 DEBUG(DL_INF, ( "Ext2UnlockVcb: Volume unlocked.\n"));
229 } else {
231 }
232
233 } _SEH2_FINALLY {
234 // Nothing
235 } _SEH2_END;
236
237 return Status;
238}
VOID Ext2ClearVpbFlag(IN PVPB Vpb, IN USHORT Flag)
Definition: fsctl.c:56
#define STATUS_NOT_LOCKED
Definition: ntstatus.h:279

Referenced by Ext2UnlockVolume().

◆ Ext2UnlockVolume()

NTSTATUS Ext2UnlockVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 241 of file fsctl.c.

244{
249 BOOLEAN VcbResourceAcquired = FALSE;
250
251 _SEH2_TRY {
252
253 ASSERT(IrpContext != NULL);
254 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
255 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
256
257 DeviceObject = IrpContext->DeviceObject;
258 IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
259
260 //
261 // This request is not allowed on the main device object
262 //
266 }
267
268 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
269 ASSERT(Vcb != NULL);
270 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
271 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
272
274 &Vcb->MainResource,
275 TRUE );
276 VcbResourceAcquired = TRUE;
277
279
280 } _SEH2_FINALLY {
281
282 if (VcbResourceAcquired) {
283 ExReleaseResourceLite(&Vcb->MainResource);
284 }
285
286 if (!IrpContext->ExceptionInProgress) {
287 Ext2CompleteIrpContext(IrpContext, Status);
288 }
289 } _SEH2_END;
290
291 return Status;
292}
NTSTATUS Ext2UnlockVcb(IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject)
Definition: fsctl.c:206

Referenced by Ext2UserFsRequest().

◆ Ext2UpdateGroupDirStat()

NTSTATUS Ext2UpdateGroupDirStat ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN ULONG  Group 
)

Definition at line 1728 of file generic.c.

1733{
1734 struct super_block *sb = &Vcb->sb;
1736 struct buffer_head *gb = NULL;
1738
1740
1741 /* get group desc */
1742 gd = ext4_get_group_desc(sb, group, &gb);
1743 if (!gd) {
1745 goto errorout;
1746 }
1747
1748 /* update group_desc and super_block */
1750 Ext2SaveGroup(IrpContext, Vcb, group);
1751 Ext2UpdateVcbStat(IrpContext, Vcb);
1753
1754errorout:
1755
1756 ExReleaseResourceLite(&Vcb->MetaInode);
1757
1758 if (gb)
1759 fini_bh(&gb);
1760
1761 return status;
1762}

Referenced by Ext2SetReparsePoint().

◆ Ext2UpdateVcbStat()

VOID Ext2UpdateVcbStat ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 997 of file generic.c.

1001{
1002 Vcb->SuperBlock->s_free_inodes_count = ext4_count_free_inodes(&Vcb->sb);
1004 Ext2SaveSuper(IrpContext, Vcb);
1005}
static void ext3_free_blocks_count_set(struct ext3_super_block *es, ext3_fsblk_t blk)
Definition: ext2fs.h:1770
ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
Definition: generic.c:3033
unsigned long ext4_count_free_inodes(struct super_block *sb)
Definition: generic.c:3054
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:67

Referenced by Ext2FreeBlock(), Ext2FreeInode(), Ext2NewBlock(), Ext2NewInode(), and Ext2UpdateGroupDirStat().

◆ Ext2UserFsRequest()

NTSTATUS Ext2UserFsRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1903 of file fsctl.c.

1904{
1905 PIRP Irp;
1906 PIO_STACK_LOCATION IoStackLocation;
1909
1910 ASSERT(IrpContext);
1911
1912 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
1913 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
1914
1915 Irp = IrpContext->Irp;
1916 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
1917
1918#ifndef _GNU_NTIFS_
1920 IoStackLocation->Parameters.FileSystemControl.FsControlCode;
1921#else
1923 IoStackLocation)->Parameters.FileSystemControl.FsControlCode;
1924#endif
1925
1926 switch (FsControlCode) {
1927
1929 Status = Ext2GetReparsePoint(IrpContext);
1930 break;
1931
1933 Status = Ext2SetReparsePoint(IrpContext);
1934 break;
1935
1937 Status = Ext2DeleteReparsePoint(IrpContext);
1938 break;
1939
1940 case FSCTL_LOCK_VOLUME:
1941 Status = Ext2LockVolume(IrpContext);
1942 break;
1943
1945 Status = Ext2UnlockVolume(IrpContext);
1946 break;
1947
1949 Status = Ext2DismountVolume(IrpContext);
1950 break;
1951
1953 Status = Ext2IsVolumeMounted(IrpContext);
1954 break;
1955
1957 Status = Ext2InvalidateVolumes(IrpContext);
1958 break;
1959
1960#if (_WIN32_WINNT >= 0x0500)
1962 Status = Ext2AllowExtendedDasdIo(IrpContext);
1963 break;
1964#endif //(_WIN32_WINNT >= 0x0500)
1965
1973
1974 Status = Ext2OplockRequest(IrpContext);
1975 break;
1976
1978 Status = Ext2IsVolumeDirty(IrpContext);
1979 break;
1980
1982 Status = Ext2QueryRetrievalPointers(IrpContext);
1983 break;
1984
1986 Status = Ext2GetRetrievalPointers(IrpContext);
1987 break;
1988
1990 Status = Ext2GetRetrievalPointerBase(IrpContext);
1991 break;
1992
1993 default:
1994
1995 DEBUG(DL_INF, ( "Ext2UserFsRequest: Invalid User Request: %xh.\n", FsControlCode));
1997
1998 Ext2CompleteIrpContext(IrpContext, Status);
1999 }
2000
2001 return Status;
2002}
NTSTATUS Ext2UnlockVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:241
NTSTATUS Ext2QueryRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:774
NTSTATUS Ext2OplockRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:451
NTSTATUS Ext2DeleteReparsePoint(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1784
NTSTATUS Ext2AllowExtendedDasdIo(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:407
NTSTATUS Ext2GetRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:911
NTSTATUS Ext2DismountVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2521
NTSTATUS Ext2GetRetrievalPointerBase(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1160
NTSTATUS Ext2GetReparsePoint(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1386
NTSTATUS Ext2InvalidateVolumes(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:296
NTSTATUS Ext2IsVolumeMounted(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2494
NTSTATUS Ext2LockVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:136
NTSTATUS Ext2IsVolumeDirty(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:618
NTSTATUS Ext2SetReparsePoint(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1572
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG FsControlCode
Definition: fltkernel.h:1370
#define FSCTL_QUERY_RETRIEVAL_POINTERS
Definition: nt_native.h:840
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
#define FSCTL_INVALIDATE_VOLUMES
Definition: nt_native.h:847
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
#define FSCTL_IS_VOLUME_MOUNTED
Definition: nt_native.h:836
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
#define FSCTL_GET_REPARSE_POINT
Definition: winioctl.h:97
#define FSCTL_SET_REPARSE_POINT
Definition: winioctl.h:98
#define FSCTL_IS_VOLUME_DIRTY
Definition: winioctl.h:714
#define FSCTL_DELETE_REPARSE_POINT
Definition: winioctl.h:99
#define FSCTL_ALLOW_EXTENDED_DASD_IO
Definition: winioctl.h:124

Referenced by Ext2FileSystemControl().

◆ Ext2VerifyVcb()

VOID Ext2VerifyVcb ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 2277 of file fsctl.c.

2279{
2281
2283 ULONG ChangeCount = 0;
2284 ULONG dwBytes;
2285
2286 PIRP Irp;
2288
2289 _SEH2_TRY {
2290
2291 ASSERT(IrpContext != NULL);
2292
2293 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2294 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2295
2296 Irp = IrpContext->Irp;
2298
2299 bVerify = IsFlagOn(Vcb->Vpb->RealDevice->Flags, DO_VERIFY_VOLUME);
2300
2301 if ( (IsFlagOn(Vcb->Flags, VCB_REMOVABLE_MEDIA) ||
2302 IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) && !bVerify ) {
2303
2304 dwBytes = sizeof(ULONG);
2306 Vcb->TargetDeviceObject,
2308 NULL,
2309 0,
2310 &ChangeCount,
2311 &dwBytes );
2312
2316 (NT_SUCCESS(Status) &&
2317 (ChangeCount != Vcb->ChangeCount))) {
2318
2319 KIRQL Irql;
2320
2322 if (Vcb->Vpb == Vcb->Vpb->RealDevice->Vpb) {
2323 SetFlag(Vcb->Vpb->RealDevice->Flags, DO_VERIFY_VOLUME);
2324 }
2326
2327 } else {
2328
2329 if (!NT_SUCCESS(Status)) {
2331 }
2332 }
2333 }
2334
2335 if ( IsFlagOn(Vcb->Vpb->RealDevice->Flags, DO_VERIFY_VOLUME)) {
2336 IoSetHardErrorOrVerifyDevice( Irp, Vcb->Vpb->RealDevice );
2337 Ext2NormalizeAndRaiseStatus ( IrpContext,
2339 }
2340
2341 if (IsMounted(Vcb)) {
2342
2343 if ( (IrpContext->MajorFunction == IRP_MJ_WRITE) ||
2344 (IrpContext->MajorFunction == IRP_MJ_SET_INFORMATION) ||
2345 (IrpContext->MajorFunction == IRP_MJ_SET_EA) ||
2346 (IrpContext->MajorFunction == IRP_MJ_FLUSH_BUFFERS) ||
2347 (IrpContext->MajorFunction == IRP_MJ_SET_VOLUME_INFORMATION) ||
2348 (IrpContext->MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL &&
2349 IrpContext->MinorFunction == IRP_MN_USER_FS_REQUEST &&
2350 IrpSp->Parameters.FileSystemControl.FsControlCode ==
2352
2353 if (IsFlagOn(Vcb->Flags, VCB_WRITE_PROTECTED)) {
2354
2355 KIRQL Irql;
2356
2358 if (Vcb->Vpb == Vcb->Vpb->RealDevice->Vpb) {
2359 SetFlag (Vcb->Vpb->RealDevice->Flags, DO_VERIFY_VOLUME);
2360 }
2362
2363 IoSetHardErrorOrVerifyDevice( Irp, Vcb->Vpb->RealDevice );
2364
2366 }
2367 }
2368 }
2369
2370 } _SEH2_FINALLY {
2371
2372 } _SEH2_END;
2373
2374}
#define IOCTL_DISK_CHECK_VERIFY
Definition: cdrw_usr.h:175
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define Ext2RaiseStatus(IRPCONTEXT, STATUS)
Definition: ext2fs.h:263
#define VCB_REMOVABLE_MEDIA
Definition: ext2fs.h:808
#define FSCTL_MARK_VOLUME_DIRTY
Definition: nt_native.h:838
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141

Referenced by Ext2Create(), Ext2Flush(), Ext2IsVolumeMounted(), and Ext2SetVolumeInformation().

◆ Ext2VerifyVolume()

NTSTATUS Ext2VerifyVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2378 of file fsctl.c.

2379{
2382 PEXT2_SUPER_BLOCK ext2_sb = NULL;
2383 PEXT2_VCB Vcb = NULL;
2384 BOOLEAN VcbResourceAcquired = FALSE;
2385 PIRP Irp;
2386 ULONG ChangeCount = 0;
2387 ULONG dwBytes;
2388
2389 _SEH2_TRY {
2390
2391 ASSERT(IrpContext != NULL);
2392 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2393 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2394
2395 DeviceObject = IrpContext->DeviceObject;
2396 //
2397 // This request is not allowed on the main device object
2398 //
2402 }
2403
2404 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
2405 ASSERT(Vcb != NULL);
2406 ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2407 (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2408
2409 VcbResourceAcquired =
2411 &Vcb->MainResource,
2412 TRUE );
2413
2414 if (!FlagOn(Vcb->TargetDeviceObject->Flags, DO_VERIFY_VOLUME)) {
2417 }
2418
2419 if (!IsMounted(Vcb)) {
2422 }
2423
2424 dwBytes = sizeof(ULONG);
2426 Vcb->TargetDeviceObject,
2428 NULL,
2429 0,
2430 &ChangeCount,
2431 &dwBytes );
2432
2433
2434 if (!NT_SUCCESS(Status)) {
2437 } else {
2438 Vcb->ChangeCount = ChangeCount;
2439 }
2440
2441 Irp = IrpContext->Irp;
2442
2443 Status = Ext2LoadSuper(Vcb, TRUE, &ext2_sb);
2444
2445 if (!NT_SUCCESS(Status)) {
2447 }
2448
2449 ASSERT(NULL != ext2_sb);
2450 if ((ext2_sb->s_magic == EXT2_SUPER_MAGIC) &&
2451 (memcmp(ext2_sb->s_uuid, SUPER_BLOCK->s_uuid, 16) == 0) &&
2452 (memcmp(ext2_sb->s_volume_name, SUPER_BLOCK->s_volume_name, 16) ==0)) {
2453
2454 ClearFlag(Vcb->TargetDeviceObject->Flags, DO_VERIFY_VOLUME);
2455
2456 if (Ext2IsMediaWriteProtected(IrpContext, Vcb->TargetDeviceObject)) {
2458 } else {
2460 }
2461
2462 DEBUG(DL_INF, ( "Ext2VerifyVolume: Volume verify succeeded.\n"));
2463
2464 } else {
2465
2468
2470 ClearFlag(Vcb->TargetDeviceObject->Flags, DO_VERIFY_VOLUME);
2471
2472 DEBUG(DL_INF, ( "Ext2VerifyVolume: Volume verify failed.\n"));
2473 }
2474
2475 } _SEH2_FINALLY {
2476
2477 if (ext2_sb)
2478 Ext2FreePool(ext2_sb, EXT2_SB_MAGIC);
2479
2480 if (VcbResourceAcquired) {
2481 ExReleaseResourceLite(&Vcb->MainResource);
2482 }
2483
2484 if (!IrpContext->ExceptionInProgress) {
2485 Ext2CompleteIrpContext(IrpContext, Status);
2486 }
2487 } _SEH2_END;
2488
2489 return Status;
2490}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BOOLEAN Ext2IsMediaWriteProtected(IN PEXT2_IRP_CONTEXT IrpContext, IN PDEVICE_OBJECT TargetDevice)
Definition: fsctl.c:2005

Referenced by Ext2FileSystemControl().

◆ Ext2WinntError()

NTSTATUS Ext2WinntError ( int  rc)

Definition at line 410 of file misc.c.

411{
412 switch (rc) {
413
414 case 0:
415 return STATUS_SUCCESS;
416
417 case -EPERM:
418 case -EACCES:
420
421 case -ENOENT:
423
424 case -EFAULT:
426
427 case -ETOOSMALL:
429
430 case -EBADMSG:
431 case -EBADF:
432 case -EINVAL:
433 case -EFBIG:
435
436 case -EBUSY:
437 return STATUS_DEVICE_BUSY;
438
439 case -ENOSYS:
441
442 case -ENOSPC:
443 return STATUS_DISK_FULL;
444
445 case -EOPNOTSUPP:
447
448 case -EDEADLK:
450
451 case -EEXIST:
453
454 case -EIO:
456
457 case -ENOTDIR:
459
460 case -EISDIR:
462
463 case -ENOTEMPTY:
465
466 case -ENODEV:
468
469 case -ENXIO:
471
472 case -EADDRNOTAVAIL:
474
475 case -ENETDOWN:
477
478 case -ENETUNREACH:
480
481 case -ECONNABORTED:
483
484 case -ECONNRESET:
486
487 case -ENOMEM:
489
490 case -ENOBUFS:
491 return STATUS_NO_MEMORY;
492
493 case -ENOTCONN:
495
496 case -ESHUTDOWN:
498
499 case -ETIMEDOUT:
500 return STATUS_TIMEOUT;
501
502 case -ECONNREFUSED:
504
505 case -EHOSTUNREACH:
507
508 case -EAGAIN:
509 return STATUS_CANT_WAIT;
510
511 case -EINTR:
512 return STATUS_CANCELLED;
513
514 case -EMSGSIZE:
516
517 case -EADDRINUSE:
519 }
520
521 return STATUS_UNSUCCESSFUL;
522}
#define EBUSY
Definition: acclib.h:87
#define ENODEV
Definition: acclib.h:89
#define EBADF
Definition: acclib.h:82
#define EPERM
Definition: acclib.h:78
#define EBADMSG
Definition: errno.h:80
#define ENXIO
Definition: errno.h:12
#define ENOTDIR
Definition: errno.h:26
#define EISDIR
Definition: errno.h:27
#define EFBIG
Definition: errno.h:33
#define STATUS_POSSIBLE_DEADLOCK
Definition: ntstatus.h:637
#define ENOSYS
Definition: errno.h:57
#define EDEADLK
Definition: errno.h:54
#define ENOTEMPTY
Definition: errno.h:58
#define STATUS_FILE_IS_A_DIRECTORY
Definition: udferr_usr.h:164
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129

Referenced by Ext2AddDotEntries(), Ext2AddEntry(), Ext2DoExtentExpand(), Ext2FreeInode(), Ext2MapExtent(), Ext2NewBlock(), Ext2NewInode(), Ext2OverwriteEa(), Ext2QueryEa(), Ext2QueryFileInformation(), Ext2RemoveEntry(), and Ext2SetEa().

◆ Ext2Write()

NTSTATUS Ext2Write ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1355 of file write.c.

1356{
1358 PEXT2_FCBVCB FcbOrVcb;
1361 PEXT2_VCB Vcb;
1362 BOOLEAN bCompleteRequest = TRUE;
1363
1364 ASSERT(IrpContext);
1365
1366 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
1367 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
1368
1369 _SEH2_TRY {
1370
1371 if (IsFlagOn(IrpContext->MinorFunction, IRP_MN_COMPLETE)) {
1372
1373 Status = Ext2WriteComplete(IrpContext);
1374 bCompleteRequest = FALSE;
1375
1376 } else {
1377
1378 DeviceObject = IrpContext->DeviceObject;
1382 }
1383 FileObject = IrpContext->FileObject;
1384
1385 Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension;
1386
1387 if (Vcb->Identifier.Type != EXT2VCB ||
1388 Vcb->Identifier.Size != sizeof(EXT2_VCB) ) {
1391 }
1392
1393 if (IsVcbReadOnly(Vcb)) {
1396 }
1397
1398 if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED) &&
1399 Vcb->LockFile != FileObject ) {
1402 }
1403
1404 FcbOrVcb = (PEXT2_FCBVCB) FileObject->FsContext;
1405
1406 if (FcbOrVcb->Identifier.Type == EXT2VCB) {
1407
1408 Status = Ext2WriteVolume(IrpContext);
1409 if (!NT_SUCCESS(Status)) {
1410 DbgBreak();
1411 }
1412 bCompleteRequest = FALSE;
1413
1414 } else if (FcbOrVcb->Identifier.Type == EXT2FCB) {
1415
1416 if (IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
1419 }
1420
1421 Status = Ext2WriteFile(IrpContext);
1422 if (!NT_SUCCESS(Status)) {
1423 DbgBreak();
1424 }
1425
1426 bCompleteRequest = FALSE;
1427 } else {
1429 }
1430 }
1431
1432 } _SEH2_FINALLY {
1433
1434 if (bCompleteRequest) {
1435 Ext2CompleteIrpContext(IrpContext, Status);
1436 }
1437 } _SEH2_END;
1438
1439 return Status;
1440}
NTSTATUS Ext2WriteFile(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: write.c:763
NTSTATUS Ext2WriteComplete(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: write.c:1321
NTSTATUS Ext2WriteVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: write.c:236

Referenced by Ext2DispatchRequest().

◆ Ext2WriteInode()

NTSTATUS Ext2WriteInode ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN ULONGLONG  Offset,
IN PVOID  Buffer,
IN ULONG  Size,
IN BOOLEAN  bDirectIo,
OUT PULONG  dwReturn 
)

Definition at line 668 of file write.c.

678{
679 PEXT2_EXTENT Chain = NULL;
681
682 _SEH2_TRY {
683
684 if (BytesWritten) {
685 *BytesWritten = 0;
686 }
687
689 IrpContext,
690 Vcb,
691 Mcb,
692 Offset,
693 Size,
694 S_ISDIR(Mcb->Inode.i_mode) ? FALSE : TRUE,
695 &Chain
696 );
697
698 if (!NT_SUCCESS(Status)) {
700 }
701
702 if (Chain == NULL) {
705 }
706
707 if (bDirectIo) {
708
709 ASSERT(IrpContext != NULL);
710
711 //
712 // We assume the offset is aligned.
713 //
714
716 IrpContext,
717 Vcb,
718 Chain,
719 Size
720 );
721
722 } else {
723
725 for (Extent = Chain; Extent != NULL; Extent = Extent->Next) {
726
727 if ( !Ext2SaveBuffer(
728 IrpContext,
729 Vcb,
730 Extent->Lba,
731 Extent->Length,
732 (PVOID)((PUCHAR)Buffer + Extent->Offset)
733 )) {
735 }
736 }
737
738 if (IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
739
740 DEBUG(DL_FLP, ("Ext2WriteInode is starting FlushingDpc...\n"));
742 }
743
745 }
746
747 } _SEH2_FINALLY {
748
749 if (Chain) {
751 }
752
755 }
756 } _SEH2_END;
757
758 return Status;
759}
#define DL_FLP
Definition: write.c:18
VOID Ext2StartFloppyFlushDpc(PEXT2_VCB Vcb, PEXT2_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:139
BOOLEAN Ext2SaveBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
Definition: generic.c:928
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960

Referenced by Ext2SetParentEntry(), Ext2WriteFile(), and Ext2WriteSymlink().

◆ Ext2WriteSymlink()

NTSTATUS Ext2WriteSymlink ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN PVOID  Buffer,
IN ULONG  Size,
OUT PULONG  BytesWritten 
)

Definition at line 1519 of file fsctl.c.

1527{
1529 PUCHAR Data = (PUCHAR)(&Mcb->Inode.i_block[0]);
1530
1531 if (Size >= EXT2_LINKLEN_IN_INODE) {
1532
1533 /* initialize inode i_block[] */
1534 if (0 == Mcb->Inode.i_blocks) {
1536 ClearFlag(Mcb->Inode.i_flags, EXT4_EXTENTS_FL);
1537 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
1538 }
1539
1540 Status = Ext2WriteInode(IrpContext, Vcb, Mcb,
1541 0, Buffer, Size,
1543 if (!NT_SUCCESS(Status)) {
1544 goto out;
1545 }
1546
1547 } else {
1548
1549 /* free inode blocks before writing in line */
1550 if (Mcb->Inode.i_blocks) {
1551 LARGE_INTEGER Zero = {0, 0};
1552 Ext2TruncateFile(IrpContext, Vcb, Mcb, &Zero);
1553 }
1554
1555 ClearFlag(Mcb->Inode.i_flags, EXT4_EXTENTS_FL);
1558 }
1559
1560 Mcb->Inode.i_size = Size;
1561 Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
1562
1563 if (BytesWritten) {
1564 *BytesWritten = Size;
1565 }
1566
1567out:
1568 return Status;
1569}
#define EXT4_EXTENTS_FL
Definition: ext3_fs.h:263
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:418

Referenced by Ext2SetReparsePoint().

◆ Ext2ZeroBuffer()

BOOLEAN Ext2ZeroBuffer ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN LONGLONG  Offset,
IN ULONG  Size 
)

Definition at line 795 of file generic.c.

800{
801 struct buffer_head *bh = NULL;
802 BOOLEAN rc = 0;
803
804 _SEH2_TRY {
805
806 while (size) {
807
809 ULONG len = 0, delta = 0;
810
812 delta = (ULONG)offset & (BLOCK_SIZE - 1);
813 len = BLOCK_SIZE - delta;
814 if (size < len)
815 len = size;
816
817 if (delta == 0 && len >= BLOCK_SIZE) {
818 bh = sb_getblk_zero(&Vcb->sb, block);
819 } else {
820 bh = sb_getblk(&Vcb->sb, block);
821 }
822
823 if (!bh) {
824 DEBUG(DL_ERR, ("Ext2SaveBuffer: can't load block %I64u\n", block));
825 DbgBreak();
827 }
828
829 if (!buffer_uptodate(bh)) {
830 int err = bh_submit_read(bh);
831 if (err < 0) {
832 DEBUG(DL_ERR, ("Ext2SaveBuffer: bh_submit_read failed: %d\n", err));
834 }
835 }
836
837 _SEH2_TRY {
838 if (delta == 0 && len >= BLOCK_SIZE) {
839 /* bh (cache) was already cleaned as zero */
840 } else {
841 RtlZeroMemory(bh->b_data + delta, len);
842 }
844 } _SEH2_FINALLY {
845 fini_bh(&bh);
846 } _SEH2_END;
847
848 offset = offset + len;
849 size = size - len;
850 }
851
852 rc = TRUE;
853
854 } _SEH2_FINALLY {
855
856 if (bh)
857 fini_bh(&bh);
858
859 } _SEH2_END;
860
861 return rc;
862}

Referenced by Ext2ClearInode().

◆ Ext2ZeroData()

BOOLEAN Ext2ZeroData ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  Start,
IN PLARGE_INTEGER  End 
)

Definition at line 186 of file write.c.

193{
195 PBCB Bcb;
196 PVOID Ptr;
197 ULONG Size;
198 BOOLEAN rc = TRUE;
199
200 ASSERT (End && Start && End->QuadPart > Start->QuadPart);
201 Fcb = (PEXT2_FCB) FileObject->FsContext;
202
203 /* skip data zero if we've already tracked unwritten part */
204 if (0 == ( End->LowPart & (BLOCK_SIZE -1)) &&
205 0 == (Start->LowPart & (BLOCK_SIZE -1))) {
206
207 if (INODE_HAS_EXTENT(Fcb->Inode)) {
208 return TRUE;
209 } else {
210#if !EXT2_PRE_ALLOCATION_SUPPORT
211 return TRUE;
212#endif
213 }
214 }
215
216 /* clear data in range [Start, End) */
217 _SEH2_TRY {
220 DbgBreak();
221 } _SEH2_END;
222
223 return rc;
224}
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898

Referenced by Ext2WriteFile().

◆ ext3_add_entry()

int ext3_add_entry ( struct ext2_icb icb,
struct dentry dentry,
struct inode inode 
)

Definition at line 1946 of file htree.c.

1947{
1948 struct inode *dir = dentry->d_parent->d_inode;
1949 struct buffer_head *bh;
1950 struct ext3_dir_entry_2 *de;
1951 struct super_block *sb;
1952 int retval;
1953#ifdef EXT2_HTREE_INDEX
1954 int dx_fallback=0;
1955#endif
1956 unsigned blocksize;
1958
1959 sb = dir->i_sb;
1960 blocksize = sb->s_blocksize;
1961 if (!dentry->d_name.len)
1962 return -EINVAL;
1963
1964#ifdef EXT2_HTREE_INDEX
1965 if (is_dx(dir)) {
1966 retval = ext3_dx_add_entry(icb, dentry, inode);
1967 if (!retval || (retval != ERR_BAD_DX_DIR))
1968 return retval;
1969 EXT3_I(dir)->i_flags &= ~EXT3_INDEX_FL;
1970 dx_fallback++;
1971 ext3_save_inode(icb, dir);
1972 }
1973#endif
1974
1975 blocks = (ext3_lblk_t)(dir->i_size >> sb->s_blocksize_bits);
1976 for (block = 0; block < blocks; block++) {
1977 bh = ext3_bread(icb, dir, block, &retval);
1978 if (!bh)
1979 return retval;
1980 retval = add_dirent_to_buf(icb, dentry, inode, NULL, bh);
1981 if (retval != -ENOSPC)
1982 return retval;
1983
1984#ifdef EXT2_HTREE_INDEX
1985 if (blocks == 1 && !dx_fallback &&
1987 return make_indexed_dir(icb, dentry, inode, bh);
1988#endif
1989
1990 brelse(bh);
1991 }
1992 bh = ext3_append(icb, dir, &block, &retval);
1993 if (!bh)
1994 return retval;
1995 de = (struct ext3_dir_entry_2 *) bh->b_data;
1996 de->inode = 0;
1997 de->rec_len = ext3_rec_len_to_disk(blocksize);
1998 return add_dirent_to_buf(icb, dentry, inode, de, bh);
1999}
#define is_dx(dir)
Definition: ext3_fs.h:901
__u32 ext3_lblk_t
Definition: ext3_fs_i.h:30
struct buffer_head * ext3_bread(struct ext2_icb *icb, struct inode *inode, unsigned long block, int *err)
Definition: htree.c:230
struct buffer_head * ext3_append(struct ext2_icb *icb, struct inode *inode, ext3_lblk_t *block, int *err)
Definition: htree.c:279
int add_dirent_to_buf(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode, struct ext3_dir_entry_2 *de, struct buffer_head *bh)
Definition: htree.c:386
static int blocks
Definition: mkdosfs.c:527

Referenced by Ext2AddEntry().

◆ ext3_append()

struct buffer_head * ext3_append ( struct ext2_icb icb,
struct inode inode,
ext3_lblk_t block,
int err 
)

Definition at line 279 of file htree.c.

281{
283 PEXT2_FCB dcb = mcb->Fcb;
285
286 ASSERT(dcb);
287 ASSERT(inode == dcb->Inode);
288
289 /* allocate new block since there's no space for us */
290 *block = (ext3_lblk_t)(inode->i_size >> inode->i_sb->s_blocksize_bits);
291 dcb->Header.AllocationSize.QuadPart += dcb->Vcb->BlockSize;
292 status = Ext2ExpandFile(icb, dcb->Vcb, mcb, &(dcb->Header.AllocationSize));
293 if (NT_SUCCESS(status)) {
294
295 /* update Dcb */
296 dcb->Header.ValidDataLength = dcb->Header.FileSize = dcb->Header.AllocationSize;
297 mcb->Inode.i_size = dcb->Header.AllocationSize.QuadPart;
298
299 /* save parent directory's inode */
300 Ext2SaveInode(icb, dcb->Vcb, inode);
301 }
302
303 return ext3_bread(icb, inode, *block, err);
304}
struct inode * Inode
Definition: ext2fs.h:866
PEXT2_VCB Vcb
Definition: ext2fs.h:869
ULONG BlockSize
Definition: ext2fs.h:728

Referenced by Ext2AddDotEntries(), and ext3_add_entry().

◆ ext3_bg_has_super()

int ext3_bg_has_super ( struct super_block sb,
ext3_group_t  group 
)

ext4_bg_has_super - number of blocks used by the superblock in group @sb: superblock for filesystem @group: group number to check

Return the number of blocks used by the superblock (primary or backup) in this group. Currently this will be only 0 or 1.

Definition at line 2686 of file generic.c.

2687{
2691 return 0;
2692 return 1;
2693}
#define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER
Definition: ext3_fs.h:671
static int ext3_group_sparse(ext3_group_t group)
Definition: generic.c:2668

Referenced by descriptor_loc(), ext4_bg_num_gdb_nometa(), and ext4_init_block_bitmap().

◆ ext3_blocks_count()

static ext3_fsblk_t ext3_blocks_count ( struct ext3_super_block es)
inlinestatic

Definition at line 1745 of file ext2fs.h.

1746{
1747 return ((ext3_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
1748 le32_to_cpu(es->s_blocks_count);
1749}
#define es
Definition: i386-dis.c:440

Referenced by Ext2InitializeVcb(), Ext2QueryVolumeInformation(), ext4_check_descriptors(), and ext4_init_block_bitmap().

◆ ext3_blocks_count_set()

static void ext3_blocks_count_set ( struct ext3_super_block es,
ext3_fsblk_t  blk 
)
inlinestatic

Definition at line 1763 of file ext2fs.h.

1765{
1766 es->s_blocks_count = cpu_to_le32((u32)blk);
1767 es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
1768}
ULONG32 u32
Definition: btrfs.h:14
#define blk
Definition: linetest.c:70

◆ ext3_bread()

struct buffer_head * ext3_bread ( struct ext2_icb icb,
struct inode inode,
unsigned long  block,
int err 
)

Definition at line 230 of file htree.c.

232{
233 struct buffer_head * bh = NULL;
235 ULONG lbn = 0, num = 0;
236
238
239 /* for symlink file, read it's target instead */
240 if (NULL != Mcb && IsMcbSymLink(Mcb))
241 Mcb = Mcb->Target;
242 if (NULL == Mcb) {
243 *err = -EINVAL;
244 return NULL;
245 }
246
247 /* mapping file offset to ext2 block */
248 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
249 status = Ext2MapExtent(icb, inode->i_sb->s_priv,
250 Mcb, block, FALSE,
251 &lbn, &num);
252 } else {
253 status = Ext2MapIndirect(icb, inode->i_sb->s_priv,
254 Mcb, block, FALSE,
255 &lbn, &num);
256 }
257
258 if (!NT_SUCCESS(status)) {
260 return bh;
261 }
262
263 bh = sb_getblk(inode->i_sb, lbn);
264 if (!bh) {
265 *err = -ENOMEM;
266 return bh;
267 }
268 if (buffer_uptodate(bh))
269 return bh;
270
271 *err = bh_submit_read(bh);
272 if (*err) {
273 __brelse(bh);
274 return NULL;
275 }
276 return bh;
277}
int Ext2LinuxError(NTSTATUS Status)
Definition: misc.c:304
GLuint GLuint num
Definition: glext.h:9618

Referenced by ext3_add_entry(), ext3_append(), ext3_find_entry(), and ext3_is_dir_empty().

◆ ext3_check_dir_entry()

int ext3_check_dir_entry ( const char function,
struct inode dir,
struct ext3_dir_entry_2 de,
struct buffer_head bh,
unsigned long  offset 
)

Definition at line 2209 of file generic.c.

2213{
2214 const char * error_msg = NULL;
2215 const int rlen = ext3_rec_len_from_disk(de->rec_len);
2216
2217 if (rlen < EXT3_DIR_REC_LEN(1))
2218 error_msg = "rec_len is smaller than minimal";
2219 else if (rlen % 4 != 0)
2220 error_msg = "rec_len % 4 != 0";
2221 else if (rlen < EXT3_DIR_REC_LEN(de->name_len))
2222 error_msg = "rec_len is too small for name_len";
2223 else if ((char *) de + rlen > bh->b_data + dir->i_sb->s_blocksize)
2224 error_msg = "directory entry across blocks";
2225 else if (le32_to_cpu(de->inode) >
2226 le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count))
2227 error_msg = "inode out of bounds";
2228
2229 if (error_msg != NULL) {
2230 DEBUG(DL_ERR, ("%s: bad entry in directory %u: %s - "
2231 "offset=%u, inode=%u, rec_len=%d, name_len=%d\n",
2232 function, dir->i_ino, error_msg, offset,
2233 (unsigned long) le32_to_cpu(de->inode),
2234 rlen, de->name_len));
2235 }
2236 return error_msg == NULL ? 1 : 0;
2237}
static const WCHAR * error_msg[8]
Definition: odbccp32.c:62

Referenced by add_dirent_to_buf(), ext3_delete_entry(), ext3_is_dir_empty(), and search_dirblock().

◆ ext3_current_time()

__u32 ext3_current_time ( struct inode in)

Definition at line 204 of file htree.c.

205{
206 LARGE_INTEGER SysTime;
207 KeQuerySystemTime(&SysTime);
208
209 return Ext2LinuxTime(SysTime);
210}

Referenced by add_dirent_to_buf(), Ext2RemoveEntry(), and Ext2SetFileType().

◆ ext3_dec_count()

void ext3_dec_count ( struct inode inode)

Definition at line 312 of file htree.c.

313{
314 inode->i_nlink--;
315}

Referenced by Ext2RemoveEntry(), Ext2SetFileType(), and Ext2SetReparsePoint().

◆ ext3_delete_entry()

int ext3_delete_entry ( struct ext2_icb icb,
struct inode dir,
struct ext3_dir_entry_2 de_del,
struct buffer_head bh 
)

Definition at line 2005 of file htree.c.

2008{
2009 struct ext3_dir_entry_2 *de, *pde = NULL;
2010 size_t i = 0;
2011
2012 de = (struct ext3_dir_entry_2 *) bh->b_data;
2013 while (i < bh->b_size) {
2014 if (!ext3_check_dir_entry("ext3_delete_entry", dir, de, bh, i))
2015 return -EIO;
2016 if (de == de_del) {
2017 if (pde)
2021 else
2022 de->inode = 0;
2023 dir->i_version++;
2024 /* ext3_journal_dirty_metadata(handle, bh); */
2025 set_buffer_dirty(bh);
2026 return 0;
2027 }
2029 pde = de;
2030 de = ext3_next_entry(de);
2031 }
2032 return -ENOENT;
2033}
struct ext3_dir_entry_2 * ext3_next_entry(struct ext3_dir_entry_2 *p)
Definition: generic.c:2244

Referenced by Ext2RemoveEntry().

◆ ext3_dx_find_entry()

struct buffer_head * ext3_dx_find_entry ( struct ext2_icb ,
struct dentry dentry,
struct ext3_dir_entry_2 **  res_dir,
int err 
)

Referenced by ext3_find_entry().

◆ ext3_dx_readdir()

int ext3_dx_readdir ( struct file filp,
filldir_t  filldir,
void context 
)

Referenced by Ext2QueryDirectory().

◆ ext3_find_entry()

struct buffer_head * ext3_find_entry ( struct ext2_icb icb,
struct dentry dentry,
struct ext3_dir_entry_2 **  res_dir 
)

Definition at line 2166 of file htree.c.

2169{
2170 struct inode *dir = dentry->d_parent->d_inode;
2171 struct super_block *sb = dir->i_sb;
2172 struct buffer_head *bh_use[NAMEI_RA_SIZE];
2173 struct buffer_head *bh, *ret = NULL;
2175 int ra_max = 0; /* Number of bh's in the readahead
2176 buffer, bh_use[] */
2177 int ra_ptr = 0; /* Current index into readahead
2178 buffer */
2179 int num = 0;
2180 ext3_lblk_t nblocks;
2181 int i, err;
2182 int namelen = dentry->d_name.len;
2183
2184 *res_dir = NULL;
2185 if (namelen > EXT3_NAME_LEN)
2186 return NULL;
2187
2188#ifdef EXT2_HTREE_INDEX
2189 if (icb->MajorFunction != IRP_MJ_CREATE && is_dx(dir)) {
2190 bh = ext3_dx_find_entry(icb, dentry, res_dir, &err);
2191 /*
2192 * On success, or if the error was file not found,
2193 * return. Otherwise, fall back to doing a search the
2194 * old fashioned way.
2195 */
2196 if (bh || (err != ERR_BAD_DX_DIR))
2197 return bh;
2198 dxtrace(printk("ext4_find_entry: dx failed, "
2199 "falling back\n"));
2200 }
2201#endif
2202
2203 nblocks = (ext3_lblk_t)(dir->i_size >> EXT3_BLOCK_SIZE_BITS(sb));
2204 start = 0;
2205 block = start;
2206restart:
2207 do {
2208 /*
2209 * We deal with the read-ahead logic here.
2210 */
2211 if (ra_ptr >= ra_max) {
2212 /* Refill the readahead buffer */
2213 ra_ptr = 0;
2214 b = block;
2215 for (ra_max = 0; ra_max < NAMEI_RA_SIZE; ra_max++) {
2216 /*
2217 * Terminate if we reach the end of the
2218 * directory and must wrap, or if our
2219 * search has finished at this block.
2220 */
2221 if (b >= nblocks || (num && block == start)) {
2222 bh_use[ra_max] = NULL;
2223 break;
2224 }
2225 num++;
2226 bh = ext3_bread(icb, dir, b++, &err);
2227 bh_use[ra_max] = bh;
2228 }
2229 }
2230 if ((bh = bh_use[ra_ptr++]) == NULL)
2231 goto next;
2232 wait_on_buffer(bh);
2233 if (!buffer_uptodate(bh)) {
2234 /* read error, skip block & hope for the best */
2235 ext3_error(sb, __FUNCTION__, "reading directory #%lu "
2236 "offset %lu", dir->i_ino,
2237 (unsigned long)block);
2238 brelse(bh);
2239 goto next;
2240 }
2241 i = search_dirblock(bh, dir, dentry,
2242 block << EXT3_BLOCK_SIZE_BITS(sb), res_dir);
2243 if (i == 1) {
2244 ret = bh;
2245 goto cleanup_and_exit;
2246 } else {
2247 brelse(bh);
2248 if (i < 0)
2249 goto cleanup_and_exit;
2250 }
2251next:
2252 if (++block >= nblocks)
2253 block = 0;
2254 } while (block != start);
2255
2256 /*
2257 * If the directory has grown while we were searching, then
2258 * search the last part of the directory before giving up.
2259 */
2260 block = nblocks;
2261 nblocks = (ext3_lblk_t)(dir->i_size >> EXT3_BLOCK_SIZE_BITS(sb));
2262 if (block < nblocks) {
2263 start = 0;
2264 goto restart;
2265 }
2266
2267cleanup_and_exit:
2268 /* Clean up the read-ahead blocks */
2269 for (; ra_ptr < ra_max; ra_ptr++)
2270 brelse(bh_use[ra_ptr]);
2271 return ret;
2272}
void restart(int argc, const char *argv[])
Definition: cmds.c:2115
#define __FUNCTION__
Definition: types.h:116
struct buffer_head * ext3_dx_find_entry(struct ext2_icb *, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir, int *err)
#define ext3_error
Definition: ext2fs.h:2593
#define EXT3_NAME_LEN
Definition: ext3_fs.h:759
#define EXT3_BLOCK_SIZE_BITS(s)
Definition: ext3_fs.h:87
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define NAMEI_RA_SIZE
Definition: htree.c:2152
static int search_dirblock(struct buffer_head *bh, struct inode *dir, struct dentry *dentry, unsigned long offset, struct ext3_dir_entry_2 **res_dir)
Definition: htree.c:2109
#define b
Definition: ke_i.h:79
#define printk
Definition: module.h:231
static void wait_on_buffer(struct buffer_head *bh)
Definition: module.h:1021
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by Ext2RemoveEntry(), Ext2ScanDir(), and Ext2SetFileType().

◆ ext3_free_blocks_count()

static ext3_fsblk_t ext3_free_blocks_count ( struct ext3_super_block es)
inlinestatic

Definition at line 1757 of file ext2fs.h.

1758{
1759 return ((ext3_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
1760 le32_to_cpu(es->s_free_blocks_count);
1761}

Referenced by Ext2CreateFile(), Ext2DeleteFile(), and Ext2QueryVolumeInformation().

◆ ext3_free_blocks_count_set()

static void ext3_free_blocks_count_set ( struct ext3_super_block es,
ext3_fsblk_t  blk 
)
inlinestatic

Definition at line 1770 of file ext2fs.h.

1772{
1773 es->s_free_blocks_count = cpu_to_le32((u32)blk);
1774 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
1775}

Referenced by Ext2UpdateVcbStat(), and ext4_check_descriptors().

◆ ext3_inc_count()

void ext3_inc_count ( struct inode inode)

Definition at line 307 of file htree.c.

308{
309 inode->i_nlink++;
310}

Referenced by Ext2AddEntry(), and Ext2SetFileType().

◆ ext3_inode_blocks()

blkcnt_t ext3_inode_blocks ( struct ext3_inode raw_inode,
struct inode inode 
)

Definition at line 2395 of file generic.c.

2397{
2398 blkcnt_t i_blocks ;
2399 struct super_block *sb = inode->i_sb;
2400 PEXT2_VCB Vcb = (PEXT2_VCB)sb->s_priv;
2401
2404 /* we are using combined 48 bit field */
2405 i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 |
2406 le32_to_cpu(raw_inode->i_blocks);
2408 /* i_blocks represent file system block size */
2409 return i_blocks << (BLOCK_BITS - 9);
2410 } else {
2411 return i_blocks;
2412 }
2413 } else {
2414 return le32_to_cpu(raw_inode->i_blocks);
2415 }
2416}
unsigned __int64 blkcnt_t
Definition: types.h:83
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE
Definition: ext3_fs.h:699
#define EXT4_HUGE_FILE_FL
Definition: ext3_fs.h:262
#define le16_to_cpu
Definition: module.h:151
#define u64
Definition: types.h:10
__le32 i_blocks
Definition: ext3_fs.h:355
__u32 i_flags
Definition: fs.h:94

Referenced by Ext2DecodeInode().

◆ ext3_inode_blocks_set()

int ext3_inode_blocks_set ( struct ext3_inode raw_inode,
struct inode inode 
)

Definition at line 2418 of file generic.c.

2420{
2421 u64 i_blocks = inode->i_blocks;
2422 struct super_block *sb = inode->i_sb;
2423 PEXT2_VCB Vcb = (PEXT2_VCB)sb->s_priv;
2424
2425 if (i_blocks < 0x100000000) {
2426 /*
2427 * i_blocks can be represnted in a 32 bit variable
2428 * as multiple of 512 bytes
2429 */
2430 raw_inode->i_blocks = cpu_to_le32(i_blocks);
2431 raw_inode->i_blocks_high = 0;
2432 inode->i_flags &= ~EXT4_HUGE_FILE_FL;
2433 return 0;
2434 }
2435
2439 }
2440
2441 if (i_blocks <= 0xffffffffffff) {
2442 /*
2443 * i_blocks can be represented in a 48 bit variable
2444 * as multiple of 512 bytes
2445 */
2446 raw_inode->i_blocks = (__u32)cpu_to_le32(i_blocks);
2447 raw_inode->i_blocks_high = (__u16)cpu_to_le16(i_blocks >> 32);
2448 inode->i_flags &= ~EXT4_HUGE_FILE_FL;
2449 } else {
2451 /* i_block is stored in file system block size */
2452 i_blocks = i_blocks >> (BLOCK_BITS - 9);
2453 raw_inode->i_blocks = (__u32)cpu_to_le32(i_blocks);
2454 raw_inode->i_blocks_high = (__u16)cpu_to_le16(i_blocks >> 32);
2455 }
2456 return 0;
2457}
ULONG64 u64
Definition: btrfs.h:15
#define EXT3_SET_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:653
#define __u16
Definition: types.h:13
#define __u32
Definition: types.h:15
__u64 i_blocks
Definition: fs.h:85

Referenced by Ext2EncodeInode().

◆ ext3_is_dir_empty()

int ext3_is_dir_empty ( struct ext2_icb icb,
struct inode inode 
)

Definition at line 2038 of file htree.c.

2039{
2040 unsigned int offset;
2041 struct buffer_head *bh;
2042 struct ext3_dir_entry_2 *de, *de1;
2043 struct super_block *sb;
2044 int err = 0;
2045
2046 sb = inode->i_sb;
2048 !(bh = ext3_bread(icb, inode, 0, &err))) {
2049 if (err)
2051 "error %d reading directory #%lu offset 0",
2052 err, inode->i_ino);
2053 else
2055 "bad directory (dir #%lu) - no data block",
2056 inode->i_ino);
2057 return 1;
2058 }
2059 de = (struct ext3_dir_entry_2 *) bh->b_data;
2060 de1 = ext3_next_entry(de);
2061 if (le32_to_cpu(de->inode) != inode->i_ino ||
2062 !le32_to_cpu(de1->inode) ||
2063 strcmp(".", de->name) ||
2064 strcmp("..", de1->name)) {
2065 ext3_warning(inode->i_sb, "empty_dir",
2066 "bad directory (dir #%lu) - no `.' or `..'",
2067 inode->i_ino);
2068 brelse(bh);
2069 return 1;
2070 }
2073 de = ext3_next_entry(de1);
2074 while (offset < inode->i_size) {
2075 if (!bh ||
2076 (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
2077 err = 0;
2078 brelse(bh);
2080 if (!bh) {
2081 if (err)
2082 ext3_error(sb, __FUNCTION__, "error %d reading directory"
2083 " #%lu offset %u", err, inode->i_ino, offset);
2084 offset += sb->s_blocksize;
2085 continue;
2086 }
2087 de = (struct ext3_dir_entry_2 *) bh->b_data;
2088 }
2089 if (!ext3_check_dir_entry("empty_dir", inode, de, bh, offset)) {
2090 de = (struct ext3_dir_entry_2 *)(bh->b_data +
2091 sb->s_blocksize);
2092 offset = (offset | (sb->s_blocksize - 1)) + 1;
2093 continue;
2094 }
2095 if (le32_to_cpu(de->inode)) {
2096 brelse(bh);
2097 return 0;
2098 }
2100 de = ext3_next_entry(de);
2101 }
2102 brelse(bh);
2103 return 1;
2104}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void ext3_warning(struct super_block *sb, const char *function, char *fmt,...)
Definition: htree.c:212

Referenced by Ext2IsDirectoryEmpty().

◆ ext3_mark_inode_dirty()

int ext3_mark_inode_dirty ( struct ext2_icb icb,
struct inode in 
)

Definition at line 360 of file htree.c.

361{
362 if (Ext2SaveInode(icb, in->i_sb->s_priv, in))
363 return 0;
364
365 return -ENOMEM;
366}

Referenced by add_dirent_to_buf(), Ext2AddDotEntries(), Ext2AddEntry(), Ext2RemoveEntry(), and Ext2SetFileType().

◆ ext3_max_bitmap_size()

loff_t ext3_max_bitmap_size ( int  bits,
int  has_huge_files 
)

Definition at line 2337 of file generic.c.

2338{
2340 int meta_blocks;
2342 /* This is calculated to be the largest file size for a
2343 * dense, bitmapped file such that the total number of
2344 * sectors in the file, including data and all indirect blocks,
2345 * does not exceed 2^48 -1
2346 * __u32 i_blocks_lo and _u16 i_blocks_high representing the
2347 * total number of 512 bytes blocks of the file
2348 */
2349
2350 if (!has_huge_files) {
2351 /*
2352 * !has_huge_files or CONFIG_LBD is not enabled
2353 * implies the inode i_block represent total blocks in
2354 * 512 bytes 32 == size of vfs inode i_blocks * 8
2355 */
2356 upper_limit = ((loff_t)1 << 32) - 1;
2357
2358 /* total blocks in file system block size */
2359 upper_limit >>= (bits - 9);
2360
2361 } else {
2362 /*
2363 * We use 48 bit ext4_inode i_blocks
2364 * With EXT4_HUGE_FILE_FL set the i_blocks
2365 * represent total number of blocks in
2366 * file system block size
2367 */
2368 upper_limit = ((loff_t)1 << 48) - 1;
2369
2370 }
2371
2372 /* indirect blocks */
2373 meta_blocks = 1;
2374 /* double indirect blocks */
2375 meta_blocks += 1 + ((loff_t)1 << (bits-2));
2376 /* tripple indirect blocks */
2377 meta_blocks += 1 + ((loff_t)1 << (bits-2)) + ((loff_t)1 << (2*(bits-2)));
2378
2379 upper_limit -= meta_blocks;
2380 upper_limit <<= bits;
2381
2382 res += (loff_t)1 << (bits-2);
2383 res += (loff_t)1 << (2*(bits-2));
2384 res += (loff_t)1 << (3*(bits-2));
2385 res <<= bits;
2386 if (res > upper_limit)
2387 res = upper_limit;
2388
2389 if (res > MAX_LFS_FILESIZE)
2391
2392 return res;
2393}
#define EXT3_NDIR_BLOCKS
Definition: ext3_fs.h:197
#define MAX_LFS_FILESIZE
Definition: generic.c:2250
GLuint res
Definition: glext.h:9613
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
DWORD upper_limit
Definition: apphelp.c:212

Referenced by Ext2InitializeVcb().

◆ ext3_max_size()

loff_t ext3_max_size ( int  blkbits,
int  has_huge_files 
)

Definition at line 2301 of file generic.c.

2302{
2303 loff_t res;
2305
2306 /* small i_blocks in vfs inode? */
2307 if (!has_huge_files) {
2308 /*
2309 * CONFIG_LBD is not enabled implies the inode
2310 * i_block represent total blocks in 512 bytes
2311 * 32 == size of vfs inode i_blocks * 8
2312 */
2313 upper_limit = ((loff_t)1 << 32) - 1;
2314
2315 /* total blocks in file system block size */
2316 upper_limit >>= (blkbits - 9);
2317 upper_limit <<= blkbits;
2318 }
2319
2320 /* 32-bit extent-start container, ee_block */
2321 res = (loff_t)1 << 32;
2322 res <<= blkbits;
2323 res -= 1;
2324
2325 /* Sanity check against vm- & vfs- imposed limits */
2326 if (res > upper_limit)
2327 res = upper_limit;
2328
2329 return res;
2330}

Referenced by Ext2InitializeVcb().

◆ ext3_next_entry()

struct ext3_dir_entry_2 * ext3_next_entry ( struct ext3_dir_entry_2 p)

Definition at line 2244 of file generic.c.

2245{
2246 return (struct ext3_dir_entry_2 *)((char *)p +
2247 ext3_rec_len_from_disk(p->rec_len));
2248}
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ext3_delete_entry(), and ext3_is_dir_empty().

◆ ext3_r_blocks_count()

static ext3_fsblk_t ext3_r_blocks_count ( struct ext3_super_block es)
inlinestatic

Definition at line 1751 of file ext2fs.h.

1752{
1753 return ((ext3_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
1754 le32_to_cpu(es->s_r_blocks_count);
1755}

◆ ext3_r_blocks_count_set()

static void ext3_r_blocks_count_set ( struct ext3_super_block es,
ext3_fsblk_t  blk 
)
inlinestatic

Definition at line 1777 of file ext2fs.h.

1779{
1780 es->s_r_blocks_count = cpu_to_le32((u32)blk);
1781 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
1782}

◆ ext3_set_de_type()

void ext3_set_de_type ( struct super_block sb,
struct ext3_dir_entry_2 de,
umode_t  mode 
)

Definition at line 347 of file htree.c.

350{
353}
unsigned char ext3_type_by_mode(umode_t mode)
Definition: htree.c:317

Referenced by add_dirent_to_buf(), Ext2AddDotEntries(), and Ext2SetFileType().

◆ ext3_update_dx_flag()

void ext3_update_dx_flag ( struct inode inode)

Definition at line 368 of file htree.c.

369{
372 EXT3_I(inode)->i_flags &= ~EXT3_INDEX_FL;
373}

Referenced by add_dirent_to_buf(), and Ext2RemoveEntry().

◆ ext3_warning()

void ext3_warning ( struct super_block sb,
const char function,
char fmt,
  ... 
)

Definition at line 212 of file htree.c.

214{
215#if DX_DEBUG
217
218 va_start(args, fmt);
219 printk("EXT3-fs warning (device %s): %s: ",
220 sb->s_id, function);
221 printk(fmt, args);
222 printk("\n");
223 va_end(args);
224#endif
225}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
Definition: match.c:390
Definition: dsound.c:943

Referenced by Ext2RemoveEntry(), and ext3_is_dir_empty().

◆ ext4_bg_num_gdb()

unsigned long ext4_bg_num_gdb ( struct super_block sb,
ext4_group_t  group 
)

ext4_bg_num_gdb - number of blocks used by the group table in group @sb: superblock for filesystem @group: group number to check

Return the number of blocks used by the group descriptor table (primary or backup) in this group. In the future there may be a different number of descriptor blocks in each group.

Definition at line 2722 of file generic.c.

2723{
2724 unsigned long first_meta_bg =
2725 le32_to_cpu(EXT3_SB(sb)->s_es->s_first_meta_bg);
2726 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
2727
2729 metagroup < first_meta_bg)
2731
2733
2734}
static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2707
static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2695

Referenced by ext4_init_block_bitmap().

◆ ext4_block_bitmap()

ext4_fsblk_t ext4_block_bitmap ( struct super_block sb,
struct ext4_group_desc bg 
)

◆ ext4_block_bitmap_set()

void ext4_block_bitmap_set ( struct super_block sb,
struct ext4_group_desc bg,
ext4_fsblk_t  blk 
)

Definition at line 2515 of file generic.c.

2517{
2520 bg->bg_block_bitmap_hi = cpu_to_le32(blk >> 32);
2521}

◆ ext4_check_descriptors()

int ext4_check_descriptors ( struct super_block sb)

Definition at line 3091 of file generic.c.

3092{
3093 PEXT2_VCB Vcb = sb->s_priv;
3094 struct ext3_sb_info *sbi = EXT3_SB(sb);
3095 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
3096 ext4_fsblk_t last_block;
3097 ext4_fsblk_t block_bitmap;
3098 ext4_fsblk_t inode_bitmap;
3099 ext4_fsblk_t inode_table;
3100 int flexbg_flag = 0;
3102
3104 flexbg_flag = 1;
3105
3106 DEBUG(DL_INF, ("Checking group descriptors"));
3107
3108 for (i = 0; i < sbi->s_groups_count; i++) {
3109
3110 struct buffer_head *bh = NULL;
3111 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, &bh);
3112
3113 if (!bh)
3114 continue;
3115
3116 if (i == sbi->s_groups_count - 1 || flexbg_flag)
3117 last_block = ext3_blocks_count(sbi->s_es) - 1;
3118 else
3119 last_block = first_block +
3121
3122 block_bitmap = ext4_block_bitmap(sb, gdp);
3123 if (block_bitmap < first_block || block_bitmap > last_block) {
3124 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3125 "Block bitmap for group %u not in group "
3126 "(block %llu)!\n", i, block_bitmap);
3127 __brelse(bh);
3128 return 0;
3129 }
3130 inode_bitmap = ext4_inode_bitmap(sb, gdp);
3131 if (inode_bitmap < first_block || inode_bitmap > last_block) {
3132 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3133 "Inode bitmap for group %u not in group "
3134 "(block %llu)!\n", i, inode_bitmap);
3135 __brelse(bh);
3136 return 0;
3137 }
3138 inode_table = ext4_inode_table(sb, gdp);
3139 if (inode_table < first_block ||
3140 inode_table + sbi->s_itb_per_group - 1 > last_block) {
3141 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3142 "Inode table for group %u not in group "
3143 "(block %llu)!\n", i, inode_table);
3144 __brelse(bh);
3145 return 0;
3146 }
3147
3148 if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
3149 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3150 "Checksum for group %u failed (%u!=%u)\n",
3152 gdp)),
3153 le16_to_cpu(gdp->bg_checksum));
3154 if (!IsVcbReadOnly(Vcb)) {
3155 __brelse(bh);
3156 return 0;
3157 }
3158 }
3159
3160 if (!flexbg_flag)
3161 first_block += EXT4_BLOCKS_PER_GROUP(sb);
3162
3163 __brelse(bh);
3164 }
3165
3167 sbi->s_es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));
3168 return 1;
3169}
#define EXT3_BLOCKS_PER_GROUP(s)
Definition: ext3_fs.h:189
#define EXT4_FEATURE_INCOMPAT_FLEX_BG
Definition: ext3_fs.h:712
unsigned int ext4_group_t
Definition: ext3_fs_i.h:35
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2648
#define KERN_ERR
Definition: module.h:225
unsigned long s_itb_per_group
Definition: ext3_fs_sb.h:44
unsigned long s_groups_count
Definition: ext3_fs_sb.h:43

Referenced by Ext2LoadGroup().

◆ ext4_count_free_blocks()

ext4_fsblk_t ext4_count_free_blocks ( struct super_block sb)

ext4_count_free_blocks() – count filesystem free blocks @sb: superblock

Adds up the number of free blocks from each block group.

Definition at line 3033 of file generic.c.

3034{
3035 ext4_fsblk_t desc_count;
3036 struct ext4_group_desc *gdp;
3037 struct buffer_head *bh = NULL;
3039 ext4_group_t ngroups = EXT3_SB(sb)->s_groups_count;
3040
3041 desc_count = 0;
3042 smp_rmb();
3043 for (i = 0; i < ngroups; i++) {
3044 gdp = ext4_get_group_desc(sb, i, &bh);
3045 if (!bh)
3046 continue;
3047 desc_count += ext4_free_blks_count(sb, gdp);
3048 fini_bh(&bh);
3049 }
3050
3051 return desc_count;
3052}
#define smp_rmb()
Definition: module.h:1219

Referenced by Ext2UpdateVcbStat(), and ext4_check_descriptors().

◆ ext4_count_free_inodes()

unsigned long ext4_count_free_inodes ( struct super_block sb)

Definition at line 3054 of file generic.c.

3055{
3056 unsigned long desc_count;
3057 struct ext4_group_desc *gdp;
3058 struct buffer_head *bh = NULL;
3060
3061 desc_count = 0;
3062 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
3063 gdp = ext4_get_group_desc(sb, i, &bh);
3064 if (!bh)
3065 continue;
3066 desc_count += ext4_free_inodes_count(sb, gdp);
3067 fini_bh(&bh);
3068 }
3069 return desc_count;
3070}

Referenced by Ext2UpdateVcbStat(), and ext4_check_descriptors().

◆ ext4_free_blks_count()

__u32 ext4_free_blks_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2483 of file generic.c.

2485{
2486 return le16_to_cpu(bg->bg_free_blocks_count) |
2488 (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0);
2489}
__le16 bg_free_blocks_count
Definition: ext3_fs.h:139
__le16 bg_free_blocks_count_hi
Definition: ext3_fs.h:149

Referenced by Ext2NewBlock(), and ext4_count_free_blocks().

◆ ext4_free_blks_set()

void ext4_free_blks_set ( struct super_block sb,
struct ext4_group_desc bg,
__u32  count 
)

◆ ext4_free_inodes_count()

__u32 ext4_free_inodes_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2491 of file generic.c.

2493{
2494 return le16_to_cpu(bg->bg_free_inodes_count) |
2496 (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0);
2497}
__le16 bg_free_inodes_count
Definition: ext3_fs.h:140
__le16 bg_free_inodes_count_hi
Definition: ext3_fs.h:150

Referenced by Ext2NewInode(), and ext4_count_free_inodes().

◆ ext4_free_inodes_set()

void ext4_free_inodes_set ( struct super_block sb,
struct ext4_group_desc bg,
__u32  count 
)

◆ ext4_get_group_desc()

struct ext4_group_desc * ext4_get_group_desc ( struct super_block sb,
ext4_group_t  block_group,
struct buffer_head **  bh 
)

ext4_get_group_desc() – load group descriptor from disk @sb: super block @block_group: given block group @bh: pointer to the buffer head to store the block group descriptor

Definition at line 2976 of file generic.c.

2978{
2979 struct ext4_group_desc *desc = NULL;
2980 struct ext3_sb_info *sbi = EXT3_SB(sb);
2981 PEXT2_VCB vcb = sb->s_priv;
2984
2985 if (bh)
2986 *bh = NULL;
2987
2988 if (block_group >= sbi->s_groups_count) {
2989 ext4_error(sb, "ext4_get_group_desc",
2990 "block_group >= groups_count - "
2991 "block_group = %u, groups_count = %u",
2992 block_group, sbi->s_groups_count);
2993
2994 return NULL;
2995 }
2996
2997 _SEH2_TRY {
2998
2999 group = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
3000 offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
3001
3002 if (!sbi->s_gd) {
3003 if (!Ext2LoadGroup(vcb)) {
3005 }
3006 } else if ( !sbi->s_gd[group].block ||
3007 !sbi->s_gd[group].bh) {
3008 if (!Ext2LoadGroupBH(vcb)) {
3010 }
3011 }
3012
3013 desc = (struct ext4_group_desc *)((PCHAR)sbi->s_gd[group].gd +
3015 if (bh) {
3016 atomic_inc(&sbi->s_gd[group].bh->b_count);
3017 *bh = sbi->s_gd[group].bh;
3018 }
3019 } _SEH2_FINALLY {
3020 /* do cleanup */
3021 } _SEH2_END;
3022
3023 return desc;
3024}
static void atomic_inc(atomic_t volatile *v)
Definition: atomic.h:95
#define ext4_error
Definition: ext2fs.h:2594
BOOLEAN Ext2LoadGroup(IN PEXT2_VCB Vcb)
Definition: generic.c:207

Referenced by Ext2CheckBitmapConsistency(), Ext2CheckSetBlock(), Ext2FreeBlock(), Ext2FreeInode(), Ext2GetInodeLba(), Ext2NewBlock(), Ext2NewInode(), Ext2SaveGroup(), Ext2UpdateGroupDirStat(), ext4_check_descriptors(), ext4_count_dirs(), ext4_count_free_blocks(), ext4_count_free_inodes(), and ext4_group_used_meta_blocks().

◆ ext4_group_desc_csum()

__le16 ext4_group_desc_csum ( struct ext3_sb_info sbi,
__u32  block_group,
struct ext4_group_desc gdp 
)

Definition at line 2619 of file generic.c.

2621{
2622 int offset;
2623 __u16 crc = 0;
2624 __le32 le_group = cpu_to_le32(block_group);
2625
2626 /* old crc16 code */
2627 if (!(sbi->s_es->s_feature_ro_compat &
2629 return 0;
2630
2631 offset = offsetof(struct ext4_group_desc, bg_checksum);
2632
2633 crc = crc16(~0, sbi->s_es->s_uuid, sizeof(sbi->s_es->s_uuid));
2634 crc = crc16(crc, (__u8 *)&le_group, sizeof(le_group));
2635 crc = crc16(crc, (__u8 *)gdp, offset);
2636 offset += sizeof(gdp->bg_checksum); /* skip checksum */
2637 /* for checksum of struct ext4_group_desc do the rest...*/
2638 if ((sbi->s_es->s_feature_incompat &
2640 offset < le16_to_cpu(sbi->s_es->s_desc_size))
2641 crc = crc16(crc, (__u8 *)gdp + offset,
2642 le16_to_cpu(sbi->s_es->s_desc_size) -
2643 offset);
2644
2645 return cpu_to_le16(crc);
2646}
u8 __u8
Definition: btrfs.h:17
#define __le32
Definition: types.h:44
#define EXT4_FEATURE_INCOMPAT_64BIT
Definition: ext3_fs.h:710
__u16 crc16(__u16 crc, __u8 const *buffer, size_t len)
Definition: generic.c:2612
#define offsetof(TYPE, MEMBER)

Referenced by Ext2NewBlock(), Ext2NewInode(), Ext2SaveGroup(), ext4_check_descriptors(), and ext4_group_desc_csum_verify().

◆ ext4_group_desc_csum_verify()

int ext4_group_desc_csum_verify ( struct ext3_sb_info sbi,
__u32  block_group,
struct ext4_group_desc gdp 
)

Definition at line 2648 of file generic.c.

2650{
2651 if ((sbi->s_es->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) &&
2652 (gdp->bg_checksum != ext4_group_desc_csum(sbi, block_group, gdp)))
2653 return 0;
2654
2655 return 1;
2656}

Referenced by ext4_check_descriptors(), ext4_init_block_bitmap(), and ext4_init_inode_bitmap().

◆ ext4_init_block_bitmap()

unsigned ext4_init_block_bitmap ( struct super_block sb,
struct buffer_head bh,
ext4_group_t  block_group,
struct ext4_group_desc gdp 
)

Definition at line 2877 of file generic.c.

2879{
2880 int bit, bit_max;
2881 unsigned free_blocks, group_blocks;
2882 struct ext3_sb_info *sbi = EXT3_SB(sb);
2883
2884 if (bh) {
2886 /* If checksum is bad mark all blocks used to prevent allocation
2887 * essentially implementing a per-group read-only flag. */
2888 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2890 "Checksum bad for group %u", block_group);
2891 ext4_free_blks_set(sb, gdp, 0);
2892 ext4_free_inodes_set(sb, gdp, 0);
2893 ext4_itable_unused_set(sb, gdp, 0);
2894 memset(bh->b_data, 0xff, sb->s_blocksize);
2895 return 0;
2896 }
2897 memset(bh->b_data, 0, sb->s_blocksize);
2898 }
2899
2900 /* Check for superblock and gdt backups in this group */
2901 bit_max = ext3_bg_has_super(sb, block_group);
2902
2904 block_group < le32_to_cpu(sbi->s_es->s_first_meta_bg) *
2905 sbi->s_desc_per_block) {
2906 if (bit_max) {
2907 bit_max += ext4_bg_num_gdb(sb, block_group);
2908 bit_max +=
2909 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks);
2910 }
2911 } else { /* For META_BG_BLOCK_GROUPS */
2912 bit_max += ext4_bg_num_gdb(sb, block_group);
2913 }
2914
2915 if (block_group == sbi->s_groups_count - 1) {
2916 /*
2917 * Even though mke2fs always initialize first and last group
2918 * if some other tool enabled the EXT4_BG_BLOCK_UNINIT we need
2919 * to make sure we calculate the right free blocks
2920 */
2921 group_blocks = (unsigned int)(ext3_blocks_count(sbi->s_es) -
2922 le32_to_cpu(sbi->s_es->s_first_data_block) -
2923 (EXT4_BLOCKS_PER_GROUP(sb) * (sbi->s_groups_count - 1)));
2924 } else {
2925 group_blocks = EXT4_BLOCKS_PER_GROUP(sb);
2926 }
2927
2928 free_blocks = group_blocks - bit_max;
2929
2930 if (bh) {
2931 ext4_fsblk_t start, tmp;
2932 int flex_bg = 0;
2933
2934 for (bit = 0; bit < bit_max; bit++)
2935 ext4_set_bit(bit, bh->b_data);
2936
2937 start = ext3_group_first_block_no(sb, block_group);
2938
2941 flex_bg = 1;
2942
2943 /* Set bits for block and inode bitmaps, and inode table */
2944 tmp = ext4_block_bitmap(sb, gdp);
2945 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2946 ext4_set_bit(tmp - start, bh->b_data);
2947
2948 tmp = ext4_inode_bitmap(sb, gdp);
2949 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2950 ext4_set_bit(tmp - start, bh->b_data);
2951
2952 tmp = ext4_inode_table(sb, gdp);
2953 for (; tmp < ext4_inode_table(sb, gdp) +
2954 sbi->s_itb_per_group; tmp++) {
2955 if (!flex_bg ||
2956 ext4_block_in_group(sb, tmp, block_group))
2957 ext4_set_bit(tmp - start, bh->b_data);
2958 }
2959 /*
2960 * Also if the number of blocks within the group is
2961 * less than the blocksize * 8 ( which is the size
2962 * of bitmap ), set rest of the block bitmap to 1
2963 */
2964 mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
2965 }
2966 return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
2967}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static int ext4_group_used_meta_blocks(struct super_block *sb, ext4_group_t block_group)
Definition: generic.c:2842
unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2722
void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
Definition: generic.c:2771
static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block, ext4_group_t block_group)
Definition: generic.c:2832
#define ext4_set_bit(n, p)
Definition: generic.c:2754

◆ ext4_init_inode_bitmap()

unsigned ext4_init_inode_bitmap ( struct super_block sb,
struct buffer_head bh,
ext4_group_t  block_group,
struct ext4_group_desc gdp 
)

Definition at line 2786 of file generic.c.

2789{
2790 struct ext3_sb_info *sbi = EXT3_SB(sb);
2791
2793
2794 /* If checksum is bad mark all blocks and inodes use to prevent
2795 * allocation, essentially implementing a per-group read-only flag. */
2796 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2797 ext4_error(sb, __FUNCTION__, "Checksum bad for group %u",
2798 block_group);
2799 ext4_free_blks_set(sb, gdp, 0);
2800 ext4_free_inodes_set(sb, gdp, 0);
2801 ext4_itable_unused_set(sb, gdp, 0);
2802 memset(bh->b_data, 0xff, sb->s_blocksize);
2803 return 0;
2804 }
2805
2806 memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8);
2807 mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8,
2808 bh->b_data);
2809 ext4_itable_unused_set(sb, gdp, EXT4_INODES_PER_GROUP(sb));
2810
2811 return EXT4_INODES_PER_GROUP(sb);
2812}

◆ ext4_inode_bitmap()

◆ ext4_inode_bitmap_set()

void ext4_inode_bitmap_set ( struct super_block sb,
struct ext4_group_desc bg,
ext4_fsblk_t  blk 
)

Definition at line 2523 of file generic.c.

2525{
2528 bg->bg_inode_bitmap_hi = cpu_to_le32(blk >> 32);
2529}

◆ ext4_inode_table()

◆ ext4_inode_table_set()

void ext4_inode_table_set ( struct super_block sb,
struct ext4_group_desc bg,
ext4_fsblk_t  blk 
)

Definition at line 2531 of file generic.c.

2533{
2536 bg->bg_inode_table_hi = cpu_to_le32(blk >> 32);
2537}

◆ ext4_itable_unused_count()

__u32 ext4_itable_unused_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2507 of file generic.c.

2509{
2510 return le16_to_cpu(bg->bg_itable_unused) |
2512 (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
2513}
__le16 bg_itable_unused
Definition: ext3_fs.h:144
__le16 bg_itable_unused_hi
Definition: ext3_fs.h:152

Referenced by Ext2NewInode().

◆ ext4_itable_unused_set()

void ext4_itable_unused_set ( struct super_block sb,
struct ext4_group_desc bg,
__u32  count 
)

◆ ext4_used_dirs_count()

__u32 ext4_used_dirs_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2499 of file generic.c.

2501{
2502 return le16_to_cpu(bg->bg_used_dirs_count) |
2504 (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0);
2505}
__le16 bg_used_dirs_count
Definition: ext3_fs.h:141
__le16 bg_used_dirs_count_hi
Definition: ext3_fs.h:151

Referenced by Ext2FreeInode(), Ext2NewInode(), Ext2UpdateGroupDirStat(), and ext4_count_dirs().

◆ ext4_used_dirs_set()

void ext4_used_dirs_set ( struct super_block sb,
struct ext4_group_desc bg,
__u32  count 
)

Definition at line 2555 of file generic.c.

Referenced by Ext2FreeInode(), Ext2NewInode(), and Ext2UpdateGroupDirStat().

Variable Documentation

◆ Ext2Global

PEXT2_GLOBAL Ext2Global
extern

Definition at line 16 of file init.c.

Referenced by Ext2TraceIrpContext(), and Ext2TraceMemory().

◆ ProcessNameOffset