eval 'exec /usr/contrib/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
$bin = "/usr/contrib/bin";
while ($ARGV[0] =~ /^[^-!(]/) {
@roots = ('.') unless @roots;
for (@roots) { $_ = "e($_); }
$roots = join(',', @roots);
s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n";
$pat = &fileglob_to_re(shift);
$out .= '/' . $pat . "/";
die "Malformed -perm argument: $onum\n" unless $onum =~ /^-?[0-7]+$/;
$onum = '0' . sprintf("%o", oct($onum) & 017777); # s/b 07777 ?
$out .= &tab . "((\$mode & $onum) == $onum)";
$onum = '0' . $onum unless $onum =~ /^0/;
$out .= &tab . "((\$mode & 0777) == $onum)";
($filetest = shift) =~ tr/s/S/;
$out .= &tab . "-$filetest _";
$out .= &tab . 'print("$name\n")';
$out .= &tab . 'print("$name\0")';
$out .= &tab . "\$uid == \$uid{'$uname'}";
$out .= &tab . "\$gid == \$gid{'$gname'}";
$out .= &tab . '!defined $uid{$uid}';
elsif ($_ eq 'nogroup') {
$out .= &tab . '!defined $gid{$gid}';
$out .= &tab . '$nlink ' . &n(shift);
$out .= &tab . '$ino ' . &n(shift);
$out .= &tab . 'int((-s _ + 511) / 512) ' . &n(shift);
$out .= &tab . 'int(-A _) ' . &n(shift);
$out .= &tab . 'int(-M _) ' . &n(shift);
$out .= &tab . 'int(-C _) ' . &n(shift);
for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
if (m#^(/bin/)?rm -f {}$#) {
$out .= &tab . 'unlink($_)';
$out .= &tab . '(unlink($_) || 1)';
elsif (m#^(/bin/)?rm {}$#) {
$out .= &tab . '(unlink($_) || warn "$name: $!\n")';
for (@cmd) { s/'/\\'/g; }
$out .= &tab . "&exec(0, '@cmd')";
for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
for (@cmd) { s/'/\\'/g; }
$out .= &tab . "&exec(1, '@cmd')";
$out .= &tab . '($prune = 1)';
$out .= &tab . '(($prune |= ($dev != $topdev)),1)';
$newername = 'AGE_OF' . $file;
$newername =~ s/[^\w]/_/g;
$newername = '$' . $newername;
$out .= "-M _ < $newername";
$initnewer .= "$newername = -M " . "e($file) . ";\n";
$out .= &tab . "eval $prog";
die "-tar must have a filename argument\n" unless @ARGV;
$initfile .= "open($fh, " . "e($file) .
qq{) || die "Can't open $fh: \$!\\n";\n};
$flushall = "\n&tflushall;\n";
die "-$_ must have a filename argument\n" unless @ARGV;
$out .= "&cpio('" . substr($_,0,1) . "', $fh)";
$initfile .= "open($fh, " . "e($file) .
qq{) || die "Can't open $fh: \$!\\n";\n};
$flushall = "\n&flushall;\n";
die "Unrecognized switch: -$_\n";
{ local($statdone) = 1; $out .= "\n" . &tab . "||\n"; }
$statdone = 0 if $indent == 1 && $delayedstat;
$out .= " &&" unless $ARGV[0] eq ')';
shift if $ARGV[0] eq '-a';
eval 'exec $bin/perl -S \$0 \${1+"\$@"}'
if \$running_under_some_shell;
@rwx = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx');
@moname = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
if ($inituser || $initls) {
print 'while (($name, $pw, $uid) = getpwent) {', "\n";
print ' $uid{$name} = $uid{$uid} = $uid;', "\n" if $inituser;
print ' $user{$uid} = $name unless $user{$uid};', "\n" if $initls;
if ($initgroup || $initls) {
print 'while (($name, $pw, $gid) = getgrent) {', "\n";
print ' $gid{$name} = $gid{$gid} = $gid;', "\n" if $initgroup;
print ' $group{$gid} = $name unless $group{$gid};', "\n" if $initls;
print $initnewer, "\n" if $initnewer;
print $initfile, "\n" if $initfile;
$find = $depth ? "finddepth" : "find";
# Traverse desired filesystems
local($old) = select(STDOUT);
return 0 unless <STDIN> =~ /^y/;
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizemm,
$atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
$blocks = int(($blocks + 1) / 2);
$blocks = int(($size + 1023) / 1024);
if (-f _) { $perms = '-'; }
elsif (-d _) { $perms = 'd'; }
elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; }
elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; }
elsif (-p _) { $perms = 'p'; }
elsif (-S _) { $perms = 's'; }
else { $perms = 'l'; $pname .= ' -> ' . readlink($_); }
$tmp = $rwx[$tmpmode & 7];
$tmp = $rwx[$tmpmode & 7] . $tmp;
$tmp = $rwx[$tmpmode & 7] . $tmp;
substr($tmp,2,1) =~ tr/-x/Ss/ if -u _;
substr($tmp,5,1) =~ tr/-x/Ss/ if -g _;
substr($tmp,8,1) =~ tr/-x/Tt/ if -k _;
$user = $user{$uid} || $uid;
$group = $group{$gid} || $gid;
($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime);
$timeyear = '19' . $year;
$timeyear = sprintf("%02d:%02d", $hour, $min);
printf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n",
sprintf("%3d, %3d", ($rdev >> 8) & 255, $rdev & 255);
if ($name eq 'TRAILER!!!') {
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
open(IN, "./$_\0") || do {
warn "Couldn't open $name: $!\n";
$size = 0 unless defined $text;
($nm = $name) =~ s#^\./##;
sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0",
$cpout{$fh} .= "\0" if length($cpout{$fh}) & 1;
$cpout{$fh} .= pack("SSSSSSSSLSLa*",
070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime,
length($nm)+1, $size, $nm . (length($nm) & 1 ? "\0" : "\0\0"));
&flush($fh) while ($l = length($cpout{$fh})) >= 5120;
while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) {
$l = length($cpout{$fh});
while (length($cpout{$fh}) >= 5120) {
syswrite($fh,$cpout{$fh},5120);
substr($cpout{$fh}, 0, 5120) = '';
foreach $fh (keys %cpout) {
$cpout{$fh} .= "0" x (5120 - length($cpout{$fh}));
print $blocks{$fh} * 10, " blocks\n";
local($linkname,$header,$l,$slop);
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
if ($linkname = $linkseen{$fh,$dev,$ino}) {
$linkseen{$fh,$dev,$ino} = $nm;
open(IN, "./$_\0") || do {
warn "Couldn't open $name: $!\n";
$size = 0 if $linkflag ne "\0";
$linkname = readlink($_);
$linkflag = 2 if defined $linkname;
$header = pack("a100a8a8a8a12a12a8a1a100",
sprintf("%6o ", $mode & 0777),
sprintf("%6o ", $uid & 0777777),
sprintf("%6o ", $gid & 0777777),
sprintf("%11o ", $mtime),
$l = length($header) % 512;
substr($header, 148, 6) = sprintf("%6o", unpack("%16C*", $header));
substr($header, 154, 1) = "\0"; # blech
$tarout{$fh} .= "\0" x (512 - $l) if $l;
&tflush($fh) while ($l = length($tarout{$fh})) >= 10240;
while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) {
$slop = length($tarout{$fh}) % 512;
$tarout{$fh} .= "\0" x (512 - $slop) if $slop;
$l = length($tarout{$fh});
while (length($tarout{$fh}) >= 10240) {
syswrite($fh,$tarout{$fh},10240);
substr($tarout{$fh}, 0, 10240) = '';
foreach $fh (keys %tarout) {
$len = 10240 - length($tarout{$fh});
$len += 10240 if $len < 1024;
$tarout{$fh} .= "\0" x $len;
############################################################################
$tabstring = "\t" x ($indent / 2) . ' ' x ($indent % 2 * 4);
if ($_ =~ /^(name|print|prune|exec|ok|\(|\))/) {
$tabstring .= <<'ENDOFSTAT' . $tabstring;
($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
$tabstring .= <<'ENDOFSTAT' . $tabstring;
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
$tabstring =~ s/^\s+/ / if $out =~ /!$/;
$tmp =~ s/([.^\$()])/\\$1/g;
$n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /;