From: Karol Lewandowski Date: Wed, 10 Feb 2021 15:57:49 +0000 (+0100) Subject: Merge branch 'upstream' into tizen_base X-Git-Tag: accepted/tizen/6.5/base/20230714.002449^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=515ae81590edfb1e35ea9ce5ed31a5c893814157;hp=b741827a4f766d7503c334994f6c7fa29b3a0018;p=platform%2Fupstream%2Fe2fsprogs.git Merge branch 'upstream' into tizen_base Change-Id: I3cf7519103132fc9e078433a621ba4e476754060 --- diff --git a/NOTICE b/NOTICE index da98a3e..a21e282 100644 --- a/NOTICE +++ b/NOTICE @@ -847,3 +847,26 @@ necessary. Here is a sample; alter the names: Ty Coon, President of Vice That's all there is to it! + +---------------------------------------------------------------------- + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/e2fsprogs.spec b/e2fsprogs.spec index a8fd1dd..1cb83d6 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -7,7 +7,7 @@ Summary: Utilities for managing ext2/ext3/ext4 filesystems Name: e2fsprogs Version: 1.46.0 Release: 0 -License: GPLv2 +License: GPL-2.0 Group: System Environment/Base Source: ftp://download.sourceforge.net/pub/sourceforge/e2fsprogs/e2fsprogs-%{version}.tar.gz Url: http://e2fsprogs.sourceforge.net/ @@ -49,7 +49,7 @@ e2fsprogs-devel, you'll also want to install e2fsprogs. %package -n uuidd Summary: helper daemon to guarantee uniqueness of time-based UUIDs Group: System Environment/Daemons -License: GPLv2 +License: BSD-3-Clause Requires: e2fsprogs = %{version} Requires(pre): shadow-utils diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 84248ff..62d06c8 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -56,6 +56,10 @@ mke2fs \- create an ext2/ext3/ext4 filesystem .I number-of-inodes ] [ +.B \-d +.I root-directory +] +[ .B \-n ] [ @@ -647,6 +651,9 @@ the ratio). This allows the user to specify the number of desired inodes directly. .TP +.BI \-d " root-directory" +Add the files from the root-directory to the filesystem. +.TP .BI \-o " creator-os" Overrides the default value of the "creator operating system" field of the filesystem. The creator field is set by default to the name of the OS the diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf new file mode 100644 index 0000000..f51716c --- /dev/null +++ b/packaging/baselibs.conf @@ -0,0 +1,10 @@ +libext2fs + targetarch ia64 block! +libcom_err + targetarch ia64 block! +e2fsprogs +e2fsprogs-devel +libext2fs-devel + requires "libext2fs- = " +libcom_err-devel + requires "libcom_err- = " diff --git a/packaging/e2fsck.conf b/packaging/e2fsck.conf new file mode 100644 index 0000000..489668f --- /dev/null +++ b/packaging/e2fsck.conf @@ -0,0 +1,4 @@ +[options] +# This will prevent e2fsck from stopping boot just because the clock is wrong +broken_system_clock = 1 + diff --git a/packaging/e2fsprogs.changes b/packaging/e2fsprogs.changes new file mode 100644 index 0000000..23e25ce --- /dev/null +++ b/packaging/e2fsprogs.changes @@ -0,0 +1,9 @@ +* Sat May 11 2013 Anas Nashif submit/tizen/20130509.173946@4ee9d9d +- Set license using %license + +* Fri Dec 21 2012 Anas Nashif upstream/1.42.4@5438d17 +- Update to 1.42.6 + +* Fri Dec 14 2012 Anas Nashif upstream/1.42.4@8afbc93 +- Initail import + diff --git a/packaging/e2fsprogs.manifest b/packaging/e2fsprogs.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/packaging/e2fsprogs.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/e2fsprogs.spec b/packaging/e2fsprogs.spec new file mode 100755 index 0000000..b7033a4 --- /dev/null +++ b/packaging/e2fsprogs.spec @@ -0,0 +1,204 @@ +Name: e2fsprogs +BuildRequires: autoconf +BuildRequires: libblkid-devel +BuildRequires: libuuid-devel +BuildRequires: pkg-config +Version: 1.46.0 +Release: 0 +Summary: Utilities for the Second Extended File System +License: GPL-2.0 +Group: System/Filesystems +Url: http://e2fsprogs.sourceforge.net +Requires: libcom_err >= %{version} +Requires: libext2fs >= %{version} +Source: http://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v%{version}/e2fsprogs-%{version}.tar.xz +Source1: baselibs.conf +Source2: e2fsck.conf +Source1001: e2fsprogs.manifest + +%description +Utilities needed to create and maintain ext2 and ext3 file systems +under Linux. Included in this package are: chattr, lsattr, mke2fs, +mklost+found, tune2fs, e2fsck, resize2fs, and badblocks. + +%package devel +Summary: Dummy development package +License: LGPL-2.0 +Group: Base/Development +Requires: libblkid-devel +Requires: libext2fs-devel = %version +Requires: libuuid-devel + +%description devel +Dummy development package for backwards compatibility. + +%package -n libext2fs +Summary: Ext2fs library +License: LGPL-2.0 +Group: Base/File Systems + +%description -n libext2fs +The basic Ext2fs shared library. + +%package -n libext2fs-devel +Summary: Development files for libext2fs +License: LGPL-2.0 +Group: Base/Development +Requires: libcom_err-devel +Requires: libext2fs = %version + +%description -n libext2fs-devel +Development files for libext2fs. + +%package -n libcom_err +Summary: E2fsprogs error reporting library +License: MIT +Group: Base/File Systems + +%description -n libcom_err +com_err is an error message display library. + +%package -n libcom_err-devel +Summary: Development files for libcom_err +License: MIT +Group: Base/Development +Requires: glibc-devel +Requires: libcom_err = %version + +%description -n libcom_err-devel +Development files for the com_err error message display library. + +%prep +%setup -q +cp %{SOURCE1001} . + +%build +%{?asan:%restore_fcommon} +export CFLAGS="${CFLAGS} -fPIE -flto " +export LDFLAGS="${LDFLAGS} -pie -flto " +%configure \ + --disable-evms \ + --with-root-prefix='' \ + --enable-elf-shlibs \ + --disable-libblkid \ + --disable-libuuid \ + --disable-uuidd \ + --disable-nls \ + --disable-fsck \ + --enable-hardening \ + +make %{?_smp_mflags} V=1 + +%install +make install install-libs DESTDIR=$RPM_BUILD_ROOT ELF_INSTALL_DIR=/%{_libdir} +find "%buildroot/%_libdir" -type f -name "*.a" \ + -print -delete +# Let boot continue even if system clock is wrong +install -p -m 644 %{SOURCE2} %{buildroot}/etc/e2fsck.conf + + +rm $RPM_BUILD_ROOT%{_libdir}/e2initrd_helper +rm -f $RPM_BUILD_ROOT/%{_sbindir}/mkfs.ext4dev +rm -f $RPM_BUILD_ROOT/%{_sbindir}/fsck.ext4dev +rm -f $RPM_BUILD_ROOT/usr/share/man/man8/mkfs.ext4dev.8* +rm -f $RPM_BUILD_ROOT/usr/share/man/man8/fsck.ext4dev.8* + +mkdir -p %{buildroot}/%{_defaultdocdir}/%{name} +install -p -m 644 README %{buildroot}/%{_defaultdocdir}/%{name}/README +install -p -m 644 RELEASE-NOTES %{buildroot}/%{_defaultdocdir}/%{name}/RELEASE-NOTES + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%post -n libext2fs -p /sbin/ldconfig + +%postun -n libext2fs -p /sbin/ldconfig + +%post -n libcom_err -p /sbin/ldconfig + +%postun -n libcom_err -p /sbin/ldconfig + +%docs_package +%doc %{_defaultdocdir}/%{name}/RELEASE-NOTES +%doc %{_defaultdocdir}/%{name}/README + +%files devel +%manifest %{name}.manifest +%doc README + +%files +%manifest %{name}.manifest +%defattr(-, root, root) +%license NOTICE +%config /etc/e2fsck.conf +%config /etc/mke2fs.conf +%config /etc/e2scrub.conf +%{_sbindir}/badblocks +%{_sbindir}/debugfs +%{_sbindir}/dumpe2fs +%{_sbindir}/e2undo +%{_sbindir}/e2fsck +%{_sbindir}/e2label +%{_sbindir}/e2scrub +%{_sbindir}/e2scrub_all +%{_sbindir}/fsck.ext2 +%{_sbindir}/fsck.ext3 +%{_sbindir}/fsck.ext4 +%{_sbindir}/mke2fs +%{_sbindir}/mkfs.ext2 +%{_sbindir}/mkfs.ext3 +%{_sbindir}/mkfs.ext4 +%{_sbindir}/resize2fs +%{_sbindir}/tune2fs +%{_sbindir}/e2image +%{_sbindir}/logsave +%{_bindir}/chattr +%{_bindir}/lsattr +%{_sbindir}/mklost+found +%{_sbindir}/filefrag +%{_sbindir}/e2freefrag +%{_sbindir}/e2mmpstatus +%{_sbindir}/e4crypt +%{_sbindir}/e4defrag + +%files -n libext2fs +%manifest %{name}.manifest +%defattr(-, root, root) +%license NOTICE +%{_libdir}/libext2fs.so.* +%{_libdir}/libe2p.so.* + +%files -n libext2fs-devel +%manifest %{name}.manifest +%defattr(-, root, root) +%{_libdir}/libext2fs.so +%{_libdir}/libe2p.so +/usr/include/ext2fs +/usr/include/e2p +%_libdir/pkgconfig/e2p.pc +%_libdir/pkgconfig/ext2fs.pc + +%files -n libcom_err +%manifest %{name}.manifest +%defattr(-, root, root) +%license debian/copyright +%{_libdir}/libcom_err.so.* +%{_libdir}/libss.so.* + +%files -n libcom_err-devel +%manifest %{name}.manifest +%defattr(-, root, root) +%_bindir/compile_et +%_bindir/mk_cmds +%{_libdir}/libcom_err.so +%{_libdir}/libss.so +%_libdir/pkgconfig/com_err.pc +%_libdir/pkgconfig/ss.pc +%_includedir/com_err.h +%_includedir/et +%_includedir/ss +%_datadir/et +%_datadir/ss + +%changelog diff --git a/resize/resize2fs.c b/resize/resize2fs.c old mode 100644 new mode 100755 index 270e4de..d14d55f --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -2893,11 +2893,12 @@ static int calc_group_overhead(ext2_filsys fs, blk64_t grp, blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) { ext2_ino_t inode_count; - dgrp_t groups, flex_groups; + dgrp_t groups; blk64_t blks_needed, data_blocks; blk64_t grp, data_needed, last_start; blk64_t overhead = 0; int old_desc_blocks; + int extra_groups = 0; int flexbg_size = 1 << fs->super->s_log_groups_per_flex; /* @@ -2942,13 +2943,10 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) * inode tables of slack space so the resize operation can be * guaranteed to finish. */ - flex_groups = groups; - if (ext2fs_has_feature_flex_bg(fs->super)) { - dgrp_t remainder = groups & (flexbg_size - 1); - - flex_groups += flexbg_size - remainder; - if (flex_groups > fs->group_desc_count) - flex_groups = fs->group_desc_count; + if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) { + extra_groups = flexbg_size - (groups & (flexbg_size - 1)); + data_needed += fs->inode_blocks_per_group * extra_groups; + extra_groups = groups % flexbg_size; } /* @@ -2957,7 +2955,7 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) */ data_blocks = EXT2_GROUPS_TO_BLOCKS(fs->super, groups); last_start = 0; - for (grp = 0; grp < flex_groups; grp++) { + for (grp = 0; grp < groups; grp++) { overhead = calc_group_overhead(fs, grp, old_desc_blocks); /* @@ -2965,14 +2963,11 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) * the groups leading up to the last group so we can determine * how big the last group needs to be */ - if (grp < (groups - 1)) + if (grp != (groups - 1)) last_start += EXT2_BLOCKS_PER_GROUP(fs->super) - overhead; - if (data_blocks > overhead) - data_blocks -= overhead; - else - data_blocks = 0; + data_blocks -= overhead; } #ifdef RESIZE2FS_DEBUG if (flags & RESIZE_DEBUG_MIN_CALC) @@ -2984,9 +2979,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) * if we need more group descriptors in order to accommodate our data * then we need to add them here */ - blks_needed = data_needed; - while (blks_needed > data_blocks) { - blk64_t remainder = blks_needed - data_blocks; + while (data_needed > data_blocks) { + blk64_t remainder = data_needed - data_blocks; dgrp_t extra_grps; /* figure out how many more groups we need for the data */ @@ -2999,19 +2993,7 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) overhead = calc_group_overhead(fs, groups-1, old_desc_blocks); last_start += EXT2_BLOCKS_PER_GROUP(fs->super) - overhead; - grp = flex_groups; - groups += extra_grps; - if (!ext2fs_has_feature_flex_bg(fs->super)) - flex_groups = groups; - else if (groups > flex_groups) { - dgrp_t r = groups & (flexbg_size - 1); - - flex_groups = groups + flexbg_size - r; - if (flex_groups > fs->group_desc_count) - flex_groups = fs->group_desc_count; - } - - for (; grp < flex_groups; grp++) { + for (grp = groups; grp < groups+extra_grps; grp++) { overhead = calc_group_overhead(fs, grp, old_desc_blocks); @@ -3019,31 +3001,41 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) * again, we need to see how much data we cram into * all of the groups leading up to the last group */ - if (grp < groups - 1) + if (grp != (groups + extra_grps - 1)) last_start += EXT2_BLOCKS_PER_GROUP(fs->super) - overhead; data_blocks -= overhead; } + groups += extra_grps; + extra_groups += extra_grps; + if (fs->super->s_feature_incompat + & EXT4_FEATURE_INCOMPAT_FLEX_BG + && extra_groups > flexbg_size) { + /* + * For ext4 we need to allow for up to a flex_bg worth + * of inode tables of slack space so the resize + * operation can be guaranteed to finish. + */ + extra_groups = flexbg_size - + (groups & (flexbg_size - 1)); + data_needed += (fs->inode_blocks_per_group * + extra_groups); + extra_groups = groups % flexbg_size; + } #ifdef RESIZE2FS_DEBUG if (flags & RESIZE_DEBUG_MIN_CALC) printf("Added %d extra group(s), " - "blks_needed %llu, data_blocks %llu, " - "last_start %llu\n", extra_grps, blks_needed, - data_blocks, last_start); + "data_needed %llu, data_blocks %llu, " + "last_start %llu\n", + extra_grps, data_needed, data_blocks, + last_start); #endif } /* now for the fun voodoo */ - grp = groups - 1; - if (ext2fs_has_feature_flex_bg(fs->super) && - (grp & ~(flexbg_size - 1)) == 0) - grp = grp & ~(flexbg_size - 1); - overhead = 0; - for (; grp < flex_groups; grp++) - overhead += calc_group_overhead(fs, grp, old_desc_blocks); - + overhead = calc_group_overhead(fs, groups-1, old_desc_blocks); #ifdef RESIZE2FS_DEBUG if (flags & RESIZE_DEBUG_MIN_CALC) printf("Last group's overhead is %llu\n", overhead); @@ -3053,8 +3045,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) * if this is the case then the last group is going to have data in it * so we need to adjust the size of the last group accordingly */ - if (last_start < blks_needed) { - blk64_t remainder = blks_needed - last_start; + if (last_start < data_needed) { + blk64_t remainder = data_needed - last_start; #ifdef RESIZE2FS_DEBUG if (flags & RESIZE_DEBUG_MIN_CALC) @@ -3080,15 +3072,10 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) printf("Final size of last group is %lld\n", overhead); #endif - /* Add extra slack for bigalloc file systems */ - if (EXT2FS_CLUSTER_RATIO(fs) > 1) - overhead += EXT2FS_CLUSTER_RATIO(fs) * 2; - /* - * since our last group doesn't have to be BLOCKS_PER_GROUP - * large, we only do groups-1, and then add the number of - * blocks needed to handle the group descriptor metadata+data - * that we need + * since our last group doesn't have to be BLOCKS_PER_GROUP large, we + * only do groups-1, and then add the number of blocks needed to + * handle the group descriptor metadata+data that we need */ blks_needed = EXT2_GROUPS_TO_BLOCKS(fs->super, groups - 1); blks_needed += overhead; @@ -3117,25 +3104,10 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags) * We need to reserve a few extra blocks if extents are * enabled, in case we need to grow the extent tree. The more * we shrink the file system, the more space we need. - * - * The absolute worst case is every single data block is in - * the part of the file system that needs to be evacuated, - * with each data block needs to be in its own extent, and - * with each inode needing at least one extent block. */ if (ext2fs_has_feature_extents(fs->super)) { blk64_t safe_margin = (ext2fs_blocks_count(fs->super) - blks_needed)/500; - unsigned int exts_per_blk = (fs->blocksize / - sizeof(struct ext3_extent)) - 1; - blk64_t worst_case = ((data_needed + exts_per_blk - 1) / - exts_per_blk); - - if (worst_case < inode_count) - worst_case = inode_count; - - if (safe_margin > worst_case) - safe_margin = worst_case; #ifdef RESIZE2FS_DEBUG if (flags & RESIZE_DEBUG_MIN_CALC) diff --git a/tests/scripts/resize_test b/tests/scripts/resize_test index 3c5e260..034ec9f 100755 --- a/tests/scripts/resize_test +++ b/tests/scripts/resize_test @@ -9,7 +9,6 @@ truncate() } resize_test () { -DBG_FLAGS=63 echo $test_description starting > $LOG rm -f $TMPFILE @@ -58,8 +57,8 @@ rm -f $OUT_TMP echo $FSCK -fy $TMPFILE >> $LOG 2>&1 $FSCK -fy $TMPFILE >> $LOG 2>&1 -echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1 -if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1 +echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1 +if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1 then return 1 fi @@ -83,13 +82,8 @@ then return 1 fi -# Uncomment to grab extra debugging image -# -#mv $TMPFILE /tmp/foo.img -#return 0 - -echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1 -if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1 +echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 +if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 then return 1 fi @@ -113,8 +107,8 @@ then return 1 fi -echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1 -if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1 +echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 +if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 then return 1 fi @@ -138,8 +132,8 @@ then return 1 fi -echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1 -if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1 +echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 +if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 then return 1 fi