1 Star 0 Fork 17

庞庆/e2fsprogs

forked from src-anolis-os/e2fsprogs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
e2fsprogs-1.45.6-Revert-libext2fs-revamp-bitmap-types-to-fix-LTO-warn.patch 48.06 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:05 . update to e2fsprogs-1.45.6-1.el8.src.rpm
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
From 1c25e64066e861f273b785b06ef3bc7636552eab Mon Sep 17 00:00:00 2001
From: Lukas Czerner <lczerner@redhat.com>
Date: Tue, 14 Jan 2020 09:49:19 +0100
Subject: [PATCH 5/7] Revert "libext2fs: revamp bitmap types to fix LTO
warnings"
This reverts commit 83d9ffccf3ee6ad4e165eeb6912acf1f6149be28 because it
breaks ABI.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
lib/ext2fs/bitmaps.c | 6 +-
lib/ext2fs/blkmap64_ba.c | 38 ++++----
lib/ext2fs/blkmap64_rb.c | 38 ++++----
lib/ext2fs/bmap64.h | 38 ++++----
lib/ext2fs/ext2fs.h | 11 +--
lib/ext2fs/gen_bitmap.c | 113 ++++++++---------------
lib/ext2fs/gen_bitmap64.c | 185 ++++++++++++++++----------------------
7 files changed, 173 insertions(+), 256 deletions(-)
diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c
index 834a3962..e0b1f7cd 100644
--- a/lib/ext2fs/bitmaps.c
+++ b/lib/ext2fs/bitmaps.c
@@ -126,7 +126,6 @@ errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
{
__u64 start, end, real_end;
ext2fs_generic_bitmap bmap;
- ext2fs_generic_bitmap_64 bmap64;
errcode_t retval;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -149,15 +148,14 @@ errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
end, real_end, descr, &bmap);
if (retval)
return retval;
- bmap64 = (ext2fs_generic_bitmap_64) bmap;
- bmap64->cluster_bits = 0;
+ bmap->cluster_bits = 0;
*ret = bmap;
return 0;
}
int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) bitmap;
+ ext2fs_generic_bitmap bmap = bitmap;
if (!EXT2FS_IS_64_BITMAP(bmap))
return 0;
diff --git a/lib/ext2fs/blkmap64_ba.c b/lib/ext2fs/blkmap64_ba.c
index 85cb38d2..3707a61e 100644
--- a/lib/ext2fs/blkmap64_ba.c
+++ b/lib/ext2fs/blkmap64_ba.c
@@ -40,7 +40,7 @@ struct ext2fs_ba_private_struct {
typedef struct ext2fs_ba_private_struct *ext2fs_ba_private;
-static errcode_t ba_alloc_private_data (ext2fs_generic_bitmap_64 bitmap)
+static errcode_t ba_alloc_private_data (ext2fs_generic_bitmap bitmap)
{
ext2fs_ba_private bp;
errcode_t retval;
@@ -69,7 +69,7 @@ static errcode_t ba_alloc_private_data (ext2fs_generic_bitmap_64 bitmap)
}
static errcode_t ba_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)),
- ext2fs_generic_bitmap_64 bitmap)
+ ext2fs_generic_bitmap bitmap)
{
ext2fs_ba_private bp;
errcode_t retval;
@@ -86,7 +86,7 @@ static errcode_t ba_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)),
return 0;
}
-static void ba_free_bmap(ext2fs_generic_bitmap_64 bitmap)
+static void ba_free_bmap(ext2fs_generic_bitmap bitmap)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
@@ -101,8 +101,8 @@ static void ba_free_bmap(ext2fs_generic_bitmap_64 bitmap)
bp = 0;
}
-static errcode_t ba_copy_bmap(ext2fs_generic_bitmap_64 src,
- ext2fs_generic_bitmap_64 dest)
+static errcode_t ba_copy_bmap(ext2fs_generic_bitmap src,
+ ext2fs_generic_bitmap dest)
{
ext2fs_ba_private src_bp = (ext2fs_ba_private) src->private;
ext2fs_ba_private dest_bp;
@@ -121,7 +121,7 @@ static errcode_t ba_copy_bmap(ext2fs_generic_bitmap_64 src,
return 0;
}
-static errcode_t ba_resize_bmap(ext2fs_generic_bitmap_64 bmap,
+static errcode_t ba_resize_bmap(ext2fs_generic_bitmap bmap,
__u64 new_end, __u64 new_real_end)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bmap->private;
@@ -162,7 +162,7 @@ static errcode_t ba_resize_bmap(ext2fs_generic_bitmap_64 bmap,
}
-static int ba_mark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
+static int ba_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
blk64_t bitno = (blk64_t) arg;
@@ -170,7 +170,7 @@ static int ba_mark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
return ext2fs_set_bit64(bitno - bitmap->start, bp->bitarray);
}
-static int ba_unmark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
+static int ba_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
blk64_t bitno = (blk64_t) arg;
@@ -178,7 +178,7 @@ static int ba_unmark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
return ext2fs_clear_bit64(bitno - bitmap->start, bp->bitarray);
}
-static int ba_test_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
+static int ba_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
blk64_t bitno = (blk64_t) arg;
@@ -186,7 +186,7 @@ static int ba_test_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
return ext2fs_test_bit64(bitno - bitmap->start, bp->bitarray);
}
-static void ba_mark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
+static void ba_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
unsigned int num)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
@@ -197,7 +197,7 @@ static void ba_mark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
ext2fs_fast_set_bit64(bitno + i - bitmap->start, bp->bitarray);
}
-static void ba_unmark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
+static void ba_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
unsigned int num)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
@@ -208,7 +208,7 @@ static void ba_unmark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
ext2fs_fast_clear_bit64(bitno + i - bitmap->start, bp->bitarray);
}
-static int ba_test_clear_bmap_extent(ext2fs_generic_bitmap_64 bitmap,
+static int ba_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap,
__u64 start, unsigned int len)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
@@ -282,7 +282,7 @@ static int ba_test_clear_bmap_extent(ext2fs_generic_bitmap_64 bitmap,
}
-static errcode_t ba_set_bmap_range(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t ba_set_bmap_range(ext2fs_generic_bitmap bitmap,
__u64 start, size_t num, void *in)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
@@ -292,7 +292,7 @@ static errcode_t ba_set_bmap_range(ext2fs_generic_bitmap_64 bitmap,
return 0;
}
-static errcode_t ba_get_bmap_range(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t ba_get_bmap_range(ext2fs_generic_bitmap bitmap,
__u64 start, size_t num, void *out)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
@@ -302,7 +302,7 @@ static errcode_t ba_get_bmap_range(ext2fs_generic_bitmap_64 bitmap,
return 0;
}
-static void ba_clear_bmap(ext2fs_generic_bitmap_64 bitmap)
+static void ba_clear_bmap(ext2fs_generic_bitmap bitmap)
{
ext2fs_ba_private bp = (ext2fs_ba_private) bitmap->private;
@@ -311,20 +311,20 @@ static void ba_clear_bmap(ext2fs_generic_bitmap_64 bitmap)
}
#ifdef ENABLE_BMAP_STATS
-static void ba_print_stats(ext2fs_generic_bitmap_64 bitmap)
+static void ba_print_stats(ext2fs_generic_bitmap bitmap)
{
fprintf(stderr, "%16llu Bytes used by bitarray\n",
((bitmap->real_end - bitmap->start) >> 3) + 1 +
sizeof(struct ext2fs_ba_private_struct));
}
#else
-static void ba_print_stats(ext2fs_generic_bitmap_64 bitmap EXT2FS_ATTR((unused)))
+static void ba_print_stats(ext2fs_generic_bitmap bitmap EXT2FS_ATTR((unused)))
{
}
#endif
/* Find the first zero bit between start and end, inclusive. */
-static errcode_t ba_find_first_zero(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t ba_find_first_zero(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out)
{
ext2fs_ba_private bp = (ext2fs_ba_private)bitmap->private;
@@ -398,7 +398,7 @@ static errcode_t ba_find_first_zero(ext2fs_generic_bitmap_64 bitmap,
}
/* Find the first one bit between start and end, inclusive. */
-static errcode_t ba_find_first_set(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t ba_find_first_set(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out)
{
ext2fs_ba_private bp = (ext2fs_ba_private)bitmap->private;
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
index 1fd55274..4cbfb1ed 100644
--- a/lib/ext2fs/blkmap64_rb.c
+++ b/lib/ext2fs/blkmap64_rb.c
@@ -177,7 +177,7 @@ static void rb_free_extent(struct ext2fs_rb_private *bp,
ext2fs_free_mem(&ext);
}
-static errcode_t rb_alloc_private_data (ext2fs_generic_bitmap_64 bitmap)
+static errcode_t rb_alloc_private_data (ext2fs_generic_bitmap bitmap)
{
struct ext2fs_rb_private *bp;
errcode_t retval;
@@ -201,7 +201,7 @@ static errcode_t rb_alloc_private_data (ext2fs_generic_bitmap_64 bitmap)
}
static errcode_t rb_new_bmap(ext2_filsys fs EXT2FS_ATTR((unused)),
- ext2fs_generic_bitmap_64 bitmap)
+ ext2fs_generic_bitmap bitmap)
{
errcode_t retval;
@@ -225,7 +225,7 @@ static void rb_free_tree(struct rb_root *root)
}
}
-static void rb_free_bmap(ext2fs_generic_bitmap_64 bitmap)
+static void rb_free_bmap(ext2fs_generic_bitmap bitmap)
{
struct ext2fs_rb_private *bp;
@@ -236,8 +236,8 @@ static void rb_free_bmap(ext2fs_generic_bitmap_64 bitmap)
bp = 0;
}
-static errcode_t rb_copy_bmap(ext2fs_generic_bitmap_64 src,
- ext2fs_generic_bitmap_64 dest)
+static errcode_t rb_copy_bmap(ext2fs_generic_bitmap src,
+ ext2fs_generic_bitmap dest)
{
struct ext2fs_rb_private *src_bp, *dest_bp;
struct bmap_rb_extent *src_ext, *dest_ext;
@@ -302,7 +302,7 @@ static void rb_truncate(__u64 new_max, struct rb_root *root)
}
}
-static errcode_t rb_resize_bmap(ext2fs_generic_bitmap_64 bmap,
+static errcode_t rb_resize_bmap(ext2fs_generic_bitmap bmap,
__u64 new_end, __u64 new_real_end)
{
struct ext2fs_rb_private *bp;
@@ -575,7 +575,7 @@ static int rb_remove_extent(__u64 start, __u64 count,
return retval;
}
-static int rb_mark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
+static int rb_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
{
struct ext2fs_rb_private *bp;
int retval;
@@ -588,7 +588,7 @@ static int rb_mark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
return retval;
}
-static int rb_unmark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
+static int rb_unmark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
{
struct ext2fs_rb_private *bp;
int retval;
@@ -603,7 +603,7 @@ static int rb_unmark_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
}
inline
-static int rb_test_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
+static int rb_test_bmap(ext2fs_generic_bitmap bitmap, __u64 arg)
{
struct ext2fs_rb_private *bp;
@@ -613,7 +613,7 @@ static int rb_test_bmap(ext2fs_generic_bitmap_64 bitmap, __u64 arg)
return rb_test_bit(bp, arg);
}
-static void rb_mark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
+static void rb_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
unsigned int num)
{
struct ext2fs_rb_private *bp;
@@ -625,7 +625,7 @@ static void rb_mark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
check_tree(&bp->root, __func__);
}
-static void rb_unmark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
+static void rb_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg,
unsigned int num)
{
struct ext2fs_rb_private *bp;
@@ -637,7 +637,7 @@ static void rb_unmark_bmap_extent(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
check_tree(&bp->root, __func__);
}
-static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap_64 bitmap,
+static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap,
__u64 start, unsigned int len)
{
struct rb_node *parent = NULL, **n;
@@ -693,7 +693,7 @@ static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap_64 bitmap,
return retval;
}
-static errcode_t rb_set_bmap_range(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t rb_set_bmap_range(ext2fs_generic_bitmap bitmap,
__u64 start, size_t num, void *in)
{
struct ext2fs_rb_private *bp;
@@ -739,7 +739,7 @@ static errcode_t rb_set_bmap_range(ext2fs_generic_bitmap_64 bitmap,
return 0;
}
-static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap bitmap,
__u64 start, size_t num, void *out)
{
@@ -804,7 +804,7 @@ static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap_64 bitmap,
return 0;
}
-static void rb_clear_bmap(ext2fs_generic_bitmap_64 bitmap)
+static void rb_clear_bmap(ext2fs_generic_bitmap bitmap)
{
struct ext2fs_rb_private *bp;
@@ -817,7 +817,7 @@ static void rb_clear_bmap(ext2fs_generic_bitmap_64 bitmap)
check_tree(&bp->root, __func__);
}
-static errcode_t rb_find_first_zero(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t rb_find_first_zero(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out)
{
struct rb_node *parent = NULL, **n;
@@ -853,7 +853,7 @@ static errcode_t rb_find_first_zero(ext2fs_generic_bitmap_64 bitmap,
return 0;
}
-static errcode_t rb_find_first_set(ext2fs_generic_bitmap_64 bitmap,
+static errcode_t rb_find_first_set(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out)
{
struct rb_node *parent = NULL, **n;
@@ -902,7 +902,7 @@ static errcode_t rb_find_first_set(ext2fs_generic_bitmap_64 bitmap,
}
#ifdef ENABLE_BMAP_STATS
-static void rb_print_stats(ext2fs_generic_bitmap_64 bitmap)
+static void rb_print_stats(ext2fs_generic_bitmap bitmap)
{
struct ext2fs_rb_private *bp;
struct rb_node *node = NULL;
@@ -963,7 +963,7 @@ static void rb_print_stats(ext2fs_generic_bitmap_64 bitmap)
eff);
}
#else
-static void rb_print_stats(ext2fs_generic_bitmap_64 bitmap EXT2FS_ATTR((unused)))
+static void rb_print_stats(ext2fs_generic_bitmap bitmap EXT2FS_ATTR((unused)))
{
}
#endif
diff --git a/lib/ext2fs/bmap64.h b/lib/ext2fs/bmap64.h
index de334548..d8c7a3c3 100644
--- a/lib/ext2fs/bmap64.h
+++ b/lib/ext2fs/bmap64.h
@@ -37,7 +37,7 @@ struct ext2_bmap_statistics {
};
-struct ext2fs_struct_generic_bitmap_64 {
+struct ext2fs_struct_generic_bitmap {
errcode_t magic;
ext2_filsys fs;
struct ext2_bitmap_ops *bitmap_ops;
@@ -53,8 +53,6 @@ struct ext2fs_struct_generic_bitmap_64 {
#endif
};
-typedef struct ext2fs_struct_generic_bitmap_64 *ext2fs_generic_bitmap_64;
-
#define EXT2FS_IS_32_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
@@ -68,37 +66,37 @@ typedef struct ext2fs_struct_generic_bitmap_64 *ext2fs_generic_bitmap_64;
struct ext2_bitmap_ops {
int type;
/* Generic bmap operators */
- errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap_64 bmap);
- void (*free_bmap)(ext2fs_generic_bitmap_64 bitmap);
- errcode_t (*copy_bmap)(ext2fs_generic_bitmap_64 src,
- ext2fs_generic_bitmap_64 dest);
- errcode_t (*resize_bmap)(ext2fs_generic_bitmap_64 bitmap,
+ errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap bmap);
+ void (*free_bmap)(ext2fs_generic_bitmap bitmap);
+ errcode_t (*copy_bmap)(ext2fs_generic_bitmap src,
+ ext2fs_generic_bitmap dest);
+ errcode_t (*resize_bmap)(ext2fs_generic_bitmap bitmap,
__u64 new_end,
__u64 new_real_end);
/* bit set/test operators */
- int (*mark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
- int (*unmark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
- int (*test_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
- void (*mark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
+ int (*mark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
+ int (*unmark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
+ int (*test_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
+ void (*mark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg,
unsigned int num);
- void (*unmark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
+ void (*unmark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg,
unsigned int num);
- int (*test_clear_bmap_extent)(ext2fs_generic_bitmap_64 bitmap,
+ int (*test_clear_bmap_extent)(ext2fs_generic_bitmap bitmap,
__u64 arg, unsigned int num);
- errcode_t (*set_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
+ errcode_t (*set_bmap_range)(ext2fs_generic_bitmap bitmap,
__u64 start, size_t num, void *in);
- errcode_t (*get_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
+ errcode_t (*get_bmap_range)(ext2fs_generic_bitmap bitmap,
__u64 start, size_t num, void *out);
- void (*clear_bmap)(ext2fs_generic_bitmap_64 bitmap);
- void (*print_stats)(ext2fs_generic_bitmap_64);
+ void (*clear_bmap)(ext2fs_generic_bitmap bitmap);
+ void (*print_stats)(ext2fs_generic_bitmap);
/* Find the first zero bit between start and end, inclusive.
* May be NULL, in which case a generic function is used. */
- errcode_t (*find_first_zero)(ext2fs_generic_bitmap_64 bitmap,
+ errcode_t (*find_first_zero)(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out);
/* Find the first set bit between start and end, inclusive.
* May be NULL, in which case a generic function is used. */
- errcode_t (*find_first_set)(ext2fs_generic_bitmap_64 bitmap,
+ errcode_t (*find_first_set)(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out);
};
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 4b7c836a..ba83534c 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -111,14 +111,9 @@ typedef struct struct_ext2_filsys *ext2_filsys;
#define EXT2FS_UNMARK_ERROR 1
#define EXT2FS_TEST_ERROR 2
-struct ext2fs_struct_generic_bitmap_base {
- errcode_t magic;
- ext2_filsys fs;
-};
-
-typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_generic_bitmap;
-typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_inode_bitmap;
-typedef struct ext2fs_struct_generic_bitmap_base *ext2fs_block_bitmap;
+typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
+typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
+typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c
index 1536d4b3..b545ed7f 100644
--- a/lib/ext2fs/gen_bitmap.c
+++ b/lib/ext2fs/gen_bitmap.c
@@ -28,7 +28,7 @@
#include "ext2_fs.h"
#include "ext2fsP.h"
-struct ext2fs_struct_generic_bitmap_32 {
+struct ext2fs_struct_generic_bitmap {
errcode_t magic;
ext2_filsys fs;
__u32 start, end;
@@ -39,8 +39,6 @@ struct ext2fs_struct_generic_bitmap_32 {
__u32 reserved[7];
};
-typedef struct ext2fs_struct_generic_bitmap_32 *ext2fs_generic_bitmap_32;
-
#define EXT2FS_IS_32_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
@@ -55,11 +53,9 @@ typedef struct ext2fs_struct_generic_bitmap_32 *ext2fs_generic_bitmap_32;
* Used by previously inlined function, so we have to export this and
* not change the function signature
*/
-void ext2fs_warn_bitmap2(ext2fs_generic_bitmap gen_bitmap,
+void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
int code, unsigned long arg)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
-
#ifndef OMIT_COM_ERR
if (bitmap->description)
com_err(0, bitmap->base_error_code+code,
@@ -83,11 +79,11 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs,
const char *descr, char *init_map,
ext2fs_generic_bitmap *ret)
{
- ext2fs_generic_bitmap_32 bitmap;
+ ext2fs_generic_bitmap bitmap;
errcode_t retval;
size_t size;
- retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap_32),
+ retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap),
&bitmap);
if (retval)
return retval;
@@ -131,7 +127,7 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs,
memcpy(bitmap->bitmap, init_map, size);
else
memset(bitmap->bitmap, 0, size);
- *ret = (ext2fs_generic_bitmap) bitmap;
+ *ret = bitmap;
return 0;
}
@@ -145,11 +141,9 @@ errcode_t ext2fs_allocate_generic_bitmap(__u32 start,
start, end, real_end, descr, 0, ret);
}
-errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap gen_src,
+errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest)
{
- ext2fs_generic_bitmap_32 src = (ext2fs_generic_bitmap_32) gen_src;
-
return (ext2fs_make_generic_bitmap(src->magic, src->fs,
src->start, src->end,
src->real_end,
@@ -157,11 +151,9 @@ errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap gen_src,
dest));
}
-void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap gen_bitmap)
+void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
-
- if (check_magic(gen_bitmap))
+ if (check_magic(bitmap))
return;
bitmap->magic = 0;
@@ -179,8 +171,6 @@ void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap gen_bitmap)
int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno)
{
- ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap;
-
if (!EXT2FS_IS_32_BITMAP(bitmap)) {
if (EXT2FS_IS_64_BITMAP(bitmap)) {
ext2fs_warn_bitmap32(bitmap, __func__);
@@ -193,18 +183,16 @@ int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
return 0;
}
- if ((bitno < bitmap32->start) || (bitno > bitmap32->end)) {
+ if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno);
return 0;
}
- return ext2fs_test_bit(bitno - bitmap32->start, bitmap32->bitmap);
+ return ext2fs_test_bit(bitno - bitmap->start, bitmap->bitmap);
}
int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 bitno)
{
- ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap;
-
if (!EXT2FS_IS_32_BITMAP(bitmap)) {
if (EXT2FS_IS_64_BITMAP(bitmap)) {
ext2fs_warn_bitmap32(bitmap, __func__);
@@ -217,18 +205,16 @@ int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
return 0;
}
- if ((bitno < bitmap32->start) || (bitno > bitmap32->end)) {
+ if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno);
return 0;
}
- return ext2fs_set_bit(bitno - bitmap32->start, bitmap32->bitmap);
+ return ext2fs_set_bit(bitno - bitmap->start, bitmap->bitmap);
}
int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno)
{
- ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap;
-
if (!EXT2FS_IS_32_BITMAP(bitmap)) {
if (EXT2FS_IS_64_BITMAP(bitmap)) {
ext2fs_warn_bitmap32(bitmap, __func__);
@@ -241,17 +227,15 @@ int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
return 0;
}
- if ((bitno < bitmap32->start) || (bitno > bitmap32->end)) {
+ if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno);
return 0;
}
- return ext2fs_clear_bit(bitno - bitmap32->start, bitmap32->bitmap);
+ return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap);
}
__u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap)
{
- ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap;
-
if (!EXT2FS_IS_32_BITMAP(bitmap)) {
if (EXT2FS_IS_64_BITMAP(bitmap)) {
ext2fs_warn_bitmap32(bitmap, __func__);
@@ -264,13 +248,11 @@ __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap)
return 0;
}
- return bitmap32->start;
+ return bitmap->start;
}
__u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap)
{
- ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap;
-
if (!EXT2FS_IS_32_BITMAP(bitmap)) {
if (EXT2FS_IS_64_BITMAP(bitmap)) {
ext2fs_warn_bitmap32(bitmap, __func__);
@@ -282,13 +264,11 @@ __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap)
#endif
return 0;
}
- return bitmap32->end;
+ return bitmap->end;
}
void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
{
- ext2fs_generic_bitmap_32 bitmap32 = (ext2fs_generic_bitmap_32) bitmap;
-
if (!EXT2FS_IS_32_BITMAP(bitmap)) {
if (EXT2FS_IS_64_BITMAP(bitmap)) {
ext2fs_warn_bitmap32(bitmap, __func__);
@@ -302,16 +282,14 @@ void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
return;
}
- memset(bitmap32->bitmap, 0,
- (size_t) (((bitmap32->real_end - bitmap32->start) / 8) + 1));
+ memset(bitmap->bitmap, 0,
+ (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
}
-errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap gen_bitmap,
+errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap,
errcode_t magic, errcode_t neq,
ext2_ino_t end, ext2_ino_t *oend)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
-
EXT2_CHECK_MAGIC(bitmap, magic);
if (end > bitmap->real_end)
@@ -324,9 +302,8 @@ errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap gen_bitmap,
errcode_t ext2fs_resize_generic_bitmap(errcode_t magic,
__u32 new_end, __u32 new_real_end,
- ext2fs_generic_bitmap gen_bmap)
+ ext2fs_generic_bitmap bmap)
{
- ext2fs_generic_bitmap_32 bmap = (ext2fs_generic_bitmap_32) gen_bmap;
errcode_t retval;
size_t size, new_size;
__u32 bitno;
@@ -367,11 +344,9 @@ errcode_t ext2fs_resize_generic_bitmap(errcode_t magic,
}
errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq,
- ext2fs_generic_bitmap gen_bm1,
- ext2fs_generic_bitmap gen_bm2)
+ ext2fs_generic_bitmap bm1,
+ ext2fs_generic_bitmap bm2)
{
- ext2fs_generic_bitmap_32 bm1 = (ext2fs_generic_bitmap_32) gen_bm1;
- ext2fs_generic_bitmap_32 bm2 = (ext2fs_generic_bitmap_32) gen_bm2;
blk_t i;
if (!bm1 || bm1->magic != magic)
@@ -386,16 +361,15 @@ errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq,
return neq;
for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
- if (ext2fs_fast_test_block_bitmap(gen_bm1, i) !=
- ext2fs_fast_test_block_bitmap(gen_bm2, i))
+ if (ext2fs_fast_test_block_bitmap(bm1, i) !=
+ ext2fs_fast_test_block_bitmap(bm2, i))
return neq;
return 0;
}
-void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap gen_map)
+void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map)
{
- ext2fs_generic_bitmap_32 map = (ext2fs_generic_bitmap_32) gen_map;
__u32 i, j;
/* Protect loop from wrap-around if map->real_end is maxed */
@@ -405,13 +379,11 @@ void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap gen_map)
ext2fs_set_bit(j, map->bitmap);
}
-errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap gen_bmap,
+errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap,
errcode_t magic,
__u32 start, __u32 num,
void *out)
{
- ext2fs_generic_bitmap_32 bmap = (ext2fs_generic_bitmap_32) gen_bmap;
-
if (!bmap || (bmap->magic != magic))
return magic;
@@ -422,13 +394,11 @@ errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap gen_bmap,
return 0;
}
-errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap gen_bmap,
+errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
errcode_t magic,
__u32 start, __u32 num,
void *in)
{
- ext2fs_generic_bitmap_32 bmap = (ext2fs_generic_bitmap_32) gen_bmap;
-
if (!bmap || (bmap->magic != magic))
return magic;
@@ -462,11 +432,10 @@ int ext2fs_mem_is_zero(const char *mem, size_t len)
/*
* Return true if all of the bits in a specified range are clear
*/
-static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap gen_bitmap,
+static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap bitmap,
unsigned int start,
unsigned int len)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
size_t start_byte, len_byte = len >> 3;
unsigned int start_bit, len_bit = len % 8;
int first_bit = 0;
@@ -535,15 +504,14 @@ static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap gen_bitm
return ext2fs_mem_is_zero(ADDR + start_byte, len_byte);
}
-errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap gen_bitmap,
+errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 start, __u32 end,
__u32 *out)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
blk_t b;
if (start < bitmap->start || end > bitmap->end || start > end) {
- ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_TEST_ERROR, start);
+ ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
return EINVAL;
}
@@ -559,15 +527,14 @@ errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap gen_bitmap
return ENOENT;
}
-errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap gen_bitmap,
+errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 start, __u32 end,
__u32 *out)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
blk_t b;
if (start < bitmap->start || end > bitmap->end || start > end) {
- ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_TEST_ERROR, start);
+ ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
return EINVAL;
}
@@ -583,11 +550,9 @@ errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap gen_bitmap,
return ENOENT;
}
-int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap gen_bitmap,
+int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
-
EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_BLOCK_BITMAP);
if ((block < bitmap->start) || (block > bitmap->real_end) ||
(block+num-1 > bitmap->real_end)) {
@@ -599,11 +564,9 @@ int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap gen_bitmap,
bitmap, block, num);
}
-int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap gen_bitmap,
+int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode, int num)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
-
EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_INODE_BITMAP);
if ((inode < bitmap->start) || (inode > bitmap->real_end) ||
(inode+num-1 > bitmap->real_end)) {
@@ -615,10 +578,9 @@ int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap gen_bitmap,
bitmap, inode, num);
}
-void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap gen_bitmap,
+void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
int i;
if ((block < bitmap->start) || (block > bitmap->end) ||
@@ -631,10 +593,9 @@ void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap gen_bitmap,
ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap);
}
-void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap gen_bitmap,
- blk_t block, int num)
+void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
+ blk_t block, int num)
{
- ext2fs_generic_bitmap_32 bitmap = (ext2fs_generic_bitmap_32) gen_bitmap;
int i;
if ((block < bitmap->start) || (block > bitmap->end) ||
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index 6e4d8b71..47ba2baf 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -68,7 +68,7 @@
* e2fsck can request an encoding which is optimized for that.
*/
-static void warn_bitmap(ext2fs_generic_bitmap_64 bitmap,
+static void warn_bitmap(ext2fs_generic_bitmap bitmap,
int code, __u64 arg)
{
#ifndef OMIT_COM_ERR
@@ -93,7 +93,7 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
const char *descr,
ext2fs_generic_bitmap *ret)
{
- ext2fs_generic_bitmap_64 bitmap;
+ ext2fs_generic_bitmap bitmap;
struct ext2_bitmap_ops *ops;
ext2_ino_t num_dirs;
errcode_t retval;
@@ -119,7 +119,7 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
return EINVAL;
}
- retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap_64),
+ retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap),
&bitmap);
if (retval)
return retval;
@@ -170,12 +170,12 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
return retval;
}
- *ret = (ext2fs_generic_bitmap) bitmap;
+ *ret = bitmap;
return 0;
}
#ifdef ENABLE_BMAP_STATS
-static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
+static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap)
{
struct ext2_bmap_statistics *stats = &bitmap->stats;
#ifdef ENABLE_BMAP_STATS_OPS
@@ -241,15 +241,13 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
}
#endif
-void ext2fs_free_generic_bmap(ext2fs_generic_bitmap gen_bmap)
+void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
-
if (!bmap)
return;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- ext2fs_free_generic_bitmap(gen_bmap);
+ ext2fs_free_generic_bitmap(bmap);
return;
}
@@ -273,25 +271,24 @@ void ext2fs_free_generic_bmap(ext2fs_generic_bitmap gen_bmap)
ext2fs_free_mem(&bmap);
}
-errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap gen_src,
+errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest)
{
- ext2fs_generic_bitmap_64 src = (ext2fs_generic_bitmap_64) gen_src;
char *descr, *new_descr;
- ext2fs_generic_bitmap_64 new_bmap;
+ ext2fs_generic_bitmap new_bmap;
errcode_t retval;
if (!src)
return EINVAL;
if (EXT2FS_IS_32_BITMAP(src))
- return ext2fs_copy_generic_bitmap(gen_src, dest);
+ return ext2fs_copy_generic_bitmap(src, dest);
if (!EXT2FS_IS_64_BITMAP(src))
return EINVAL;
/* Allocate a new bitmap struct */
- retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap_64),
+ retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap),
&new_bmap);
if (retval)
return retval;
@@ -339,23 +336,21 @@ errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap gen_src,
return retval;
}
- *dest = (ext2fs_generic_bitmap) new_bmap;
+ *dest = new_bmap;
return 0;
}
-errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap gen_bmap,
+errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
__u64 new_end,
__u64 new_real_end)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
-
if (!bmap)
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bmap))
- return ext2fs_resize_generic_bitmap(gen_bmap->magic, new_end,
- new_real_end, gen_bmap);
+ return ext2fs_resize_generic_bitmap(bmap->magic, new_end,
+ new_real_end, bmap);
if (!EXT2FS_IS_64_BITMAP(bmap))
return EINVAL;
@@ -365,12 +360,10 @@ errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap gen_bmap,
return bmap->bitmap_ops->resize_bmap(bmap, new_end, new_real_end);
}
-errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap gen_bitmap,
+errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
errcode_t neq,
__u64 end, __u64 *oend)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
-
if (!bitmap)
return EINVAL;
@@ -378,8 +371,7 @@ errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap gen_bitmap,
ext2_ino_t tmp_oend;
int retval;
- retval = ext2fs_fudge_generic_bitmap_end(gen_bitmap,
- bitmap->magic,
+ retval = ext2fs_fudge_generic_bitmap_end(bitmap, bitmap->magic,
neq, end, &tmp_oend);
if (oend)
*oend = tmp_oend;
@@ -397,15 +389,13 @@ errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap gen_bitmap,
return 0;
}
-__u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap gen_bitmap)
+__u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
-
if (!bitmap)
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bitmap))
- return ext2fs_get_generic_bitmap_start(gen_bitmap);
+ return ext2fs_get_generic_bitmap_start(bitmap);
if (!EXT2FS_IS_64_BITMAP(bitmap))
return EINVAL;
@@ -413,15 +403,13 @@ __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap gen_bitmap)
return bitmap->start;
}
-__u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap gen_bitmap)
+__u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
-
if (!bitmap)
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bitmap))
- return ext2fs_get_generic_bitmap_end(gen_bitmap);
+ return ext2fs_get_generic_bitmap_end(bitmap);
if (!EXT2FS_IS_64_BITMAP(bitmap))
return EINVAL;
@@ -429,31 +417,27 @@ __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap gen_bitmap)
return bitmap->end;
}
-void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap gen_bitmap)
+void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
-
if (EXT2FS_IS_32_BITMAP(bitmap))
- ext2fs_clear_generic_bitmap(gen_bitmap);
+ ext2fs_clear_generic_bitmap(bitmap);
else
- bitmap->bitmap_ops->clear_bmap(bitmap);
+ bitmap->bitmap_ops->clear_bmap (bitmap);
}
-int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap gen_bitmap,
+int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 arg)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
-
if (!bitmap)
return 0;
if (EXT2FS_IS_32_BITMAP(bitmap)) {
if (arg & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(gen_bitmap,
+ ext2fs_warn_bitmap2(bitmap,
EXT2FS_MARK_ERROR, 0xffffffff);
return 0;
}
- return ext2fs_mark_generic_bitmap(gen_bitmap, arg);
+ return ext2fs_mark_generic_bitmap(bitmap, arg);
}
if (!EXT2FS_IS_64_BITMAP(bitmap))
@@ -478,21 +462,19 @@ int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap gen_bitmap,
return bitmap->bitmap_ops->mark_bmap(bitmap, arg);
}
-int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap gen_bitmap,
+int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 arg)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
-
if (!bitmap)
return 0;
if (EXT2FS_IS_32_BITMAP(bitmap)) {
if (arg & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_UNMARK_ERROR,
+ ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR,
0xffffffff);
return 0;
}
- return ext2fs_unmark_generic_bitmap(gen_bitmap, arg);
+ return ext2fs_unmark_generic_bitmap(bitmap, arg);
}
if (!EXT2FS_IS_64_BITMAP(bitmap))
@@ -510,20 +492,19 @@ int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap gen_bitmap,
return bitmap->bitmap_ops->unmark_bmap(bitmap, arg);
}
-int ext2fs_test_generic_bmap(ext2fs_generic_bitmap gen_bitmap,
+int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 arg)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
if (!bitmap)
return 0;
if (EXT2FS_IS_32_BITMAP(bitmap)) {
if (arg & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(gen_bitmap, EXT2FS_TEST_ERROR,
+ ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR,
0xffffffff);
return 0;
}
- return ext2fs_test_generic_bitmap(gen_bitmap, arg);
+ return ext2fs_test_generic_bitmap(bitmap, arg);
}
if (!EXT2FS_IS_64_BITMAP(bitmap))
@@ -548,22 +529,20 @@ int ext2fs_test_generic_bmap(ext2fs_generic_bitmap gen_bitmap,
return bitmap->bitmap_ops->test_bmap(bitmap, arg);
}
-errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap gen_bmap,
+errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
__u64 start, unsigned int num,
void *in)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
-
if (!bmap)
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bmap)) {
if ((start+num-1) & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(gen_bmap, EXT2FS_UNMARK_ERROR,
+ ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR,
0xffffffff);
return EINVAL;
}
- return ext2fs_set_generic_bitmap_range(gen_bmap, bmap->magic,
+ return ext2fs_set_generic_bitmap_range(bmap, bmap->magic,
start, num, in);
}
@@ -575,22 +554,20 @@ errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap gen_bmap,
return bmap->bitmap_ops->set_bmap_range(bmap, start, num, in);
}
-errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap gen_bmap,
+errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
__u64 start, unsigned int num,
void *out)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
-
if (!bmap)
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bmap)) {
if ((start+num-1) & ~0xffffffffULL) {
- ext2fs_warn_bitmap2(gen_bmap,
+ ext2fs_warn_bitmap2(bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return EINVAL;
}
- return ext2fs_get_generic_bitmap_range(gen_bmap, bmap->magic,
+ return ext2fs_get_generic_bitmap_range(bmap, bmap->magic,
start, num, out);
}
@@ -603,11 +580,9 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap gen_bmap,
}
errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
- ext2fs_generic_bitmap gen_bm1,
- ext2fs_generic_bitmap gen_bm2)
+ ext2fs_generic_bitmap bm1,
+ ext2fs_generic_bitmap bm2)
{
- ext2fs_generic_bitmap_64 bm1 = (ext2fs_generic_bitmap_64) gen_bm1;
- ext2fs_generic_bitmap_64 bm2 = (ext2fs_generic_bitmap_64) gen_bm2;
blk64_t i;
if (!bm1 || !bm2)
@@ -617,8 +592,7 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
/* Now we know both bitmaps have the same magic */
if (EXT2FS_IS_32_BITMAP(bm1))
- return ext2fs_compare_generic_bitmap(bm1->magic, neq,
- gen_bm1, gen_bm2);
+ return ext2fs_compare_generic_bitmap(bm1->magic, neq, bm1, bm2);
if (!EXT2FS_IS_64_BITMAP(bm1))
return EINVAL;
@@ -628,20 +602,19 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
return neq;
for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
- if (ext2fs_test_generic_bmap(gen_bm1, i) !=
- ext2fs_test_generic_bmap(gen_bm2, i))
+ if (ext2fs_test_generic_bmap(bm1, i) !=
+ ext2fs_test_generic_bmap(bm2, i))
return neq;
return 0;
}
-void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap gen_bmap)
+void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
__u64 start, num;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- ext2fs_set_generic_bitmap_padding(gen_bmap);
+ ext2fs_set_generic_bitmap_padding(bmap);
return;
}
@@ -651,10 +624,9 @@ void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap gen_bmap)
/* XXX ought to warn on error */
}
-int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
+int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap,
blk64_t block, unsigned int num)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
__u64 end = block + num;
if (!bmap)
@@ -696,10 +668,9 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
return bmap->bitmap_ops->test_clear_bmap_extent(bmap, block, num);
}
-void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
+void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap,
blk64_t block, unsigned int num)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
__u64 end = block + num;
if (!bmap)
@@ -737,10 +708,9 @@ void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
bmap->bitmap_ops->mark_bmap_extent(bmap, block, num);
}
-void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
+void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap,
blk64_t block, unsigned int num)
{
- ext2fs_generic_bitmap_64 bmap = (ext2fs_generic_bitmap_64) gen_bmap;
__u64 end = block + num;
if (!bmap)
@@ -778,10 +748,8 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap gen_bmap,
bmap->bitmap_ops->unmark_bmap_extent(bmap, block, num);
}
-void ext2fs_warn_bitmap32(ext2fs_generic_bitmap gen_bitmap, const char *func)
+void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func)
{
- ext2fs_generic_bitmap_64 bitmap = (ext2fs_generic_bitmap_64) gen_bitmap;
-
#ifndef OMIT_COM_ERR
if (bitmap && bitmap->description)
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
@@ -796,22 +764,21 @@ void ext2fs_warn_bitmap32(ext2fs_generic_bitmap gen_bitmap, const char *func)
errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
ext2fs_block_bitmap *bitmap)
{
- ext2fs_generic_bitmap_64 bmap, cmap;
- ext2fs_block_bitmap gen_bmap = *bitmap, gen_cmap;
+ ext2fs_block_bitmap cmap, bmap;
errcode_t retval;
blk64_t i, b_end, c_end;
int n, ratio;
- bmap = (ext2fs_generic_bitmap_64) gen_bmap;
- if (fs->cluster_ratio_bits == ext2fs_get_bitmap_granularity(gen_bmap))
+ bmap = *bitmap;
+
+ if (fs->cluster_ratio_bits == ext2fs_get_bitmap_granularity(bmap))
return 0; /* Nothing to do */
retval = ext2fs_allocate_block_bitmap(fs, "converted cluster bitmap",
- &gen_cmap);
+ &cmap);
if (retval)
return retval;
- cmap = (ext2fs_generic_bitmap_64) gen_cmap;
i = bmap->start;
b_end = bmap->end;
bmap->end = bmap->real_end;
@@ -820,8 +787,8 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
n = 0;
ratio = 1 << fs->cluster_ratio_bits;
while (i < bmap->real_end) {
- if (ext2fs_test_block_bitmap2(gen_bmap, i)) {
- ext2fs_mark_block_bitmap2(gen_cmap, i);
+ if (ext2fs_test_block_bitmap2(bmap, i)) {
+ ext2fs_mark_block_bitmap2(cmap, i);
i += ratio - n;
n = 0;
continue;
@@ -832,15 +799,14 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
}
bmap->end = b_end;
cmap->end = c_end;
- ext2fs_free_block_bitmap(gen_bmap);
- *bitmap = (ext2fs_block_bitmap) cmap;
+ ext2fs_free_block_bitmap(bmap);
+ *bitmap = cmap;
return 0;
}
errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out)
{
- ext2fs_generic_bitmap_64 bmap64 = (ext2fs_generic_bitmap_64) bitmap;
__u64 cstart, cend, cout;
errcode_t retval;
@@ -866,27 +832,27 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
if (!EXT2FS_IS_64_BITMAP(bitmap))
return EINVAL;
- cstart = start >> bmap64->cluster_bits;
- cend = end >> bmap64->cluster_bits;
+ cstart = start >> bitmap->cluster_bits;
+ cend = end >> bitmap->cluster_bits;
- if (cstart < bmap64->start || cend > bmap64->end || start > end) {
- warn_bitmap(bmap64, EXT2FS_TEST_ERROR, start);
+ if (cstart < bitmap->start || cend > bitmap->end || start > end) {
+ warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start);
return EINVAL;
}
- if (bmap64->bitmap_ops->find_first_zero) {
- retval = bmap64->bitmap_ops->find_first_zero(bmap64, cstart,
+ if (bitmap->bitmap_ops->find_first_zero) {
+ retval = bitmap->bitmap_ops->find_first_zero(bitmap, cstart,
cend, &cout);
if (retval)
return retval;
found:
- cout <<= bmap64->cluster_bits;
+ cout <<= bitmap->cluster_bits;
*out = (cout >= start) ? cout : start;
return 0;
}
for (cout = cstart; cout <= cend; cout++)
- if (!bmap64->bitmap_ops->test_bmap(bmap64, cout))
+ if (!bitmap->bitmap_ops->test_bmap(bitmap, cout))
goto found;
return ENOENT;
@@ -895,7 +861,6 @@ errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end, __u64 *out)
{
- ext2fs_generic_bitmap_64 bmap64 = (ext2fs_generic_bitmap_64) bitmap;
__u64 cstart, cend, cout;
errcode_t retval;
@@ -921,27 +886,27 @@ errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
if (!EXT2FS_IS_64_BITMAP(bitmap))
return EINVAL;
- cstart = start >> bmap64->cluster_bits;
- cend = end >> bmap64->cluster_bits;
+ cstart = start >> bitmap->cluster_bits;
+ cend = end >> bitmap->cluster_bits;
- if (cstart < bmap64->start || cend > bmap64->end || start > end) {
- warn_bitmap(bmap64, EXT2FS_TEST_ERROR, start);
+ if (cstart < bitmap->start || cend > bitmap->end || start > end) {
+ warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start);
return EINVAL;
}
- if (bmap64->bitmap_ops->find_first_set) {
- retval = bmap64->bitmap_ops->find_first_set(bmap64, cstart,
+ if (bitmap->bitmap_ops->find_first_set) {
+ retval = bitmap->bitmap_ops->find_first_set(bitmap, cstart,
cend, &cout);
if (retval)
return retval;
found:
- cout <<= bmap64->cluster_bits;
+ cout <<= bitmap->cluster_bits;
*out = (cout >= start) ? cout : start;
return 0;
}
for (cout = cstart; cout <= cend; cout++)
- if (bmap64->bitmap_ops->test_bmap(bmap64, cout))
+ if (bitmap->bitmap_ops->test_bmap(bitmap, cout))
goto found;
return ENOENT;
--
2.21.3
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pang-qing/e2fsprogs.git
git@gitee.com:pang-qing/e2fsprogs.git
pang-qing
e2fsprogs
e2fsprogs
a8

搜索帮助