ReactOS 0.4.15-dev-5853-gcb454ef
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 SIZE_256K   0x40000
 
#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 2680 of file generic.c.

◆ MAX_LFS_FILESIZE

#define MAX_LFS_FILESIZE   0x7fffffffffffffff

Definition at line 2176 of file generic.c.

◆ SIZE_256K

#define SIZE_256K   0x40000

Definition at line 861 of file generic.c.

Function Documentation

◆ crc16()

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

Definition at line 2538 of file generic.c.

2539{
2540 while (len--)
2541 crc = crc16_byte(crc, *buffer++);
2542 return crc;
2543}
static __u16 crc16_byte(__u16 crc, const __u8 data)
Definition: generic.c:2533
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722

Referenced by ext4_group_desc_csum().

◆ crc16_byte()

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

Definition at line 2533 of file generic.c.

2534{
2535 return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
2536}
__u16 const crc16_table[256]
Definition: generic.c:2498
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 2662 of file generic.c.

2664{
2665 struct ext3_sb_info *sbi = EXT3_SB(sb);
2666 ext3_group_t bg, first_meta_bg;
2667 int has_super = 0;
2668
2669 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
2670
2672 nr < first_meta_bg)
2673 return logical_sb_block + nr + 1;
2674 bg = sbi->s_desc_per_block * nr;
2675 if (ext3_bg_has_super(sb, bg))
2676 has_super = 1;
2677 return (has_super + ext3_group_first_block_no(sb, bg));
2678}
superblock * sb
Definition: btrfs.c:4261
#define EXT3_SB(sb)
Definition: ext3_fs.h:615
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
#define EXT4_FEATURE_INCOMPAT_META_BG
Definition: ext3_fs.h:708
unsigned int ext3_group_t
Definition: ext3_fs_i.h:34
int ext3_bg_has_super(struct super_block *sb, ext3_group_t group)
Definition: generic.c:2612
#define le32_to_cpu
Definition: module.h:147
ULONG nr
Definition: thread.c:7
struct ext3_super_block * s_es
Definition: ext3_fs_sb.h:61
unsigned long s_desc_per_block
Definition: ext3_fs_sb.h:39

Referenced by Ext2LoadGroup().

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

1813{
1814 struct dentry *de = NULL;
1815
1817 OEM_STRING oem;
1818 int rc;
1819
1820 BOOLEAN MainResourceAcquired = FALSE;
1821
1822 if (!IsDirectory(Dcb)) {
1823 DbgBreak();
1825 }
1826
1827 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1828 MainResourceAcquired = TRUE;
1829
1830 _SEH2_TRY {
1831
1832 Ext2ReferXcb(&Dcb->ReferenceCount);
1833 de = Ext2BuildEntry(Vcb, Dcb->Mcb, FileName);
1834 if (!de) {
1837 }
1838 de->d_inode = Inode;
1839
1840 rc = ext3_add_entry(IrpContext, de, Inode);
1841 status = Ext2WinntError(rc);
1842 if (NT_SUCCESS(status)) {
1843
1844 /* increase dir inode's nlink for .. */
1845 if (S_ISDIR(Inode->i_mode)) {
1846 ext3_inc_count(Dcb->Inode);
1847 ext3_mark_inode_dirty(IrpContext, Dcb->Inode);
1848 }
1849
1850 /* increase inode nlink reference */
1851 ext3_inc_count(Inode);
1852 ext3_mark_inode_dirty(IrpContext, Inode);
1853
1854 if (Dentry) {
1855 *Dentry = de;
1856 de = NULL;
1857 }
1858 }
1859
1860 } _SEH2_FINALLY {
1861
1862 Ext2DerefXcb(&Dcb->ReferenceCount);
1863
1864 if (MainResourceAcquired) {
1865 ExReleaseResourceLite(&Dcb->MainResource);
1866 }
1867
1868 if (de)
1869 Ext2FreeEntry(de);
1870 } _SEH2_END;
1871
1872 return status;
1873}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define S_ISDIR(mode)
Definition: various.h:18
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4140
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
NTSTATUS Ext2WinntError(int rc)
Definition: misc.c:410
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
#define IsDirectory(Fcb)
Definition: ext2fs.h:278
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
struct dentry * Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName)
Definition: memory.c:444
int ext3_add_entry(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode)
Definition: htree.c:1946
#define DbgBreak()
Definition: ext2fs.h:46
VOID Ext2FreeEntry(IN struct dentry *de)
Definition: memory.c:432
void ext3_inc_count(struct inode *inode)
Definition: htree.c:307
#define Ext2DerefXcb(_C)
Definition: ext2fs.h:968
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_LEAVE
Definition: filesup.c:20
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define Vcb
Definition: cdprocs.h:1415
Definition: fs.h:117
struct inode * d_inode
Definition: fs.h:123
Definition: ps.c:97
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
STRING OEM_STRING
Definition: umtypes.h:203

◆ 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
542errorout:
543
544 return rc;
545}
#define DEBUG(args)
Definition: rdesktop.h:129
#define DL_ERR
Definition: ext2fs.h:1397
BOOLEAN Ext2ZeroBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size)
Definition: generic.c:791
BOOLEAN Ext2GetInodeLba(IN PEXT2_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: generic.c:414
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
int64_t LONGLONG
Definition: typedefs.h:68

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}
#define S_ISREG(mode)
Definition: various.h:17
u32 __u32
Definition: btrfs.h:19
unsigned __int64 loff_t
Definition: types.h:80
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE
Definition: ext3_fs.h:702
#define EXT3_HAS_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:647
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
blkcnt_t ext3_inode_blocks(struct ext3_inode *raw_inode, struct inode *inode)
Definition: generic.c:2321
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

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
277
278 while (!IsListEmpty(&Vcb->bd.bd_bh_free)) {
279 struct buffer_head *bh;
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);
287 }
288 }
289
290 } _SEH2_FINALLY {
291 ExReleaseResourceLite(&Vcb->bd.bd_bh_lock);
292 } _SEH2_END;
293
295}
#define atomic_read(v)
Definition: atomic.h:23
r l[0]
Definition: byte_order.h:167
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define VCB_INITIALIZED
Definition: ext2fs.h:779
#define VCB_BEING_DROPPED
Definition: ext2fs.h:789
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
VOID Ext2DropGroupBH(IN PEXT2_VCB Vcb)
Definition: generic.c:128
void free_buffer_head(struct buffer_head *bh)
Definition: linux.c:346
void buffer_head_remove(struct block_device *bdev, struct buffer_head *bh)
Definition: linux.c:424
Definition: typedefs.h:120
LIST_ENTRY b_link
Definition: module.h:714
atomic_t b_count
Definition: module.h:730
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

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}
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
static void fini_bh(struct buffer_head **bh)
Definition: module.h:951
struct ext3_gd * s_gd
Definition: ext3_fs_sb.h:35

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}
u16 __u16
Definition: btrfs.h:18
#define __u32
Definition: types.h:15
int ext3_inode_blocks_set(struct ext3_inode *raw_inode, struct inode *inode)
Definition: generic.c:2344
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44

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
GLdouble s
Definition: gl.h:2039
#define e
Definition: ke_i.h:82
uint32_t ULONG
Definition: typedefs.h:59

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 */
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
376errorout:
377 return STATUS_SUCCESS;
378}
#define BLOCK_BITS
Definition: stream.h:22
struct rb_node * rb_first(struct rb_root *)
Definition: rbtree.c:294
struct rb_node * rb_next(struct rb_node *)
Definition: rbtree.c:320
#define VCB_GD_LOADED
Definition: ext2fs.h:787
VOID Ext2FlushRange(IN PEXT2_VCB Vcb, LARGE_INTEGER s, LARGE_INTEGER e)
Definition: generic.c:299
VOID Ext2DropBH(IN PEXT2_VCB Vcb)
Definition: generic.c:262
#define container_of(ptr, type, member)
Definition: glue.h:15
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
#define STATUS_SUCCESS
Definition: shellext.h:65
struct rb_node b_rb_node
Definition: module.h:731
size_t b_size
Definition: module.h:724
blkcnt_t b_blocknr
Definition: module.h:723
Definition: rbtree.h:98
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 1143 of file generic.c.

1149{
1150 struct super_block *sb = &Vcb->sb;
1152 struct buffer_head *gb = NULL;
1153 ext4_fsblk_t bitmap_blk;
1154
1155 RTL_BITMAP BlockBitmap;
1157
1158 PBCB BitmapBcb;
1159 PVOID BitmapCache;
1160
1161 ULONG Group;
1162 ULONG Index;
1163 ULONG Length;
1164 ULONG Count;
1165
1167
1169
1170 DEBUG(DL_INF, ("Ext2FreeBlock: Block %xh - %x to be freed.\n",
1171 Block, Block + Number));
1172
1175
1176Again:
1177
1178 if (gb)
1179 fini_bh(&gb);
1180
1181 if ( Block < EXT2_FIRST_DATA_BLOCK ||
1182 Block >= TOTAL_BLOCKS ||
1183 Group >= Vcb->sbi.s_groups_count) {
1184
1185 DbgBreak();
1187
1188 } else {
1189
1190 gd = ext4_get_group_desc(sb, Group, &gb);
1191 if (!gd) {
1192 DbgBreak();
1194 goto errorout;
1195 }
1196 bitmap_blk = ext4_block_bitmap(sb, gd);
1197
1198 /* check the block is valid or not */
1199 if (bitmap_blk >= TOTAL_BLOCKS) {
1200 DbgBreak();
1202 goto errorout;
1203 }
1204
1205 /* get bitmap block offset and length */
1206 Offset.QuadPart = bitmap_blk;
1207 Offset.QuadPart = Offset.QuadPart << BLOCK_BITS;
1208
1209 if (Group == Vcb->sbi.s_groups_count - 1) {
1210
1212
1213 /* s_blocks_count is integer multiple of s_blocks_per_group */
1214 if (Length == 0) {
1216 }
1217
1218 } else {
1220 }
1221
1222 /* read and initialize bitmap */
1223 if (!CcPinRead( Vcb->Volume,
1224 &Offset,
1225 Vcb->BlockSize,
1226 PIN_WAIT,
1227 &BitmapBcb,
1228 &BitmapCache ) ) {
1229
1230 DEBUG(DL_ERR, ("Ext2FreeBlock: failed to PinLock bitmap block %xh.\n",
1231 bitmap_blk));
1233 DbgBreak();
1234 goto errorout;
1235 }
1236
1237 /* clear usused bits */
1238 RtlInitializeBitMap(&BlockBitmap, BitmapCache, Length);
1239 Count = min(Length - Index, Number);
1240 RtlClearBits(&BlockBitmap, Index, Count);
1241
1242 /* update group description table */
1243 ext4_free_blks_set(sb, gd, RtlNumberOfClearBits(&BlockBitmap));
1244
1245 /* indict the cache range is dirty */
1246 CcSetDirtyPinnedData(BitmapBcb, NULL );
1247 Ext2AddVcbExtent(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1248 CcUnpinData(BitmapBcb);
1249 BitmapBcb = NULL;
1250 BitmapCache = NULL;
1251 Ext2SaveGroup(IrpContext, Vcb, Group);
1252
1253 /* remove dirty MCB to prevent Volume's lazy writing. */
1254 if (Ext2RemoveBlockExtent(Vcb, NULL, Block, Count)) {
1255 } else {
1256 DbgBreak();
1258 }
1259
1260 /* save super block (used/unused blocks statics) */
1261 Ext2UpdateVcbStat(IrpContext, Vcb);
1262
1263 /* try next group to clear all remaining */
1264 Number -= Count;
1265 if (Number) {
1266 Group += 1;
1267 if (Group < Vcb->sbi.s_groups_count) {
1268 Index = 0;
1269 Block += Count;
1270 goto Again;
1271 } else {
1272 DEBUG(DL_ERR, ("Ext2FreeBlock: block number beyonds max group.\n"));
1273 goto errorout;
1274 }
1275 }
1276 }
1277
1279
1280errorout:
1281
1282 if (gb)
1283 fini_bh(&gb);
1284
1285 ExReleaseResourceLite(&Vcb->MetaBlock);
1286
1287 return Status;
1288}
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
#define EXT2_FIRST_DATA_BLOCK
Definition: ext2fs.h:103
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
#define DL_INF
Definition: ext2fs.h:1399
BOOLEAN Ext2RemoveBlockExtent(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Start, IN ULONG Number)
Definition: memory.c:1097
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100
BOOLEAN Ext2AddVcbExtent(IN PEXT2_VCB Vcb, IN LONGLONG Vbn, IN LONGLONG Length)
Definition: memory.c:648
Status
Definition: gdiplustypes.h:25
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2385
struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh)
Definition: generic.c:2902
void ext4_free_blks_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2465
VOID Ext2UpdateVcbStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:923
BOOLEAN Ext2SaveGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:382
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
NTSYSAPI ULONG WINAPI RtlNumberOfClearBits(PCRTL_BITMAP)
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define min(a, b)
Definition: monoChain.cc:55
_In_opt_ PSID Group
Definition: rtlfuncs.h:1646
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define PIN_WAIT
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
Definition: fs.h:64
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
_In_ WDFCOLLECTION _In_ ULONG Index

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

1698{
1699 struct super_block *sb = &Vcb->sb;
1701 struct buffer_head *gb = NULL;
1702 struct buffer_head *bh = NULL;
1703 ext4_fsblk_t bitmap_blk;
1704
1705 RTL_BITMAP InodeBitmap;
1706 ULONG Group;
1707 ULONG Length;
1709
1710 ULONG dwIno;
1711 BOOLEAN bModified = FALSE;
1712
1714
1716
1717 Group = (Inode - 1) / INODES_PER_GROUP;
1718 dwIno = (Inode - 1) % INODES_PER_GROUP;
1719
1720 DEBUG(DL_INF, ( "Ext2FreeInode: Inode: %xh (Group/Off = %xh/%xh)\n",
1721 Inode, Group, dwIno));
1722
1723 if (Group >= Vcb->sbi.s_groups_count) {
1724 DbgBreak();
1725 goto errorout;
1726 }
1727
1728 gd = ext4_get_group_desc(sb, Group, &gb);
1729 if (!gd) {
1730 DbgBreak();
1732 goto errorout;
1733 }
1734
1735 bitmap_blk = ext4_inode_bitmap(sb, gd);
1736 bh = sb_getblk(sb, bitmap_blk);
1737 if (!bh) {
1738 DbgBreak();
1740 goto errorout;
1741 }
1742 if (!buffer_uptodate(bh)) {
1743 int err = bh_submit_read(bh);
1744 if (err < 0) {
1745 DbgPrint("bh_submit_read error! err: %d\n", err);
1747 goto errorout;
1748 }
1749 }
1750
1751 if (Group == Vcb->sbi.s_groups_count - 1) {
1752
1754 if (!Length) {
1755 /* s_inodes_count is integer multiple of s_inodes_per_group */
1757 }
1758 } else {
1760 }
1761
1762 RtlInitializeBitMap(&InodeBitmap, (PULONG)bh->b_data, Length);
1763
1764 if (RtlCheckBit(&InodeBitmap, dwIno) == 0) {
1765 DbgBreak();
1767 } else {
1768 RtlClearBits(&InodeBitmap, dwIno, 1);
1769 bModified = TRUE;
1770 }
1771
1772 if (bModified) {
1773 /* update group free inodes */
1775 RtlNumberOfClearBits(&InodeBitmap));
1776
1777 /* set inode block dirty and add to vcb dirty range */
1779
1780 /* update group_desc and super_block */
1781 if (Type == EXT2_FT_DIR) {
1783 ext4_used_dirs_count(sb, gd) - 1);
1784 }
1785 Ext2SaveGroup(IrpContext, Vcb, Group);
1786 Ext2UpdateVcbStat(IrpContext, Vcb);
1788 }
1789
1790errorout:
1791
1792 ExReleaseResourceLite(&Vcb->MetaInode);
1793
1794 if (bh)
1795 fini_bh(&bh);
1796
1797 if (gb)
1798 fini_bh(&gb);
1799
1800 return Status;
1801}
Type
Definition: Type.h:7
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define INODES_COUNT
Definition: ext2fs.h:97
void ext4_used_dirs_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2481
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2393
__u32 ext4_used_dirs_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2425
void ext4_free_inodes_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2473
#define DbgPrint
Definition: hal.h:12
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:884
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:966
void mark_buffer_dirty(struct buffer_head *bh)
Definition: linux.c:906
#define err(...)
#define EXT2_FT_DIR
Definition: ext2_fs.h:531
char * b_data
Definition: module.h:725
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3152

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{
421 struct buffer_head *bh = NULL;
422 ext4_fsblk_t loc;
423 int group;
424
425 if (inode < 1 || inode > INODES_COUNT) {
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}
ext4_fsblk_t ext4_inode_table(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2401
GLboolean GLuint group
Definition: glext.h:11120
GLintptr offset
Definition: glext.h:5920
void __brelse(struct buffer_head *)
Definition: linux.c:800
Definition: fs.h:78

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();
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));
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}
Definition: bufpool.h:45
#define BLOCK_SIZE
Definition: dlist.c:220
unsigned __int64 sector_t
Definition: types.h:78
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

◆ 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
743 ULONG len = 0, delta = 0;
744
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();
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));
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}
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned char * PUCHAR
Definition: typedefs.h:53
static unsigned int block
Definition: xmlmemory.c:101

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"));
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));
233 }
234 }
235
236 if (!Ext2LoadGroupBH(Vcb)) {
237 DEBUG(DL_ERR, ("Ext2LoadGroup: Failed to load group descriptions !\n"));
239 }
240
242 DbgBreak();
243 DEBUG(DL_ERR, ("Ext2LoadGroup: group descriptors corrupted !\n"));
245 }
246
247 SetFlag(Vcb->Flags, VCB_GD_LOADED);
248 rc = TRUE;
249
250 } _SEH2_FINALLY {
251
252 if (!rc)
254
255 ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
256 } _SEH2_END;
257
258 return rc;
259}
#define EXT4_MIN_BLOCK_SIZE
Definition: ext3_fs.h:169
#define EXT3_MIN_BLOCK_SIZE
Definition: ext3_fs.h:75
unsigned long long ext3_fsblk_t
Definition: ext3_fs_i.h:26
BOOLEAN Ext2LoadGroupBH(IN PEXT2_VCB Vcb)
Definition: generic.c:166
int ext4_check_descriptors(struct super_block *sb)
Definition: generic.c:3017
VOID Ext2PutGroup(IN PEXT2_VCB Vcb)
Definition: generic.c:146
ext3_fsblk_t descriptor_loc(struct super_block *sb, ext3_fsblk_t logical_sb_block, unsigned int nr)
Definition: generic.c:2662
#define GFP_KERNEL
Definition: module.h:658
void * kzalloc(int size, int flags)
Definition: linux.c:34
unsigned long s_gdb_count
Definition: ext3_fs_sb.h:38

Referenced by Ext2InitializeVcb(), and ext4_get_group_desc().

◆ Ext2LoadGroupBH()

BOOLEAN Ext2LoadGroupBH ( IN PEXT2_VCB  Vcb)

Definition at line 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();
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}

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}
void Ext2DecodeInode(struct inode *dst, struct ext3_inode *src)
Definition: generic.c:448
BOOLEAN Ext2LoadBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG offset, IN ULONG size, IN PVOID buf)
Definition: generic.c:729

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}
void Ext2EncodeInode(struct ext3_inode *dst, struct inode *src)
Definition: generic.c:475
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43

Referenced by ext4_fs_get_xattr_ref().

◆ 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)
37 );
38 if (!Ext2Sb) {
40 goto errorout;
41 }
42
44 Vcb,
47 (PVOID) Ext2Sb,
48 bVerify );
49
50 if (!NT_SUCCESS(Status)) {
52 Ext2Sb = NULL;
53 }
54
55errorout:
56
57 *Sb = Ext2Sb;
58 return Status;
59}
struct ext2_sblock * PEXT2_SUPER_BLOCK
Definition: ext2.h:171
#define PagedPool
Definition: env_spec_w32.h:308
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
#define SUPER_BLOCK_SIZE
Definition: ext2fs.h:86
#define EXT2_SB_MAGIC
Definition: ext2fs.h:297
NTSTATUS Ext2ReadDisk(IN PEXT2_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:539
#define SUPER_BLOCK_OFFSET
Definition: ext2fs.h:85
uint64_t ULONGLONG
Definition: typedefs.h:67
static BOOL bVerify
Definition: verify.c:27

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

942{
943 struct super_block *sb = &Vcb->sb;
945 struct buffer_head *gb = NULL;
946 struct buffer_head *bh = NULL;
947 ext4_fsblk_t bitmap_blk;
948
949 RTL_BITMAP BlockBitmap;
950
951 ULONG Group = 0;
952 ULONG Index = 0xFFFFFFFF;
953 ULONG dwHint = 0;
954 ULONG Count = 0;
955 ULONG Length = 0;
956
958
959 *Block = 0;
960
962
963 /* validate the hint group and hint block */
964 if (GroupHint >= Vcb->sbi.s_groups_count) {
965 DbgBreak();
966 GroupHint = Vcb->sbi.s_groups_count - 1;
967 }
968
969 if (BlockHint != 0) {
970 GroupHint = (BlockHint - EXT2_FIRST_DATA_BLOCK) / BLOCKS_PER_GROUP;
971 dwHint = (BlockHint - EXT2_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
972 }
973
974 Group = GroupHint;
975
976Again:
977
978 if (bh)
979 fini_bh(&bh);
980
981 if (gb)
982 fini_bh(&gb);
983
984 gd = ext4_get_group_desc(sb, Group, &gb);
985 if (!gd) {
986 DbgBreak();
988 goto errorout;
989 }
990
991 bitmap_blk = ext4_block_bitmap(sb, gd);
992
993 if (gd->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
994 bh = sb_getblk_zero(sb, bitmap_blk);
995 if (!bh) {
996 DbgBreak();
998 goto errorout;
999 }
1000 gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1002 set_buffer_uptodate(bh);
1003 gd->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
1004 Ext2SaveGroup(IrpContext, Vcb, Group);
1005 } else {
1006 bh = sb_getblk(sb, bitmap_blk);
1007 if (!bh) {
1008 DbgBreak();
1010 goto errorout;
1011 }
1012 }
1013
1014 if (!buffer_uptodate(bh)) {
1015 int err = bh_submit_read(bh);
1016 if (err < 0) {
1017 DbgPrint("bh_submit_read error! err: %d\n", err);
1019 goto errorout;
1020 }
1021 }
1022
1023 if (ext4_free_blks_count(sb, gd)) {
1024
1025 if (Group == Vcb->sbi.s_groups_count - 1) {
1026
1028
1029 /* s_blocks_count is integer multiple of s_blocks_per_group */
1030 if (Length == 0) {
1032 }
1033 } else {
1035 }
1036
1037 /* initialize bitmap buffer */
1038 RtlInitializeBitMap(&BlockBitmap, (PULONG)bh->b_data, Length);
1039
1040 /* try to find a clear bit range */
1041 Index = RtlFindClearBits(&BlockBitmap, *Number, dwHint);
1042
1043 /* We could not get new block in the prefered group */
1044 if (Index == 0xFFFFFFFF) {
1045
1046 /* search clear bits from the hint block */
1047 Count = RtlFindNextForwardRunClear(&BlockBitmap, dwHint, &Index);
1048 if (dwHint != 0 && Count == 0) {
1049 /* search clear bits from the very beginning */
1050 Count = RtlFindNextForwardRunClear(&BlockBitmap, 0, &Index);
1051 }
1052
1053 if (Count == 0) {
1054
1055 RtlZeroMemory(&BlockBitmap, sizeof(RTL_BITMAP));
1056
1057 /* no blocks found: set bg_free_blocks_count to 0 */
1058 ext4_free_blks_set(sb, gd, 0);
1059 Ext2SaveGroup(IrpContext, Vcb, Group);
1060
1061 /* will try next group */
1062 goto Again;
1063
1064 } else {
1065
1066 /* we got free blocks */
1067 if (Count <= *Number) {
1068 *Number = Count;
1069 }
1070 }
1071 }
1072
1073 } else {
1074
1075 /* try next group */
1076 dwHint = 0;
1077 Group = (Group + 1) % Vcb->sbi.s_groups_count;
1078 if (Group != GroupHint) {
1079 goto Again;
1080 }
1081
1082 Index = 0xFFFFFFFF;
1083 }
1084
1085 if (Index < Length) {
1086
1087 /* mark block bits as allocated */
1088 RtlSetBits(&BlockBitmap, Index, *Number);
1089
1090 /* set block bitmap dirty in cache */
1092
1093 /* update group description */
1094 ext4_free_blks_set(sb, gd, RtlNumberOfClearBits(&BlockBitmap));
1095 Ext2SaveGroup(IrpContext, Vcb, Group);
1096
1097 /* update Vcb free blocks */
1098 Ext2UpdateVcbStat(IrpContext, Vcb);
1099
1100 /* validate the new allocated block number */
1102 if (*Block >= TOTAL_BLOCKS || *Block + *Number > TOTAL_BLOCKS) {
1103 DbgBreak();
1104 dwHint = 0;
1105 goto Again;
1106 }
1107
1108 if (ext4_block_bitmap(sb, gd) == *Block ||
1109 ext4_inode_bitmap(sb, gd) == *Block ||
1110 ext4_inode_table(sb, gd) == *Block ) {
1111 DbgBreak();
1112 dwHint = 0;
1113 goto Again;
1114 }
1115
1116 /* Always remove dirty MCB to prevent Volume's lazy writing.
1117 Metadata blocks will be re-added during modifications.*/
1118 if (Ext2RemoveBlockExtent(Vcb, NULL, *Block, *Number)) {
1119 } else {
1120 DbgBreak();
1122 }
1123
1124 DEBUG(DL_INF, ("Ext2NewBlock: Block %xh - %x allocated.\n",
1125 *Block, *Block + *Number));
1127 }
1128
1129errorout:
1130
1131 ExReleaseResourceLite(&Vcb->MetaBlock);
1132
1133 if (bh)
1134 fini_bh(&bh);
1135
1136 if (gb)
1137 fini_bh(&gb);
1138
1139 return Status;
1140}
#define EXT4_BG_BLOCK_UNINIT
Definition: ext3_fs.h:734
__le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2545
__u32 ext4_free_blks_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2409
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:2803
NTSYSAPI ULONG WINAPI RtlFindClearBits(PCRTL_BITMAP, ULONG, ULONG)
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
NTSYSAPI ULONG WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP, ULONG, PULONG)
static struct buffer_head * sb_getblk_zero(struct super_block *sb, sector_t block)
Definition: module.h:972
#define cpu_to_le16
Definition: module.h:148
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155

Referenced by Ext2ExpandLast(), and ext4_new_meta_blocks().

◆ Ext2NewInode()

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

Definition at line 1292 of file generic.c.

1299{
1300 struct super_block *sb = &Vcb->sb;
1302 struct buffer_head *gb = NULL;
1303 struct buffer_head *bh = NULL;
1304 ext4_fsblk_t bitmap_blk;
1305
1306 RTL_BITMAP InodeBitmap;
1307
1308 ULONG Group, i, j;
1309 ULONG Average, Length;
1310
1311 ULONG dwInode;
1312
1314
1315 *Inode = dwInode = 0XFFFFFFFF;
1316
1318
1319 if (GroupHint >= Vcb->sbi.s_groups_count)
1320 GroupHint = GroupHint % Vcb->sbi.s_groups_count;
1321
1322repeat:
1323
1324 if (bh)
1325 fini_bh(&bh);
1326
1327 if (gb)
1328 fini_bh(&gb);
1329
1330 Group = i = 0;
1331 gd = NULL;
1332
1333 if (Type == EXT2_FT_DIR) {
1334
1335 Average = Vcb->SuperBlock->s_free_inodes_count / Vcb->sbi.s_groups_count;
1336
1337 for (j = 0; j < Vcb->sbi.s_groups_count; j++) {
1338
1339 i = (j + GroupHint) % (Vcb->sbi.s_groups_count);
1340 gd = ext4_get_group_desc(sb, i, &gb);
1341 if (!gd) {
1342 DbgBreak();
1344 goto errorout;
1345 }
1346
1347 if ((gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) ||
1348 (ext4_used_dirs_count(sb, gd) << 8 <
1349 ext4_free_inodes_count(sb, gd)) ) {
1350 Group = i + 1;
1351 break;
1352 }
1353 fini_bh(&gb);
1354 }
1355
1356 if (!Group) {
1357
1359
1360 gd = NULL;
1361
1362 /* get the group with the biggest vacancy */
1363 for (j = 0; j < Vcb->sbi.s_groups_count; j++) {
1364
1365 struct buffer_head *gt = NULL;
1366 desc = ext4_get_group_desc(sb, j, &gt);
1367 if (!desc) {
1368 DbgBreak();
1370 goto errorout;
1371 }
1372
1373 /* return the group if it's not initialized yet */
1374 if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1375 Group = j + 1;
1376 gd = desc;
1377
1378 if (gb)
1379 fini_bh(&gb);
1380 gb = gt;
1381 gt = NULL;
1382 break;
1383 }
1384
1385 if (!gd) {
1386 if (ext4_free_inodes_count(sb, desc) > 0) {
1387 Group = j + 1;
1388 gd = desc;
1389 if (gb)
1390 fini_bh(&gb);
1391 gb = gt;
1392 gt = NULL;
1393 }
1394 } else {
1397 Group = j + 1;
1398 gd = desc;
1399 if (gb)
1400 fini_bh(&gb);
1401 gb = gt;
1402 gt = NULL;
1403 break;
1404 }
1405 }
1406 if (gt)
1407 fini_bh(&gt);
1408 }
1409 }
1410
1411 } else {
1412
1413 /*
1414 * Try to place the inode in its parent directory (GroupHint)
1415 */
1416
1417 gd = ext4_get_group_desc(sb, GroupHint, &gb);
1418 if (!gb) {
1419 DbgBreak();
1421 goto errorout;
1422 }
1423
1424 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1426
1427 Group = GroupHint + 1;
1428
1429 } else {
1430
1431 /* this group is 100% cocucpied */
1432 fini_bh(&gb);
1433
1434 i = GroupHint;
1435
1436 /*
1437 * Use a quadratic hash to find a group with a free inode
1438 */
1439
1440 for (j = 1; j < Vcb->sbi.s_groups_count; j <<= 1) {
1441
1442
1443 i = (i + j) % Vcb->sbi.s_groups_count;
1444 gd = ext4_get_group_desc(sb, i, &gb);
1445 if (!gd) {
1446 DbgBreak();
1448 goto errorout;
1449 }
1450
1451 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1453 Group = i + 1;
1454 break;
1455 }
1456
1457 fini_bh(&gb);
1458 }
1459 }
1460
1461 if (!Group) {
1462 /*
1463 * That failed: try linear search for a free inode
1464 */
1465 i = GroupHint;
1466 for (j = 2; j < Vcb->sbi.s_groups_count; j++) {
1467
1468 i = (i + 1) % Vcb->sbi.s_groups_count;
1469 gd = ext4_get_group_desc(sb, i, &gb);
1470 if (!gd) {
1471 DbgBreak();
1473 goto errorout;
1474 }
1475
1476 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||
1478 Group = i + 1;
1479 break;
1480 }
1481
1482 fini_bh(&gb);
1483 }
1484 }
1485 }
1486
1487 if (gd == NULL || Group == 0) {
1488 goto errorout;
1489 }
1490
1491 /* finally we got the group, but is it valid ? */
1492 if (Group > Vcb->sbi.s_groups_count) {
1493 DbgBreak();
1494 goto errorout;
1495 }
1496
1497 /* valid group number starts from 1, not 0 */
1498 Group -= 1;
1499
1500 ASSERT(gd);
1501 bitmap_blk = ext4_inode_bitmap(sb, gd);
1502 /* check the block is valid or not */
1503 if (bitmap_blk == 0 || bitmap_blk >= TOTAL_BLOCKS) {
1504 DbgBreak();
1506 goto errorout;
1507 }
1508
1509 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1510 bh = sb_getblk_zero(sb, bitmap_blk);
1511 if (!bh) {
1512 DbgBreak();
1514 goto errorout;
1515 }
1516 gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1518 set_buffer_uptodate(bh);
1519 gd->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
1520 Ext2SaveGroup(IrpContext, Vcb, Group);
1521 } else {
1522 bh = sb_getblk(sb, bitmap_blk);
1523 if (!bh) {
1524 DbgBreak();
1526 goto errorout;
1527 }
1528 }
1529
1530 if (!buffer_uptodate(bh)) {
1531 int err = bh_submit_read(bh);
1532 if (err < 0) {
1533 DbgPrint("bh_submit_read error! err: %d\n", err);
1535 goto errorout;
1536 }
1537 }
1538
1539 if (Vcb->sbi.s_groups_count == 1) {
1541 } else {
1542 if (Group + 1 == Vcb->sbi.s_groups_count) {
1544 if (!Length) {
1545 /* INODES_COUNT is integer multiple of INODES_PER_GROUP */
1547 }
1548 } else {
1550 }
1551 }
1552
1553 RtlInitializeBitMap(&InodeBitmap, (PULONG)bh->b_data, Length);
1554 dwInode = RtlFindClearBits(&InodeBitmap, 1, 0);
1555
1556 if (dwInode == 0xFFFFFFFF || dwInode >= Length) {
1557
1558 RtlZeroMemory(&InodeBitmap, sizeof(RTL_BITMAP));
1559 if (ext4_free_inodes_count(sb, gd) > 0) {
1560 ext4_free_inodes_set(sb, gd, 0);
1561 Ext2SaveGroup(IrpContext, Vcb, Group);
1562 }
1563 goto repeat;
1564
1565 } else {
1566
1567 __u32 count = 0;
1568
1569 /* update unused inodes count */
1570 count = ext4_free_inodes_count(sb, gd) - 1;
1572
1573 RtlSetBits(&InodeBitmap, dwInode, 1);
1574
1575 /* set block bitmap dirty in cache */
1577
1578 /* If we didn't allocate from within the initialized part of the inode
1579 * table then we need to initialize up to this inode. */
1581
1582 __u32 free;
1583
1584 if (gd->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
1585 gd->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
1586 /* When marking the block group with
1587 * ~EXT4_BG_INODE_UNINIT we don't want to depend
1588 * on the value of bg_itable_unused even though
1589 * mke2fs could have initialized the same for us.
1590 * Instead we calculated the value below
1591 */
1592
1593 free = 0;
1594 } else {
1596 }
1597
1598 /*
1599 * Check the relative inode number against the last used
1600 * relative inode number in this group. if it is greater
1601 * we need to update the bg_itable_unused count
1602 *
1603 */
1604 if (dwInode + 1 > free) {
1606 (EXT3_INODES_PER_GROUP(sb) - 1 - dwInode));
1607 }
1608
1609 /* We may have to initialize the block bitmap if it isn't already */
1610 if (gd->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
1611
1612 struct buffer_head *block_bitmap_bh = NULL;
1613
1614 /* recheck and clear flag under lock if we still need to */
1615 block_bitmap_bh = sb_getblk_zero(sb, ext4_block_bitmap(sb, gd));
1616 if (block_bitmap_bh) {
1617 gd->bg_checksum = ext4_group_desc_csum(EXT3_SB(sb), Group, gd);
1618 free = ext4_init_block_bitmap(sb, block_bitmap_bh, Group, gd);
1619 set_buffer_uptodate(block_bitmap_bh);
1620 brelse(block_bitmap_bh);
1621 gd->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
1623 Ext2SaveGroup(IrpContext, Vcb, Group);
1624 }
1625 }
1626 }
1627
1628 *Inode = dwInode + 1 + Group * INODES_PER_GROUP;
1629
1630 /* update group_desc / super_block */
1631 if (Type == EXT2_FT_DIR) {
1633 }
1634 Ext2SaveGroup(IrpContext, Vcb, Group);
1635 Ext2UpdateVcbStat(IrpContext, Vcb);
1637 }
1638
1639errorout:
1640
1641 ExReleaseResourceLite(&Vcb->MetaInode);
1642
1643 if (bh)
1644 fini_bh(&bh);
1645
1646 if (gb)
1647 fini_bh(&gb);
1648
1649
1650 return Status;
1651}
#define free
Definition: debug_ros.c:5
#define EXT3_INODES_PER_GROUP(s)
Definition: ext3_fs.h:191
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM
Definition: ext3_fs.h:700
#define EXT4_BG_INODE_UNINIT
Definition: ext3_fs.h:733
__u32 ext4_free_inodes_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2417
__u32 ext4_itable_unused_count(struct super_block *sb, struct ext4_group_desc *bg)
Definition: generic.c:2433
void ext4_itable_unused_set(struct super_block *sb, struct ext4_group_desc *bg, __u32 count)
Definition: generic.c:2489
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:2712
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static void brelse(struct buffer_head *bh)
Definition: module.h:945
static const WCHAR desc[]
Definition: protectdata.c:36
static int repeat
Definition: xmllint.c:137

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}
#define kfree(p)
Definition: module.h:1116

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}

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}
LARGE_INTEGER Ext2NtTime(IN ULONG i_time)
Definition: misc.c:40
BOOLEAN Ext2LoadInode(IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:504
static PIO_STATUS_BLOCK iosb
Definition: file.c:98

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

1953{
1954 struct inode *dir = Dcb->Inode;
1955 struct buffer_head *bh = NULL;
1956 struct ext3_dir_entry_2 *de;
1957 struct inode *inode;
1958 int rc = -ENOENT;
1960 BOOLEAN MainResourceAcquired = FALSE;
1961
1962 if (!IsDirectory(Dcb)) {
1964 }
1965
1966 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1967 MainResourceAcquired = TRUE;
1968
1969 _SEH2_TRY {
1970
1971 Ext2ReferXcb(&Dcb->ReferenceCount);
1972
1973 bh = ext3_find_entry(IrpContext, Mcb->de, &de);
1974 if (!bh)
1976
1977 inode = &Mcb->Inode;
1978 if (le32_to_cpu(de->inode) != inode->i_ino)
1980
1981 if (!inode->i_nlink) {
1982 ext3_warning (inode->i_sb, "ext3_unlink",
1983 "Deleting nonexistent file (%lu), %d",
1985 inode->i_nlink = 1;
1986 }
1987 rc = ext3_delete_entry(IrpContext, dir, de, bh);
1988 if (rc) {
1989 Status = Ext2WinntError(rc);
1991 }
1992 /*
1993 if (!inode->i_nlink)
1994 ext3_orphan_add(handle, inode);
1995 */
1996 inode->i_ctime = dir->i_ctime = dir->i_mtime = ext3_current_time(dir);
1998 ext3_mark_inode_dirty(IrpContext, inode);
1999
2000 /* decrease dir inode's nlink for .. */
2001 if (S_ISDIR(inode->i_mode)) {
2004 ext3_mark_inode_dirty(IrpContext, dir);
2005 }
2006
2008
2009 } _SEH2_FINALLY {
2010
2011 Ext2DerefXcb(&Dcb->ReferenceCount);
2012
2013 if (MainResourceAcquired)
2014 ExReleaseResourceLite(&Dcb->MainResource);
2015
2016 if (bh)
2017 brelse(bh);
2018 } _SEH2_END;
2019
2020 return Status;
2021}
#define ENOENT
Definition: acclib.h:79
unsigned int dir
Definition: maze.c:112
__u32 ext3_current_time(struct inode *in)
Definition: htree.c:204
struct buffer_head * ext3_find_entry(struct ext2_icb *icb, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir)
Definition: htree.c:2166
void ext3_warning(struct super_block *sb, const char *function, char *fmt,...)
Definition: htree.c:212
void ext3_dec_count(struct inode *inode)
Definition: htree.c:312
int ext3_delete_entry(struct ext2_icb *icb, struct inode *dir, struct ext3_dir_entry_2 *de_del, struct buffer_head *bh)
Definition: htree.c:2005
void ext3_update_dx_flag(struct inode *inode)
Definition: htree.c:368
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:348
Definition: ext3_fs.h:774
__le32 inode
Definition: ext3_fs.h:775
__u32 i_ino
Definition: fs.h:79
umode_t i_mode
Definition: fs.h:87
struct super_block * i_sb
Definition: fs.h:96
__u16 i_nlink
Definition: fs.h:91
__u32 i_ctime
Definition: fs.h:82

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();
710 }
711
712 if (!buffer_uptodate(bh)) {
713 }
714
717 rc = TRUE;
718
719 } _SEH2_FINALLY {
720
721 if (bh)
722 fini_bh(&bh);
723 } _SEH2_END;
724
725 return rc;
726}

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

869{
870 BOOLEAN rc;
871
872 while (Size) {
873
874 PBCB Bcb;
877
878 Length = (ULONG)Offset & (SIZE_256K - 1);
880 if (Size < Length)
881 Length = Size;
882
883 if ( !CcPreparePinWrite(
884 Vcb->Volume,
886 Length,
887 FALSE,
889 &Bcb,
890 &Buffer )) {
891
892 DEBUG(DL_ERR, ( "Ext2SaveBuffer: failed to PinLock offset %I64xh ...\n", Offset));
893 return FALSE;
894 }
895
896 _SEH2_TRY {
897
900 SetFlag(Vcb->Volume->Flags, FO_FILE_MODIFIED);
901
903 if (!rc) {
904 DbgBreak();
905 Ext2Sleep(100);
907 }
908
909 } _SEH2_FINALLY {
911 } _SEH2_END;
912
913 Buf = (PUCHAR)Buf + Length;
914 Offset = Offset + Length;
915 Size = Size - Length;
916 }
917
918 return rc;
919}
VOID Ext2Sleep(ULONG ms)
Definition: misc.c:297
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:414
#define SIZE_256K
Definition: generic.c:861
#define PIN_EXCLUSIVE
BOOLEAN NTAPI CcPreparePinWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Zero, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:827
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define FO_FILE_MODIFIED
Definition: iotypes.h:1788

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);
398 fini_bh(&gb);
399
400 return TRUE;
401}
__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
581errorout:
582 return rc;
583}
VOID Ext2StartFloppyFlushDpc(PEXT2_VCB Vcb, PEXT2_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:123
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
BOOLEAN Ext2SaveBuffer(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
Definition: generic.c:864

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
649errorout:
650 return rc;
651}
#define EXT2_GOOD_OLD_INODE_SIZE
Definition: ext2.h:54

Referenced by ext4_fs_put_xattr_ref().

◆ Ext2SaveSuper()

BOOLEAN Ext2SaveSuper ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 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}

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

1884{
1885 struct inode *dir = Dcb->Inode;
1886 struct buffer_head *bh = NULL;
1887 struct ext3_dir_entry_2 *de;
1888 struct inode *inode;
1890 BOOLEAN MainResourceAcquired = FALSE;
1891
1893 return STATUS_SUCCESS;
1894 }
1895
1896 if (!IsDirectory(Dcb)) {
1898 }
1899
1900 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1901 MainResourceAcquired = TRUE;
1902
1903 _SEH2_TRY {
1904
1905 Ext2ReferXcb(&Dcb->ReferenceCount);
1906
1907 bh = ext3_find_entry(IrpContext, Mcb->de, &de);
1908 if (!bh)
1910
1911 inode = &Mcb->Inode;
1912 if (le32_to_cpu(de->inode) != inode->i_ino)
1914
1917
1918 if (S_ISDIR(inode->i_mode) == S_ISDIR(mode)) {
1919 } else if (S_ISDIR(inode->i_mode)) {
1921 } else if (S_ISDIR(mode)) {
1923 }
1924 dir->i_ctime = dir->i_mtime = ext3_current_time(dir);
1925 ext3_mark_inode_dirty(IrpContext, dir);
1926
1927 inode->i_mode = mode;
1928 ext3_mark_inode_dirty(IrpContext, inode);
1929
1931
1932 } _SEH2_FINALLY {
1933
1934 Ext2DerefXcb(&Dcb->ReferenceCount);
1935
1936 if (MainResourceAcquired)
1937 ExReleaseResourceLite(&Dcb->MainResource);
1938
1939 if (bh)
1940 brelse(bh);
1941 } _SEH2_END;
1942
1943 return Status;
1944}
void ext3_set_de_type(struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
Definition: htree.c:347
#define EXT3_FEATURE_INCOMPAT_FILETYPE
Definition: ext3_fs.h:679
GLenum mode
Definition: glext.h:6217

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

2030{
2032
2033 PEXT2_DIR_ENTRY2 pSelf = NULL;
2035
2036 ULONG dwBytes = 0;
2037
2038 BOOLEAN MainResourceAcquired = FALSE;
2039
2040 ULONG Offset = 0;
2041
2042 if (!IsDirectory(Dcb)) {
2044 }
2045
2046 if (OldParent == NewParent) {
2047 return STATUS_SUCCESS;
2048 }
2049
2050 MainResourceAcquired =
2051 ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
2052
2053 _SEH2_TRY {
2054
2055 Ext2ReferXcb(&Dcb->ReferenceCount);
2056
2057 pSelf = (PEXT2_DIR_ENTRY2)
2059 PagedPool,
2062 );
2063 if (!pSelf) {
2064 DEBUG(DL_ERR, ( "Ex2SetParentEntry: failed to allocate pSelf.\n"));
2067 }
2068
2069 dwBytes = 0;
2070
2071 //
2072 // Reading the DCB contents
2073 //
2074
2076 IrpContext,
2077 Vcb,
2078 Dcb->Mcb,
2080 (PVOID)pSelf,
2082 FALSE,
2083 &dwBytes );
2084
2085 if (!NT_SUCCESS(Status)) {
2086 DEBUG(DL_ERR, ( "Ext2SetParentEntry: failed to read directory.\n"));
2088 }
2089
2090 ASSERT(dwBytes == EXT2_DIR_REC_LEN(1) + EXT2_DIR_REC_LEN(2));
2091
2092 pParent = (PEXT2_DIR_ENTRY2)((PUCHAR)pSelf + pSelf->rec_len);
2093
2094 if (pSelf->name_len == 1 && pSelf->name[0] == '.' &&
2095 pParent->name_len == 2 && pParent->name[0] == '.' &&
2096 pParent->name[1] == '.') {
2097
2098 if (pParent->inode != OldParent) {
2099 DbgBreak();
2100 }
2101 pParent->inode = NewParent;
2102
2104 IrpContext,
2105 Vcb,
2106 Dcb->Mcb,
2108 pSelf,
2109 dwBytes,
2110 FALSE,
2111 &dwBytes );
2112 } else {
2113 DbgBreak();
2114 }
2115
2116 } _SEH2_FINALLY {
2117
2118
2119 if (Ext2DerefXcb(&Dcb->ReferenceCount) == 0) {
2120 DEBUG(DL_ERR, ( "Ext2SetParentEntry: Dcb reference goes to ZERO.\n"));
2121 }
2122
2123 if (MainResourceAcquired) {
2124 ExReleaseResourceLite(&Dcb->MainResource);
2125 }
2126
2127 if (pSelf) {
2129 }
2130 } _SEH2_END;
2131
2132 return Status;
2133}
BOOLEAN Ext2ReadInode(PEXT2_VOLUME_INFO Volume, ULONG Inode, PEXT2_INODE InodeBuffer)
Definition: ext2.c:907
#define EXT2_DIR_REC_LEN(name_len)
Definition: ext2_fs.h:536
struct ext3_dir_entry_2 * PEXT2_DIR_ENTRY2
Definition: ext2fs.h:109
#define EXT2_DENTRY_MAGIC
Definition: ext2fs.h:295
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
FxObject * pParent
Definition: fxdpcapi.cpp:86

Referenced by Ext2SetRenameInfo().

◆ Ext2UpdateGroupDirStat()

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

Definition at line 1654 of file generic.c.

1659{
1660 struct super_block *sb = &Vcb->sb;
1662 struct buffer_head *gb = NULL;
1664
1666
1667 /* get group desc */
1668 gd = ext4_get_group_desc(sb, group, &gb);
1669 if (!gd) {
1671 goto errorout;
1672 }
1673
1674 /* update group_desc and super_block */
1676 Ext2SaveGroup(IrpContext, Vcb, group);
1677 Ext2UpdateVcbStat(IrpContext, Vcb);
1679
1680errorout:
1681
1682 ExReleaseResourceLite(&Vcb->MetaInode);
1683
1684 if (gb)
1685 fini_bh(&gb);
1686
1687 return status;
1688}

Referenced by Ext2SetReparsePoint().

◆ Ext2UpdateVcbStat()

VOID Ext2UpdateVcbStat ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb 
)

Definition at line 923 of file generic.c.

927{
928 Vcb->SuperBlock->s_free_inodes_count = ext4_count_free_inodes(&Vcb->sb);
930 Ext2SaveSuper(IrpContext, Vcb);
931}
#define SUPER_BLOCK
Definition: ext2fs.h:90
static void ext3_free_blocks_count_set(struct ext3_super_block *es, ext3_fsblk_t blk)
Definition: ext2fs.h:1717
ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
Definition: generic.c:2959
unsigned long ext4_count_free_inodes(struct super_block *sb)
Definition: generic.c:2980
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:63

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
805 ULONG len = 0, delta = 0;
806
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();
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));
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 }
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}

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

2613{
2617 return 0;
2618 return 1;
2619}
#define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER
Definition: ext3_fs.h:671
static int ext3_group_sparse(ext3_group_t group)
Definition: generic.c:2594

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

2139{
2140 const char * error_msg = NULL;
2141 const int rlen = ext3_rec_len_from_disk(de->rec_len);
2142
2143 if (rlen < EXT3_DIR_REC_LEN(1))
2144 error_msg = "rec_len is smaller than minimal";
2145 else if (rlen % 4 != 0)
2146 error_msg = "rec_len % 4 != 0";
2147 else if (rlen < EXT3_DIR_REC_LEN(de->name_len))
2148 error_msg = "rec_len is too small for name_len";
2149 else if ((char *) de + rlen > bh->b_data + dir->i_sb->s_blocksize)
2150 error_msg = "directory entry across blocks";
2151 else if (le32_to_cpu(de->inode) >
2152 le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count))
2153 error_msg = "inode out of bounds";
2154
2155 if (error_msg != NULL) {
2156 DEBUG(DL_ERR, ("%s: bad entry in directory %u: %s - "
2157 "offset=%u, inode=%u, rec_len=%d, name_len=%d\n",
2158 function, dir->i_ino, error_msg, offset,
2159 (unsigned long) le32_to_cpu(de->inode),
2160 rlen, de->name_len));
2161 }
2162 return error_msg == NULL ? 1 : 0;
2163}
#define EXT3_DIR_REC_LEN(len)
Definition: ext3_fs.h:867
static unsigned ext3_rec_len_from_disk(__le16 dlen)
Definition: ext3_fs.h:871
__u8 name_len
Definition: ext3_fs.h:777
__le16 rec_len
Definition: ext3_fs.h:776
static const WCHAR * error_msg[8]
Definition: odbccp32.c:62

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

◆ ext3_group_sparse()

static int ext3_group_sparse ( ext3_group_t  group)
static

Definition at line 2594 of file generic.c.

2595{
2596 if (group <= 1)
2597 return 1;
2598 if (!(group & 1))
2599 return 0;
2600 return (test_root(group, 7) || test_root(group, 5) ||
2601 test_root(group, 3));
2602}
static int test_root(ext3_group_t a, ext3_group_t b)
Definition: generic.c:2585

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

2323{
2324 blkcnt_t i_blocks ;
2325 struct super_block *sb = inode->i_sb;
2326 PEXT2_VCB Vcb = (PEXT2_VCB)sb->s_priv;
2327
2330 /* we are using combined 48 bit field */
2331 i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 |
2332 le32_to_cpu(raw_inode->i_blocks);
2334 /* i_blocks represent file system block size */
2335 return i_blocks << (BLOCK_BITS - 9);
2336 } else {
2337 return i_blocks;
2338 }
2339 } else {
2340 return le32_to_cpu(raw_inode->i_blocks);
2341 }
2342}
unsigned __int64 blkcnt_t
Definition: types.h:79
#define u64
Definition: types.h:10
struct _EXT2_VCB * PEXT2_VCB
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE
Definition: ext3_fs.h:699
#define EXT4_HUGE_FILE_FL
Definition: ext3_fs.h:262
#define le16_to_cpu
Definition: module.h:149
__le32 i_blocks
Definition: ext3_fs.h:355
__u32 i_flags
Definition: fs.h:94

Referenced by Ext2DecodeInode().

◆ ext3_inode_blocks_set()

int ext3_inode_blocks_set ( struct ext3_inode raw_inode,
struct inode inode 
)

Definition at line 2344 of file generic.c.

2346{
2347 u64 i_blocks = inode->i_blocks;
2348 struct super_block *sb = inode->i_sb;
2349 PEXT2_VCB Vcb = (PEXT2_VCB)sb->s_priv;
2350
2351 if (i_blocks < 0x100000000) {
2352 /*
2353 * i_blocks can be represnted in a 32 bit variable
2354 * as multiple of 512 bytes
2355 */
2356 raw_inode->i_blocks = cpu_to_le32(i_blocks);
2357 raw_inode->i_blocks_high = 0;
2358 inode->i_flags &= ~EXT4_HUGE_FILE_FL;
2359 return 0;
2360 }
2361
2365 }
2366
2367 if (i_blocks <= 0xffffffffffff) {
2368 /*
2369 * i_blocks can be represented in a 48 bit variable
2370 * as multiple of 512 bytes
2371 */
2372 raw_inode->i_blocks = (__u32)cpu_to_le32(i_blocks);
2373 raw_inode->i_blocks_high = (__u16)cpu_to_le16(i_blocks >> 32);
2374 inode->i_flags &= ~EXT4_HUGE_FILE_FL;
2375 } else {
2377 /* i_block is stored in file system block size */
2378 i_blocks = i_blocks >> (BLOCK_BITS - 9);
2379 raw_inode->i_blocks = (__u32)cpu_to_le32(i_blocks);
2380 raw_inode->i_blocks_high = (__u16)cpu_to_le16(i_blocks >> 32);
2381 }
2382 return 0;
2383}
ULONG64 u64
Definition: btrfs.h:15
#define __u16
Definition: types.h:13
#define EXT3_SET_RO_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:653
#define cpu_to_le32
Definition: module.h:146
__u64 i_blocks
Definition: fs.h:85

Referenced by Ext2EncodeInode().

◆ ext3_max_bitmap_size()

loff_t ext3_max_bitmap_size ( int  bits,
int  has_huge_files 
)

Definition at line 2263 of file generic.c.

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

Referenced by Ext2InitializeVcb().

◆ ext3_max_size()

loff_t ext3_max_size ( int  blkbits,
int  has_huge_files 
)

Definition at line 2227 of file generic.c.

2228{
2229 loff_t res;
2231
2232 /* small i_blocks in vfs inode? */
2233 if (!has_huge_files) {
2234 /*
2235 * CONFIG_LBD is not enabled implies the inode
2236 * i_block represent total blocks in 512 bytes
2237 * 32 == size of vfs inode i_blocks * 8
2238 */
2239 upper_limit = ((loff_t)1 << 32) - 1;
2240
2241 /* total blocks in file system block size */
2242 upper_limit >>= (blkbits - 9);
2243 upper_limit <<= blkbits;
2244 }
2245
2246 /* 32-bit extent-start container, ee_block */
2247 res = (loff_t)1 << 32;
2248 res <<= blkbits;
2249 res -= 1;
2250
2251 /* Sanity check against vm- & vfs- imposed limits */
2252 if (res > upper_limit)
2253 res = upper_limit;
2254
2255 return res;
2256}

Referenced by Ext2InitializeVcb().

◆ ext3_next_entry()

struct ext3_dir_entry_2 * ext3_next_entry ( struct ext3_dir_entry_2 p)

Definition at line 2170 of file generic.c.

2171{
2172 return (struct ext3_dir_entry_2 *)((char *)p +
2173 ext3_rec_len_from_disk(p->rec_len));
2174}
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 2648 of file generic.c.

2649{
2650 unsigned long first_meta_bg =
2651 le32_to_cpu(EXT3_SB(sb)->s_es->s_first_meta_bg);
2652 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
2653
2655 metagroup < first_meta_bg)
2657
2659
2660}
static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2633
static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2621

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

2623{
2624 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
2625 ext4_group_t first = metagroup * EXT4_DESC_PER_BLOCK(sb);
2626 ext4_group_t last = first + EXT4_DESC_PER_BLOCK(sb) - 1;
2627
2628 if (group == first || group == first + 1 || group == last)
2629 return 1;
2630 return 0;
2631}
unsigned int ext4_group_t
Definition: ext3_fs_i.h:35
const GLint * first
Definition: glext.h:5794
POINT last
Definition: font.c:46

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

2635{
2636 return ext3_bg_has_super(sb, group) ? EXT3_SB(sb)->s_gdb_count : 0;
2637}

Referenced by ext4_bg_num_gdb().

◆ ext4_block_bitmap()

ext4_fsblk_t ext4_block_bitmap ( struct super_block sb,
struct ext4_group_desc bg 
)

◆ ext4_block_bitmap_set()

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

Definition at line 2441 of file generic.c.

2443{
2446 bg->bg_block_bitmap_hi = cpu_to_le32(blk >> 32);
2447}
ULONG32 u32
Definition: btrfs.h:14
#define blk
Definition: linetest.c:70

◆ ext4_block_in_group()

static int ext4_block_in_group ( struct super_block sb,
ext4_fsblk_t  block,
ext4_group_t  block_group 
)
static

Definition at line 2758 of file generic.c.

2760{
2761 ext4_group_t actual_group;
2762 ext4_get_group_no_and_offset(sb, block, &actual_group, NULL);
2763 if (actual_group == block_group)
2764 return 1;
2765 return 0;
2766}
void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp)
Definition: generic.c:2743

Referenced by ext4_group_used_meta_blocks(), and ext4_init_block_bitmap().

◆ ext4_check_descriptors()

int ext4_check_descriptors ( struct super_block sb)

Definition at line 3017 of file generic.c.

3018{
3019 PEXT2_VCB Vcb = sb->s_priv;
3020 struct ext3_sb_info *sbi = EXT3_SB(sb);
3021 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
3022 ext4_fsblk_t last_block;
3023 ext4_fsblk_t block_bitmap;
3024 ext4_fsblk_t inode_bitmap;
3025 ext4_fsblk_t inode_table;
3026 int flexbg_flag = 0;
3028
3030 flexbg_flag = 1;
3031
3032 DEBUG(DL_INF, ("Checking group descriptors"));
3033
3034 for (i = 0; i < sbi->s_groups_count; i++) {
3035
3036 struct buffer_head *bh = NULL;
3037 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, &bh);
3038
3039 if (!bh)
3040 continue;
3041
3042 if (i == sbi->s_groups_count - 1 || flexbg_flag)
3043 last_block = ext3_blocks_count(sbi->s_es) - 1;
3044 else
3045 last_block = first_block +
3047
3048 block_bitmap = ext4_block_bitmap(sb, gdp);
3049 if (block_bitmap < first_block || block_bitmap > last_block) {
3050 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3051 "Block bitmap for group %u not in group "
3052 "(block %llu)!\n", i, block_bitmap);
3053 __brelse(bh);
3054 return 0;
3055 }
3056 inode_bitmap = ext4_inode_bitmap(sb, gdp);
3057 if (inode_bitmap < first_block || inode_bitmap > last_block) {
3058 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3059 "Inode bitmap for group %u not in group "
3060 "(block %llu)!\n", i, inode_bitmap);
3061 __brelse(bh);
3062 return 0;
3063 }
3064 inode_table = ext4_inode_table(sb, gdp);
3065 if (inode_table < first_block ||
3066 inode_table + sbi->s_itb_per_group - 1 > last_block) {
3067 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3068 "Inode table for group %u not in group "
3069 "(block %llu)!\n", i, inode_table);
3070 __brelse(bh);
3071 return 0;
3072 }
3073
3074 if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
3075 printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
3076 "Checksum for group %u failed (%u!=%u)\n",
3078 gdp)),
3079 le16_to_cpu(gdp->bg_checksum));
3080 if (!IsVcbReadOnly(Vcb)) {
3081 __brelse(bh);
3082 return 0;
3083 }
3084 }
3085
3086 if (!flexbg_flag)
3087 first_block += EXT4_BLOCKS_PER_GROUP(sb);
3088
3089 __brelse(bh);
3090 }
3091
3093 sbi->s_es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));
3094 return 1;
3095}
static ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
Definition: ext2fs.h:1692
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:805
#define EXT3_BLOCKS_PER_GROUP(s)
Definition: ext3_fs.h:189
#define EXT4_FEATURE_INCOMPAT_FLEX_BG
Definition: ext3_fs.h:712
int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group, struct ext4_group_desc *gdp)
Definition: generic.c:2574
#define printk
Definition: module.h:229
#define KERN_ERR
Definition: module.h:223
unsigned long s_itb_per_group
Definition: ext3_fs_sb.h:44
unsigned long s_groups_count
Definition: ext3_fs_sb.h:43

Referenced by Ext2LoadGroup().

◆ ext4_count_dirs()

unsigned long ext4_count_dirs ( struct super_block sb)

Definition at line 2999 of file generic.c.

3000{
3001 struct ext4_group_desc *gdp;
3002 struct buffer_head *bh = NULL;
3003 unsigned long count = 0;
3005
3006 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
3007 gdp = ext4_get_group_desc(sb, i, &bh);
3008 if (!bh)
3009 continue;
3010 count += ext4_used_dirs_count(sb, gdp);
3011 fini_bh(&bh);
3012 }
3013 return count;
3014}

◆ ext4_count_free_blocks()

ext4_fsblk_t ext4_count_free_blocks ( struct super_block sb)

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

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

Definition at line 2959 of file generic.c.

2960{
2961 ext4_fsblk_t desc_count;
2962 struct ext4_group_desc *gdp;
2963 struct buffer_head *bh = NULL;
2965 ext4_group_t ngroups = EXT3_SB(sb)->s_groups_count;
2966
2967 desc_count = 0;
2968 smp_rmb();
2969 for (i = 0; i < ngroups; i++) {
2970 gdp = ext4_get_group_desc(sb, i, &bh);
2971 if (!bh)
2972 continue;
2973 desc_count += ext4_free_blks_count(sb, gdp);
2974 fini_bh(&bh);
2975 }
2976
2977 return desc_count;
2978}
#define smp_rmb()
Definition: module.h:1209

Referenced by Ext2UpdateVcbStat(), and ext4_check_descriptors().

◆ ext4_count_free_inodes()

unsigned long ext4_count_free_inodes ( struct super_block sb)

Definition at line 2980 of file generic.c.

2981{
2982 unsigned long desc_count;
2983 struct ext4_group_desc *gdp;
2984 struct buffer_head *bh = NULL;
2986
2987 desc_count = 0;
2988 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
2989 gdp = ext4_get_group_desc(sb, i, &bh);
2990 if (!bh)
2991 continue;
2992 desc_count += ext4_free_inodes_count(sb, gdp);
2993 fini_bh(&bh);
2994 }
2995 return desc_count;
2996}

Referenced by Ext2UpdateVcbStat(), and ext4_check_descriptors().

◆ ext4_free_blks_count()

__u32 ext4_free_blks_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2409 of file generic.c.

2411{
2412 return le16_to_cpu(bg->bg_free_blocks_count) |
2414 (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0);
2415}
__le16 bg_free_blocks_count
Definition: ext3_fs.h:139
__le16 bg_free_blocks_count_hi
Definition: ext3_fs.h:149

Referenced by Ext2NewBlock(), and ext4_count_free_blocks().

◆ ext4_free_blks_set()

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

◆ ext4_free_inodes_count()

__u32 ext4_free_inodes_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2417 of file generic.c.

2419{
2420 return le16_to_cpu(bg->bg_free_inodes_count) |
2422 (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0);
2423}
__le16 bg_free_inodes_count
Definition: ext3_fs.h:140
__le16 bg_free_inodes_count_hi
Definition: ext3_fs.h:150

Referenced by Ext2NewInode(), and ext4_count_free_inodes().

◆ ext4_free_inodes_set()

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

◆ ext4_get_group_desc()

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

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

Definition at line 2902 of file generic.c.

2904{
2905 struct ext4_group_desc *desc = NULL;
2906 struct ext3_sb_info *sbi = EXT3_SB(sb);
2907 PEXT2_VCB vcb = sb->s_priv;
2910
2911 if (bh)
2912 *bh = NULL;
2913
2914 if (block_group >= sbi->s_groups_count) {
2915 ext4_error(sb, "ext4_get_group_desc",
2916 "block_group >= groups_count - "
2917 "block_group = %u, groups_count = %u",
2918 block_group, sbi->s_groups_count);
2919
2920 return NULL;
2921 }
2922
2923 _SEH2_TRY {
2924
2925 group = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
2926 offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
2927
2928 if (!sbi->s_gd) {
2929 if (!Ext2LoadGroup(vcb)) {
2931 }
2932 } else if ( !sbi->s_gd[group].block ||
2933 !sbi->s_gd[group].bh) {
2934 if (!Ext2LoadGroupBH(vcb)) {
2936 }
2937 }
2938
2939 desc = (struct ext4_group_desc *)((PCHAR)sbi->s_gd[group].gd +
2941 if (bh) {
2942 atomic_inc(&sbi->s_gd[group].bh->b_count);
2943 *bh = sbi->s_gd[group].bh;
2944 }
2945 } _SEH2_FINALLY {
2946 /* do cleanup */
2947 } _SEH2_END;
2948
2949 return desc;
2950}
static void atomic_inc(atomic_t volatile *v)
Definition: atomic.h:95
#define ext4_error
Definition: ext2fs.h:2476
BOOLEAN Ext2LoadGroup(IN PEXT2_VCB Vcb)
Definition: generic.c:203
char * PCHAR
Definition: typedefs.h:51

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

◆ ext4_get_group_no_and_offset()

void ext4_get_group_no_and_offset ( struct super_block sb,
ext4_fsblk_t  blocknr,
ext4_group_t blockgrpp,
ext4_grpblk_t offsetp 
)

Definition at line 2743 of file generic.c.

2745{
2746 struct ext3_super_block *es = EXT3_SB(sb)->s_es;
2748
2749 blocknr = blocknr - le32_to_cpu(es->s_first_data_block);
2750 offset = do_div(blocknr, EXT4_BLOCKS_PER_GROUP(sb));
2751 if (offsetp)
2752 *offsetp = offset;
2753 if (blockgrpp)
2754 *blockgrpp = (ext4_grpblk_t)blocknr;
2755
2756}
int ext4_grpblk_t
Definition: ext3_fs_i.h:23
#define es
Definition: i386-dis.c:441
#define do_div(n, b)
Definition: module.h:1220

Referenced by ext4_block_in_group().

◆ ext4_group_desc_csum()

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

Definition at line 2545 of file generic.c.

2547{
2548 int offset;
2549 __u16 crc = 0;
2550 __le32 le_group = cpu_to_le32(block_group);
2551
2552 /* old crc16 code */
2553 if (!(sbi->s_es->s_feature_ro_compat &
2555 return 0;
2556
2557 offset = offsetof(struct ext4_group_desc, bg_checksum);
2558
2559 crc = crc16(~0, sbi->s_es->s_uuid, sizeof(sbi->s_es->s_uuid));
2560 crc = crc16(crc, (__u8 *)&le_group, sizeof(le_group));
2561 crc = crc16(crc, (__u8 *)gdp, offset);
2562 offset += sizeof(gdp->bg_checksum); /* skip checksum */
2563 /* for checksum of struct ext4_group_desc do the rest...*/
2564 if ((sbi->s_es->s_feature_incompat &
2566 offset < le16_to_cpu(sbi->s_es->s_desc_size))
2567 crc = crc16(crc, (__u8 *)gdp + offset,
2568 le16_to_cpu(sbi->s_es->s_desc_size) -
2569 offset);
2570
2571 return cpu_to_le16(crc);
2572}
u8 __u8
Definition: btrfs.h:17
#define __le32
Definition: types.h:40
#define EXT4_FEATURE_INCOMPAT_64BIT
Definition: ext3_fs.h:710
__u16 crc16(__u16 crc, __u8 const *buffer, size_t len)
Definition: generic.c:2538
#define offsetof(TYPE, MEMBER)

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

◆ ext4_group_desc_csum_verify()

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

Definition at line 2574 of file generic.c.

2576{
2577 if ((sbi->s_es->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) &&
2578 (gdp->bg_checksum != ext4_group_desc_csum(sbi, block_group, gdp)))
2579 return 0;
2580
2581 return 1;
2582}

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

◆ ext4_group_used_meta_blocks()

static int ext4_group_used_meta_blocks ( struct super_block sb,
ext4_group_t  block_group 
)
static

Definition at line 2768 of file generic.c.

2770{
2771 ext4_fsblk_t tmp;
2772 struct ext3_sb_info *sbi = EXT3_SB(sb);
2773 /* block bitmap, inode bitmap, and inode table blocks */
2774 int used_blocks = sbi->s_itb_per_group + 2;
2775
2777 struct ext4_group_desc *gdp;
2778 struct buffer_head *bh = NULL;
2779
2780 gdp = ext4_get_group_desc(sb, block_group, &bh);
2782 block_group))
2783 used_blocks--;
2784
2786 block_group))
2787 used_blocks--;
2788
2789 tmp = ext4_inode_table(sb, gdp);
2790 for (; tmp < ext4_inode_table(sb, gdp) +
2791 sbi->s_itb_per_group; tmp++) {
2792 if (!ext4_block_in_group(sb, tmp, block_group))
2793 used_blocks -= 1;
2794 }
2795 if (bh)
2796 fini_bh(&bh);
2797 }
2798 return used_blocks;
2799}
static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block, ext4_group_t block_group)
Definition: generic.c:2758

Referenced by ext4_init_block_bitmap().

◆ ext4_init_block_bitmap()

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

Definition at line 2803 of file generic.c.

2805{
2806 int bit, bit_max;
2807 unsigned free_blocks, group_blocks;
2808 struct ext3_sb_info *sbi = EXT3_SB(sb);
2809
2810 if (bh) {
2812 /* If checksum is bad mark all blocks used to prevent allocation
2813 * essentially implementing a per-group read-only flag. */
2814 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2816 "Checksum bad for group %u", block_group);
2817 ext4_free_blks_set(sb, gdp, 0);
2818 ext4_free_inodes_set(sb, gdp, 0);
2819 ext4_itable_unused_set(sb, gdp, 0);
2820 memset(bh->b_data, 0xff, sb->s_blocksize);
2821 return 0;
2822 }
2823 memset(bh->b_data, 0, sb->s_blocksize);
2824 }
2825
2826 /* Check for superblock and gdt backups in this group */
2827 bit_max = ext3_bg_has_super(sb, block_group);
2828
2830 block_group < le32_to_cpu(sbi->s_es->s_first_meta_bg) *
2831 sbi->s_desc_per_block) {
2832 if (bit_max) {
2833 bit_max += ext4_bg_num_gdb(sb, block_group);
2834 bit_max +=
2835 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks);
2836 }
2837 } else { /* For META_BG_BLOCK_GROUPS */
2838 bit_max += ext4_bg_num_gdb(sb, block_group);
2839 }
2840
2841 if (block_group == sbi->s_groups_count - 1) {
2842 /*
2843 * Even though mke2fs always initialize first and last group
2844 * if some other tool enabled the EXT4_BG_BLOCK_UNINIT we need
2845 * to make sure we calculate the right free blocks
2846 */
2847 group_blocks = (unsigned int)(ext3_blocks_count(sbi->s_es) -
2848 le32_to_cpu(sbi->s_es->s_first_data_block) -
2849 (EXT4_BLOCKS_PER_GROUP(sb) * (sbi->s_groups_count - 1)));
2850 } else {
2851 group_blocks = EXT4_BLOCKS_PER_GROUP(sb);
2852 }
2853
2854 free_blocks = group_blocks - bit_max;
2855
2856 if (bh) {
2857 ext4_fsblk_t start, tmp;
2858 int flex_bg = 0;
2859
2860 for (bit = 0; bit < bit_max; bit++)
2861 ext4_set_bit(bit, bh->b_data);
2862
2863 start = ext3_group_first_block_no(sb, block_group);
2864
2867 flex_bg = 1;
2868
2869 /* Set bits for block and inode bitmaps, and inode table */
2870 tmp = ext4_block_bitmap(sb, gdp);
2871 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2872 ext4_set_bit(tmp - start, bh->b_data);
2873
2874 tmp = ext4_inode_bitmap(sb, gdp);
2875 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
2876 ext4_set_bit(tmp - start, bh->b_data);
2877
2878 tmp = ext4_inode_table(sb, gdp);
2879 for (; tmp < ext4_inode_table(sb, gdp) +
2880 sbi->s_itb_per_group; tmp++) {
2881 if (!flex_bg ||
2882 ext4_block_in_group(sb, tmp, block_group))
2883 ext4_set_bit(tmp - start, bh->b_data);
2884 }
2885 /*
2886 * Also if the number of blocks within the group is
2887 * less than the blocksize * 8 ( which is the size
2888 * of bitmap ), set rest of the block bitmap to 1
2889 */
2890 mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
2891 }
2892 return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
2893}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define __FUNCTION__
Definition: types.h:112
static int ext4_group_used_meta_blocks(struct super_block *sb, ext4_group_t block_group)
Definition: generic.c:2768
unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group)
Definition: generic.c:2648
void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
Definition: generic.c:2697
#define ext4_set_bit(n, p)
Definition: generic.c:2680
GLuint start
Definition: gl.h:1545
#define memset(x, y, z)
Definition: compat.h:39

Referenced by Ext2NewBlock(), and Ext2NewInode().

◆ ext4_init_inode_bitmap()

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

Definition at line 2712 of file generic.c.

2715{
2716 struct ext3_sb_info *sbi = EXT3_SB(sb);
2717
2719
2720 /* If checksum is bad mark all blocks and inodes use to prevent
2721 * allocation, essentially implementing a per-group read-only flag. */
2722 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
2723 ext4_error(sb, __FUNCTION__, "Checksum bad for group %u",
2724 block_group);
2725 ext4_free_blks_set(sb, gdp, 0);
2726 ext4_free_inodes_set(sb, gdp, 0);
2727 ext4_itable_unused_set(sb, gdp, 0);
2728 memset(bh->b_data, 0xff, sb->s_blocksize);
2729 return 0;
2730 }
2731
2732 memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8);
2733 mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8,
2734 bh->b_data);
2735 ext4_itable_unused_set(sb, gdp, EXT4_INODES_PER_GROUP(sb));
2736
2737 return EXT4_INODES_PER_GROUP(sb);
2738}

Referenced by Ext2NewInode().

◆ ext4_inode_bitmap()

◆ ext4_inode_bitmap_set()

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

Definition at line 2449 of file generic.c.

2451{
2454 bg->bg_inode_bitmap_hi = cpu_to_le32(blk >> 32);
2455}

◆ ext4_inode_table()

◆ ext4_inode_table_set()

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

Definition at line 2457 of file generic.c.

2459{
2462 bg->bg_inode_table_hi = cpu_to_le32(blk >> 32);
2463}

◆ ext4_itable_unused_count()

__u32 ext4_itable_unused_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2433 of file generic.c.

2435{
2436 return le16_to_cpu(bg->bg_itable_unused) |
2438 (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
2439}
__le16 bg_itable_unused
Definition: ext3_fs.h:144
__le16 bg_itable_unused_hi
Definition: ext3_fs.h:152

Referenced by Ext2NewInode().

◆ ext4_itable_unused_set()

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

◆ ext4_max_size()

static loff_t ext4_max_size ( int  blkbits,
int  has_huge_files 
)
static

Definition at line 2187 of file generic.c.

2188{
2189 loff_t res;
2191
2192 /* small i_blocks in vfs inode? */
2193 if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) {
2194 /*
2195 * CONFIG_LBD is not enabled implies the inode
2196 * i_block represent total blocks in 512 bytes
2197 * 32 == size of vfs inode i_blocks * 8
2198 */
2199 upper_limit = (1LL << 32) - 1;
2200
2201 /* total blocks in file system block size */
2202 upper_limit >>= (blkbits - 9);
2203 upper_limit <<= blkbits;
2204 }
2205
2206 /* 32-bit extent-start container, ee_block */
2207 res = 1LL << 32;
2208 res <<= blkbits;
2209 res -= 1;
2210
2211 /* Sanity check against vm- & vfs- imposed limits */
2212 if (res > upper_limit)
2213 res = upper_limit;
2214
2215 return res;
2216}

◆ ext4_used_dirs_count()

__u32 ext4_used_dirs_count ( struct super_block sb,
struct ext4_group_desc bg 
)

Definition at line 2425 of file generic.c.

2427{
2428 return le16_to_cpu(bg->bg_used_dirs_count) |
2430 (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0);
2431}
__le16 bg_used_dirs_count
Definition: ext3_fs.h:141
__le16 bg_used_dirs_count_hi
Definition: ext3_fs.h:151

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

◆ ext4_used_dirs_set()

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

Definition at line 2481 of file generic.c.

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

◆ mark_bitmap_end()

void mark_bitmap_end ( int  start_bit,
int  end_bit,
char bitmap 
)

Definition at line 2697 of file generic.c.

2698{
2699 int i;
2700
2701 if (start_bit >= end_bit)
2702 return;
2703
2704 DEBUG(DL_INF, ("mark end bits +%d through +%d used\n", start_bit, end_bit));
2705 for (i = start_bit; (unsigned)i < ((start_bit + 7) & ~7UL); i++)
2707 if (i < end_bit)
2708 memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
2709}
static unsigned(__cdecl *hash_bstr)(bstr_t s)
Definition: uimain.c:89

Referenced by ext4_init_block_bitmap(), and ext4_init_inode_bitmap().

◆ test_root()

static int test_root ( ext3_group_t  a,
ext3_group_t  b 
)
inlinestatic

Definition at line 2585 of file generic.c.

2586{
2587 ext3_group_t num = b;
2588
2589 while (a > num)
2590 num *= b;
2591 return num == a;
2592}
GLuint GLuint num
Definition: glext.h:9618
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

Referenced by ext3_group_sparse().

Variable Documentation

◆ crc16_table

__u16 const crc16_table[256]

CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1)

Definition at line 2498 of file generic.c.

Referenced by crc16_byte().

◆ Ext2Global

PEXT2_GLOBAL Ext2Global
extern

Definition at line 16 of file init.c.