summaryrefslogtreecommitdiffstats
path: root/source/a/zerofree
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2020-01-31 20:46:25 +0000
committer Eric Hameleers <alien@slackware.com>2020-02-01 08:59:50 +0100
commit4e955dc4b6fff43956d47c0286bb698e03f14b11 (patch)
tree8821f786c06617480dce97b28c23ee78836010c2 /source/a/zerofree
parent0012caf61824ffcca7bbe5cd19b79612d6445307 (diff)
downloadcurrent-4e955dc4b6fff43956d47c0286bb698e03f14b11.tar.gz
current-4e955dc4b6fff43956d47c0286bb698e03f14b11.tar.xz
Fri Jan 31 20:46:25 UTC 202020200131204625
a/util-linux-2.35.1-x86_64-1.txz: Upgraded. a/zerofree-1.1.1-x86_64-1.txz: Added. Also queued up for the next installer build. Thanks to bifferos. ap/sudo-1.8.31-x86_64-1.txz: Upgraded. This update fixes a security issue: In Sudo before 1.8.31, if pwfeedback is enabled in /etc/sudoers, users can trigger a stack-based buffer overflow in the privileged sudo process. (pwfeedback is a default setting in some Linux distributions; however, it is not the default for upstream or in Slackware, and would exist only if enabled by an administrator.) The attacker needs to deliver a long string to the stdin of getln() in tgetpass.c. For more information, see: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-18634 (* Security fix *) n/NetworkManager-1.22.6-x86_64-1.txz: Upgraded. n/openldap-client-2.4.49-x86_64-1.txz: Upgraded. xfce/Thunar-1.8.11-x86_64-1.txz: Removed. xfce/thunar-1.8.12-x86_64-1.txz: Added. Changed package name from "Thunar" to "thunar" to follow upstream's naming.
Diffstat (limited to 'source/a/zerofree')
-rw-r--r--source/a/zerofree/slack-desc19
-rw-r--r--source/a/zerofree/sparsify.c274
-rwxr-xr-xsource/a/zerofree/zerofree.SlackBuild115
-rw-r--r--source/a/zerofree/zerofree.sgml163
4 files changed, 571 insertions, 0 deletions
diff --git a/source/a/zerofree/slack-desc b/source/a/zerofree/slack-desc
new file mode 100644
index 000000000..261ae363f
--- /dev/null
+++ b/source/a/zerofree/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+zerofree: zerofree (zero free blocks from ext* filesystems)
+zerofree:
+zerofree: Zerofree finds the unallocated, non-zeroed blocks in an ext2, ext3,
+zerofree: or ext4 filesystem and fills them with zeroes. This is useful if the
+zerofree: device on which this file-system resides is a disk image. In this
+zerofree: case, depending on the type of disk image, a secondary utility may be
+zerofree: able to reduce the size of the disk image after zerofree has been run.
+zerofree:
+zerofree: Homepage: https://frippery.org/uml/
+zerofree:
+zerofree:
diff --git a/source/a/zerofree/sparsify.c b/source/a/zerofree/sparsify.c
new file mode 100644
index 000000000..4c52e0075
--- /dev/null
+++ b/source/a/zerofree/sparsify.c
@@ -0,0 +1,274 @@
+/*
+ * sparsify - a tool to make files on an ext2 filesystem sparse
+ *
+ * Copyright (C) 2004-2012 R M Yorston
+ *
+ * This file may be redistributed under the terms of the GNU General Public
+ * License, version 2.
+ */
+#include <ext2fs/ext2fs.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#define USAGE "usage: %s [-n] [-v] filesystem filename ...\n"
+
+/* initially assume pre-ext4 API version */
+#define API 140
+
+#if defined(BLOCK_FLAG_READ_ONLY)
+#undef API
+#define API 141
+#endif
+
+#if defined(EXT2_FLAG_64BITS)
+#undef API
+#define API 142
+#endif
+
+struct process_data {
+ unsigned char *buf;
+ int verbose;
+ int dryrun;
+ blk_t count;
+ blk_t blocks;
+ blk_t total_blocks;
+ int old_percent;
+};
+
+static int process(ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt,
+ blk_t ref_block, int ref_offset, void *priv)
+{
+ struct process_data *p;
+ errcode_t errcode;
+ int i, group;
+ int ret = 0;
+
+ p = (struct process_data *)priv;
+
+ p->blocks++;
+ if ( blockcnt >= 0 ) {
+ errcode = io_channel_read_blk(fs->io, *blocknr, 1, p->buf);
+ if ( errcode ) {
+ return BLOCK_ABORT;
+ }
+
+ for ( i=0; i < fs->blocksize; ++i ) {
+ if ( p->buf[i] ) {
+ break;
+ }
+ }
+
+ if ( i == fs->blocksize ) {
+ p->count++;
+
+ if ( !p->dryrun ) {
+ ext2fs_unmark_block_bitmap(fs->block_map, *blocknr);
+ group = ext2fs_group_of_blk(fs, *blocknr);
+#if API >= 142
+ ext2fs_bg_free_blocks_count_set(fs, group,
+ ext2fs_bg_free_blocks_count(fs, group)+1);
+ ext2fs_free_blocks_count_add(fs->super, (blk64_t)1);
+#else
+ fs->group_desc[group].bg_free_blocks_count++;
+ fs->super->s_free_blocks_count++;
+#endif
+#if API >= 141
+ ext2fs_group_desc_csum_set(fs, group);
+#endif
+ *blocknr = 0;
+ ret = BLOCK_CHANGED;
+ }
+ }
+
+ if ( p->verbose ) {
+ double percent;
+
+ percent = 100.0 * (double)p->blocks/(double)p->total_blocks;
+
+ if ( (int)(percent*10) != p->old_percent ) {
+ fprintf(stderr, "\r%4.1f%%", percent);
+ p->old_percent = (int)(percent*10);
+ }
+ }
+ }
+
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ int verbose = 0;
+ int dryrun = 0;
+ errcode_t ret;
+ int flags;
+ int superblock = 0;
+ int open_flags = EXT2_FLAG_RW;
+ int iter_flags = 0;
+ int blocksize = 0;
+ ext2_filsys fs = NULL;
+ struct ext2_inode inode;
+ ext2_ino_t root, cwd, inum;
+ int i, c;
+ struct process_data pdata;
+
+ while ( (c=getopt(argc, argv, "nv")) != -1 ) {
+ switch (c) {
+ case 'n' :
+ dryrun = 1;
+#if defined(BLOCK_FLAG_READ_ONLY)
+ iter_flags |= BLOCK_FLAG_READ_ONLY;
+#endif
+ break;
+ case 'v' :
+ verbose = 1;
+ break;
+ default :
+ fprintf(stderr, USAGE, argv[0]);
+ return 1;
+ }
+ }
+
+ if ( argc < optind+2 ) {
+ fprintf(stderr, USAGE, argv[0]);
+ return 1;
+ }
+
+ ret = ext2fs_check_if_mounted(argv[optind], &flags);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to determine filesystem mount state %s\n",
+ argv[0], argv[optind]);
+ return 1;
+ }
+
+ if ( flags & EXT2_MF_MOUNTED ) {
+ fprintf(stderr, "%s: filesystem %s is mounted\n",
+ argv[0], argv[optind]);
+ return 1;
+ }
+
+ ret = ext2fs_open(argv[optind], open_flags, superblock, blocksize,
+ unix_io_manager, &fs);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to open filesystem %s\n",
+ argv[0], argv[optind]);
+ return 1;
+ }
+
+ pdata.buf = (unsigned char *)malloc(fs->blocksize);
+ if ( pdata.buf == NULL ) {
+ fprintf(stderr, "%s: out of memory (surely not?)\n", argv[0]);
+ return 1;
+ }
+
+ ret = ext2fs_read_inode_bitmap(fs);
+ if ( ret ) {
+ fprintf(stderr, "%s: error while reading inode bitmap\n", argv[0]);
+ return 1;
+ }
+
+ ret = ext2fs_read_block_bitmap(fs);
+ if ( ret ) {
+ fprintf(stderr, "%s: error while reading block bitmap\n", argv[0]);
+ return 1;
+ }
+
+ root = cwd = EXT2_ROOT_INO;
+
+ for ( i=optind+1; i<argc; ++i ) {
+ ret = ext2fs_namei(fs, root, cwd, argv[i], &inum);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to find file %s\n", argv[0], argv[i]);
+ continue;
+ }
+
+ ret = ext2fs_read_inode(fs, inum, &inode);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to open inode %d\n", argv[0], inum);
+ continue;
+ }
+
+ if ( !ext2fs_inode_has_valid_blocks(&inode) ) {
+ fprintf(stderr, "%s: file %s has no valid blocks\n", argv[0],
+ argv[i]);
+ continue;
+ }
+
+#if defined(EXT4_EXTENTS_FL) && API < 141
+ if ( inode.i_flags & EXT4_EXTENTS_FL ) {
+ fprintf(stderr, "%s: unable to process %s, it uses extents\n",
+ argv[0], argv[i]);
+ continue;
+ }
+#endif
+
+#if defined(EXT4_FEATURE_RO_COMPAT_HUGE_FILE) && defined(EXT4_HUGE_FILE_FL)
+ if ( (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
+ && (inode.i_flags & EXT4_HUGE_FILE_FL) ) {
+ fprintf(stderr, "%s: unable to process %s, it's huge\n",
+ argv[0], argv[i]);
+ continue;
+ }
+#endif
+
+ if ( verbose ) {
+ printf("processing %s\n", argv[i]);
+ }
+
+ pdata.verbose = verbose;
+ pdata.dryrun = dryrun;
+ pdata.count = pdata.blocks = 0;
+ pdata.total_blocks = inode.i_blocks/(fs->blocksize >> 9);
+ pdata.old_percent = 1000;
+ ret = ext2fs_block_iterate2(fs, inum, iter_flags, NULL,
+ process, &pdata);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to process file %s\n", argv[0],
+ argv[i]);
+ continue;
+ }
+
+ if ( pdata.count && !dryrun ) {
+ ext2fs_mark_bb_dirty(fs);
+ ext2fs_mark_super_dirty(fs);
+
+ ret = ext2fs_read_inode(fs, inum, &inode);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to open inode (%s)\n", argv[0],
+ argv[i]);
+ continue;
+ }
+
+#if API >= 141
+ ret = ext2fs_iblk_sub_blocks(fs, &inode, (blk64_t)pdata.count);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to update block count (%s)\n",
+ argv[0], argv[i]);
+ continue;
+ }
+#else
+ inode.i_blocks -= pdata.count * (fs->blocksize >> 9);
+#endif
+
+ ret = ext2fs_write_inode(fs, inum, &inode);
+ if ( ret ) {
+ fprintf(stderr, "%s: failed to write inode (%s)\n",
+ argv[0], argv[i]);
+ continue;
+ }
+ }
+
+ if ( verbose ) {
+ printf("\r%d/%d/%d %s\n", pdata.count, pdata.blocks,
+ pdata.total_blocks, argv[i]);
+ }
+ }
+
+ ret = ext2fs_close(fs);
+ if ( ret ) {
+ fprintf(stderr, "%s: error while closing filesystem\n", argv[0]);
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/source/a/zerofree/zerofree.SlackBuild b/source/a/zerofree/zerofree.SlackBuild
new file mode 100755
index 000000000..3553afce1
--- /dev/null
+++ b/source/a/zerofree/zerofree.SlackBuild
@@ -0,0 +1,115 @@
+#!/bin/bash
+
+# Copyright 2020 Patrick J. Volkerding, Sebeka, Minnesota, USA
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+cd $(dirname $0) ; CWD=$(pwd)
+
+PKGNAM=zerofree
+VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
+BUILD=${BUILD:-1}
+
+# Automatically determine the architecture we're building on:
+if [ -z "$ARCH" ]; then
+ case "$(uname -m)" in
+ i?86) ARCH=i586 ;;
+ arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;;
+ # Unless $ARCH is already set, use uname -m for all other archs:
+ *) ARCH=$(uname -m) ;;
+ esac
+ export ARCH
+fi
+
+# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
+# the name of the created package would be, and then exit. This information
+# could be useful to other scripts.
+if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
+ echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz"
+ exit 0
+fi
+
+NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}
+
+if [ "$ARCH" = "i586" ]; then
+ SLKCFLAGS="-O2 -march=i586 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "s390" ]; then
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+elif [ "$ARCH" = "armv7hl" ]; then
+ SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16"
+ LIBDIRSUFFIX=""
+else
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+fi
+
+TMP=${TMP:-/tmp}
+PKG=$TMP/package-$PKGNAM
+
+rm -rf $PKG
+mkdir -p $TMP $PKG
+
+cd $TMP
+rm -rf $PKGNAM-$VERSION
+tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1
+cd $PKGNAM-$VERSION || exit 1
+
+chown -R root:root .
+find . \
+ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
+ -exec chmod 755 {} \+ -o \
+ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
+ -exec chmod 644 {} \+
+
+CFLAGS="$SLKCFLAGS" make
+
+mkdir -p $PKG/usr/sbin
+cp -a zerofree $PKG/usr/sbin/zerofree
+gcc $SLKCFLAGS $CWD/sparsify.c -o $PKG/usr/sbin/sparsify -lext2fs
+strip --strip-unneeded $PKG/usr/sbin/*
+mkdir -p $PKG/usr/man/man8
+docbook2man -o $PKG/usr/man/man8 $CWD/zerofree.sgml
+rm -f $PKG/usr/man/man8/manpage*
+mv $PKG/usr/man/man8/ZEROFREE.8 $PKG/usr/man/man8/zerofree.8 || exit 1
+gzip -9 $PKG/usr/man/man8/zerofree.8
+
+# Add a documentation directory:
+mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
+cat << EOF > $PKG/usr/doc/${PKGNAM}-$VERSION/LICENSE
+ * zerofree - a tool to zero free blocks in an ext[2-4] filesystem
+ *
+ * Copyright (C) 2004-2017 R M Yorston
+ *
+ * This file may be redistributed under the terms of the GNU General Public
+ * License, version 2.
+EOF
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz
diff --git a/source/a/zerofree/zerofree.sgml b/source/a/zerofree/zerofree.sgml
new file mode 100644
index 000000000..af6e3a537
--- /dev/null
+++ b/source/a/zerofree/zerofree.sgml
@@ -0,0 +1,163 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+
+<!-- Process this file with docbook-to-man to generate an nroff manual
+ page: `docbook-to-man manpage.sgml > manpage.1'. You may view
+ the manual page with: `docbook-to-man manpage.sgml | nroff -man |
+ less'.
+ -->
+
+ <!ENTITY dhfirstname "<firstname>Thibaut</firstname>">
+ <!ENTITY dhsurname "<surname>Paumard</surname>">
+ <!-- Please adjust the date whenever revising the manpage. -->
+ <!ENTITY dhdate "<date>February 6, 2008</date>">
+ <!ENTITY dhsection "<manvolnum>8</manvolnum>">
+ <!ENTITY dhemail "<email>&lt;paumard@users.sourceforge.net&gt;</email>">
+ <!ENTITY dhusername "Thibaut Paumard">
+ <!ENTITY dhucpackage "<refentrytitle>ZEROFREE</refentrytitle>">
+ <!ENTITY dhpackage "zerofree">
+
+ <!ENTITY debian "<productname>Debian</productname>">
+ <!ENTITY gnu "<acronym>GNU</acronym>">
+ <!ENTITY gpl "&gnu; <acronym>GPL</acronym>">
+]>
+
+<refentry>
+ <refentryinfo>
+ <address>
+ &dhemail;
+ </address>
+ <author>
+ &dhfirstname;
+ &dhsurname;
+ </author>
+ <copyright>
+ <year>2003</year>
+ <holder>&dhusername;</holder>
+ </copyright>
+ &dhdate;
+ </refentryinfo>
+ <refmeta>
+ &dhucpackage;
+
+ &dhsection;
+ </refmeta>
+ <refnamediv>
+ <refname>&dhpackage;</refname>
+
+ <refpurpose>zero free blocks from ext2/3/4 file-systems</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>&dhpackage;</command>
+
+ <arg><option>-n</option></arg>
+
+ <arg><option>-v</option></arg>
+
+ <arg choice=req><replaceable>filesystem</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>DESCRIPTION</title>
+
+ <para><command>&dhpackage;</command> finds the unallocated,
+ non-zeroed blocks in an ext2, ext3, or ext4
+ <replaceable>filesystem</replaceable> (e.g. /dev/hda1) and
+ fills them with zeroes. This is useful if the device on which
+ this file-system resides is a disk image. In this case,
+ depending on the type of disk image, a secondary utility may be
+ able to reduce the size of the disk image after zerofree has
+ been run.</para>
+
+ <para>The usual way to achieve the same result (zeroing the
+ unallocated blocks) is to run <command>dd</command> (1) to
+ create a file full of zeroes that takes up the entire free
+ space on the drive, and then delete this file. This has many
+ disadvantages, which zerofree alleviates:</para>
+ <itemizedlist>
+ <listitem><para>it is slow;</para></listitem>
+
+ <listitem><para>it makes the disk image (temporarily) grow to its maximal
+ extent;</para></listitem>
+
+ <listitem><para>it (temporarily) uses all free space on the disk, so other
+ concurrent write actions may fail.</para></listitem>
+
+ </itemizedlist>
+
+ <para><replaceable>filesystem</replaceable> has to be unmounted or
+ mounted read-only for <command>&dhpackage;</command> to work. It
+ will exit with an error message if the
+ <replaceable>filesystem</replaceable> is mounted writable. To
+ remount the root file-system readonly, you can first switch to
+ single user runlevel (<command>telinit 1</command>) then use
+ <command>mount -o remount,ro
+ <replaceable>filesystem</replaceable></command>.</para>
+
+ <para><command>&dhpackage;</command> has been written to be
+ run from GNU/Linux systems installed as guest OSes inside a
+ virtual machine. It may however be useful in other
+ situations.</para>
+
+ </refsect1>
+ <refsect1>
+ <title>OPTIONS</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><option>-n</option>
+ </term>
+ <listitem>
+ <para>Perform a dry run (do not modify the file-system);</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-v</option>
+ </term>
+ <listitem>
+ <para>Be verbose.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1>
+ <title>SEE ALSO</title>
+
+ <para>dd (1).</para>
+
+ </refsect1>
+ <refsect1>
+ <title>AUTHOR</title>
+
+ <para>This manual page was written by &dhusername; &dhemail; for
+ the &debian; system (but may be used by others). Permission is
+ granted to copy, distribute and/or modify this document under
+ the terms of the &gnu; General Public License, Version 2 or any
+ later version published by the Free Software Foundation.
+ </para>
+ <para>
+ On Debian systems, the complete text of the GNU General Public
+ License can be found in /usr/share/common-licenses/GPL-2.
+ </para>
+
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
+
+