tags 255457 + patch thanks This BTS ping-pong with myself is getting silly...
Anyway. This patch is correct: diff -ruN perforate-1.1/debian/files perforate-1.1.mine/debian/files --- perforate-1.1/debian/files 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/files 2005-11-11 05:02:50.000000000 +0100 @@ -0,0 +1 @@ +perforate_1.1-5_powerpc.deb utils optional diff -ruN perforate-1.1/debian/perforate/DEBIAN/control perforate-1.1.mine/debian/perforate/DEBIAN/control --- perforate-1.1/debian/perforate/DEBIAN/control 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/DEBIAN/control 2005-11-11 05:02:50.000000000 +0100 @@ -0,0 +1,16 @@ +Package: perforate +Version: 1.1-5 +Section: utils +Priority: optional +Architecture: powerpc +Depends: libc6 (>= 2.3.5-1) +Installed-Size: 84 +Maintainer: Amaya Rodrigo Sastre <[EMAIL PROTECTED]> +Description: Utilities to save disk space + GNU cp used to detect files that contain 0-filled holes and save disk space + by skipping them with lseek when writing a file and thus not allocating + disk blocks. Unfortunately it does no longer. So here is program to make + holes in existing files. + . + Also there are some scripts that help cleaning up the hard disk + (finding duplicated and/or unstripped files). diff -ruN perforate-1.1/debian/perforate/DEBIAN/md5sums perforate-1.1.mine/debian/perforate/DEBIAN/md5sums --- perforate-1.1/debian/perforate/DEBIAN/md5sums 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/DEBIAN/md5sums 2005-11-11 05:02:51.000000000 +0100 @@ -0,0 +1,10 @@ +a75c8b7cc1f0c7882c4fa4d075738128 usr/bin/finddup +01d56a4a6144c6faafb6e7389d0f04ed usr/bin/findstrip +0bf17a36be985619794abf619f9143bb usr/bin/zum +38376902edebc7e755f1c641a1c10ac3 usr/share/doc/perforate/README.perforate +e9383891d38c2b9a94d924c721edb594 usr/share/doc/perforate/README.Debian +6893da550b91e01dc98922ac5ed49803 usr/share/doc/perforate/copyright +5d32164847730ba213900d63fa485832 usr/share/doc/perforate/changelog.Debian.gz +ac946ef745d8930d80c9ee37be16a8b9 usr/share/man/man1/zum.1.gz +18727ddf38827e9f8a1fc3dfb65b4545 usr/share/man/man1/finddup.1.gz +357746fc0f12b50293d78a53a541ea83 usr/share/man/man1/findstrip.1.gz diff -ruN perforate-1.1/debian/perforate/usr/bin/finddup perforate-1.1.mine/debian/perforate/usr/bin/finddup --- perforate-1.1/debian/perforate/usr/bin/finddup 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/usr/bin/finddup 2005-11-11 05:01:44.000000000 +0100 @@ -0,0 +1,232 @@ +#! /usr/bin/perl +# +# finddup 2.0 - find identical files and do something with them. +# + +use strict; +use warnings; + +use File::Find (); +use Digest::MD5; +use Getopt::Long; +use Pod::Usage; + +# for the convenience of &wanted calls, including -eval statements: +use vars qw(*name *dir *prune); +*name = *File::Find::name; +*dir = *File::Find::dir; +*prune = *File::Find::prune; + +use vars qw($RCS_VERSION $VERSION @dir $opt %filelist %md5list); + +sub wanted; + +$RCS_VERSION = '$Id: finddup,v 2.3 2005/02/06 18:57:42 klaus Exp $'; +($VERSION = '$Revision: 2.3 $') =~ s/^\D*([\d.]*)\D*$/$1/; + +GetOptions($opt = {}, qw(help|h man version noaction|n verbose|v quiet|q link|l oldresult|o dir=s@)) || pod2usage 2; +pod2usage(1) if $opt->{help}; +pod2usage(-exitstatus => 0, -verbose => 2) if $opt->{man}; +if ($opt->{version}) { print "Version: $VERSION\n"; exit 0; } +# Force some options +$opt->{verbose} = 1 if not exists $opt->{verbose} and $opt->{noaction}; +$opt->{link} = 1 if not exists $opt->{link} and $0 =~ /^(.*\/)?nodup(.pl)?$/; +$opt->{oldresult} = 1 if not exists $opt->{oldresult} and $0 =~ /^(.*\/)?nodup(.pl)?$/; + +my @dir = @{$opt->{dir}}; +if (scalar(@dir) eq 0) { + push @dir, '.'; +} + +if ($opt->{oldresult}) +{ + my $md5 = 0; # This is not really necessary in this mode, so make this faster + while (<>) + { + chomp; + s/^(\d+) '//; + my $size = $1; + s/'$//; + my @files = split(/' '/); + $md5list{$md5++} = [[$size, [EMAIL PROTECTED]; + } # while (<>) +} # if ($opt->{oldresult}) +else +{ + # Traverse desired filesystems + File::Find::find({wanted => \&wanted}, @dir); + + # Now calculate all md5sums. Afterwards %filelist can be freed. + foreach (sort {$a->[1]->[0] cmp $b->[1]->[0]} values(%filelist)) + { + if (open(IN, "<", $_->[1]->[0])) + { + my $md5 = Digest::MD5->new->addfile(*IN)->hexdigest; + close IN; + $md5list{$md5} = [] unless exists $md5list{$md5}; + push @{$md5list{$md5}}, $_; + } + else + { + warn "Cannot open File '" . $_->[1]->[0] . "'"; + } + } # foreach (sort {$a->[1]->[0] cm... + %filelist = (); +} # if ($opt->{oldresult}) { ... }... + +# Now we can output doubles sorted by size +foreach (sort {$md5list{$b}->[0]->[0] <=> $md5list{$a}->[0]->[0]} keys(%md5list)) +{ + next unless @{$md5list{$_}} > 1 or $opt->{oldresult}; # This file is single + my $size = $md5list{$_}->[0]->[0]; + if ($size) # Do not output empty files + { + if ($opt->{link}) + { + my $reffile = shift @{$md5list{$_}->[0]->[1]}; # Remove the first file to not unlink them + print "Länge: $size Files:\t$reffile\n" if $opt->{verbose}; + foreach (@{$md5list{$_}}) + { + foreach (@{$_->[1]}) + { + print "\t\t\t$_\n" if $opt->{verbose}; + unless ($opt->{noaction}) + { + unlink $_ || die "Fehler beim Löschen von '$_'"; + link $reffile, $_ || die "Fehler beim ln '$reffile' '$_'"; + } + } + } + print "\n" if $opt->{verbose}; + } # if ($opt->{link}) + else + { + print "$size" unless $opt->{quiet}; + foreach (@{$md5list{$_}}) + { + foreach (@{$_->[1]}) + { + print " '$_'" unless $opt->{quiet}; + } + } + print "\n" unless $opt->{quiet}; + } # if ($opt->{link}) { ... } else + } # if ($size) # Do not output emp... +} # foreach (keys(%md5list)) + +exit 0; + + +sub wanted +{ + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size); + + if ((($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = lstat($_)) && !($File::Find::prune |= ($dev != $File::Find::topdev)) && -f _) + { + $filelist{$ino} = [$size, []] unless exists $filelist{$ino}; + push @{$filelist{$ino}->[1]}, $name; + } +} + +__END__ + +=head1 NAME + +finddup - Find identical files and do something with them + +=head1 SYNOPSIS + +B<finddup> [I<options>...] + + --man the manpage + -h, --help a short help + --version the version (CVS) of the program + -n, --noaction do just nothing, just print out (implies -v) + -v, --verbose just what the name says + -q, --quiet be quiet + -l, --link link the identical files together + -o, --oldresult Use the old output of this script + -d, --dir Define the dir to check (you may specify more than one) + +=head1 DESCRIPTION + +finddup search the working directory and all files below on the same partition +for duplicate files. + +finddup can optional hardlink such files to save space. + +Files size 0 will not be reported or hardlinked as this might give problemes +later. + +This is a complete rewrite of the finddup in perl to handle several issues: + +=over + +=item + +Allow spaces and other characters in filenames + +=item + +be faster + +=item + +include nodup in same script + +=item + +Handle files that already have other hardlinks in the same tree + +=item + +Several improvements + +=back + +If started as nodup or nodup.pl the script will act like started with options --link and +--oldresult + +=head1 COPYRIGHT + +Copyright (c) 2005 by Klaus Ethgen. All rights reserved. + +=head1 LICENSE + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +=head1 AUTHOR + +S<Klaus Ethgen E<lt>[EMAIL PROTECTED]<gt>> + +=head1 HISTORY + + $Log: finddup,v $ + Revision 2.3 2005/02/06 18:57:42 klaus + * Make --oldresult faster by not calculating the md5sum again + * Fix a but that with --oldresult no links will be done cause the internal + datastructure + * Do handle errors in open for md5sum calculation + + Revision 2.2 2005/02/06 12:21:02 klaus + Little but important bug in link routine. + + Revision 2.1 2005/02/05 18:43:11 klaus + Just cosmetic + + Revision 2.0 2005/02/05 18:41:20 klaus + Completely new version + +=cut diff -ruN perforate-1.1/debian/perforate/usr/bin/findstrip perforate-1.1.mine/debian/perforate/usr/bin/findstrip --- perforate-1.1/debian/perforate/usr/bin/findstrip 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/usr/bin/findstrip 2005-11-11 05:01:44.000000000 +0100 @@ -0,0 +1,18 @@ +#!/bin/sh - + +# +# findstrip 1.00 - find programs that are not stripped +# +# Oleg Kibirev * April 1995 * [EMAIL PROTECTED] +# +# This code is covered by General Public License, version 2 or any later +# version of your choice. You should recieve file "COPYING" which contains +# text of the license with any distribution of this program; if you don't +# have it, a copy is available from ftp.gnu.ai.mit.edu. +# + + +find . -xdev -type f \! \( -name '*.o' -o -name '*.so.*' -o -name 'lib*' -o -name '*.do' \) -print | +xargs file | +awk -F: '$2 ~ /not .*strip/ { print $1 }' + diff -ruN perforate-1.1/debian/perforate/usr/bin/nodup perforate-1.1.mine/debian/perforate/usr/bin/nodup --- perforate-1.1/debian/perforate/usr/bin/nodup 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/usr/bin/nodup 2005-11-11 05:01:44.000000000 +0100 @@ -0,0 +1,232 @@ +#! /usr/bin/perl +# +# finddup 2.0 - find identical files and do something with them. +# + +use strict; +use warnings; + +use File::Find (); +use Digest::MD5; +use Getopt::Long; +use Pod::Usage; + +# for the convenience of &wanted calls, including -eval statements: +use vars qw(*name *dir *prune); +*name = *File::Find::name; +*dir = *File::Find::dir; +*prune = *File::Find::prune; + +use vars qw($RCS_VERSION $VERSION @dir $opt %filelist %md5list); + +sub wanted; + +$RCS_VERSION = '$Id: finddup,v 2.3 2005/02/06 18:57:42 klaus Exp $'; +($VERSION = '$Revision: 2.3 $') =~ s/^\D*([\d.]*)\D*$/$1/; + +GetOptions($opt = {}, qw(help|h man version noaction|n verbose|v quiet|q link|l oldresult|o dir=s@)) || pod2usage 2; +pod2usage(1) if $opt->{help}; +pod2usage(-exitstatus => 0, -verbose => 2) if $opt->{man}; +if ($opt->{version}) { print "Version: $VERSION\n"; exit 0; } +# Force some options +$opt->{verbose} = 1 if not exists $opt->{verbose} and $opt->{noaction}; +$opt->{link} = 1 if not exists $opt->{link} and $0 =~ /^(.*\/)?nodup(.pl)?$/; +$opt->{oldresult} = 1 if not exists $opt->{oldresult} and $0 =~ /^(.*\/)?nodup(.pl)?$/; + +my @dir = @{$opt->{dir}}; +if (scalar(@dir) eq 0) { + push @dir, '.'; +} + +if ($opt->{oldresult}) +{ + my $md5 = 0; # This is not really necessary in this mode, so make this faster + while (<>) + { + chomp; + s/^(\d+) '//; + my $size = $1; + s/'$//; + my @files = split(/' '/); + $md5list{$md5++} = [[$size, [EMAIL PROTECTED]; + } # while (<>) +} # if ($opt->{oldresult}) +else +{ + # Traverse desired filesystems + File::Find::find({wanted => \&wanted}, @dir); + + # Now calculate all md5sums. Afterwards %filelist can be freed. + foreach (sort {$a->[1]->[0] cmp $b->[1]->[0]} values(%filelist)) + { + if (open(IN, "<", $_->[1]->[0])) + { + my $md5 = Digest::MD5->new->addfile(*IN)->hexdigest; + close IN; + $md5list{$md5} = [] unless exists $md5list{$md5}; + push @{$md5list{$md5}}, $_; + } + else + { + warn "Cannot open File '" . $_->[1]->[0] . "'"; + } + } # foreach (sort {$a->[1]->[0] cm... + %filelist = (); +} # if ($opt->{oldresult}) { ... }... + +# Now we can output doubles sorted by size +foreach (sort {$md5list{$b}->[0]->[0] <=> $md5list{$a}->[0]->[0]} keys(%md5list)) +{ + next unless @{$md5list{$_}} > 1 or $opt->{oldresult}; # This file is single + my $size = $md5list{$_}->[0]->[0]; + if ($size) # Do not output empty files + { + if ($opt->{link}) + { + my $reffile = shift @{$md5list{$_}->[0]->[1]}; # Remove the first file to not unlink them + print "Länge: $size Files:\t$reffile\n" if $opt->{verbose}; + foreach (@{$md5list{$_}}) + { + foreach (@{$_->[1]}) + { + print "\t\t\t$_\n" if $opt->{verbose}; + unless ($opt->{noaction}) + { + unlink $_ || die "Fehler beim Löschen von '$_'"; + link $reffile, $_ || die "Fehler beim ln '$reffile' '$_'"; + } + } + } + print "\n" if $opt->{verbose}; + } # if ($opt->{link}) + else + { + print "$size" unless $opt->{quiet}; + foreach (@{$md5list{$_}}) + { + foreach (@{$_->[1]}) + { + print " '$_'" unless $opt->{quiet}; + } + } + print "\n" unless $opt->{quiet}; + } # if ($opt->{link}) { ... } else + } # if ($size) # Do not output emp... +} # foreach (keys(%md5list)) + +exit 0; + + +sub wanted +{ + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size); + + if ((($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = lstat($_)) && !($File::Find::prune |= ($dev != $File::Find::topdev)) && -f _) + { + $filelist{$ino} = [$size, []] unless exists $filelist{$ino}; + push @{$filelist{$ino}->[1]}, $name; + } +} + +__END__ + +=head1 NAME + +finddup - Find identical files and do something with them + +=head1 SYNOPSIS + +B<finddup> [I<options>...] + + --man the manpage + -h, --help a short help + --version the version (CVS) of the program + -n, --noaction do just nothing, just print out (implies -v) + -v, --verbose just what the name says + -q, --quiet be quiet + -l, --link link the identical files together + -o, --oldresult Use the old output of this script + -d, --dir Define the dir to check (you may specify more than one) + +=head1 DESCRIPTION + +finddup search the working directory and all files below on the same partition +for duplicate files. + +finddup can optional hardlink such files to save space. + +Files size 0 will not be reported or hardlinked as this might give problemes +later. + +This is a complete rewrite of the finddup in perl to handle several issues: + +=over + +=item + +Allow spaces and other characters in filenames + +=item + +be faster + +=item + +include nodup in same script + +=item + +Handle files that already have other hardlinks in the same tree + +=item + +Several improvements + +=back + +If started as nodup or nodup.pl the script will act like started with options --link and +--oldresult + +=head1 COPYRIGHT + +Copyright (c) 2005 by Klaus Ethgen. All rights reserved. + +=head1 LICENSE + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +=head1 AUTHOR + +S<Klaus Ethgen E<lt>[EMAIL PROTECTED]<gt>> + +=head1 HISTORY + + $Log: finddup,v $ + Revision 2.3 2005/02/06 18:57:42 klaus + * Make --oldresult faster by not calculating the md5sum again + * Fix a but that with --oldresult no links will be done cause the internal + datastructure + * Do handle errors in open for md5sum calculation + + Revision 2.2 2005/02/06 12:21:02 klaus + Little but important bug in link routine. + + Revision 2.1 2005/02/05 18:43:11 klaus + Just cosmetic + + Revision 2.0 2005/02/05 18:41:20 klaus + Completely new version + +=cut Binary files perforate-1.1/debian/perforate/usr/bin/zum and perforate-1.1.mine/debian/perforate/usr/bin/zum differ Binary files perforate-1.1/debian/perforate/usr/share/doc/perforate/changelog.Debian.gz and perforate-1.1.mine/debian/perforate/usr/share/doc/perforate/changelog.Debian.gz differ diff -ruN perforate-1.1/debian/perforate/usr/share/doc/perforate/copyright perforate-1.1.mine/debian/perforate/usr/share/doc/perforate/copyright --- perforate-1.1/debian/perforate/usr/share/doc/perforate/copyright 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/usr/share/doc/perforate/copyright 2005-11-11 02:12:35.000000000 +0100 @@ -0,0 +1,14 @@ +This is the Debian prepackaged version of perforate. + +This package was put together by Michael Meskes <[EMAIL PROTECTED]> from +sources obtained from gd.cs.CSUFresno.EDU:/pub/sun4bin/src, and subsequently +maintained by Heiko Schlittermann <[EMAIL PROTECTED]>. + +You may use, distribute and copy this program according to the terms of the +GNU General Public License version 2 or later. + +On Debian systems, the complete text of the GNU General Public License +(Version 2.0) can be found in /usr/share/common-licenses/GPL . + +Michael Meskes <[EMAIL PROTECTED]> Wed May 29 13:52:27 MET DST 1996 +Heiko Schlittermann <[EMAIL PROTECTED]> Wed Sep 11 00:28:41 MET DST 1996 diff -ruN perforate-1.1/debian/perforate/usr/share/doc/perforate/README.Debian perforate-1.1.mine/debian/perforate/usr/share/doc/perforate/README.Debian --- perforate-1.1/debian/perforate/usr/share/doc/perforate/README.Debian 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/usr/share/doc/perforate/README.Debian 2005-11-11 02:12:35.000000000 +0100 @@ -0,0 +1,5 @@ +Warning to lilo users: + +If you zum under /boot, where your kernel image lives, your system will become +unbootable unless you run lilo again. + diff -ruN perforate-1.1/debian/perforate/usr/share/doc/perforate/README.perforate perforate-1.1.mine/debian/perforate/usr/share/doc/perforate/README.perforate --- perforate-1.1/debian/perforate/usr/share/doc/perforate/README.perforate 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate/usr/share/doc/perforate/README.perforate 1995-04-13 01:58:26.000000000 +0200 @@ -0,0 +1,70 @@ + GNU cp used to detect files that contain 0-filled holes and save disk +space by skipping them with lseek when writing a file and thus not allocating +disk blocks. + + Unfortunately, as people using Slackware 2.2 can notice, it does no +longer. So I wrote a program to make holes in existing files. To use +it, run + + zum file1 file2 ... + +or, if you want to process all files on your system (recommened), do: + + find / -xdev -type f -print | zum + + It should work find under Linux. If it runs out of disk space when +processing files (it has to make a copy of each before replacing it), just +Ctrl-C and delete all files that end with __zum__ (eq find / -xdev -name +'*__zum__' -print | xargs rm). After you free some space, it's safe to run it +from the beginning one more time. Nevertheless shell scripts in this package +modify your files and I am not responsible for anything that might happen +(hey, you have source code!) + + By the way, don't try to do this on other UNIX varieties without +preliminary investigation. For example, SunOS can't boot from vmlinux with +holes (it's Ok to zum shared libraries however, because I unlink programs +before overwriting them). + + While I was at it, I wrote some more scripts to save disk +space. finddup finds all the duplicate files in a subtree rooted in current +directory. Run it as: + + + cd / + /some/dir/finddup > /tmp/duplist + + + It takes quite a while to run. At the end, /tmp/duplist has groups of +duplicate files sorted in the order of decreasing size (so you can look at the +most interesting ones first). They can be merged with hard links: + + cd / + /some/dir/nodup < /tmp/duplist + + + However you shouldn't merge all of them. Instead edit the duplist and +see what they are. For example, /root/.zshenv and /home/snowcat/.zshenv +shouldn't be merged even if they are identical, because in future I may want +to edit my .zshenv without changing root's setup. Likewise, don't link +/etc/nntpserver and /usr/adm/messages even if both consist of a single newline +character. + + Finally, findstrip will find all unstripped files and write them to +stdout, line by line. Remember that you can strip only real executables, but +not shared libraries, objects and some other things like .do files in Andrew +toolkit. findstrip filters out everything I know about, but if you don't edit +the list before stripping it, you are quite likely to get in trouble. + + + On full Slackware 2.2 distribution (w/o Tex), these 3 scripts together +can save about 15M. It may be not much but at least it's free and doesn't have +any performance penalty :) Anyone willing to include them as part of +installation process? + + Also, it's useful to make holes in files on rescue floppies. + + Oleg Kibirev <[EMAIL PROTECTED]> + +PS: tzx is covered by GPL unless someone can give me a compeling reason to +relax restrictions. + Binary files perforate-1.1/debian/perforate/usr/share/man/man1/finddup.1.gz and perforate-1.1.mine/debian/perforate/usr/share/man/man1/finddup.1.gz differ Binary files perforate-1.1/debian/perforate/usr/share/man/man1/findstrip.1.gz and perforate-1.1.mine/debian/perforate/usr/share/man/man1/findstrip.1.gz differ Binary files perforate-1.1/debian/perforate/usr/share/man/man1/nodup.1.gz and perforate-1.1.mine/debian/perforate/usr/share/man/man1/nodup.1.gz differ Binary files perforate-1.1/debian/perforate/usr/share/man/man1/zum.1.gz and perforate-1.1.mine/debian/perforate/usr/share/man/man1/zum.1.gz differ diff -ruN perforate-1.1/debian/perforate.substvars perforate-1.1.mine/debian/perforate.substvars --- perforate-1.1/debian/perforate.substvars 1970-01-01 01:00:00.000000000 +0100 +++ perforate-1.1.mine/debian/perforate.substvars 2005-11-11 05:02:49.000000000 +0100 @@ -0,0 +1 @@ +shlibs:Depends=libc6 (>= 2.3.5-1) diff -ruN perforate-1.1/debian/rules perforate-1.1.mine/debian/rules --- perforate-1.1/debian/rules 2005-11-11 03:32:54.000000000 +0100 +++ perforate-1.1.mine/debian/rules 2005-11-11 04:18:50.000000000 +0100 @@ -2,10 +2,13 @@ export DH_COMPAT=4 -CFLAGS := -O2 -Wall +CFLAGS := -Wall ifneq ($(findstring debug,$(DEB_BUILD_OPTIONS)),) CFLAGS += -g endif +ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) +CFLAGS += -O2 +endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif Binary files perforate-1.1/zum and perforate-1.1.mine/zum differ diff -ruN perforate-1.1/zum.c perforate-1.1.mine/zum.c --- perforate-1.1/zum.c 1996-09-11 00:15:34.000000000 +0200 +++ perforate-1.1.mine/zum.c 2005-11-11 11:02:27.000000000 +0100 @@ -2,6 +2,8 @@ * zum 1.00 - free more disk space by making holes in files. * * Oleg Kibirev * April 1995 * [EMAIL PROTECTED] + * 2005-11-11: Wouter Verhelst <[EMAIL PROTECTED]>: clean up the code a bit (so + * that it no longer produces any warnings, add large file support. * * This code is covered by General Public License, version 2 or any later * version of your choice. You should recieve file "COPYING" which contains @@ -9,7 +11,11 @@ * have it, a copy is available from ftp.gnu.ai.mit.edu. */ +#define _FILE_OFFSET_BITS 64 +#define _LARGEFILE_SOURCE + #include <stdio.h> +#include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/file.h> @@ -25,10 +31,26 @@ static char suffix[] = "__zum__"; -static int zero_copy(int fds, int fdd, int size) +static void* my_mmap(void *ptr, int fd, off_t size, off_t *pos) +{ + if(size-(*pos) > (off_t)1<<30) { + size=1<<30; + } else { + size=size-(*pos); + } + if(ptr) + munmap(ptr, 1<<30); + ptr=mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, (*pos)); + (*pos)+=size; + return ptr; +} + +static int zero_copy(int fds, int fdd, off_t size) { char *ms; char *bp, *p, *ep; + off_t pos=0; + int offset; lseek(fdd, 0L, SEEK_SET); if(ftruncate(fdd, 0) < 0) { @@ -36,23 +58,33 @@ return -1; } - if((ms = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fds, 0)) == -1) { + offset = (size > 1<<30) ? 1<<30 : size; + if((ms = my_mmap(NULL, fds, size, &pos)) == MAP_FAILED) { perror("mmap"); return -1; } - p = ms; ep = ms + size; + p = ms; ep = ms + offset; while(p < ep) { for(bp = p; p < ep && *p; p++); if(p != bp && write(fdd, bp, p-bp) != p-bp) { perror("write"); - munmap(ms, size); + munmap(ms, offset); return -1; } for(bp = p; p < ep && !*p; p++); if(p != bp) lseek(fdd, p-bp, SEEK_CUR); + if((p == ep) && (size > 1<<30) && (size != pos)) { + offset = ((size - pos) > 1<<30) ? 1<<30 : (size - pos); + if((ms = my_mmap(ms, fds, size, &pos)) == MAP_FAILED) { + perror("mmap"); + return -1; + } else { + p = ms; ep = ms + offset; + } + } } munmap(ms, size); return ftruncate(fdd, size); @@ -102,7 +134,7 @@ return; } - printf(" [%uK] ", (st.st_blocks-std.st_blocks)*st.st_blksize/1024); + printf(" [%uK] ", (unsigned int)((st.st_blocks-std.st_blocks)*st.st_blksize/1024)); fflush(stdout); if(st.st_nlink == 1) { @@ -141,16 +173,16 @@ } } -main(int argc, char **argv) +int main(int argc, char **argv) { char *p; if(argc > 1) - while(p = *(++argv)) + while((p = *(++argv))) zero_unmap(p); else { char buf[MAXPATHLEN]; - while(gets(buf)) + while(fgets(buf, MAXPATHLEN, stdin)) zero_unmap(buf); } return 0; Enjoy! -- .../ -/ ---/ .--./ / .--/ .-/ .../ -/ ../ -./ --./ / -.--/ ---/ ..-/ .-./ / -/ ../ --/ ./ / .--/ ../ -/ ..../ / -../ ./ -.-./ ---/ -../ ../ -./ --./ / --/ -.--/ / .../ ../ --./ -./ .-/ -/ ..-/ .-./ ./ .-.-.-/ / --/ ---/ .-./ .../ ./ / ../ .../ / ---/ ..-/ -/ -../ .-/ -/ ./ -../ / -/ ./ -.-./ ..../ -./ ---/ .-../ ---/ --./ -.--/ / .-/ -./ -.--/ .--/ .-/ -.--/ .-.-.-/ / ...-.-/