ReactOS  0.4.14-dev-384-g5b37caa
generic.c File Reference
#include "ext2fs.h"
#include "linux/ext4.h"
Include dependency graph for generic.c:

Go to the source code of this file.

Macros

#define MAX_LFS_FILESIZE   0x7fffffffffffffff
 
#define ext4_set_bit(n, p)   set_bit((int)(n), (unsigned long *)(p))
 

Functions

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)
 
VOID Ext2DropGroupBH (IN PEXT2_VCB Vcb)
 
VOID Ext2PutGroup (IN PEXT2_VCB Vcb)
 
BOOLEAN Ext2LoadGroupBH (IN PEXT2_VCB Vcb)
 
BOOLEAN Ext2LoadGroup (IN PEXT2_VCB Vcb)
 
VOID Ext2DropBH (IN PEXT2_VCB Vcb)
 
VOID Ext2FlushRange (IN PEXT2_VCB Vcb, LARGE_INTEGER s, LARGE_INTEGER e)
 
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)
 
void Ext2DecodeInode (struct inode *dst, struct ext3_inode *src)
 
void Ext2EncodeInode (struct ext3_inode *dst, struct inode *src)
 
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 Index, IN PVOID Buffer)
 
BOOLEAN Ext2SaveBlock (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Index, 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)
 
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, 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)
 
int ext3_check_dir_entry (const char *function, struct inode *dir, struct ext3_dir_entry_2 *de, struct buffer_head *bh, unsigned long offset)
 
struct ext3_dir_entry_2ext3_next_entry (struct ext3_dir_entry_2 *p)
 
static loff_t ext4_max_size (int blkbits, int has_huge_files)
 
loff_t ext3_max_size (int blkbits, int has_huge_files)
 
loff_t ext3_max_bitmap_size (int bits, int has_huge_files)
 
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)
 
static __u16 crc16_byte (__u16 crc, const __u8 data)
 
__u16 crc16 (__u16 crc, __u8 const *buffer, size_t len)
 
__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)
 
static int test_root (ext3_group_t a, ext3_group_t b)
 
static int ext3_group_sparse (ext3_group_t group)
 
int ext3_bg_has_super (struct super_block *sb, ext3_group_t group)
 
static unsigned long ext4_bg_num_gdb_meta (struct super_block *sb, ext4_group_t group)
 
static unsigned long ext4_bg_num_gdb_nometa (struct super_block *sb, ext4_group_t group)
 
unsigned long ext4_bg_num_gdb (struct super_block *sb, ext4_group_t group)
 
ext3_fsblk_t descriptor_loc (struct super_block *sb, ext3_fsblk_t logical_sb_block, unsigned int nr)
 
void mark_bitmap_end (int start_bit, int end_bit, char *bitmap)
 
unsigned ext4_init_inode_bitmap (struct super_block *sb, struct buffer_head *bh, ext4_group_t block_group, struct ext4_group_desc *gdp)
 
void ext4_get_group_no_and_offset (struct super_block *sb, ext4_fsblk_t blocknr, ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp)
 
static int ext4_block_in_group (struct super_block *sb, ext4_fsblk_t block, ext4_group_t block_group)
 
static int ext4_group_used_meta_blocks (struct super_block *sb, ext4_group_t block_group)
 
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)
 
unsigned long ext4_count_dirs (struct super_block *sb)
 
int ext4_check_descriptors (struct super_block *sb)
 

Variables

PEXT2_GLOBAL Ext2Global
 
__u16 const crc16_table [256]
 

Macro Definition Documentation

◆ ext4_set_bit

#define ext4_set_bit (   n,
  p 
)    set_bit((int)(n), (unsigned long *)(p))

Definition at line 2687 of file generic.c.

◆ MAX_LFS_FILESIZE

#define MAX_LFS_FILESIZE   0x7fffffffffffffff

Definition at line 2183 of file generic.c.

Function Documentation

◆ crc16()

__u16 crc16 ( __u16  crc,
__u8 const buffer,
size_t  len 
)

Definition at line 2545 of file generic.c.

2546 {
2547  while (len--)
2548  crc = crc16_byte(crc, *buffer++);
2549  return crc;
2550 }
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
static __u16 crc16_byte(__u16 crc, const __u8 data)
Definition: generic.c:2540

Referenced by ext4_group_desc_csum().

◆ crc16_byte()

static __u16 crc16_byte ( __u16  crc,
const __u8  data 
)
inlinestatic

Definition at line 2540 of file generic.c.

2541 {
2542  return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
2543 }
__u16 const crc16_table[256]
Definition: generic.c:2505
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by crc16().

◆ descriptor_loc()

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

Definition at line 2669 of file generic.c.

2671 {
2672  struct ext3_sb_info *sbi = EXT3_SB(sb);
2673  ext3_group_t bg, first_meta_bg;
2674  int has_super = 0;
2675 
2676  first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
2677 
2679  nr < first_meta_bg)
2680  return logical_sb_block + nr + 1;
2681  bg = sbi->s_desc_per_block * nr;
2682  if (ext3_bg_has_super(sb, bg))
2683  has_super = 1;
2684  return (has_super + ext3_group_first_block_no(sb, bg));
2685 }
ULONG nr
Definition: thread.c:7
superblock * sb
Definition: btrfs.c:4137
#define EXT4_FEATURE_INCOMPAT_META_BG
Definition: ext3_fs.h:708
unsigned long s_desc_per_block
Definition: ext3_fs_sb.h:39
#define le32_to_cpu
Definition: module.h:147
struct ext3_super_block * s_es
Definition: ext3_fs_sb.h:61
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
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:2619
#define EXT3_SB(sb)
Definition: ext3_fs.h:615

Referenced by Ext2LoadGroup().

◆ Ext2AddEntry()

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

Definition at line 1812 of file generic.c.

1820 {
1821  struct dentry *de = NULL;
1822 
1824  OEM_STRING oem;
1825  int rc;
1826 
1827  BOOLEAN MainResourceAcquired = FALSE;
1828 
1829  if (!IsDirectory(Dcb)) {
1830  DbgBreak();
1831  return STATUS_NOT_A_DIRECTORY;
1832  }
1833 
1834  ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1835  MainResourceAcquired = TRUE;
1836 
1837  _SEH2_TRY {
1838 
1839  Ext2ReferXcb(&Dcb->ReferenceCount);
1840  de = Ext2BuildEntry(Vcb, Dcb->Mcb, FileName);
1841  if (!de) {
1843  _SEH2_LEAVE;
1844  }
1845  de->d_inode = Inode;
1846 
1847  rc = ext3_add_entry(IrpContext, de, Inode);
1848  status = Ext2WinntError(rc);
1849  if (NT_SUCCESS(status)) {
1850 
1851  /* increase dir inode's nlink for .. */
1852  if (S_ISDIR(Inode->i_mode)) {
1853  ext3_inc_count(Dcb->Inode);
1854  ext3_mark_inode_dirty(IrpContext, Dcb->Inode);
1855  }
1856 
1857  /* increase inode nlink reference */
1858  ext3_inc_count(Inode);
1859  ext3_mark_inode_dirty(IrpContext, Inode);
1860 
1861  if (Dentry) {
1862  *Dentry = de;
1863  de = NULL;
1864  }
1865  }
1866 
1867  } _SEH2_FINALLY {
1868 
1869  Ext2DerefXcb(&Dcb->ReferenceCount);
1870 
1871  if (MainResourceAcquired) {
1872  ExReleaseResourceLite(&Dcb->MainResource);
1873  }
1874 
1875  if (de)
1876  Ext2FreeEntry(de);
1877  } _SEH2_END;
1878 
1879  return status;
1880 }
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
STRING OEM_STRING
Definition: umtypes.h:203
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: fs.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define S_ISDIR(mode)
Definition: various.h:18
#define Vcb
Definition: cdprocs.h:1425
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
void ext3_inc_count(struct inode *inode)
Definition: htree.c:307
int ext3_add_entry(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode)
Definition: htree.c:1946
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define DbgBreak()
Definition: ext2fs.h:46
#define _SEH2_LEAVE
Definition: filesup.c:20
static SERVICE_STATUS status
Definition: service.c:31
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:968
struct inode * d_inode
Definition: fs.h:123
struct dentry * Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName)
Definition: memory.c:444
Definition: ps.c:97

◆ Ext2ClearInode()

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

Definition at line 526 of file generic.c.

530 {
531  LONGLONG Offset = 0;
532  BOOLEAN rc;
533 
534  rc = Ext2GetInodeLba(Vcb, Inode, &Offset);
535  if (!rc) {
536  DEBUG(DL_ERR, ( "Ext2SaveInode: failed inode %u.\n", Inode));
537  goto errorout;
538  }
539 
540  rc = Ext2ZeroBuffer(IrpContext, Vcb, Offset, Vcb->InodeSize);
541 
542 errorout:
543 
544  return rc;
545 }
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned char BOOLEAN
int64_t LONGLONG
Definition: typedefs.h:66
BOOLEAN Ext2ZeroBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size)
Definition: generic.c:791
#define Vcb
Definition: cdprocs.h:1425
#define DL_ERR
Definition: ext2fs.h:1397
#define DEBUG(args)
Definition: rdesktop.h:129
BOOLEAN Ext2GetInodeLba(IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: generic.c:414

Referenced by Ext2CreateInode().

◆ Ext2DecodeInode()

void Ext2DecodeInode ( struct inode dst,
struct ext3_inode src 
)

Definition at line 448 of file generic.c.

449 {
450  dst->i_mode = src->i_mode;
451  dst->i_flags = src->i_flags;
452  dst->i_uid = src->i_uid;
453  dst->i_gid = src->i_gid;
454  dst->i_nlink = src->i_links_count;
455  dst->i_generation = src->i_generation;
456  dst->i_size = src->i_size;
457  if (S_ISREG(src->i_mode)) {
458  dst->i_size |= (loff_t)src->i_size_high << 32;
459  }
460  dst->i_file_acl = src->i_file_acl_lo;
461  dst->i_file_acl |= (ext4_fsblk_t)src->osd2.linux2.l_i_file_acl_high << 32;
462  dst->i_atime = src->i_atime;
463  dst->i_ctime = src->i_ctime;
464  dst->i_mtime = src->i_mtime;
465  dst->i_dtime = src->i_dtime;
466  dst->i_blocks = ext3_inode_blocks(src, dst);
467  memcpy(&dst->i_block[0], &src->i_block[0], sizeof(__u32) * 15);
470  dst->i_extra_isize = src->i_extra_isize;
471  else
472  dst->i_extra_isize = 0;
473 }
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
unsigned int __u32
Definition: compat.h:90
unsigned __int64 loff_t
Definition: types.h:80
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE
Definition: ext3_fs.h:702
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
blkcnt_t ext3_inode_blocks(struct ext3_inode *raw_inode, struct inode *inode)
Definition: generic.c:2328
GLenum GLenum dst
Definition: glext.h:6340
#define S_ISREG(mode)
Definition: various.h:17

Referenced by Ext2LoadInode().

◆ Ext2DropBH()

VOID Ext2DropBH ( IN PEXT2_VCB  Vcb)

Definition at line 262 of file generic.c.

263 {
264  struct ext3_sb_info *sbi = &Vcb->sbi;
265 
266  /* do nothing if Vcb is not initialized yet */
267  if (!IsFlagOn(Vcb->Flags, VCB_INITIALIZED))
268  return;
269 
270  _SEH2_TRY {
271 
272  /* acquire bd lock to avoid bh creation */
273  ExAcquireResourceExclusiveLite(&Vcb->bd.bd_bh_lock, TRUE);
274 
275  SetFlag(Vcb->Flags, VCB_BEING_DROPPED);
277 
278  while (!IsListEmpty(&Vcb->bd.bd_bh_free)) {
279  struct buffer_head *bh;
280  PLIST_ENTRY l;
281  l = RemoveHeadList(&Vcb->bd.bd_bh_free);
282  bh = CONTAINING_RECORD(l, struct buffer_head, b_link);
284  if (0 == atomic_read(&bh->b_count)) {
285  buffer_head_remove(&Vcb->bd, bh);
286  free_buffer_head(bh);
287  }
288  }
289 
290  } _SEH2_FINALLY {
291  ExReleaseResourceLite(&Vcb->bd.bd_bh_lock);
292  } _SEH2_END;
293 
295 }
#define TRUE
Definition: types.h:120
atomic_t b_count
Definition: module.h:730
void free_buffer_head(struct buffer_head *bh)
Definition: linux.c:346
LIST_ENTRY b_link
Definition: module.h:714
#define atomic_read(v)
Definition: atomic.h:23
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
VOID Ext2DropGroupBH(IN PEXT2_VCB Vcb)
Definition: generic.c:128
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
r l[0]
Definition: byte_order.h:167
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
Definition: typedefs.h:117
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
void buffer_head_remove(struct block_device *bdev, struct buffer_head *bh)
Definition: linux.c:424
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_SEH2_FINALLY
Definition: create.c:4395
#define VCB_BEING_DROPPED
Definition: ext2fs.h:789
#define VCB_INITIALIZED
Definition: ext2fs.h:779

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

◆ Ext2DropGroupBH()

VOID Ext2DropGroupBH ( IN PEXT2_VCB  Vcb)

Definition at line 128 of file generic.c.

129 {
130  struct ext3_sb_info *sbi = &Vcb->sbi;
131  unsigned long i;
132 
133  if (NULL == Vcb->sbi.s_gd) {
134  return;
135  }
136 
137  for (i = 0; i < Vcb->sbi.s_gdb_count; i++) {
138  if (Vcb->sbi.s_gd[i].bh) {
139  fini_bh(&sbi->s_gd[i].bh);
140  Vcb->sbi.s_gd[i].bh = NULL;
141  }
142  }
143 }
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
struct ext3_gd * s_gd
Definition: ext3_fs_sb.h:35
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
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425

Referenced by Ext2DropBH(), and Ext2PutGroup().

◆ Ext2EncodeInode()

void Ext2EncodeInode ( struct ext3_inode dst,
struct inode src 
)

Definition at line 475 of file generic.c.

476 {
477  dst->i_mode = src->i_mode;
478  dst->i_flags = src->i_flags;
479  dst->i_uid = src->i_uid;
480  dst->i_gid = src->i_gid;
481  dst->i_links_count = src->i_nlink;
482  dst->i_generation = src->i_generation;
483  dst->i_size = (__u32)src->i_size;
484  if (S_ISREG(src->i_mode)) {
485  dst->i_size_high = (__u32)(src->i_size >> 32);
486  }
487  dst->i_file_acl_lo = (__u32)src->i_file_acl;
488  dst->osd2.linux2.l_i_file_acl_high |= (__u16)(src->i_file_acl >> 32);
489  dst->i_atime = src->i_atime;
490  dst->i_ctime = src->i_ctime;
491  dst->i_mtime = src->i_mtime;
492  dst->i_dtime = src->i_dtime;
493  dst->i_extra_isize = src->i_extra_isize;
494  ASSERT(src->i_sb);
496  memcpy(&dst->i_block[0], &src->i_block[0], sizeof(__u32) * 15);
499  dst->i_extra_isize = src->i_extra_isize;
500 }
unsigned short __u16
Definition: compat.h:89
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
unsigned int __u32
Definition: compat.h:90
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE
Definition: ext3_fs.h:702
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
int ext3_inode_blocks_set(struct ext3_inode *raw_inode, struct inode *inode)
Definition: generic.c:2351
GLenum GLenum dst
Definition: glext.h:6340
#define S_ISREG(mode)
Definition: various.h:17

Referenced by Ext2LoadInodeXattr(), and Ext2SaveInode().

◆ Ext2FlushRange()

VOID Ext2FlushRange ( IN PEXT2_VCB  Vcb,
LARGE_INTEGER  s,
LARGE_INTEGER  e 
)

Definition at line 299 of file generic.c.

300 {
301  ULONG len;
302 
303  if (e.QuadPart <= s.QuadPart)
304  return;
305 
306  /* loop per 2G */
307  while (s.QuadPart < e.QuadPart) {
308  if (e.QuadPart > s.QuadPart + 1024 * 1024 * 1024) {
309  len = 1024 * 1024 * 1024;
310  } else {
311  len = (ULONG) (e.QuadPart - s.QuadPart);
312  }
313  CcFlushCache(&Vcb->SectionObject, &s, len, NULL);
314  s.QuadPart += len;
315  }
316 }
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 e
Definition: ke_i.h:82
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
unsigned int ULONG
Definition: retypes.h:1

Referenced by Ext2FlushVcb().

◆ Ext2FlushVcb()

NTSTATUS Ext2FlushVcb ( IN PEXT2_VCB  Vcb)

Definition at line 319 of file generic.c.

320 {
321  LARGE_INTEGER s = {0}, o;
322  struct ext3_sb_info *sbi = &Vcb->sbi;
323  struct rb_node *node;
324  struct buffer_head *bh;
325 
326  if (!IsFlagOn(Vcb->Flags, VCB_GD_LOADED)) {
327  CcFlushCache(&Vcb->SectionObject, NULL, 0, NULL);
328  goto errorout;
329  }
330 
332 
333  _SEH2_TRY {
334 
335  /* acqurie gd block */
336  ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
337 
338  /* acquire bd lock to avoid bh creation */
339  ExAcquireResourceExclusiveLite(&Vcb->bd.bd_bh_lock, TRUE);
340 
341  /* drop unused bh */
342  Ext2DropBH(Vcb);
343 
344  /* flush volume with all outstanding bh skipped */
345 
346  node = rb_first(&Vcb->bd.bd_bh_root);
347  while (node) {
348 
349  bh = container_of(node, struct buffer_head, b_rb_node);
350  node = rb_next(node);
351 
352  o.QuadPart = bh->b_blocknr << BLOCK_BITS;
353  ASSERT(o.QuadPart >= s.QuadPart);
354 
355  if (o.QuadPart == s.QuadPart) {
356  s.QuadPart = s.QuadPart + bh->b_size;
357  continue;
358  }
359 
360  if (o.QuadPart > s.QuadPart) {
361  Ext2FlushRange(Vcb, s, o);
362  s.QuadPart = (bh->b_blocknr << BLOCK_BITS) + bh->b_size;
363  continue;
364  }
365  }
366 
367  o = Vcb->PartitionInformation.PartitionLength;
368  Ext2FlushRange(Vcb, s, o);
369 
370  } _SEH2_FINALLY {
371 
372  ExReleaseResourceLite(&Vcb->bd.bd_bh_lock);
373  ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
374  } _SEH2_END;
375 
376 errorout:
377  return STATUS_SUCCESS;
378 }
VOID Ext2DropBH(IN PEXT2_VCB Vcb)
Definition: generic.c:262
#define TRUE
Definition: types.h:120
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
struct rb_node * rb_next(struct rb_node *)
Definition: rbtree.c:320
VOID Ext2FlushRange(IN PEXT2_VCB Vcb, LARGE_INTEGER s, LARGE_INTEGER e)
Definition: generic.c:299
size_t b_size
Definition: module.h:724
struct rb_node * rb_first(struct rb_root *)
Definition: rbtree.c:294
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
struct node node
struct rb_node b_rb_node
Definition: module.h:731
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
#define Vcb
Definition: cdprocs.h:1425
#define container_of(ptr, type, member)
Definition: glue.h:15
blkcnt_t b_blocknr
Definition: module.h:723
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
GLdouble s
Definition: gl.h:2039
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define VCB_GD_LOADED
Definition: ext2fs.h:787
Definition: rbtree.h:97
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: dlist.c:348

Referenced by Ext2FloppyFlush(), and Ext2FlushVolume().

◆ Ext2FreeBlock()

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

Definition at line 1150 of file generic.c.

1156 {
1157  struct super_block *sb = &Vcb->sb;
1158  PEXT2_GROUP_DESC gd;
1159  struct buffer_head *gb = NULL;
1160  ext4_fsblk_t bitmap_blk;
1161 
1162  RTL_BITMAP BlockBitmap;
1164 
1165  PBCB BitmapBcb;
1166  PVOID BitmapCache;
1167 
1168  ULONG Group;
1169  ULONG Index;
1170  ULONG Length;
1171  ULONG Count;
1172 
1174 
1175  ExAcquireResourceExclusiveLite(&Vcb->MetaBlock, TRUE);
1176 
1177  DEBUG(DL_INF, ("Ext2FreeBlock: Block %xh - %x to be freed.\n",
1178  Block, Block + Number));
1179 
1182 
1183 Again:
1184 
1185  if (gb)
1186  fini_bh(&gb);
1187 
1188  if ( Block < EXT2_FIRST_DATA_BLOCK ||
1189  Block >= TOTAL_BLOCKS ||
1190  Group >= Vcb->sbi.s_groups_count) {
1191 
1192  DbgBreak();
1194 
1195  } else {
1196 
1197  gd = ext4_get_group_desc(sb, Group, &gb);
1198  if (!gd) {
1199  DbgBreak();
1201  goto errorout;
1202  }
1203  bitmap_blk = ext4_block_bitmap(sb, gd);
1204 
1205  /* check the block is valid or not */
1206  if (bitmap_blk >= TOTAL_BLOCKS) {
1207  DbgBreak();
1209  goto errorout;
1210  }
1211 
1212  /* get bitmap block offset and length */
1213  Offset.QuadPart = bitmap_blk;
1214  Offset.QuadPart = Offset.QuadPart << BLOCK_BITS;
1215 
1216  if (Group == Vcb->sbi.s_groups_count - 1) {
1217 
1219 
1220  /* s_blocks_count is integer multiple of s_blocks_per_group */
1221  if (Length == 0) {
1223  }
1224 
1225  } else {
1227  }
1228 
1229  /* read and initialize bitmap */
1230  if (!CcPinRead( Vcb->Volume,
1231  &Offset,
1232  Vcb->BlockSize,
1233  PIN_WAIT,
1234  &BitmapBcb,
1235  &BitmapCache ) ) {
1236 
1237  DEBUG(DL_ERR, ("Ext2FreeBlock: failed to PinLock bitmap block %xh.\n",
1238  bitmap_blk));
1240  DbgBreak();
1241  goto errorout;
1242  }
1243 
1244  /* clear usused bits */
1245  RtlInitializeBitMap(&BlockBitmap, BitmapCache, Length);
1246  Count = min(Length - Index, Number);
1247  RtlClearBits(&BlockBitmap, Index, Count);
1248 
1249  /* update group description table */
1250  ext4_free_blks_set(sb, gd, RtlNumberOfClearBits(&BlockBitmap));
1251 
1252  /* indict the cache range is dirty */
1253  CcSetDirtyPinnedData(BitmapBcb, NULL );
1254  Ext2AddVcbExtent(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1255  CcUnpinData(BitmapBcb);
1256  BitmapBcb = NULL;
1257  BitmapCache = NULL;
1258  Ext2SaveGroup(IrpContext, Vcb, Group);
1259 
1260  /* remove dirty MCB to prevent Volume's lazy writing. */
1261  if (Ext2RemoveBlockExtent(Vcb, NULL, Block, Count)) {
1262  } else {
1263  DbgBreak();
1264  Ext2RemoveBlockExtent(Vcb, NULL, Block, Count);
1265  }
1266 
1267  /* save super block (used/unused blocks statics) */
1268  Ext2UpdateVcbStat(IrpContext, Vcb);
1269 
1270  /* try next group to clear all remaining */
1271  Number -= Count;
1272  if (Number) {
1273  Group += 1;
1274  if (Group < Vcb->sbi.s_groups_count) {
1275  Index = 0;
1276  Block += Count;
1277  goto Again;
1278  } else {
1279  DEBUG(DL_ERR, ("Ext2FreeBlock: block number beyonds max group.\n"));
1280  goto errorout;
1281  }
1282  }
1283  }
1284 
1286 
1287 errorout:
1288 
1289  if (gb)
1290  fini_bh(&gb);
1291 
1292  ExReleaseResourceLite(&Vcb->MetaBlock);
1293 
1294  return Status;
1295 }
VOID Ext2UpdateVcbStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:930
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
superblock * sb
Definition: btrfs.c:4137
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2472
#define EXT2_FIRST_DATA_BLOCK
Definition: ext2fs.h:103
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
Definition: fs.h:64
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define PIN_WAIT
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI ULONG WINAPI RtlNumberOfClearBits(PCRTL_BITMAP)
BOOLEAN Ext2RemoveBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Number)
Definition: memory.c:1097
int64_t LONGLONG
Definition: typedefs.h:66
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
BOOLEAN Ext2AddVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
Definition: memory.c:648
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
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
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
Status
Definition: gdiplustypes.h:24
#define DL_ERR
Definition: ext2fs.h:1397
BOOLEAN Ext2SaveGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:382
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2392
#define min(a, b)
Definition: monoChain.cc:55
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
unsigned int ULONG
Definition: retypes.h:1
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438

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

◆ Ext2FreeInode()

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

Definition at line 1699 of file generic.c.

1705 {
1706  struct super_block *sb = &Vcb->sb;
1707  PEXT2_GROUP_DESC gd;
1708  struct buffer_head *gb = NULL;
1709  struct buffer_head *bh = NULL;
1710  ext4_fsblk_t bitmap_blk;
1711 
1712  RTL_BITMAP InodeBitmap;
1713  ULONG Group;
1714  ULONG Length;
1716 
1717  ULONG dwIno;
1718  BOOLEAN bModified = FALSE;
1719 
1721 
1722  ExAcquireResourceExclusiveLite(&Vcb->MetaInode, TRUE);
1723 
1724  Group = (Inode - 1) / INODES_PER_GROUP;
1725  dwIno = (Inode - 1) % INODES_PER_GROUP;
1726 
1727  DEBUG(DL_INF, ( "Ext2FreeInode: Inode: %xh (Group/Off = %xh/%xh)\n",
1728  Inode, Group, dwIno));
1729 
1730  if (Group >= Vcb->sbi.s_groups_count) {
1731  DbgBreak();
1732  goto errorout;
1733  }
1734 
1735  gd = ext4_get_group_desc(sb, Group, &gb);
1736  if (!gd) {
1737  DbgBreak();
1739  goto errorout;
1740  }
1741 
1742  bitmap_blk = ext4_inode_bitmap(sb, gd);
1743  bh = sb_getblk(sb, bitmap_blk);
1744  if (!bh) {
1745  DbgBreak();
1747  goto errorout;
1748  }
1749  if (!buffer_uptodate(bh)) {
1750  int err = bh_submit_read(bh);
1751  if (err < 0) {
1752  DbgPrint("bh_submit_read error! err: %d\n", err);
1754  goto errorout;
1755  }
1756  }
1757 
1758  if (Group == Vcb->sbi.s_groups_count - 1) {
1759 
1761  if (!Length) {
1762  /* s_inodes_count is integer multiple of s_inodes_per_group */
1764  }
1765  } else {
1767  }
1768 
1769  RtlInitializeBitMap(&InodeBitmap, (PULONG)bh->b_data, Length);
1770 
1771  if (RtlCheckBit(&InodeBitmap, dwIno) == 0) {
1772  DbgBreak();
1774  } else {
1775  RtlClearBits(&InodeBitmap, dwIno, 1);
1776  bModified = TRUE;
1777  }
1778 
1779  if (bModified) {
1780  /* update group free inodes */
1782  RtlNumberOfClearBits(&InodeBitmap));
1783 
1784  /* set inode block dirty and add to vcb dirty range */
1785  mark_buffer_dirty(bh);
1786 
1787  /* update group_desc and super_block */
1788  if (Type == EXT2_FT_DIR) {
1789  ext4_used_dirs_set(sb, gd,
1790  ext4_used_dirs_count(sb, gd) - 1);
1791  }
1792  Ext2SaveGroup(IrpContext, Vcb, Group);
1793  Ext2UpdateVcbStat(IrpContext, Vcb);
1795  }
1796 
1797 errorout:
1798 
1799  ExReleaseResourceLite(&Vcb->MetaInode);
1800 
1801  if (bh)
1802  fini_bh(&bh);
1803 
1804  if (gb)
1805  fini_bh(&gb);
1806 
1807  return Status;
1808 }
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
VOID Ext2UpdateVcbStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:930
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
__u32 ext4_used_dirs_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2432
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Type
Definition: Type.h:6
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2480
void ext4_used_dirs_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2488
#define DbgPrint
Definition: loader.c:25
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
superblock * sb
Definition: btrfs.c:4137
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
Definition: fs.h:64
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
LONG NTSTATUS
Definition: precomp.h:26
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3154
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2400
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI ULONG WINAPI RtlNumberOfClearBits(PCRTL_BITMAP)
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define err(...)
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
char * b_data
Definition: module.h:725
Status
Definition: gdiplustypes.h:24
BOOLEAN Ext2SaveGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:382
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define INODES_COUNT
Definition: ext2fs.h:97
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by Ext2CreateInode(), and Ext2DeleteFile().

◆ Ext2GetInodeLba()

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

Definition at line 414 of file generic.c.

419 {
420  PEXT2_GROUP_DESC gd;
421  struct buffer_head *bh = NULL;
422  ext4_fsblk_t loc;
423  int group;
424 
426  DEBUG(DL_ERR, ( "Ext2GetInodeLba: Inode value %xh is invalid.\n",inode));
427  *offset = 0;
428  return FALSE;
429  }
430 
431  group = (inode - 1) / INODES_PER_GROUP ;
432  gd = ext4_get_group_desc(&Vcb->sb, group, &bh);
433  if (!bh) {
434  *offset = 0;
435  DbgBreak();
436  return FALSE;
437  }
438  loc = (LONGLONG)ext4_inode_table(&Vcb->sb, gd);
439  loc = loc << BLOCK_BITS;
440  loc = loc + ((inode - 1) % INODES_PER_GROUP) * Vcb->InodeSize;
441 
442  *offset = loc;
443  __brelse(bh);
444 
445  return TRUE;
446 }
#define TRUE
Definition: types.h:120
GLintptr offset
Definition: glext.h:5920
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
Definition: fs.h:78
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLuint group
Definition: glext.h:11120
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2408
void __brelse(struct buffer_head *)
Definition: linux.c:800
#define DL_ERR
Definition: ext2fs.h:1397
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define INODES_COUNT
Definition: ext2fs.h:97
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129

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

◆ Ext2LoadBlock()

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

Definition at line 655 of file generic.c.

658 {
659  struct buffer_head *bh = NULL;
660  BOOLEAN rc = 0;
661 
662  _SEH2_TRY {
663 
664  bh = sb_getblk(&Vcb->sb, (sector_t)Index);
665 
666  if (!bh) {
667  DEBUG(DL_ERR, ("Ext2Loadblock: can't load block %u\n", Index));
668  DbgBreak();
669  _SEH2_LEAVE;
670  }
671 
672  if (!buffer_uptodate(bh)) {
673  int err = bh_submit_read(bh);
674  if (err < 0) {
675  DEBUG(DL_ERR, ("Ext2LoadBlock: reading failed %d\n", err));
676  _SEH2_LEAVE;
677  }
678  }
679 
681  rc = TRUE;
682 
683  } _SEH2_FINALLY {
684 
685  if (bh)
686  fini_bh(&bh);
687  } _SEH2_END;
688 
689  return rc;
690 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned __int64 sector_t
Definition: types.h:78
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
_SEH2_TRY
Definition: create.c:4250
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define BLOCK_SIZE
Definition: dlist.c:220
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
#define err(...)
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
char * b_data
Definition: module.h:725
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20

◆ Ext2LoadBuffer()

BOOLEAN Ext2LoadBuffer ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN LONGLONG  offset,
IN ULONG  size,
IN PVOID  buf 
)

Definition at line 729 of file generic.c.

734 {
735  struct buffer_head *bh = NULL;
736  BOOLEAN rc;
737 
738  _SEH2_TRY {
739 
740  while (size) {
741 
742  sector_t block;
743  ULONG len = 0, delta = 0;
744 
745  block = (sector_t) (offset >> BLOCK_BITS);
746  delta = (ULONG)offset & (BLOCK_SIZE - 1);
747  len = BLOCK_SIZE - delta;
748  if (size < len)
749  len = size;
750 
751  bh = sb_getblk(&Vcb->sb, block);
752  if (!bh) {
753  DEBUG(DL_ERR, ("Ext2SaveBuffer: can't load block %I64u\n", block));
754  DbgBreak();
755  _SEH2_LEAVE;
756  }
757 
758  if (!buffer_uptodate(bh)) {
759  int err = bh_submit_read(bh);
760  if (err < 0) {
761  DEBUG(DL_ERR, ("Ext2SaveBuffer: bh_submit_read failed: %d\n", err));
762  _SEH2_LEAVE;
763  }
764  }
765 
766  _SEH2_TRY {
767  RtlCopyMemory(buf, bh->b_data + delta, len);
768  } _SEH2_FINALLY {
769  fini_bh(&bh);
770  } _SEH2_END;
771 
772  buf = (PUCHAR)buf + len;
773  offset = offset + len;
774  size = size - len;
775  }
776 
777  rc = TRUE;
778 
779  } _SEH2_FINALLY {
780 
781  if (bh)
782  fini_bh(&bh);
783 
784  } _SEH2_END;
785 
786  return rc;
787 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned __int64 sector_t
Definition: types.h:78
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
unsigned char * PUCHAR
Definition: retypes.h:3
GLintptr offset
Definition: glext.h:5920
_SEH2_TRY
Definition: create.c:4250
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define BLOCK_SIZE
Definition: dlist.c:220
GLsizeiptr size
Definition: glext.h:5919
#define Vcb
Definition: cdprocs.h:1425
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
char * b_data
Definition: module.h:725
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20

Referenced by Ext2LoadInode(), and Ext2SaveInode().

◆ Ext2LoadGroup()

BOOLEAN Ext2LoadGroup ( IN PEXT2_VCB  Vcb)

Definition at line 203 of file generic.c.

204 {
205  struct super_block *sb = &Vcb->sb;
206  struct ext3_sb_info *sbi = &Vcb->sbi;
207  ext3_fsblk_t sb_block = 1;
208  unsigned long i;
209  BOOLEAN rc = FALSE;
210 
211  _SEH2_TRY {
212 
213  ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
214 
215  if (NULL == sbi->s_gd) {
216  sbi->s_gd = kzalloc(sbi->s_gdb_count * sizeof(struct ext3_gd),
217  GFP_KERNEL);
218  }
219  if (sbi->s_gd == NULL) {
220  DEBUG(DL_ERR, ("Ext2LoadGroup: not enough memory.\n"));
221  _SEH2_LEAVE;
222  }
223 
225  sb_block = EXT4_MIN_BLOCK_SIZE / BLOCK_SIZE;
226  }
227 
228  for (i = 0; i < sbi->s_gdb_count; i++) {
229  sbi->s_gd[i].block = descriptor_loc(sb, sb_block, i);
230  if (!sbi->s_gd[i].block) {
231  DEBUG(DL_ERR, ("Ext2LoadGroup: can't locate group descriptor %d\n", i));
232  _SEH2_LEAVE;
233  }
234  }
235 
236  if (!Ext2LoadGroupBH(Vcb)) {
237  DEBUG(DL_ERR, ("Ext2LoadGroup: Failed to load group descriptions !\n"));
238  _SEH2_LEAVE;
239  }
240 
241  if (!ext4_check_descriptors(sb)) {
242  DbgBreak();
243  DEBUG(DL_ERR, ("Ext2LoadGroup: group descriptors corrupted !\n"));
244  _SEH2_LEAVE;
245  }
246 
247  SetFlag(Vcb->Flags, VCB_GD_LOADED);
248  rc = TRUE;
249 
250  } _SEH2_FINALLY {
251 
252  if (!rc)
253  Ext2PutGroup(Vcb);
254 
255  ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
256  } _SEH2_END;
257 
258  return rc;
259 }
#define TRUE
Definition: types.h:120
int ext4_check_descriptors(struct super_block *sb)
Definition: generic.c:3024
#define EXT4_MIN_BLOCK_SIZE
Definition: ext3_fs.h:169
superblock * sb
Definition: btrfs.c:4137
Definition: fs.h:64
#define GFP_KERNEL
Definition: module.h:658
struct ext3_gd * s_gd
Definition: ext3_fs_sb.h:35
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
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
BOOLEAN Ext2LoadGroupBH(IN PEXT2_VCB Vcb)
Definition: generic.c:166
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define BLOCK_SIZE
Definition: dlist.c:220
#define Vcb
Definition: cdprocs.h:1425
unsigned long s_gdb_count
Definition: ext3_fs_sb.h:38
ext3_fsblk_t descriptor_loc(struct super_block *sb, ext3_fsblk_t logical_sb_block, unsigned int nr)
Definition: generic.c:2669
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define DL_ERR
Definition: ext2fs.h:1397
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define EXT3_MIN_BLOCK_SIZE
Definition: ext3_fs.h:75
VOID Ext2PutGroup(IN PEXT2_VCB Vcb)
Definition: generic.c:146
#define VCB_GD_LOADED
Definition: ext2fs.h:787
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
unsigned long long ext3_fsblk_t
Definition: ext3_fs_i.h:26
#define _SEH2_LEAVE
Definition: filesup.c:20
void * kzalloc(int size, int flags)
Definition: linux.c:34

Referenced by Ext2InitializeVcb(), and ext4_get_group_desc().

◆ Ext2LoadGroupBH()

BOOLEAN Ext2LoadGroupBH ( IN PEXT2_VCB  Vcb)

Definition at line 166 of file generic.c.

167 {
168  struct super_block *sb = &Vcb->sb;
169  struct ext3_sb_info *sbi = &Vcb->sbi;
170  unsigned long i;
171  BOOLEAN rc = FALSE;
172 
173  _SEH2_TRY {
174 
175  ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
176  ASSERT (NULL != sbi->s_gd);
177 
178  for (i = 0; i < sbi->s_gdb_count; i++) {
179  ASSERT (sbi->s_gd[i].block);
180  if (sbi->s_gd[i].bh)
181  continue;
182  sbi->s_gd[i].bh = sb_getblk(sb, sbi->s_gd[i].block);
183  if (!sbi->s_gd[i].bh) {
184  DEBUG(DL_ERR, ("Ext2LoadGroupBH: can't read group descriptor %d\n", i));
185  DbgBreak();
186  _SEH2_LEAVE;
187  }
188  sbi->s_gd[i].gd = (struct ext4_group_desc *)sbi->s_gd[i].bh->b_data;
189  }
190 
191  rc = TRUE;
192 
193  } _SEH2_FINALLY {
194 
195  ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
196  } _SEH2_END;
197 
198  return rc;
199 }
#define TRUE
Definition: types.h:120
superblock * sb
Definition: btrfs.c:4137
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
Definition: fs.h:64
struct ext3_gd * s_gd
Definition: ext3_fs_sb.h:35
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
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
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
unsigned long s_gdb_count
Definition: ext3_fs_sb.h:38
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20

Referenced by Ext2LoadGroup(), and ext4_get_group_desc().

◆ Ext2LoadInode()

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

Definition at line 504 of file generic.c.

506 {
507  struct ext3_inode ext3i = {0};
509 
510  if (!Ext2GetInodeLba(Vcb, Inode->i_ino, &offset)) {
511  DEBUG(DL_ERR, ("Ext2LoadInode: failed inode %u.\n", Inode->i_ino));
512  return FALSE;
513  }
514 
515  if (!Ext2LoadBuffer(NULL, Vcb, offset, sizeof(ext3i), &ext3i)) {
516  return FALSE;
517  }
518 
519  Ext2DecodeInode(Inode, &ext3i);
520 
521  return TRUE;
522 }
#define TRUE
Definition: types.h:120
BOOLEAN Ext2LoadBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:729
GLintptr offset
Definition: glext.h:5920
void Ext2DecodeInode(struct inode *dst, struct ext3_inode *src)
Definition: generic.c:448
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
#define DL_ERR
Definition: ext2fs.h:1397
#define DEBUG(args)
Definition: rdesktop.h:129
BOOLEAN Ext2GetInodeLba(IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: generic.c:414

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 586 of file generic.c.

589 {
592 
593  if (!Ext2GetInodeLba(Vcb, Inode->i_ino, &Offset)) {
594  DEBUG(DL_ERR, ("Ext2LoadRawInode: error get inode(%xh)'s addr.\n", Inode->i_ino));
595  return FALSE;
596  }
597 
598  if (!CcCopyRead(
599  Vcb->Volume,
601  Vcb->InodeSize,
602  PIN_WAIT,
603  (PVOID)InodeXattr,
604  &IoStatus)) {
605  return FALSE;
606  }
607 
608  if (!NT_SUCCESS(IoStatus.Status)) {
609  return FALSE;
610  }
611 
612  Ext2EncodeInode(InodeXattr, Inode);
613  return TRUE;
614 }
#define TRUE
Definition: types.h:120
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define PIN_WAIT
void Ext2EncodeInode(struct ext3_inode *dst, struct inode *src)
Definition: generic.c:475
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
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
#define DL_ERR
Definition: ext2fs.h:1397
#define DEBUG(args)
Definition: rdesktop.h:129
BOOLEAN Ext2GetInodeLba(IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: generic.c:414

Referenced by ext4_fs_get_xattr_ref().

◆ Ext2LoadSuper()

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

Definition at line 25 of file generic.c.

28 {
30  PEXT2_SUPER_BLOCK Ext2Sb = NULL;
31 
32  Ext2Sb = (PEXT2_SUPER_BLOCK)
34  PagedPool,
37  );
38  if (!Ext2Sb) {
40  goto errorout;
41  }
42 
44  Vcb,
47  (PVOID) Ext2Sb,
48  bVerify );
49 
50  if (!NT_SUCCESS(Status)) {
51  Ext2FreePool(Ext2Sb, EXT2_SB_MAGIC);
52  Ext2Sb = NULL;
53  }
54 
55 errorout:
56 
57  *Sb = Ext2Sb;
58  return Status;
59 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct ext2_sblock * PEXT2_SUPER_BLOCK
Definition: ext2.h:171
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS Ext2ReadDisk(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:539
smooth NULL
Definition: ftsmooth.c:416
static BOOL bVerify
Definition: verify.c:27
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
#define SUPER_BLOCK_SIZE
Definition: ext2fs.h:86
Status
Definition: gdiplustypes.h:24
#define SUPER_BLOCK_OFFSET
Definition: ext2fs.h:85
#define EXT2_SB_MAGIC
Definition: ext2fs.h:297
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684

Referenced by Ext2MountVolume(), and Ext2VerifyVolume().

◆ 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 941 of file generic.c.

949 {
950  struct super_block *sb = &Vcb->sb;
951  PEXT2_GROUP_DESC gd;
952  struct buffer_head *gb = NULL;
953  struct buffer_head *bh = NULL;
954  ext4_fsblk_t bitmap_blk;
955 
956  RTL_BITMAP BlockBitmap;
957 
958  ULONG Group = 0;
959  ULONG Index = 0xFFFFFFFF;
960  ULONG dwHint = 0;
961  ULONG Count = 0;
962  ULONG Length = 0;
963 
965 
966  *Block = 0;
967 
969 
970  /* validate the hint group and hint block */
971  if (GroupHint >= Vcb->sbi.s_groups_count) {
972  DbgBreak();
973  GroupHint = Vcb->sbi.s_groups_count - 1;
974  }
975 
976  if (BlockHint != 0) {
977  GroupHint = (BlockHint - EXT2_FIRST_DATA_BLOCK) / BLOCKS_PER_GROUP;
978  dwHint = (BlockHint - EXT2_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
979  }
980 
981  Group = GroupHint;
982 
983 Again:
984 
985  if (bh)
986  fini_bh(&bh);
987 
988  if (gb)
989  fini_bh(&gb);
990 
991  gd = ext4_get_group_desc(sb, Group, &gb);
992  if (!gd) {
993  DbgBreak();
995  goto errorout;
996  }
997 
998  bitmap_blk = ext4_block_bitmap(sb, gd);
999 
1000  if (gd->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
1001  bh = sb_getblk_zero(sb, bitmap_blk);
1002  if (!bh) {
1003  DbgBreak();
1005  goto errorout;
1006  }
1007  gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1008  ext4_init_block_bitmap(sb, bh, Group, gd);
1009  set_buffer_uptodate(bh);
1010  gd->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
1011  Ext2SaveGroup(IrpContext, Vcb, Group);
1012  } else {
1013  bh = sb_getblk(sb, bitmap_blk);
1014  if (!bh) {
1015  DbgBreak();
1017  goto errorout;
1018  }
1019  }
1020 
1021  if (!buffer_uptodate(bh)) {
1022  int err = bh_submit_read(bh);
1023  if (err < 0) {
1024  DbgPrint("bh_submit_read error! err: %d\n", err);
1026  goto errorout;
1027  }
1028  }
1029 
1030  if (ext4_free_blks_count(sb, gd)) {
1031 
1032  if (Group == Vcb->sbi.s_groups_count - 1) {
1033 
1035 
1036  /* s_blocks_count is integer multiple of s_blocks_per_group */
1037  if (Length == 0) {
1039  }
1040  } else {
1042  }
1043 
1044  /* initialize bitmap buffer */
1045  RtlInitializeBitMap(&BlockBitmap, (PULONG)bh->b_data, Length);
1046 
1047  /* try to find a clear bit range */
1048  Index = RtlFindClearBits(&BlockBitmap, *Number, dwHint);
1049 
1050  /* We could not get new block in the prefered group */
1051  if (Index == 0xFFFFFFFF) {
1052 
1053  /* search clear bits from the hint block */
1054  Count = RtlFindNextForwardRunClear(&BlockBitmap, dwHint, &Index);
1055  if (dwHint != 0 && Count == 0) {
1056  /* search clear bits from the very beginning */
1057  Count = RtlFindNextForwardRunClear(&BlockBitmap, 0, &Index);
1058  }
1059 
1060  if (Count == 0) {
1061 
1062  RtlZeroMemory(&BlockBitmap, sizeof(RTL_BITMAP));
1063 
1064  /* no blocks found: set bg_free_blocks_count to 0 */
1065  ext4_free_blks_set(sb, gd, 0);
1066  Ext2SaveGroup(IrpContext, Vcb, Group);
1067 
1068  /* will try next group */
1069  goto Again;
1070 
1071  } else {
1072 
1073  /* we got free blocks */
1074  if (Count <= *Number) {
1075  *Number = Count;
1076  }
1077  }
1078  }
1079 
1080  } else {
1081 
1082  /* try next group */
1083  dwHint = 0;
1084  Group = (Group + 1) % Vcb->sbi.s_groups_count;
1085  if (Group != GroupHint) {
1086  goto Again;
1087  }
1088 
1089  Index = 0xFFFFFFFF;
1090  }
1091 
1092  if (Index < Length) {
1093 
1094  /* mark block bits as allocated */
1095  RtlSetBits(&BlockBitmap, Index, *Number);
1096 
1097  /* set block bitmap dirty in cache */
1098  mark_buffer_dirty(bh);
1099 
1100  /* update group description */
1101  ext4_free_blks_set(sb, gd, RtlNumberOfClearBits(&BlockBitmap));
1102  Ext2SaveGroup(IrpContext, Vcb, Group);
1103 
1104  /* update Vcb free blocks */
1105  Ext2UpdateVcbStat(IrpContext, Vcb);
1106 
1107  /* validate the new allocated block number */
1109  if (*Block >= TOTAL_BLOCKS || *Block + *Number > TOTAL_BLOCKS) {
1110  DbgBreak();
1111  dwHint = 0;
1112  goto Again;
1113  }
1114 
1115  if (ext4_block_bitmap(sb, gd) == *Block ||
1116  ext4_inode_bitmap(sb, gd) == *Block ||
1117  ext4_inode_table(sb, gd) == *Block ) {
1118  DbgBreak();
1119  dwHint = 0;
1120  goto Again;
1121  }
1122 
1123  /* Always remove dirty MCB to prevent Volume's lazy writing.
1124  Metadata blocks will be re-added during modifications.*/
1125  if (Ext2RemoveBlockExtent(Vcb, NULL, *Block, *Number)) {
1126  } else {
1127  DbgBreak();
1128  Ext2RemoveBlockExtent(Vcb, NULL, *Block, *Number);
1129  }
1130 
1131  DEBUG(DL_INF, ("Ext2NewBlock: Block %xh - %x allocated.\n",
1132  *Block, *Block + *Number));
1134  }
1135 
1136 errorout:
1137 
1138  ExReleaseResourceLite(&Vcb->MetaBlock);
1139 
1140  if (bh)
1141  fini_bh(&bh);
1142 
1143  if (gb)
1144  fini_bh(&gb);
1145 
1146  return Status;
1147 }
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
VOID Ext2UpdateVcbStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:930
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define DbgPrint
Definition: loader.c:25
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
superblock * sb
Definition: btrfs.c:4137
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2472
#define EXT2_FIRST_DATA_BLOCK
Definition: ext2fs.h:103
Definition: fs.h:64
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
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:2810
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2400
#define EXT4_BG_BLOCK_UNINIT
Definition: ext3_fs.h:734
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
NTSYSAPI ULONG WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP, ULONG, PULONG)
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI ULONG WINAPI RtlNumberOfClearBits(PCRTL_BITMAP)
BOOLEAN Ext2RemoveBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Number)
Definition: memory.c:1097
static struct buffer_head * sb_getblk_zero(struct super_block *sb, sector_t block)
Definition: module.h:972
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
__u32 ext4_free_blks_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2416
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2408
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
__le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2552
#define err(...)
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
char * b_data
Definition: module.h:725
Status
Definition: gdiplustypes.h:24
BOOLEAN Ext2SaveGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:382
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2392
unsigned int * PULONG
Definition: retypes.h:1
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
#define DbgBreak()
Definition: ext2fs.h:46
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
#define DEBUG(args)
Definition: rdesktop.h:129
#define cpu_to_le16
Definition: module.h:148
return STATUS_SUCCESS
Definition: btrfs.c:2938
NTSYSAPI ULONG WINAPI RtlFindClearBits(PCRTL_BITMAP, ULONG, ULONG)
#define EXT3_SB(sb)
Definition: ext3_fs.h:615
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100

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 1299 of file generic.c.

1306 {
1307  struct super_block *sb = &Vcb->sb;
1308  PEXT2_GROUP_DESC gd;
1309  struct buffer_head *gb = NULL;
1310  struct buffer_head *bh = NULL;
1311  ext4_fsblk_t bitmap_blk;
1312 
1313  RTL_BITMAP InodeBitmap;
1314 
1315  ULONG Group, i, j;
1316  ULONG Average, Length;
1317 
1318  ULONG dwInode;
1319 
1321 
1322  *Inode = dwInode = 0XFFFFFFFF;
1323 
1324  ExAcquireResourceExclusiveLite(&Vcb->MetaInode, TRUE);
1325 
1326  if (GroupHint >= Vcb->sbi.s_groups_count)
1327  GroupHint = GroupHint % Vcb->sbi.s_groups_count;
1328 
1329 repeat:
1330 
1331  if (bh)
1332  fini_bh(&bh);
1333 
1334  if (gb)
1335  fini_bh(&gb);
1336 
1337  Group = i = 0;
1338  gd = NULL;
1339 
1340  if (Type == EXT2_FT_DIR) {
1341 
1342  Average = Vcb->SuperBlock->s_free_inodes_count / Vcb->sbi.s_groups_count;
1343 
1344  for (j = 0; j < Vcb->sbi.s_groups_count; j++) {
1345 
1346  i = (j + GroupHint) % (Vcb->sbi.s_groups_count);
1347  gd = ext4_get_group_desc(sb, i, &gb);
1348  if (!gd) {
1349  DbgBreak();
1351  goto errorout;
1352  }
1353 
1354  if ((gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) ||
1355  (ext4_used_dirs_count(sb, gd) << 8 <
1356  ext4_free_inodes_count(sb, gd)) ) {
1357  Group = i + 1;
1358  break;
1359  }
1360  fini_bh(&gb);
1361  }
1362 
1363  if (!Group) {
1364 
1366 
1367  gd = NULL;
1368 
1369  /* get the group with the biggest vacancy */
1370  for (j = 0; j < Vcb->sbi.s_groups_count; j++) {
1371 
1372  struct buffer_head *gt = NULL;
1373  desc = ext4_get_group_desc(sb, j, &gt);
1374  if (!desc) {
1375  DbgBreak();
1377  goto errorout;
1378  }
1379 
1380  /* return the group if it's not initialized yet */
1381  if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1382  Group = j + 1;
1383  gd = desc;
1384 
1385  if (gb)
1386  fini_bh(&gb);
1387  gb = gt;
1388  gt = NULL;
1389  break;
1390  }
1391 
1392  if (!gd) {
1393  if (ext4_free_inodes_count(sb, desc) > 0) {
1394  Group = j + 1;
1395  gd = desc;
1396  if (gb)
1397  fini_bh(&gb);
1398  gb = gt;
1399  gt = NULL;
1400  }
1401  } else {
1403  ext4_free_inodes_count(sb, gd)) {
1404  Group = j + 1;
1405  gd = desc;
1406  if (gb)
1407  fini_bh(&gb);
1408  gb = gt;
1409  gt = NULL;
1410  break;
1411  }
1412  }
1413  if (gt)
1414  fini_bh(&gt);
1415  }
1416  }
1417 
1418  } else {
1419 
1420  /*
1421  * Try to place the inode in its parent directory (GroupHint)
1422  */
1423 
1424  gd = ext4_get_group_desc(sb, GroupHint, &gb);
1425  if (!gb) {
1426  DbgBreak();
1428  goto errorout;
1429  }
1430 
1431  if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1432  ext4_free_inodes_count(sb, gd)) {
1433 
1434  Group = GroupHint + 1;
1435 
1436  } else {
1437 
1438  /* this group is 100% cocucpied */
1439  fini_bh(&gb);
1440 
1441  i = GroupHint;
1442 
1443  /*
1444  * Use a quadratic hash to find a group with a free inode
1445  */
1446 
1447  for (j = 1; j < Vcb->sbi.s_groups_count; j <<= 1) {
1448 
1449 
1450  i = (i + j) % Vcb->sbi.s_groups_count;
1451  gd = ext4_get_group_desc(sb, i, &gb);
1452  if (!gd) {
1453  DbgBreak();
1455  goto errorout;
1456  }
1457 
1458  if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1459  ext4_free_inodes_count(sb, gd)) {
1460  Group = i + 1;
1461  break;
1462  }
1463 
1464  fini_bh(&gb);
1465  }
1466  }
1467 
1468  if (!Group) {
1469  /*
1470  * That failed: try linear search for a free inode
1471  */
1472  i = GroupHint;
1473  for (j = 2; j < Vcb->sbi.s_groups_count; j++) {
1474 
1475  i = (i + 1) % Vcb->sbi.s_groups_count;
1476  gd = ext4_get_group_desc(sb, i, &gb);
1477  if (!gd) {
1478  DbgBreak();
1480  goto errorout;
1481  }
1482 
1483  if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1484  ext4_free_inodes_count(sb, gd)) {
1485  Group = i + 1;
1486  break;
1487  }
1488 
1489  fini_bh(&gb);
1490  }
1491  }
1492  }
1493 
1494  if (gd == NULL || Group == 0) {
1495  goto errorout;
1496  }
1497 
1498  /* finally we got the group, but is it valid ? */
1499  if (Group > Vcb->sbi.s_groups_count) {
1500  DbgBreak();
1501  goto errorout;
1502  }
1503 
1504  /* valid group number starts from 1, not 0 */
1505  Group -= 1;
1506 
1507  ASSERT(gd);
1508  bitmap_blk = ext4_inode_bitmap(sb, gd);
1509  /* check the block is valid or not */
1510  if (bitmap_blk == 0 || bitmap_blk >= TOTAL_BLOCKS) {
1511  DbgBreak();
1513  goto errorout;
1514  }
1515 
1516  if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1517  bh = sb_getblk_zero(sb, bitmap_blk);
1518  if (!bh) {
1519  DbgBreak();
1521  goto errorout;
1522  }
1523  gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1524  ext4_init_inode_bitmap(sb, bh, Group, gd);
1525  set_buffer_uptodate(bh);
1526  gd->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
1527  Ext2SaveGroup(IrpContext, Vcb, Group);
1528  } else {
1529  bh = sb_getblk(sb, bitmap_blk);
1530  if (!bh) {
1531  DbgBreak();
1533  goto errorout;
1534  }
1535  }
1536 
1537  if (!buffer_uptodate(bh)) {
1538  int err = bh_submit_read(bh);
1539  if (err < 0) {
1540  DbgPrint("bh_submit_read error! err: %d\n", err);
1542  goto errorout;
1543  }
1544  }
1545 
1546  if (Vcb->sbi.s_groups_count == 1) {
1547  Length = INODES_COUNT;
1548  } else {
1549  if (Group + 1 == Vcb->sbi.s_groups_count) {
1551  if (!Length) {
1552  /* INODES_COUNT is integer multiple of INODES_PER_GROUP */
1554  }
1555  } else {
1557  }
1558  }
1559 
1560  RtlInitializeBitMap(&InodeBitmap, (PULONG)bh->b_data, Length);
1561  dwInode = RtlFindClearBits(&InodeBitmap, 1, 0);
1562 
1563  if (dwInode == 0xFFFFFFFF || dwInode >= Length) {
1564 
1565  RtlZeroMemory(&InodeBitmap, sizeof(RTL_BITMAP));
1566  if (ext4_free_inodes_count(sb, gd) > 0) {
1567  ext4_free_inodes_set(sb, gd, 0);
1568  Ext2SaveGroup(IrpContext, Vcb, Group);
1569  }
1570  goto repeat;
1571 
1572  } else {
1573 
1574  __u32 count = 0;
1575 
1576  /* update unused inodes count */
1577  count = ext4_free_inodes_count(sb, gd) - 1;
1579 
1580  RtlSetBits(&InodeBitmap, dwInode, 1);
1581 
1582  /* set block bitmap dirty in cache */
1583  mark_buffer_dirty(bh);
1584 
1585  /* If we didn't allocate from within the initialized part of the inode
1586  * table then we need to initialize up to this inode. */
1588 
1589  __u32 free;
1590 
1591  if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1592  gd->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
1593  /* When marking the block group with
1594  * ~EXT4_BG_INODE_UNINIT we don't want to depend
1595  * on the value of bg_itable_unused even though
1596  * mke2fs could have initialized the same for us.
1597  * Instead we calculated the value below
1598  */
1599 
1600  free = 0;
1601  } else {
1603  }
1604 
1605  /*
1606  * Check the relative inode number against the last used
1607  * relative inode number in this group. if it is greater
1608  * we need to update the bg_itable_unused count
1609  *
1610  */
1611  if (dwInode + 1 > free) {
1613  (EXT3_INODES_PER_GROUP(sb) - 1 - dwInode));
1614  }
1615 
1616  /* We may have to initialize the block bitmap if it isn't already */
1617  if (gd->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
1618 
1619  struct buffer_head *block_bitmap_bh = NULL;
1620 
1621  /* recheck and clear flag under lock if we still need to */
1622  block_bitmap_bh = sb_getblk_zero(sb, ext4_block_bitmap(sb, gd));
1623  if (block_bitmap_bh) {
1624  gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1625  free = ext4_init_block_bitmap(sb, block_bitmap_bh, Group, gd);
1626  set_buffer_uptodate(block_bitmap_bh);
1627  brelse(block_bitmap_bh);
1628  gd->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
1629  ext4_free_blks_set(sb, gd, free);
1630  Ext2SaveGroup(IrpContext, Vcb, Group);
1631  }
1632  }
1633  }
1634 
1635  *Inode = dwInode + 1 + Group * INODES_PER_GROUP;
1636 
1637  /* update group_desc / super_block */
1638  if (Type == EXT2_FT_DIR) {
1640  }
1641  Ext2SaveGroup(IrpContext, Vcb, Group);
1642  Ext2UpdateVcbStat(IrpContext, Vcb);
1644  }
1645 
1646 errorout:
1647 
1648  ExReleaseResourceLite(&Vcb->MetaInode);
1649 
1650  if (bh)
1651  fini_bh(&bh);
1652 
1653  if (gb)
1654  fini_bh(&gb);
1655 
1656 
1657  return Status;
1658 }
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
VOID Ext2UpdateVcbStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:930
__u32 ext4_used_dirs_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2432
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Type
Definition: Type.h:6
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2480
void ext4_used_dirs_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2488
#define DbgPrint
Definition: loader.c:25
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
superblock * sb
Definition: btrfs.c:4137
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2472
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2496
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: fs.h:64
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
#define free
Definition: debug_ros.c:5
LONG NTSTATUS
Definition: precomp.h:26
__u32 ext4_free_inodes_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2424
#define EXT4_BG_INODE_UNINIT
Definition: ext3_fs.h:733
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:2810
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2400
#define EXT4_BG_BLOCK_UNINIT
Definition: ext3_fs.h:734
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
static void brelse(struct buffer_head *bh)
Definition: module.h:945
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
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
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
static const WCHAR desc[]
Definition: protectdata.c:36
smooth NULL
Definition: ftsmooth.c:416
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
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM
Definition: ext3_fs.h:700
static struct buffer_head * sb_getblk_zero(struct super_block *sb, sector_t block)
Definition: module.h:972
#define Vcb
Definition: cdprocs.h:1425
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
unsigned int __u32
Definition: compat.h:90
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
__le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2552
#define err(...)
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
static int repeat
Definition: xmllint.c:143
char * b_data
Definition: module.h:725
Status
Definition: gdiplustypes.h:24
BOOLEAN Ext2SaveGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:382
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2392
__u32 ext4_itable_unused_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2440
#define EXT3_INODES_PER_GROUP(s)
Definition: ext3_fs.h:191
unsigned int * PULONG
Definition: retypes.h:1
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:2719
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define INODES_COUNT
Definition: ext2fs.h:97
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
#define DbgBreak()
Definition: ext2fs.h:46
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
#define cpu_to_le16
Definition: module.h:148
return STATUS_SUCCESS
Definition: btrfs.c:2938
NTSYSAPI ULONG WINAPI RtlFindClearBits(PCRTL_BITMAP, ULONG, ULONG)
#define EXT3_SB(sb)
Definition: ext3_fs.h:615

Referenced by Ext2CreateInode().

◆ Ext2PutGroup()

VOID Ext2PutGroup ( IN PEXT2_VCB  Vcb)

Definition at line 146 of file generic.c.

147 {
148  struct ext3_sb_info *sbi = &Vcb->sbi;
149  unsigned long i;
150 
151 
152  if (NULL == Vcb->sbi.s_gd) {
153  return;
154  }
155 
157 
158  kfree(Vcb->sbi.s_gd);
159  Vcb->sbi.s_gd = NULL;
160 
161  ClearFlag(Vcb->Flags, VCB_GD_LOADED);
162 }
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
VOID Ext2DropGroupBH(IN PEXT2_VCB Vcb)
Definition: generic.c:128
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
#define VCB_GD_LOADED
Definition: ext2fs.h:787
void kfree(const void *)

Referenced by Ext2InitializeVcb(), and Ext2LoadGroup().

◆ Ext2RefreshGroup()

BOOLEAN Ext2RefreshGroup ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 405 of file generic.c.

409 {
410  return TRUE;
411 }
#define TRUE
Definition: types.h:120

Referenced by Ext2RecoverJournal().

◆ Ext2RefreshSuper()

BOOLEAN Ext2RefreshSuper ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 88 of file generic.c.

92 {
95 
97  if (!CcCopyRead(
98  Vcb->Volume,
101  TRUE,
102  (PVOID)Vcb->SuperBlock,
103  &iosb )) {
104  return FALSE;
105  }
106 
107  if (!NT_SUCCESS(iosb.Status)) {
108  return FALSE;
109  }
110 
111  /* reload root inode */
112  if (Vcb->McbTree) {
113 
114  if (!Ext2LoadInode(Vcb, &Vcb->McbTree->Inode))
115  return FALSE;
116 
117  /* initializeroot node */
118  Vcb->McbTree->CreationTime = Ext2NtTime(Vcb->McbTree->Inode.i_ctime);
119  Vcb->McbTree->LastAccessTime = Ext2NtTime(Vcb->McbTree->Inode.i_atime);
120  Vcb->McbTree->LastWriteTime = Ext2NtTime(Vcb->McbTree->Inode.i_mtime);
121  Vcb->McbTree->ChangeTime = Ext2NtTime(Vcb->McbTree->Inode.i_mtime);
122  }
123 
124  return TRUE;
125 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define TRUE
Definition: types.h:120
LARGE_INTEGER Ext2NtTime(IN ULONG i_time)
Definition: misc.c:40
GLintptr offset
Definition: glext.h:5920
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
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
#define SUPER_BLOCK_SIZE
Definition: ext2fs.h:86
#define SUPER_BLOCK_OFFSET
Definition: ext2fs.h:85
BOOLEAN Ext2LoadInode(IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:504

Referenced by Ext2RecoverJournal().

◆ Ext2RemoveEntry()

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

Definition at line 1954 of file generic.c.

1960 {
1961  struct inode *dir = Dcb->Inode;
1962  struct buffer_head *bh = NULL;
1963  struct ext3_dir_entry_2 *de;
1964  struct inode *inode;
1965  int rc = -ENOENT;
1967  BOOLEAN MainResourceAcquired = FALSE;
1968 
1969  if (!IsDirectory(Dcb)) {
1970  return STATUS_NOT_A_DIRECTORY;
1971  }
1972 
1973  ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1974  MainResourceAcquired = TRUE;
1975 
1976  _SEH2_TRY {
1977 
1978  Ext2ReferXcb(&Dcb->ReferenceCount);
1979 
1980  bh = ext3_find_entry(IrpContext, Mcb->de, &de);
1981  if (!bh)
1982  _SEH2_LEAVE;
1983 
1984  inode = &Mcb->Inode;
1985  if (le32_to_cpu(de->inode) != inode->i_ino)
1986  _SEH2_LEAVE;
1987 
1988  if (!inode->i_nlink) {
1989  ext3_warning (inode->i_sb, "ext3_unlink",
1990  "Deleting nonexistent file (%lu), %d",
1991  inode->i_ino, inode->i_nlink);
1992  inode->i_nlink = 1;
1993  }
1994  rc = ext3_delete_entry(IrpContext, dir, de, bh);
1995  if (rc) {
1996  Status = Ext2WinntError(rc);
1997  _SEH2_LEAVE;
1998  }
1999  /*
2000  if (!inode->i_nlink)
2001  ext3_orphan_add(handle, inode);
2002  */
2003  inode->i_ctime = dir->i_ctime = dir->i_mtime = ext3_current_time(dir);
2005  ext3_mark_inode_dirty(IrpContext, inode);
2006 
2007  /* decrease dir inode's nlink for .. */
2008  if (S_ISDIR(inode->i_mode)) {
2011  ext3_mark_inode_dirty(IrpContext, dir);
2012  }
2013 
2015 
2016  } _SEH2_FINALLY {
2017 
2018  Ext2DerefXcb(&Dcb->ReferenceCount);
2019 
2020  if (MainResourceAcquired)
2021  ExReleaseResourceLite(&Dcb->MainResource);
2022 
2023  if (bh)
2024  brelse(bh);
2025  } _SEH2_END;
2026 
2027  return Status;
2028 }
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
#define TRUE
Definition: types.h:120
void ext3_update_dx_flag(struct inode *inode)
Definition: htree.c:368
Definition: ext3_fs.h:774
umode_t i_mode
Definition: fs.h:87
LONG NTSTATUS
Definition: precomp.h:26
__u16 i_nlink
Definition: fs.h:91
_SEH2_TRY
Definition: create.c:4250
static void brelse(struct buffer_head *bh)
Definition: module.h:945
void ext3_dec_count(struct inode *inode)
Definition: htree.c:312
Definition: fs.h:78
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
#define le32_to_cpu
Definition: module.h:147
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
__u32 i_ctime
Definition: fs.h:82
void ext3_warning(struct super_block *sb, const char *function, char *fmt,...)
Definition: htree.c:212
#define S_ISDIR(mode)
Definition: various.h:18
__u32 ext3_current_time(struct inode *in)
Definition: htree.c:204
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
__le32 inode
Definition: ext3_fs.h:775
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
struct buffer_head * ext3_find_entry(struct ext2_icb *icb, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir)
Definition: htree.c:2166
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
__u32 i_ino
Definition: fs.h:79
Status
Definition: gdiplustypes.h:24
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
_SEH2_END
Definition: create.c:4424
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_SEH2_FINALLY
Definition: create.c:4395
Definition: arc.h:46
struct super_block * i_sb
Definition: fs.h:96
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:968

Referenced by Ext2DeleteFile(), and Ext2SetRenameInfo().

◆ Ext2SaveBlock()

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

Definition at line 694 of file generic.c.

698 {
699  struct buffer_head *bh = NULL;
700  BOOLEAN rc = 0;
701 
702  _SEH2_TRY {
703 
704  bh = sb_getblk_zero(&Vcb->sb, (sector_t)Index);
705 
706  if (!bh) {
707  DEBUG(DL_ERR, ("Ext2Saveblock: can't load block %u\n", Index));
708  DbgBreak();
709  _SEH2_LEAVE;
710  }
711 
712  if (!buffer_uptodate(bh)) {
713  }
714 
715  RtlCopyMemory(bh->b_data, Buf, BLOCK_SIZE);
716  mark_buffer_dirty(bh);
717  rc = TRUE;
718 
719  } _SEH2_FINALLY {
720 
721  if (bh)
722  fini_bh(&bh);
723  } _SEH2_END;
724 
725  return rc;
726 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned __int64 sector_t
Definition: types.h:78
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
_SEH2_TRY
Definition: create.c:4250
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define BLOCK_SIZE
Definition: dlist.c:220
static struct buffer_head * sb_getblk_zero(struct super_block *sb, sector_t block)
Definition: module.h:972
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
char * b_data
Definition: module.h:725
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20

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 862 of file generic.c.

867 {
868  struct buffer_head *bh = NULL;
869  BOOLEAN rc = 0;
870 
871  _SEH2_TRY {
872 
873  while (size) {
874 
875  sector_t block;
876  ULONG len = 0, delta = 0;
877 
878  block = (sector_t) (offset >> BLOCK_BITS);
879  delta = (ULONG)offset & (BLOCK_SIZE - 1);
880  len = BLOCK_SIZE - delta;
881  if (size < len)
882  len = size;
883 
884  if (delta == 0 && len >= BLOCK_SIZE) {
885  bh = sb_getblk_zero(&Vcb->sb, block);
886  } else {
887  bh = sb_getblk(&Vcb->sb, block);
888  }
889 
890  if (!bh) {
891  DEBUG(DL_ERR, ("Ext2SaveBuffer: can't load block %I64u\n", block));
892  DbgBreak();
893  _SEH2_LEAVE;
894  }
895 
896  if (!buffer_uptodate(bh)) {
897  int err = bh_submit_read(bh);
898  if (err < 0) {
899  DEBUG(DL_ERR, ("Ext2SaveBuffer: bh_submit_read failed: %d\n", err));
900  _SEH2_LEAVE;
901  }
902  }
903 
904  _SEH2_TRY {
905  RtlCopyMemory(bh->b_data + delta, buf, len);
906  mark_buffer_dirty(bh);
907  } _SEH2_FINALLY {
908  fini_bh(&bh);
909  } _SEH2_END;
910 
911  buf = (PUCHAR)buf + len;
912  offset = offset + len;
913  size = size - len;
914  }
915 
916  rc = TRUE;
917 
918  } _SEH2_FINALLY {
919 
920  if (bh)
921  fini_bh(&bh);
922 
923  } _SEH2_END;
924 
925  return rc;
926 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned __int64 sector_t
Definition: types.h:78
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
unsigned char * PUCHAR
Definition: retypes.h:3
GLintptr offset
Definition: glext.h:5920
_SEH2_TRY
Definition: create.c:4250
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define BLOCK_SIZE
Definition: dlist.c:220
GLsizeiptr size
Definition: glext.h:5919
static struct buffer_head * sb_getblk_zero(struct super_block *sb, sector_t block)
Definition: module.h:972
#define Vcb
Definition: cdprocs.h:1425
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
char * b_data
Definition: module.h:725
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20

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 382 of file generic.c.

387 {
388  struct ext4_group_desc *gd;
389  struct buffer_head *gb = NULL;
390  unsigned long i;
391 
392  gd = ext4_get_group_desc(&Vcb->sb, Group, &gb);
393  if (!gd)
394  return 0;
395 
396  gd->bg_checksum = ext4_group_desc_csum(&Vcb->sbi, Group, gd);
397  mark_buffer_dirty(gb);
398  fini_bh(&gb);
399 
400  return TRUE;
401 }
#define TRUE
Definition: types.h:120
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
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
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
__le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2552
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
__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 548 of file generic.c.

551 {
552  struct ext3_inode ext3i = {0};
553 
554  LONGLONG Offset = 0;
555  ULONG InodeSize = sizeof(ext3i);
556  BOOLEAN rc = 0;
557 
558  DEBUG(DL_INF, ( "Ext2SaveInode: Saving Inode %xh: Mode=%xh Size=%xh\n",
559  Inode->i_ino, Inode->i_mode, Inode->i_size));
560  rc = Ext2GetInodeLba(Vcb, Inode->i_ino, &Offset);
561  if (!rc) {
562  DEBUG(DL_ERR, ( "Ext2SaveInode: failed inode %u.\n", Inode->i_ino));
563  goto errorout;
564  }
565 
566  rc = Ext2LoadBuffer(NULL, Vcb, Offset, InodeSize, &ext3i);
567  if (!rc) {
568  DEBUG(DL_ERR, ( "Ext2SaveInode: failed reading inode %u.\n", Inode->i_ino));
569  goto errorout;;
570  }
571 
572  Ext2EncodeInode(&ext3i, Inode);
573  if (InodeSize > Vcb->InodeSize)
574  InodeSize = Vcb->InodeSize;
575  rc = Ext2SaveBuffer(IrpContext, Vcb, Offset, InodeSize, &ext3i);
576 
577  if (rc && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
579  }
580 
581 errorout:
582  return rc;
583 }
BOOLEAN Ext2LoadBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:729
void Ext2EncodeInode(struct ext3_inode *dst, struct inode *src)
Definition: generic.c:475
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
VOID Ext2StartFloppyFlushDpc(PEXT2_VCB Vcb, PEXT2_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:123
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
#define DL_ERR
Definition: ext2fs.h:1397
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
unsigned int ULONG
Definition: retypes.h:1
#define DEBUG(args)
Definition: rdesktop.h:129
BOOLEAN Ext2GetInodeLba(IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: generic.c:414
BOOLEAN Ext2SaveBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:862

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 617 of file generic.c.

621 {
623  LONGLONG Offset = 0;
624  ULONG InodeSize = Vcb->InodeSize;
625  BOOLEAN rc = 0;
626 
627  /* There is no way to put EA information in such a small inode */
628  if (InodeSize == EXT2_GOOD_OLD_INODE_SIZE)
629  return FALSE;
630 
631  DEBUG(DL_INF, ("Ext2SaveInodeXattr: Saving Inode %xh: Mode=%xh Size=%xh\n",
632  Inode->i_ino, Inode->i_mode, Inode->i_size));
633  rc = Ext2GetInodeLba(Vcb, Inode->i_ino, &Offset);
634  if (!rc) {
635  DEBUG(DL_ERR, ("Ext2SaveInodeXattr: error get inode(%xh)'s addr.\n", Inode->i_ino));
636  goto errorout;
637  }
638 
639  rc = Ext2SaveBuffer(IrpContext,
640  Vcb,
641  Offset + EXT2_GOOD_OLD_INODE_SIZE + Inode->i_extra_isize,
642  InodeSize - EXT2_GOOD_OLD_INODE_SIZE - Inode->i_extra_isize,
643  (char *)InodeXattr + EXT2_GOOD_OLD_INODE_SIZE + Inode->i_extra_isize);
644 
645  if (rc && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
647  }
648 
649 errorout:
650  return rc;
651 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
VOID Ext2StartFloppyFlushDpc(PEXT2_VCB Vcb, PEXT2_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:123
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
#define DL_ERR
Definition: ext2fs.h:1397
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
#define EXT2_GOOD_OLD_INODE_SIZE
Definition: ext2.h:54
unsigned int ULONG
Definition: retypes.h:1
#define DEBUG(args)
Definition: rdesktop.h:129
BOOLEAN Ext2GetInodeLba(IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: generic.c:414
BOOLEAN Ext2SaveBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:862

Referenced by ext4_fs_put_xattr_ref().

◆ Ext2SaveSuper()

BOOLEAN Ext2SaveSuper ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 63 of file generic.c.

67 {
69  BOOLEAN rc;
70 
72  rc = Ext2SaveBuffer( IrpContext,
73  Vcb,
74  offset,
76  Vcb->SuperBlock
77  );
78 
79  if (IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
81  }
82 
83  return rc;
84 }
GLintptr offset
Definition: glext.h:5920
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
VOID Ext2StartFloppyFlushDpc(PEXT2_VCB Vcb, PEXT2_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:123
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
#define SUPER_BLOCK_SIZE
Definition: ext2fs.h:86
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
#define SUPER_BLOCK_OFFSET
Definition: ext2fs.h:85
BOOLEAN Ext2SaveBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:862

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

◆ 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 1884 of file generic.c.

1891 {
1892  struct inode *dir = Dcb->Inode;
1893  struct buffer_head *bh = NULL;
1894  struct ext3_dir_entry_2 *de;
1895  struct inode *inode;
1897  BOOLEAN MainResourceAcquired = FALSE;
1898 
1900  return STATUS_SUCCESS;
1901  }
1902 
1903  if (!IsDirectory(Dcb)) {
1904  return STATUS_NOT_A_DIRECTORY;
1905  }
1906 
1907  ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1908  MainResourceAcquired = TRUE;
1909 
1910  _SEH2_TRY {
1911 
1912  Ext2ReferXcb(&Dcb->ReferenceCount);
1913 
1914  bh = ext3_find_entry(IrpContext, Mcb->de, &de);
1915  if (!bh)
1916  _SEH2_LEAVE;
1917 
1918  inode = &Mcb->Inode;
1919  if (le32_to_cpu(de->inode) != inode->i_ino)
1920  _SEH2_LEAVE;
1921 
1923  mark_buffer_dirty(bh);
1924 
1925  if (S_ISDIR(inode->i_mode) == S_ISDIR(mode)) {
1926  } else if (S_ISDIR(inode->i_mode)) {
1928  } else if (S_ISDIR(mode)) {
1930  }
1931  dir->i_ctime = dir->i_mtime = ext3_current_time(dir);
1932  ext3_mark_inode_dirty(IrpContext, dir);
1933 
1934  inode->i_mode = mode;
1935  ext3_mark_inode_dirty(IrpContext, inode);
1936 
1938 
1939  } _SEH2_FINALLY {
1940 
1941  Ext2DerefXcb(&Dcb->ReferenceCount);
1942 
1943  if (MainResourceAcquired)
1944  ExReleaseResourceLite(&Dcb->MainResource);
1945 
1946  if (bh)
1947  brelse(bh);
1948  } _SEH2_END;
1949 
1950  return Status;
1951 }
#define TRUE
Definition: types.h:120
Definition: ext3_fs.h:774
umode_t i_mode
Definition: fs.h:87
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4250
static void brelse(struct buffer_head *bh)
Definition: module.h:945
void ext3_dec_count(struct inode *inode)
Definition: htree.c:312
Definition: fs.h:78
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
#define le32_to_cpu
Definition: module.h:147
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
#define EXT3_FEATURE_INCOMPAT_FILETYPE
Definition: ext3_fs.h:679
#define S_ISDIR(mode)
Definition: various.h:18
__u32 ext3_current_time(struct inode *in)
Definition: htree.c:204
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
__le32 inode
Definition: ext3_fs.h:775
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
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_inc_count(struct inode *inode)
Definition: htree.c:307
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
GLenum mode
Definition: glext.h:6217
__u32 i_ino
Definition: fs.h:79
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_SEH2_FINALLY
Definition: create.c:4395
struct super_block * i_sb
Definition: fs.h:96
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:968
void ext3_set_de_type(struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
Definition: htree.c:347

Referenced by Ext2SetReparsePoint().

◆ 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 2031 of file generic.c.

2037 {
2039 
2040  PEXT2_DIR_ENTRY2 pSelf = NULL;
2041  PEXT2_DIR_ENTRY2 pParent = NULL;
2042 
2043  ULONG dwBytes = 0;
2044 
2045  BOOLEAN MainResourceAcquired = FALSE;
2046 
2047  ULONG Offset = 0;
2048 
2049  if (!IsDirectory(Dcb)) {
2050  return STATUS_NOT_A_DIRECTORY;
2051  }
2052 
2053  if (OldParent == NewParent) {
2054  return STATUS_SUCCESS;
2055  }
2056 
2057  MainResourceAcquired =
2058  ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
2059 
2060  _SEH2_TRY {
2061 
2062  Ext2ReferXcb(&Dcb->ReferenceCount);
2063 
2064  pSelf = (PEXT2_DIR_ENTRY2)
2066  PagedPool,
2069  );
2070  if (!pSelf) {
2071  DEBUG(DL_ERR, ( "Ex2SetParentEntry: failed to allocate pSelf.\n"));
2073  _SEH2_LEAVE;
2074  }
2075 
2076  dwBytes = 0;
2077 
2078  //
2079  // Reading the DCB contents
2080  //
2081 
2083  IrpContext,
2084  Vcb,
2085  Dcb->Mcb,
2086  (ULONGLONG)Offset,
2087  (PVOID)pSelf,
2089  FALSE,
2090  &dwBytes );
2091 
2092  if (!NT_SUCCESS(Status)) {
2093  DEBUG(DL_ERR, ( "Ext2SetParentEntry: failed to read directory.\n"));
2094  _SEH2_LEAVE;
2095  }
2096 
2097  ASSERT(dwBytes == EXT2_DIR_REC_LEN(1) + EXT2_DIR_REC_LEN(2));
2098 
2099  pParent = (PEXT2_DIR_ENTRY2)((PUCHAR)pSelf + pSelf->rec_len);
2100 
2101  if (pSelf->name_len == 1 && pSelf->name[0] == '.' &&
2102  pParent->name_len == 2 && pParent->name[0] == '.' &&
2103  pParent->name[1] == '.') {
2104 
2105  if (pParent->inode != OldParent) {
2106  DbgBreak();
2107  }
2108  pParent->inode = NewParent;
2109 
2111  IrpContext,
2112  Vcb,
2113  Dcb->Mcb,
2114  (ULONGLONG)Offset,
2115  pSelf,
2116  dwBytes,
2117  FALSE,
2118  &dwBytes );
2119  } else {
2120  DbgBreak();
2121  }
2122 
2123  } _SEH2_FINALLY {
2124 
2125 
2126  if (Ext2DerefXcb(&Dcb->ReferenceCount) == 0) {
2127  DEBUG(DL_ERR, ( "Ext2SetParentEntry: Dcb reference goes to ZERO.\n"));
2128  }
2129 
2130  if (MainResourceAcquired) {
2131  ExReleaseResourceLite(&Dcb->MainResource);
2132  }
2133 
2134  if (pSelf) {
2136  }
2137  } _SEH2_END;
2138 
2139  return Status;
2140 }
BOOLEAN Ext2ReadInode(PEXT2_VOLUME_INFO Volume, ULONG Inode, PEXT2_INODE InodeBuffer)
Definition: ext2.c:909
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: ext3_fs.h:774
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define EXT2_DIR_REC_LEN(name_len)
Definition: ext2_fs.h:536
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
char name[EXT3_NAME_LEN]
Definition: ext3_fs.h:779
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
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:652
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
struct ext3_dir_entry_2 * PEXT2_DIR_ENTRY2
Definition: ext2fs.h:109
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
__le32 inode
Definition: ext3_fs.h:775
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
#define EXT2_DENTRY_MAGIC
Definition: ext2fs.h:295
Status
Definition: gdiplustypes.h:24
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
__u8 name_len
Definition: ext3_fs.h:777
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:968

Referenced by Ext2SetRenameInfo().

◆ Ext2UpdateGroupDirStat()

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

Definition at line 1661 of file generic.c.

1666 {
1667  struct super_block *sb = &Vcb->sb;
1668  PEXT2_GROUP_DESC gd;
1669  struct buffer_head *gb = NULL;
1670  NTSTATUS status;
1671 
1672  ExAcquireResourceExclusiveLite(&Vcb->MetaInode, TRUE);
1673 
1674  /* get group desc */
1675  gd = ext4_get_group_desc(sb, group, &gb);
1676  if (!gd) {
1678  goto errorout;
1679  }
1680 
1681  /* update group_desc and super_block */
1683  Ext2SaveGroup(IrpContext, Vcb, group);
1684  Ext2UpdateVcbStat(IrpContext, Vcb);
1686 
1687 errorout:
1688 
1689  ExReleaseResourceLite(&Vcb->MetaInode);
1690 
1691  if (gb)
1692  fini_bh(&gb);
1693 
1694  return status;
1695 }
VOID Ext2UpdateVcbStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:930
__u32 ext4_used_dirs_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2432
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
void ext4_used_dirs_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2488
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
superblock * sb
Definition: btrfs.c:4137
Definition: fs.h:64
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLuint group
Definition: glext.h:11120
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
BOOLEAN Ext2SaveGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:382
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2909
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Ext2SetReparsePoint().

◆ Ext2UpdateVcbStat()

VOID Ext2UpdateVcbStat ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 930 of file generic.c.

934 {
935  Vcb->SuperBlock->s_free_inodes_count = ext4_count_free_inodes(&Vcb->sb);
937  Ext2SaveSuper(IrpContext, Vcb);
938 }
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:63
unsigned long ext4_count_free_inodes(struct super_block *sb)
Definition: generic.c:2987
ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
Definition: generic.c:2966
#define SUPER_BLOCK
Definition: ext2fs.h:90
#define Vcb
Definition: cdprocs.h:1425
static void ext3_free_blocks_count_set(struct ext3_super_block *es, ext3_fsblk_t blk)
Definition: ext2fs.h:1717

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

◆ Ext2ZeroBuffer()

BOOLEAN Ext2ZeroBuffer ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN LONGLONG  offset,
IN ULONG  size 
)

Definition at line 791 of file generic.c.

796 {
797  struct buffer_head *bh = NULL;
798  BOOLEAN rc = 0;
799 
800  _SEH2_TRY {
801 
802  while (size) {
803 
804  sector_t block;
805  ULONG len = 0, delta = 0;
806 
807  block = (sector_t) (offset >> BLOCK_BITS);
808  delta = (ULONG)offset & (BLOCK_SIZE - 1);
809  len = BLOCK_SIZE - delta;
810  if (size < len)
811  len = size;
812 
813  if (delta == 0 && len >= BLOCK_SIZE) {
814  bh = sb_getblk_zero(&Vcb->sb, block);
815  } else {
816  bh = sb_getblk(&Vcb->sb, block);
817  }
818 
819  if (!bh) {
820  DEBUG(DL_ERR, ("Ext2SaveBuffer: can't load block %I64u\n", block));
821  DbgBreak();
822  _SEH2_LEAVE;
823  }
824 
825  if (!buffer_uptodate(bh)) {
826  int err = bh_submit_read(bh);
827  if (err < 0) {
828  DEBUG(DL_ERR, ("Ext2SaveBuffer: bh_submit_read failed: %d\n", err));
829  _SEH2_LEAVE;
830  }
831  }
832 
833  _SEH2_TRY {
834  if (delta == 0 && len >= BLOCK_SIZE) {
835  /* bh (cache) was already cleaned as zero */
836  } else {
837  RtlZeroMemory(bh->b_data + delta, len);
838  }
839  mark_buffer_dirty(bh);
840  } _SEH2_FINALLY {
841  fini_bh(&bh);
842  } _SEH2_END;
843 
844  offset = offset + len;
845  size = size - len;
846  }
847 
848  rc = TRUE;
849 
850  } _SEH2_FINALLY {
851 
852  if (bh)
853  fini_bh(&bh);
854 
855  } _SEH2_END;
856 
857  return rc;
858 }
static unsigned int block
Definition: xmlmemory.c:118
#define TRUE
Definition: types.h:120
unsigned __int64 sector_t
Definition: types.h:78
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
GLintptr offset
Definition: glext.h:5920
_SEH2_TRY
Definition: create.c:4250
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define BLOCK_SIZE
Definition: dlist.c:220
GLsizeiptr size
Definition: glext.h:5919
static struct buffer_head * sb_getblk_zero(struct super_block *sb, sector_t block)
Definition: module.h:972
#define Vcb
Definition: cdprocs.h:1425
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
char * b_data
Definition: module.h:725
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DbgBreak()
Definition: ext2fs.h:46
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20

Referenced by Ext2ClearInode().

◆ 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 2619 of file generic.c.

2620 {
2624  return 0;
2625  return 1;
2626 }
superblock * sb
Definition: btrfs.c:4137
#define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER
Definition: ext3_fs.h:671
static int ext3_group_sparse(ext3_group_t group)
Definition: generic.c:2601
GLboolean GLuint group
Definition: glext.h:11120
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647

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

◆ 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 2142 of file generic.c.

2146 {
2147  const char * error_msg = NULL;
2148  const int rlen = ext3_rec_len_from_disk(de->rec_len);
2149 
2150  if (rlen < EXT3_DIR_REC_LEN(1))
2151  error_msg = "rec_len is smaller than minimal";
2152  else if (rlen % 4 != 0)
2153  error_msg = "rec_len % 4 != 0";
2154  else if (rlen < EXT3_DIR_REC_LEN(de->name_len))
2155  error_msg = "rec_len is too small for name_len";
2156  else if ((char *) de + rlen > bh->b_data + dir->i_sb->s_blocksize)
2157  error_msg = "directory entry across blocks";
2158  else if (le32_to_cpu(de->inode) >
2159  le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count))
2160  error_msg = "inode out of bounds";
2161 
2162  if (error_msg != NULL) {
2163  DEBUG(DL_ERR, ("%s: bad entry in directory %u: %s - "
2164  "offset=%u, inode=%u, rec_len=%d, name_len=%d\n",
2165  function, dir->i_ino, error_msg, offset,
2166  (unsigned long) le32_to_cpu(de->inode),
2167  rlen, de->name_len));
2168  }
2169  return error_msg == NULL ? 1 : 0;
2170 }
#define EXT3_DIR_REC_LEN(len)
Definition: ext3_fs.h:867
static const WCHAR * error_msg[8]
Definition: odbccp32.c:62
GLintptr offset
Definition: glext.h:5920
#define le32_to_cpu
Definition: module.h:147
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
__le32 inode
Definition: ext3_fs.h:775
char * b_data
Definition: module.h:725
#define DL_ERR
Definition: ext2fs.h:1397
__u8 name_len
Definition: ext3_fs.h:777
static unsigned ext3_rec_len_from_disk(__le16 dlen)
Definition: ext3_fs.h:871
__le16 rec_len
Definition: ext3_fs.h:776
#define DEBUG(args)
Definition: rdesktop.h:129
#define EXT3_SB(sb)
Definition: ext3_fs.h:615

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

◆ ext3_group_sparse()

static int ext3_group_sparse ( ext3_group_t  group)
static

Definition at line 2601 of file generic.c.

2602 {
2603  if (group <= 1)
2604  return 1;
2605  if (!(group & 1))
2606  return 0;
2607  return (test_root(group, 7) || test_root(group, 5) ||
2608  test_root(group, 3));
2609 }
static int test_root(ext3_group_t a, ext3_group_t b)
Definition: generic.c:2592
GLboolean GLuint group
Definition: glext.h:11120

Referenced by ext3_bg_has_super().

◆ ext3_inode_blocks()

blkcnt_t ext3_inode_blocks ( struct ext3_inode raw_inode,
struct inode inode 
)

Definition at line 2328 of file generic.c.

2330 {
2331  blkcnt_t i_blocks ;
2332  struct super_block *sb = inode->i_sb;
2333  PEXT2_VCB Vcb = (PEXT2_VCB)sb->s_priv;
2334 
2337  /* we are using combined 48 bit field */
2338  i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 |
2339  le32_to_cpu(raw_inode->i_blocks);
2340  if (inode->i_flags & EXT4_HUGE_FILE_FL) {
2341  /* i_blocks represent file system block size */
2342  return i_blocks << (BLOCK_BITS - 9);
2343  } else {
2344  return i_blocks;
2345  }
2346  } else {
2347  return le32_to_cpu(raw_inode->i_blocks);
2348  }
2349 }
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE
Definition: ext3_fs.h:699
superblock * sb
Definition: btrfs.c:4137
Definition: fs.h:64
#define le16_to_cpu
Definition: module.h:149
Definition: fs.h:78
unsigned __int64 blkcnt_t
Definition: types.h:79
#define le32_to_cpu
Definition: module.h:147
#define BLOCK_BITS
Definition: stream.h:22
__u32 i_flags
Definition: fs.h:94
#define EXT4_HUGE_FILE_FL
Definition: ext3_fs.h:262
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
ULONG64 u64
Definition: btrfs.h:15
struct super_block * i_sb
Definition: fs.h:96
struct _EXT2_VCB * PEXT2_VCB
__le32 i_blocks
Definition: ext3_fs.h:355

Referenced by Ext2DecodeInode().

◆ ext3_inode_blocks_set()

int ext3_inode_blocks_set ( struct ext3_inode raw_inode,
struct inode inode 
)

Definition at line 2351 of file generic.c.

2353 {
2354  u64 i_blocks = inode->i_blocks;
2355  struct super_block *sb = inode->i_sb;
2356  PEXT2_VCB Vcb = (PEXT2_VCB)sb->s_priv;
2357 
2358  if (i_blocks < 0x100000000) {
2359  /*
2360  * i_blocks can be represnted in a 32 bit variable
2361  * as multiple of 512 bytes
2362  */
2363  raw_inode->i_blocks = cpu_to_le32(i_blocks);
2364  raw_inode->i_blocks_high = 0;
2366  return 0;
2367  }
2368 
2372  }
2373 
2374  if (i_blocks <= 0xffffffffffff) {
2375  /*
2376  * i_blocks can be represented in a 48 bit variable
2377  * as multiple of 512 bytes
2378  */
2379  raw_inode->i_blocks = (__u32)cpu_to_le32(i_blocks);
2380  raw_inode->i_blocks_high = (__u16)cpu_to_le16(i_blocks >> 32);
2382  } else {
2384  /* i_block is stored in file system block size */
2385  i_blocks = i_blocks >> (BLOCK_BITS - 9);
2386  raw_inode->i_blocks = (__u32)cpu_to_le32(i_blocks);
2387  raw_inode->i_blocks_high = (__u16)cpu_to_le16(i_blocks >> 32);
2388  }
2389  return 0;
2390 }
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE
Definition: ext3_fs.h:699
superblock * sb
Definition: btrfs.c:4137
Definition: fs.h:64
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:63
Definition: fs.h:78
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define EXT3_SET_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:653
__u64 i_blocks
Definition: fs.h:85
__u32 i_flags
Definition: fs.h:94
#define EXT4_HUGE_FILE_FL
Definition: ext3_fs.h:262
unsigned short __u16
Definition: compat.h:89
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
unsigned int __u32
Definition: compat.h:90
ULONG64 u64
Definition: btrfs.h:15
struct super_block * i_sb
Definition: fs.h:96
struct _EXT2_VCB * PEXT2_VCB
#define cpu_to_le16
Definition: module.h:148
#define cpu_to_le32
Definition: module.h:146
__le32 i_blocks
Definition: ext3_fs.h:355

Referenced by Ext2EncodeInode().

◆ ext3_max_bitmap_size()

loff_t ext3_max_bitmap_size ( int  bits,
int  has_huge_files 
)

Definition at line 2270 of file generic.c.

2271 {
2273  int meta_blocks;
2275  /* This is calculated to be the largest file size for a
2276  * dense, bitmapped file such that the total number of
2277  * sectors in the file, including data and all indirect blocks,
2278  * does not exceed 2^48 -1
2279  * __u32 i_blocks_lo and _u16 i_blocks_high representing the
2280  * total number of 512 bytes blocks of the file
2281  */
2282 
2283  if (!has_huge_files) {
2284  /*
2285  * !has_huge_files or CONFIG_LBD is not enabled
2286  * implies the inode i_block represent total blocks in
2287  * 512 bytes 32 == size of vfs inode i_blocks * 8
2288  */
2289  upper_limit = ((loff_t)1 << 32) - 1;
2290 
2291  /* total blocks in file system block size */
2292  upper_limit >>= (bits - 9);
2293 
2294  } else {
2295  /*
2296  * We use 48 bit ext4_inode i_blocks
2297  * With EXT4_HUGE_FILE_FL set the i_blocks
2298  * represent total number of blocks in
2299  * file system block size
2300  */
2301  upper_limit = ((loff_t)1 << 48) - 1;
2302 
2303  }
2304 
2305  /* indirect blocks */
2306  meta_blocks = 1;
2307  /* double indirect blocks */
2308  meta_blocks += 1 + ((loff_t)1 << (bits-2));
2309  /* tripple indirect blocks */
2310  meta_blocks += 1 + ((loff_t)1 << (bits-2)) + ((loff_t)1 << (2*(bits-2)));
2311 
2312  upper_limit -= meta_blocks;
2313  upper_limit <<= bits;
2314 
2315  res += (loff_t)1 << (bits-2);
2316  res += (loff_t)1 << (2*(bits-2));
2317  res += (loff_t)1 << (3*(bits-2));
2318  res <<= bits;
2319  if (res > upper_limit)
2320  res = upper_limit;
2321 
2322  if (res > MAX_LFS_FILESIZE)
2324 
2325  return res;
2326 }
#define MAX_LFS_FILESIZE
Definition: generic.c:2183
#define EXT3_NDIR_BLOCKS
Definition: ext3_fs.h:197
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
unsigned __int64 loff_t
Definition: types.h:80
DWORD upper_limit
Definition: apphelp.c:210
GLuint res
Definition: glext.h:9613

Referenced by Ext2InitializeVcb().

◆ ext3_max_size()

loff_t ext3_max_size ( int  blkbits,
int  has_huge_files 
)

Definition at line 2234 of file generic.c.

2235 {
2236  loff_t res;
2238 
2239  /* small i_blocks in vfs inode? */
2240  if (!has_huge_files) {
2241  /*
2242  * CONFIG_LBD is not enabled implies the inode
2243  * i_block represent total blocks in 512 bytes
2244  * 32 == size of vfs inode i_blocks * 8
2245  */
2246  upper_limit = ((loff_t)1 << 32) - 1;
2247 
2248  /* total blocks in file system block size */
2249  upper_limit >>= (blkbits - 9);
2250  upper_limit <<= blkbits;
2251  }
2252 
2253  /* 32-bit extent-start container, ee_block */
2254  res = (loff_t)1 << 32;
2255  res <<= blkbits;
2256  res -= 1;
2257 
2258  /* Sanity check against vm- & vfs- imposed limits */
2259  if (res > upper_limit)
2260  res = upper_limit;
2261 
2262  return res;
2263 }
#define MAX_LFS_FILESIZE
Definition: generic.c:2183
unsigned __int64 loff_t
Definition: types.h:80
DWORD upper_limit
Definition: apphelp.c:210
GLuint res
Definition: glext.h:9613

Referenced by Ext2InitializeVcb().

◆ ext3_next_entry()

struct ext3_dir_entry_2* ext3_next_entry ( struct ext3_dir_entry_2 p)

Definition at line 2177 of file generic.c.

2178 {
2179  return (struct ext3_dir_entry_2 *)((char *)p +
2180  ext3_rec_len_from_disk(p->rec_len));
2181 }
Definition: ext3_fs.h:774
static unsigned ext3_rec_len_from_disk(__le16 dlen)
Definition: ext3_fs.h:871
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ext3_delete_entry(), 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 2655 of file generic.c.

2656 {
2657  unsigned long first_meta_bg =
2658  le32_to_cpu(EXT3_SB(sb)->s_es->s_first_meta_bg);
2659  unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
2660 
2662  metagroup < first_meta_bg)
2663  return ext4_bg_num_gdb_nometa(sb, group);
2664 
2665  return ext4_bg_num_gdb_meta(sb,group);
2666 
2667 }
superblock * sb
Definition: btrfs.c:4137
#define EXT4_FEATURE_INCOMPAT_META_BG
Definition: ext3_fs.h:708
#define le32_to_cpu
Definition: module.h:147
GLboolean GLuint group
Definition: glext.h:11120
static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2628
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2640
#define EXT3_SB(sb)
Definition: ext3_fs.h:615

Referenced by ext4_init_block_bitmap().

◆ ext4_bg_num_gdb_meta()

static unsigned long ext4_bg_num_gdb_meta ( struct super_block sb,
ext4_group_t  group 
)
static

Definition at line 2628 of file generic.c.

2630 {
2631  unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
2632  ext4_group_t first = metagroup * EXT4_DESC_PER_BLOCK(sb);
2633  ext4_group_t last = first + EXT4_DESC_PER_BLOCK(sb) - 1;
2634 
2635  if (group == first || group == first + 1 || group == last)
2636  return 1;
2637  return 0;
2638 }
POINT last
Definition: font.c:46
superblock * sb
Definition: btrfs.c:4137
const GLint * first
Definition: glext.h:5794
GLboolean GLuint group
Definition: glext.h:11120
unsigned int ext4_group_t
Definition: ext3_fs_i.h:35

Referenced by ext4_bg_num_gdb().

◆ ext4_bg_num_gdb_nometa()

static unsigned long ext4_bg_num_gdb_nometa ( struct super_block sb,
ext4_group_t  group 
)
static

Definition at line 2640 of file generic.c.

2642 {
2643  return ext3_bg_has_super(sb, group) ? EXT3_SB(sb)->s_gdb_count : 0;
2644 }
superblock * sb
Definition: btrfs.c:4137
GLboolean GLuint group
Definition: glext.h:11120
int ext3_bg_has_super(struct super_block *sb, ext3_group_t group)
Definition: generic.c:2619
#define EXT3_SB(sb)
Definition: ext3_fs.h:615

Referenced by ext4_bg_num_gdb().

◆ ext4_block_bitmap()

ext4_fsblk_t ext4_block_bitmap ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2392 of file generic.c.

2394 {
2395  return le32_to_cpu(bg->bg_block_bitmap) |
2397  (ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0);
2398 }