| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
13317
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
125
|
|
|
4
|
3
|
|
|
3
|
|
13
|
use vars qw/$statdone/; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
173
|
|
|
5
|
3
|
|
|
3
|
|
1249
|
use File::Spec::Functions 'curdir'; |
|
|
3
|
|
|
|
|
2406
|
|
|
|
3
|
|
|
|
|
253
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use Config; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
15421
|
|
|
7
|
3
|
|
|
|
|
493881
|
my ($perlpath) = $Config{perlpath}; |
|
8
|
3
|
|
|
|
|
14
|
my $startperl = "#! $perlpath -w"; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub tab (); |
|
11
|
|
|
|
|
|
|
sub n ($$); |
|
12
|
|
|
|
|
|
|
sub fileglob_to_re ($); |
|
13
|
|
|
|
|
|
|
sub quote ($); |
|
14
|
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
8
|
my @roots = (); |
|
16
|
3
|
|
|
|
|
29
|
while ($ARGV[0] =~ /^[^-!(]/) { |
|
17
|
3
|
|
|
|
|
25
|
push(@roots, shift); |
|
18
|
|
|
|
|
|
|
} |
|
19
|
3
|
50
|
|
|
|
13
|
@roots = (curdir()) unless @roots; |
|
20
|
3
|
|
|
|
|
9
|
for (@roots) { $_ = quote($_) } |
|
|
3
|
|
|
|
|
16
|
|
|
21
|
3
|
|
|
|
|
11
|
my $roots = join(', ', @roots); |
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
6
|
my $find = "find"; |
|
24
|
3
|
|
|
|
|
8
|
my $indent_depth = 1; |
|
25
|
3
|
|
|
|
|
6
|
my $stat = 'lstat'; |
|
26
|
3
|
|
|
|
|
6
|
my $decl = ''; |
|
27
|
3
|
|
|
|
|
7
|
my $flushall = ''; |
|
28
|
3
|
|
|
|
|
7
|
my $initfile = ''; |
|
29
|
3
|
|
|
|
|
6
|
my $initnewer = ''; |
|
30
|
3
|
|
|
|
|
7
|
my $out = ''; |
|
31
|
3
|
|
|
|
|
6
|
my $declaresubs = "sub wanted;\n"; |
|
32
|
3
|
|
|
|
|
7
|
my %init = (); |
|
33
|
3
|
|
|
|
|
8
|
my ($follow_in_effect,$Skip_And) = (0,0); |
|
34
|
3
|
|
|
|
|
6
|
my $print_needed = 1; |
|
35
|
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
29
|
while (@ARGV) { |
|
37
|
5
|
|
|
|
|
12
|
$_ = shift; |
|
38
|
5
|
50
|
33
|
|
|
62
|
s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n"; |
|
39
|
5
|
50
|
|
|
|
163
|
if ($_ eq '(') { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
$out .= tab . "(\n"; |
|
41
|
0
|
|
|
|
|
0
|
$indent_depth++; |
|
42
|
0
|
|
|
|
|
0
|
next; |
|
43
|
|
|
|
|
|
|
} elsif ($_ eq ')') { |
|
44
|
0
|
|
|
|
|
0
|
--$indent_depth; |
|
45
|
0
|
|
|
|
|
0
|
$out .= tab . ")"; |
|
46
|
|
|
|
|
|
|
} elsif ($_ eq 'follow') { |
|
47
|
0
|
|
|
|
|
0
|
$follow_in_effect= 1; |
|
48
|
0
|
|
|
|
|
0
|
$stat = 'stat'; |
|
49
|
0
|
|
|
|
|
0
|
$Skip_And= 1; |
|
50
|
|
|
|
|
|
|
} elsif ($_ eq '!') { |
|
51
|
0
|
|
|
|
|
0
|
$out .= tab . "!"; |
|
52
|
0
|
|
|
|
|
0
|
next; |
|
53
|
|
|
|
|
|
|
} elsif (/^(i)?name$/) { |
|
54
|
0
|
|
|
|
|
0
|
$out .= tab . '/' . fileglob_to_re(shift) . "/s$1"; |
|
55
|
|
|
|
|
|
|
} elsif (/^(i)?path$/) { |
|
56
|
0
|
|
|
|
|
0
|
$out .= tab . '$File::Find::name =~ /' . fileglob_to_re(shift) . "/s$1"; |
|
57
|
|
|
|
|
|
|
} elsif ($_ eq 'perm') { |
|
58
|
0
|
|
|
|
|
0
|
my $onum = shift; |
|
59
|
0
|
0
|
|
|
|
0
|
$onum =~ /^-?[0-7]+$/ |
|
60
|
|
|
|
|
|
|
|| die "Malformed -perm argument: $onum\n"; |
|
61
|
0
|
|
|
|
|
0
|
$out .= tab; |
|
62
|
0
|
0
|
|
|
|
0
|
if ($onum =~ s/^-//) { |
|
63
|
0
|
|
|
|
|
0
|
$onum = sprintf("0%o", oct($onum) & 07777); |
|
64
|
0
|
|
|
|
|
0
|
$out .= "((\$mode & $onum) == $onum)"; |
|
65
|
|
|
|
|
|
|
} else { |
|
66
|
0
|
|
|
|
|
0
|
$onum =~ s/^0*/0/; |
|
67
|
0
|
|
|
|
|
0
|
$out .= "((\$mode & 0777) == $onum)"; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} elsif ($_ eq 'type') { |
|
70
|
3
|
|
|
|
|
12
|
(my $filetest = shift) =~ tr/s/S/; |
|
71
|
3
|
|
|
|
|
21
|
$out .= tab . "-$filetest _"; |
|
72
|
|
|
|
|
|
|
} elsif ($_ eq 'print') { |
|
73
|
0
|
|
|
|
|
0
|
$out .= tab . 'print("$name\n")'; |
|
74
|
0
|
|
|
|
|
0
|
$print_needed = 0; |
|
75
|
|
|
|
|
|
|
} elsif ($_ eq 'print0') { |
|
76
|
0
|
|
|
|
|
0
|
$out .= tab . 'print("$name\0")'; |
|
77
|
0
|
|
|
|
|
0
|
$print_needed = 0; |
|
78
|
|
|
|
|
|
|
} elsif ($_ eq 'fstype') { |
|
79
|
0
|
|
|
|
|
0
|
my $type = shift; |
|
80
|
0
|
|
|
|
|
0
|
$out .= tab; |
|
81
|
0
|
0
|
|
|
|
0
|
if ($type eq 'nfs') { |
|
82
|
0
|
|
|
|
|
0
|
$out .= '($dev < 0)'; |
|
83
|
|
|
|
|
|
|
} else { |
|
84
|
0
|
|
|
|
|
0
|
$out .= '($dev >= 0)'; #XXX |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} elsif ($_ eq 'user') { |
|
87
|
0
|
|
|
|
|
0
|
my $uname = shift; |
|
88
|
0
|
|
|
|
|
0
|
$out .= tab . "(\$uid == \$uid{'$uname'})"; |
|
89
|
0
|
|
|
|
|
0
|
$init{user} = 1; |
|
90
|
|
|
|
|
|
|
} elsif ($_ eq 'group') { |
|
91
|
0
|
|
|
|
|
0
|
my $gname = shift; |
|
92
|
0
|
|
|
|
|
0
|
$out .= tab . "(\$gid == \$gid{'$gname'})"; |
|
93
|
0
|
|
|
|
|
0
|
$init{group} = 1; |
|
94
|
|
|
|
|
|
|
} elsif ($_ eq 'nouser') { |
|
95
|
0
|
|
|
|
|
0
|
$out .= tab . '!exists $uid{$uid}'; |
|
96
|
0
|
|
|
|
|
0
|
$init{user} = 1; |
|
97
|
|
|
|
|
|
|
} elsif ($_ eq 'nogroup') { |
|
98
|
0
|
|
|
|
|
0
|
$out .= tab . '!exists $gid{$gid}'; |
|
99
|
0
|
|
|
|
|
0
|
$init{group} = 1; |
|
100
|
|
|
|
|
|
|
} elsif ($_ eq 'links') { |
|
101
|
0
|
|
|
|
|
0
|
$out .= tab . n('$nlink', shift); |
|
102
|
|
|
|
|
|
|
} elsif ($_ eq 'inum') { |
|
103
|
0
|
|
|
|
|
0
|
$out .= tab . n('$ino', shift); |
|
104
|
|
|
|
|
|
|
} elsif ($_ eq 'size') { |
|
105
|
0
|
|
|
|
|
0
|
$_ = shift; |
|
106
|
0
|
|
|
|
|
0
|
my $n = 'int(((-s _) + 511) / 512)'; |
|
107
|
0
|
0
|
|
|
|
0
|
if (s/c\z//) { |
|
|
|
0
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
0
|
$n = 'int(-s _)'; |
|
109
|
|
|
|
|
|
|
} elsif (s/k\z//) { |
|
110
|
0
|
|
|
|
|
0
|
$n = 'int(((-s _) + 1023) / 1024)'; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
0
|
|
|
|
|
0
|
$out .= tab . n($n, $_); |
|
113
|
|
|
|
|
|
|
} elsif ($_ eq 'atime') { |
|
114
|
0
|
|
|
|
|
0
|
$out .= tab . n('int(-A _)', shift); |
|
115
|
|
|
|
|
|
|
} elsif ($_ eq 'mtime') { |
|
116
|
0
|
|
|
|
|
0
|
$out .= tab . n('int(-M _)', shift); |
|
117
|
|
|
|
|
|
|
} elsif ($_ eq 'ctime') { |
|
118
|
0
|
|
|
|
|
0
|
$out .= tab . n('int(-C _)', shift); |
|
119
|
|
|
|
|
|
|
} elsif ($_ eq 'amin') { |
|
120
|
1
|
|
|
|
|
4
|
$out .= tab . n('int(1440 * -A _)', shift); |
|
121
|
|
|
|
|
|
|
} elsif ($_ eq 'mmin') { |
|
122
|
1
|
|
|
|
|
3
|
$out .= tab . n('int(1440 * -M _)', shift); |
|
123
|
|
|
|
|
|
|
} elsif ($_ eq 'cmin') { |
|
124
|
0
|
|
|
|
|
0
|
$out .= tab . n('int(1440 * -C _)', shift); |
|
125
|
|
|
|
|
|
|
} elsif ($_ eq 'exec') { |
|
126
|
0
|
|
|
|
|
0
|
my @cmd = (); |
|
127
|
0
|
|
0
|
|
|
0
|
while (@ARGV && $ARGV[0] ne ';') |
|
128
|
0
|
|
|
|
|
0
|
{ push(@cmd, shift) } |
|
129
|
0
|
|
|
|
|
0
|
shift; |
|
130
|
0
|
|
|
|
|
0
|
$out .= tab; |
|
131
|
0
|
0
|
0
|
|
|
0
|
if ($cmd[0] =~m#^(?:(?:/usr)?/bin/)?rm$# |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
132
|
|
|
|
|
|
|
&& $cmd[$#cmd] eq '{}' |
|
133
|
|
|
|
|
|
|
&& (@cmd == 2 || (@cmd == 3 && $cmd[1] eq '-f'))) { |
|
134
|
0
|
0
|
|
|
|
0
|
if (@cmd == 2) { |
|
|
|
0
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
0
|
$out .= '(unlink($_) || warn "$name: $!\n")'; |
|
136
|
|
|
|
|
|
|
} elsif (!@ARGV) { |
|
137
|
0
|
|
|
|
|
0
|
$out .= 'unlink($_)'; |
|
138
|
|
|
|
|
|
|
} else { |
|
139
|
0
|
|
|
|
|
0
|
$out .= '(unlink($_) || 1)'; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
} else { |
|
142
|
0
|
|
|
|
|
0
|
for (@cmd) |
|
143
|
0
|
|
|
|
|
0
|
{ s/'/\\'/g } |
|
144
|
0
|
|
|
|
|
0
|
{ local $" = "','"; $out .= "doexec(0, '@cmd')"; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
145
|
0
|
|
|
|
|
0
|
$declaresubs .= "sub doexec (\$\@);\n"; |
|
146
|
0
|
|
|
|
|
0
|
$init{doexec} = 1; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
0
|
|
|
|
|
0
|
$print_needed = 0; |
|
149
|
|
|
|
|
|
|
} elsif ($_ eq 'ok') { |
|
150
|
0
|
|
|
|
|
0
|
my @cmd = (); |
|
151
|
0
|
|
0
|
|
|
0
|
while (@ARGV && $ARGV[0] ne ';') |
|
152
|
0
|
|
|
|
|
0
|
{ push(@cmd, shift) } |
|
153
|
0
|
|
|
|
|
0
|
shift; |
|
154
|
0
|
|
|
|
|
0
|
$out .= tab; |
|
155
|
0
|
|
|
|
|
0
|
for (@cmd) |
|
156
|
0
|
|
|
|
|
0
|
{ s/'/\\'/g } |
|
157
|
0
|
|
|
|
|
0
|
{ local $" = "','"; $out .= "doexec(1, '@cmd')"; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
158
|
0
|
|
|
|
|
0
|
$declaresubs .= "sub doexec (\$\@);\n"; |
|
159
|
0
|
|
|
|
|
0
|
$init{doexec} = 1; |
|
160
|
0
|
|
|
|
|
0
|
$print_needed = 0; |
|
161
|
|
|
|
|
|
|
} elsif ($_ eq 'prune') { |
|
162
|
0
|
|
|
|
|
0
|
$out .= tab . '($File::Find::prune = 1)'; |
|
163
|
|
|
|
|
|
|
} elsif ($_ eq 'xdev') { |
|
164
|
0
|
|
|
|
|
0
|
$out .= tab . '!($File::Find::prune |= ($dev != $File::Find::topdev))' |
|
165
|
|
|
|
|
|
|
; |
|
166
|
|
|
|
|
|
|
} elsif ($_ eq 'newer') { |
|
167
|
0
|
|
|
|
|
0
|
my $file = shift; |
|
168
|
0
|
|
|
|
|
0
|
my $newername = 'AGE_OF' . $file; |
|
169
|
0
|
|
|
|
|
0
|
$newername =~ s/\W/_/g; |
|
170
|
0
|
|
|
|
|
0
|
$newername = '$' . $newername; |
|
171
|
0
|
|
|
|
|
0
|
$out .= tab . "(-M _ < $newername)"; |
|
172
|
0
|
|
|
|
|
0
|
$initnewer .= "my $newername = -M " . quote($file) . ";\n"; |
|
173
|
|
|
|
|
|
|
} elsif ($_ eq 'eval') { |
|
174
|
0
|
|
|
|
|
0
|
my $prog = shift; |
|
175
|
0
|
|
|
|
|
0
|
$prog =~ s/'/\\'/g; |
|
176
|
0
|
|
|
|
|
0
|
$out .= tab . "eval {$prog}"; |
|
177
|
0
|
|
|
|
|
0
|
$print_needed = 0; |
|
178
|
|
|
|
|
|
|
} elsif ($_ eq 'depth') { |
|
179
|
0
|
|
|
|
|
0
|
$find = 'finddepth'; |
|
180
|
0
|
|
|
|
|
0
|
next; |
|
181
|
|
|
|
|
|
|
} elsif ($_ eq 'ls') { |
|
182
|
0
|
|
|
|
|
0
|
$out .= tab . "ls"; |
|
183
|
0
|
|
|
|
|
0
|
$declaresubs .= "sub ls ();\n"; |
|
184
|
0
|
|
|
|
|
0
|
$init{ls} = 1; |
|
185
|
0
|
|
|
|
|
0
|
$print_needed = 0; |
|
186
|
|
|
|
|
|
|
} elsif ($_ eq 'tar') { |
|
187
|
0
|
0
|
|
|
|
0
|
die "-tar must have a filename argument\n" unless @ARGV; |
|
188
|
0
|
|
|
|
|
0
|
my $file = shift; |
|
189
|
0
|
|
|
|
|
0
|
my $fh = 'FH' . $file; |
|
190
|
0
|
|
|
|
|
0
|
$fh =~ s/\W/_/g; |
|
191
|
0
|
|
|
|
|
0
|
$out .= tab . "tar(*$fh, \$name)"; |
|
192
|
0
|
|
|
|
|
0
|
$flushall .= "tflushall;\n"; |
|
193
|
0
|
|
|
|
|
0
|
$declaresubs .= "sub tar;\nsub tflushall ();\n"; |
|
194
|
0
|
|
|
|
|
0
|
$initfile .= "open($fh, " . quote('> ' . $file) . |
|
195
|
|
|
|
|
|
|
qq{) || die "Can't open $fh: \$!\\n";\n}; |
|
196
|
0
|
|
|
|
|
0
|
$init{tar} = 1; |
|
197
|
|
|
|
|
|
|
} elsif (/^(n?)cpio\z/) { |
|
198
|
0
|
0
|
|
|
|
0
|
die "-$_ must have a filename argument\n" unless @ARGV; |
|
199
|
0
|
|
|
|
|
0
|
my $file = shift; |
|
200
|
0
|
|
|
|
|
0
|
my $fh = 'FH' . $file; |
|
201
|
0
|
|
|
|
|
0
|
$fh =~ s/\W/_/g; |
|
202
|
0
|
|
|
|
|
0
|
$out .= tab . "cpio(*$fh, \$name, '$1')"; |
|
203
|
0
|
|
|
|
|
0
|
$find = 'finddepth'; |
|
204
|
0
|
|
|
|
|
0
|
$flushall .= "cflushall;\n"; |
|
205
|
0
|
|
|
|
|
0
|
$declaresubs .= "sub cpio;\nsub cflushall ();\n"; |
|
206
|
0
|
|
|
|
|
0
|
$initfile .= "open($fh, " . quote('> ' . $file) . |
|
207
|
|
|
|
|
|
|
qq{) || die "Can't open $fh: \$!\\n";\n}; |
|
208
|
0
|
|
|
|
|
0
|
$init{cpio} = 1; |
|
209
|
|
|
|
|
|
|
} else { |
|
210
|
0
|
|
|
|
|
0
|
die "Unrecognized switch: -$_\n"; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
5
|
100
|
|
|
|
21
|
if (@ARGV) { |
|
214
|
2
|
50
|
|
|
|
8
|
if ($ARGV[0] eq '-o') { |
|
215
|
0
|
|
|
|
|
0
|
{ local($statdone) = 1; $out .= "\n" . tab . "||\n"; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
216
|
0
|
0
|
0
|
|
|
0
|
$statdone = 0 if $indent_depth == 1 && exists $init{delayedstat}; |
|
217
|
0
|
|
|
|
|
0
|
$init{saw_or} = 1; |
|
218
|
0
|
|
|
|
|
0
|
shift; |
|
219
|
|
|
|
|
|
|
} else { |
|
220
|
2
|
50
|
33
|
|
|
16
|
$out .= " &&" unless $Skip_And || $ARGV[0] eq ')'; |
|
221
|
2
|
|
|
|
|
4
|
$out .= "\n"; |
|
222
|
2
|
50
|
|
|
|
32
|
shift if $ARGV[0] eq '-a'; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
|
|
227
|
3
|
50
|
|
|
|
10
|
if ($print_needed) { |
|
228
|
3
|
|
|
|
|
9
|
my $t = tab; |
|
229
|
3
|
50
|
|
|
|
17
|
if ($t !~ /&&\s*$/) { $t .= '&& ' } |
|
|
3
|
|
|
|
|
7
|
|
|
230
|
3
|
|
|
|
|
8
|
$out .= "\n" . $t . 'print("$name\n")'; |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
|
|
234
|
3
|
|
|
|
|
52
|
print <<"END"; |
|
235
|
|
|
|
|
|
|
$startperl |
|
236
|
|
|
|
|
|
|
eval 'exec $perlpath -S \$0 \${1+"\$@"}' |
|
237
|
|
|
|
|
|
|
if 0; #\$running_under_some_shell |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
use strict; |
|
240
|
|
|
|
|
|
|
use File::Find (); |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# Set the variable \$File::Find::dont_use_nlink if you're using AFS, |
|
243
|
|
|
|
|
|
|
# since AFS cheats. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# for the convenience of &wanted calls, including -eval statements: |
|
246
|
|
|
|
|
|
|
use vars qw/*name *dir *prune/; |
|
247
|
|
|
|
|
|
|
*name = *File::Find::name; |
|
248
|
|
|
|
|
|
|
*dir = *File::Find::dir; |
|
249
|
|
|
|
|
|
|
*prune = *File::Find::prune; |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$declaresubs |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
END |
|
254
|
|
|
|
|
|
|
|
|
255
|
3
|
50
|
|
|
|
18
|
if (exists $init{doexec}) { |
|
256
|
0
|
|
|
|
|
0
|
print <<'END'; |
|
257
|
|
|
|
|
|
|
use Cwd (); |
|
258
|
|
|
|
|
|
|
my $cwd = Cwd::cwd(); |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
END |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
3
|
50
|
|
|
|
11
|
if (exists $init{ls}) { |
|
264
|
0
|
|
|
|
|
0
|
print <<'END'; |
|
265
|
|
|
|
|
|
|
my @rwx = qw(--- --x -w- -wx r-- r-x rw- rwx); |
|
266
|
|
|
|
|
|
|
my @moname = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
END |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
3
|
50
|
33
|
|
|
36
|
if (exists $init{user} || exists $init{ls} || exists $init{tar}) { |
|
|
|
|
33
|
|
|
|
|
|
272
|
0
|
|
|
|
|
0
|
print "my (%uid, %user);\n"; |
|
273
|
0
|
|
|
|
|
0
|
print "while (my (\$name, \$pw, \$uid) = getpwent) {\n"; |
|
274
|
|
|
|
|
|
|
print ' $uid{$name} = $uid{$uid} = $uid;', "\n" |
|
275
|
0
|
0
|
|
|
|
0
|
if exists $init{user}; |
|
276
|
|
|
|
|
|
|
print ' $user{$uid} = $name unless exists $user{$uid};', "\n" |
|
277
|
0
|
0
|
0
|
|
|
0
|
if exists $init{ls} || exists $init{tar}; |
|
278
|
0
|
|
|
|
|
0
|
print "}\n\n"; |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
|
|
281
|
3
|
50
|
33
|
|
|
39
|
if (exists $init{group} || exists $init{ls} || exists $init{tar}) { |
|
|
|
|
33
|
|
|
|
|
|
282
|
0
|
|
|
|
|
0
|
print "my (%gid, %group);\n"; |
|
283
|
0
|
|
|
|
|
0
|
print "while (my (\$name, \$pw, \$gid) = getgrent) {\n"; |
|
284
|
|
|
|
|
|
|
print ' $gid{$name} = $gid{$gid} = $gid;', "\n" |
|
285
|
0
|
0
|
|
|
|
0
|
if exists $init{group}; |
|
286
|
|
|
|
|
|
|
print ' $group{$gid} = $name unless exists $group{$gid};', "\n" |
|
287
|
0
|
0
|
0
|
|
|
0
|
if exists $init{ls} || exists $init{tar}; |
|
288
|
0
|
|
|
|
|
0
|
print "}\n\n"; |
|
289
|
|
|
|
|
|
|
} |
|
290
|
|
|
|
|
|
|
|
|
291
|
3
|
50
|
|
|
|
10
|
print $initnewer, "\n" if $initnewer ne ''; |
|
292
|
3
|
50
|
|
|
|
13
|
print $initfile, "\n" if $initfile ne ''; |
|
293
|
3
|
|
|
|
|
8
|
$flushall .= "exit;\n"; |
|
294
|
3
|
50
|
|
|
|
10
|
if (exists $init{declarestat}) { |
|
295
|
3
|
|
|
|
|
40
|
$out = <<'END' . $out; |
|
296
|
|
|
|
|
|
|
my ($dev,$ino,$mode,$nlink,$uid,$gid); |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
END |
|
299
|
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
3
|
50
|
|
|
|
11
|
if ( $follow_in_effect ) { |
|
302
|
0
|
|
|
|
|
0
|
$out =~ s/lstat\(\$_\)/lstat(_)/; |
|
303
|
0
|
|
|
|
|
0
|
print <<"END"; |
|
304
|
|
|
|
|
|
|
$decl |
|
305
|
|
|
|
|
|
|
# Traverse desired filesystems |
|
306
|
|
|
|
|
|
|
File::Find::$find( {wanted => \\&wanted, follow => 1}, $roots); |
|
307
|
|
|
|
|
|
|
$flushall |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
sub wanted { |
|
310
|
|
|
|
|
|
|
$out; |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
END |
|
314
|
|
|
|
|
|
|
} else { |
|
315
|
3
|
|
|
|
|
19
|
print <<"END"; |
|
316
|
|
|
|
|
|
|
$decl |
|
317
|
|
|
|
|
|
|
# Traverse desired filesystems |
|
318
|
|
|
|
|
|
|
File::Find::$find({wanted => \\&wanted}, $roots); |
|
319
|
|
|
|
|
|
|
$flushall |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub wanted { |
|
322
|
|
|
|
|
|
|
$out; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
END |
|
326
|
|
|
|
|
|
|
} |
|
327
|
|
|
|
|
|
|
|
|
328
|
3
|
50
|
|
|
|
19
|
if (exists $init{doexec}) { |
|
329
|
0
|
|
|
|
|
0
|
print <<'END'; |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub doexec ($@) { |
|
332
|
|
|
|
|
|
|
my $ok = shift; |
|
333
|
|
|
|
|
|
|
my @command = @_; # copy so we don't try to s/// aliases to constants |
|
334
|
|
|
|
|
|
|
for my $word (@command) |
|
335
|
|
|
|
|
|
|
{ $word =~ s#{}#$name#g } |
|
336
|
|
|
|
|
|
|
if ($ok) { |
|
337
|
|
|
|
|
|
|
my $old = select(STDOUT); |
|
338
|
|
|
|
|
|
|
$| = 1; |
|
339
|
|
|
|
|
|
|
print "@command"; |
|
340
|
|
|
|
|
|
|
select($old); |
|
341
|
|
|
|
|
|
|
return 0 unless =~ /^y/; |
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
chdir $cwd; #sigh |
|
344
|
|
|
|
|
|
|
system @command; |
|
345
|
|
|
|
|
|
|
chdir $File::Find::dir; |
|
346
|
|
|
|
|
|
|
return !$?; |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
END |
|
350
|
|
|
|
|
|
|
} |
|
351
|
|
|
|
|
|
|
|
|
352
|
3
|
50
|
|
|
|
9
|
if (exists $init{ls}) { |
|
353
|
0
|
|
|
|
|
0
|
print <<'INTRO', <<"SUB", <<'END'; |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub sizemm { |
|
356
|
|
|
|
|
|
|
my $rdev = shift; |
|
357
|
|
|
|
|
|
|
sprintf("%3d, %3d", ($rdev >> 8) & 0xff, $rdev & 0xff); |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
sub ls () { |
|
361
|
|
|
|
|
|
|
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, |
|
362
|
|
|
|
|
|
|
INTRO |
|
363
|
|
|
|
|
|
|
\$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_); |
|
364
|
|
|
|
|
|
|
SUB |
|
365
|
|
|
|
|
|
|
my $pname = $name; |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
$blocks |
|
368
|
|
|
|
|
|
|
or $blocks = int(($size + 1023) / 1024); |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
my $perms = $rwx[$mode & 7]; |
|
371
|
|
|
|
|
|
|
$mode >>= 3; |
|
372
|
|
|
|
|
|
|
$perms = $rwx[$mode & 7] . $perms; |
|
373
|
|
|
|
|
|
|
$mode >>= 3; |
|
374
|
|
|
|
|
|
|
$perms = $rwx[$mode & 7] . $perms; |
|
375
|
|
|
|
|
|
|
substr($perms, 2, 1) =~ tr/-x/Ss/ if -u _; |
|
376
|
|
|
|
|
|
|
substr($perms, 5, 1) =~ tr/-x/Ss/ if -g _; |
|
377
|
|
|
|
|
|
|
substr($perms, 8, 1) =~ tr/-x/Tt/ if -k _; |
|
378
|
|
|
|
|
|
|
if (-f _) { $perms = '-' . $perms; } |
|
379
|
|
|
|
|
|
|
elsif (-d _) { $perms = 'd' . $perms; } |
|
380
|
|
|
|
|
|
|
elsif (-l _) { $perms = 'l' . $perms; $pname .= ' -> ' . readlink($_); } |
|
381
|
|
|
|
|
|
|
elsif (-c _) { $perms = 'c' . $perms; $size = sizemm($rdev); } |
|
382
|
|
|
|
|
|
|
elsif (-b _) { $perms = 'b' . $perms; $size = sizemm($rdev); } |
|
383
|
|
|
|
|
|
|
elsif (-p _) { $perms = 'p' . $perms; } |
|
384
|
|
|
|
|
|
|
elsif (-S _) { $perms = 's' . $perms; } |
|
385
|
|
|
|
|
|
|
else { $perms = '?' . $perms; } |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
my $user = $user{$uid} || $uid; |
|
388
|
|
|
|
|
|
|
my $group = $group{$gid} || $gid; |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
my ($sec,$min,$hour,$mday,$mon,$timeyear) = localtime($mtime); |
|
391
|
|
|
|
|
|
|
if (-M _ > 365.25 / 2) { |
|
392
|
|
|
|
|
|
|
$timeyear += 1900; |
|
393
|
|
|
|
|
|
|
} else { |
|
394
|
|
|
|
|
|
|
$timeyear = sprintf("%02d:%02d", $hour, $min); |
|
395
|
|
|
|
|
|
|
} |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
printf "%5lu %4ld %-10s %3d %-8s %-8s %8s %s %2d %5s %s\n", |
|
398
|
|
|
|
|
|
|
$ino, |
|
399
|
|
|
|
|
|
|
$blocks, |
|
400
|
|
|
|
|
|
|
$perms, |
|
401
|
|
|
|
|
|
|
$nlink, |
|
402
|
|
|
|
|
|
|
$user, |
|
403
|
|
|
|
|
|
|
$group, |
|
404
|
|
|
|
|
|
|
$size, |
|
405
|
|
|
|
|
|
|
$moname[$mon], |
|
406
|
|
|
|
|
|
|
$mday, |
|
407
|
|
|
|
|
|
|
$timeyear, |
|
408
|
|
|
|
|
|
|
$pname; |
|
409
|
|
|
|
|
|
|
1; |
|
410
|
|
|
|
|
|
|
} |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
END |
|
413
|
|
|
|
|
|
|
} |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
|
|
416
|
3
|
50
|
33
|
|
|
34
|
if (exists $init{cpio} || exists $init{tar}) { |
|
417
|
0
|
|
|
|
|
0
|
print <<'END'; |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
my %blocks = (); |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
sub flush { |
|
422
|
|
|
|
|
|
|
my ($fh, $varref, $blksz) = @_; |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
while (length($$varref) >= $blksz) { |
|
425
|
|
|
|
|
|
|
no strict qw/refs/; |
|
426
|
|
|
|
|
|
|
syswrite($fh, $$varref, $blksz); |
|
427
|
|
|
|
|
|
|
substr($$varref, 0, $blksz) = ''; |
|
428
|
|
|
|
|
|
|
++$blocks{$fh}; |
|
429
|
|
|
|
|
|
|
} |
|
430
|
|
|
|
|
|
|
} |
|
431
|
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
END |
|
433
|
|
|
|
|
|
|
} |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
|
|
436
|
3
|
50
|
|
|
|
17
|
if (exists $init{cpio}) { |
|
437
|
0
|
|
|
|
|
0
|
print <<'INTRO', <<"SUB", <<'END'; |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
my %cpout = (); |
|
440
|
|
|
|
|
|
|
my %nc = (); |
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
sub cpio { |
|
443
|
|
|
|
|
|
|
my ($fh, $fname, $nc) = @_; |
|
444
|
|
|
|
|
|
|
my $text = ''; |
|
445
|
|
|
|
|
|
|
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, |
|
446
|
|
|
|
|
|
|
$atime,$mtime,$ctime,$blksize,$blocks); |
|
447
|
|
|
|
|
|
|
local (*IN); |
|
448
|
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
if ( ! defined $fname ) { |
|
450
|
|
|
|
|
|
|
$fname = 'TRAILER!!!'; |
|
451
|
|
|
|
|
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, |
|
452
|
|
|
|
|
|
|
$atime,$mtime,$ctime,$blksize,$blocks) = (0) x 13; |
|
453
|
|
|
|
|
|
|
} else { |
|
454
|
|
|
|
|
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, |
|
455
|
|
|
|
|
|
|
INTRO |
|
456
|
|
|
|
|
|
|
\$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_); |
|
457
|
|
|
|
|
|
|
SUB |
|
458
|
|
|
|
|
|
|
if (-f _) { |
|
459
|
|
|
|
|
|
|
open(IN, "./$_\0") || do { |
|
460
|
|
|
|
|
|
|
warn "Couldn't open $fname: $!\n"; |
|
461
|
|
|
|
|
|
|
return; |
|
462
|
|
|
|
|
|
|
} |
|
463
|
|
|
|
|
|
|
} else { |
|
464
|
|
|
|
|
|
|
$text = readlink($_); |
|
465
|
|
|
|
|
|
|
$size = 0 unless defined $text; |
|
466
|
|
|
|
|
|
|
} |
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
$fname =~ s#^\./##; |
|
470
|
|
|
|
|
|
|
$nc{$fh} = $nc; |
|
471
|
|
|
|
|
|
|
if ($nc eq 'n') { |
|
472
|
|
|
|
|
|
|
$cpout{$fh} .= |
|
473
|
|
|
|
|
|
|
sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0", |
|
474
|
|
|
|
|
|
|
070707, |
|
475
|
|
|
|
|
|
|
$dev & 0777777, |
|
476
|
|
|
|
|
|
|
$ino & 0777777, |
|
477
|
|
|
|
|
|
|
$mode & 0777777, |
|
478
|
|
|
|
|
|
|
$uid & 0777777, |
|
479
|
|
|
|
|
|
|
$gid & 0777777, |
|
480
|
|
|
|
|
|
|
$nlink & 0777777, |
|
481
|
|
|
|
|
|
|
$rdev & 0177777, |
|
482
|
|
|
|
|
|
|
$mtime, |
|
483
|
|
|
|
|
|
|
length($fname)+1, |
|
484
|
|
|
|
|
|
|
$size, |
|
485
|
|
|
|
|
|
|
$fname); |
|
486
|
|
|
|
|
|
|
} else { |
|
487
|
|
|
|
|
|
|
$cpout{$fh} .= "\0" if length($cpout{$fh}) & 1; |
|
488
|
|
|
|
|
|
|
$cpout{$fh} .= pack("SSSSSSSSLSLa*", |
|
489
|
|
|
|
|
|
|
070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime, |
|
490
|
|
|
|
|
|
|
length($fname)+1, $size, |
|
491
|
|
|
|
|
|
|
$fname . (length($fname) & 1 ? "\0" : "\0\0")); |
|
492
|
|
|
|
|
|
|
} |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
if ($text ne '') { |
|
495
|
|
|
|
|
|
|
$cpout{$fh} .= $text; |
|
496
|
|
|
|
|
|
|
} elsif ($size) { |
|
497
|
|
|
|
|
|
|
my $l; |
|
498
|
|
|
|
|
|
|
flush($fh, \$cpout{$fh}, 5120) |
|
499
|
|
|
|
|
|
|
while ($l = length($cpout{$fh})) >= 5120; |
|
500
|
|
|
|
|
|
|
while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) { |
|
501
|
|
|
|
|
|
|
flush($fh, \$cpout{$fh}, 5120); |
|
502
|
|
|
|
|
|
|
$l = length($cpout{$fh}); |
|
503
|
|
|
|
|
|
|
} |
|
504
|
|
|
|
|
|
|
close IN; |
|
505
|
|
|
|
|
|
|
} |
|
506
|
|
|
|
|
|
|
} |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
sub cflushall () { |
|
509
|
|
|
|
|
|
|
for my $fh (keys %cpout) { |
|
510
|
|
|
|
|
|
|
cpio($fh, undef, $nc{$fh}); |
|
511
|
|
|
|
|
|
|
$cpout{$fh} .= "0" x (5120 - length($cpout{$fh})); |
|
512
|
|
|
|
|
|
|
flush($fh, \$cpout{$fh}, 5120); |
|
513
|
|
|
|
|
|
|
print $blocks{$fh} * 10, " blocks\n"; |
|
514
|
|
|
|
|
|
|
} |
|
515
|
|
|
|
|
|
|
} |
|
516
|
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
END |
|
518
|
|
|
|
|
|
|
} |
|
519
|
|
|
|
|
|
|
|
|
520
|
3
|
50
|
|
|
|
20
|
if (exists $init{tar}) { |
|
521
|
0
|
|
|
|
|
0
|
print <<'INTRO', <<"SUB", <<'END'; |
|
522
|
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
my %tarout = (); |
|
524
|
|
|
|
|
|
|
my %linkseen = (); |
|
525
|
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
sub tar { |
|
527
|
|
|
|
|
|
|
my ($fh, $fname) = @_; |
|
528
|
|
|
|
|
|
|
my $prefix = ''; |
|
529
|
|
|
|
|
|
|
my $typeflag = '0'; |
|
530
|
|
|
|
|
|
|
my $linkname; |
|
531
|
|
|
|
|
|
|
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, |
|
532
|
|
|
|
|
|
|
INTRO |
|
533
|
|
|
|
|
|
|
\$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_); |
|
534
|
|
|
|
|
|
|
SUB |
|
535
|
|
|
|
|
|
|
local (*IN); |
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
if ($nlink > 1) { |
|
538
|
|
|
|
|
|
|
if ($linkname = $linkseen{$fh, $dev, $ino}) { |
|
539
|
|
|
|
|
|
|
if (length($linkname) > 100) { |
|
540
|
|
|
|
|
|
|
warn "$0: omitting file with linkname ", |
|
541
|
|
|
|
|
|
|
"too long for tar output: $linkname\n"; |
|
542
|
|
|
|
|
|
|
return; |
|
543
|
|
|
|
|
|
|
} |
|
544
|
|
|
|
|
|
|
$typeflag = '1'; |
|
545
|
|
|
|
|
|
|
$size = 0; |
|
546
|
|
|
|
|
|
|
} else { |
|
547
|
|
|
|
|
|
|
$linkseen{$fh, $dev, $ino} = $fname; |
|
548
|
|
|
|
|
|
|
} |
|
549
|
|
|
|
|
|
|
} |
|
550
|
|
|
|
|
|
|
if ($typeflag eq '0') { |
|
551
|
|
|
|
|
|
|
if (-f _) { |
|
552
|
|
|
|
|
|
|
open(IN, "./$_\0") || do { |
|
553
|
|
|
|
|
|
|
warn "Couldn't open $fname: $!\n"; |
|
554
|
|
|
|
|
|
|
return; |
|
555
|
|
|
|
|
|
|
} |
|
556
|
|
|
|
|
|
|
} else { |
|
557
|
|
|
|
|
|
|
$linkname = readlink($_); |
|
558
|
|
|
|
|
|
|
if (defined $linkname) { $typeflag = '2' } |
|
559
|
|
|
|
|
|
|
elsif (-c _) { $typeflag = '3' } |
|
560
|
|
|
|
|
|
|
elsif (-b _) { $typeflag = '4' } |
|
561
|
|
|
|
|
|
|
elsif (-d _) { $typeflag = '5' } |
|
562
|
|
|
|
|
|
|
elsif (-p _) { $typeflag = '6' } |
|
563
|
|
|
|
|
|
|
} |
|
564
|
|
|
|
|
|
|
} |
|
565
|
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
if (length($fname) > 100) { |
|
567
|
|
|
|
|
|
|
($prefix, $fname) = ($fname =~ m#\A(.*?)/(.{,100})\Z(?!\n)#); |
|
568
|
|
|
|
|
|
|
if (!defined($fname) || length($prefix) > 155) { |
|
569
|
|
|
|
|
|
|
warn "$0: omitting file with name too long for tar output: ", |
|
570
|
|
|
|
|
|
|
$fname, "\n"; |
|
571
|
|
|
|
|
|
|
return; |
|
572
|
|
|
|
|
|
|
} |
|
573
|
|
|
|
|
|
|
} |
|
574
|
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
$size = 0 if $typeflag ne '0'; |
|
576
|
|
|
|
|
|
|
my $header = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155", |
|
577
|
|
|
|
|
|
|
$fname, |
|
578
|
|
|
|
|
|
|
sprintf("%7o ", $mode & 0777), |
|
579
|
|
|
|
|
|
|
sprintf("%7o ", $uid & 0777777), |
|
580
|
|
|
|
|
|
|
sprintf("%7o ", $gid & 0777777), |
|
581
|
|
|
|
|
|
|
sprintf("%11o ", $size), |
|
582
|
|
|
|
|
|
|
sprintf("%11o ", $mtime), |
|
583
|
|
|
|
|
|
|
' 'x8, |
|
584
|
|
|
|
|
|
|
$typeflag, |
|
585
|
|
|
|
|
|
|
defined $linkname ? $linkname : '', |
|
586
|
|
|
|
|
|
|
"ustar\0", |
|
587
|
|
|
|
|
|
|
"00", |
|
588
|
|
|
|
|
|
|
$user{$uid}, |
|
589
|
|
|
|
|
|
|
$group{$gid}, |
|
590
|
|
|
|
|
|
|
($rdev >> 8) & 0xff, |
|
591
|
|
|
|
|
|
|
$rdev & 0xff, |
|
592
|
|
|
|
|
|
|
$prefix, |
|
593
|
|
|
|
|
|
|
); |
|
594
|
|
|
|
|
|
|
substr($header, 148, 8) = sprintf("%7o ", unpack("%16C*", $header)); |
|
595
|
|
|
|
|
|
|
my $l = length($header) % 512; |
|
596
|
|
|
|
|
|
|
$tarout{$fh} .= $header; |
|
597
|
|
|
|
|
|
|
$tarout{$fh} .= "\0" x (512 - $l) if $l; |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
if ($size) { |
|
600
|
|
|
|
|
|
|
flush($fh, \$tarout{$fh}, 10240) |
|
601
|
|
|
|
|
|
|
while ($l = length($tarout{$fh})) >= 10240; |
|
602
|
|
|
|
|
|
|
while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) { |
|
603
|
|
|
|
|
|
|
my $slop = length($tarout{$fh}) % 512; |
|
604
|
|
|
|
|
|
|
$tarout{$fh} .= "\0" x (512 - $slop) if $slop; |
|
605
|
|
|
|
|
|
|
flush($fh, \$tarout{$fh}, 10240); |
|
606
|
|
|
|
|
|
|
$l = length($tarout{$fh}); |
|
607
|
|
|
|
|
|
|
} |
|
608
|
|
|
|
|
|
|
close IN; |
|
609
|
|
|
|
|
|
|
} |
|
610
|
|
|
|
|
|
|
} |
|
611
|
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
sub tflushall () { |
|
613
|
|
|
|
|
|
|
my $len; |
|
614
|
|
|
|
|
|
|
for my $fh (keys %tarout) { |
|
615
|
|
|
|
|
|
|
$len = 10240 - length($tarout{$fh}); |
|
616
|
|
|
|
|
|
|
$len += 10240 if $len < 1024; |
|
617
|
|
|
|
|
|
|
$tarout{$fh} .= "\0" x $len; |
|
618
|
|
|
|
|
|
|
flush($fh, \$tarout{$fh}, 10240); |
|
619
|
|
|
|
|
|
|
} |
|
620
|
|
|
|
|
|
|
} |
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
END |
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
|
|
625
|
3
|
|
|
|
|
0
|
exit; |
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
############################################################################ |
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
sub tab () { |
|
630
|
8
|
|
|
8
|
|
16
|
my $tabstring; |
|
631
|
|
|
|
|
|
|
|
|
632
|
8
|
|
|
|
|
40
|
$tabstring = "\t" x ($indent_depth/2) . ' ' x ($indent_depth%2 * 4); |
|
633
|
8
|
100
|
|
|
|
23
|
if (!$statdone) { |
|
634
|
3
|
50
|
|
|
|
14
|
if ($_ =~ /^(?:name|print|prune|exec|ok|\(|\))/) { |
|
635
|
0
|
|
|
|
|
0
|
$init{delayedstat} = 1; |
|
636
|
|
|
|
|
|
|
} else { |
|
637
|
3
|
|
|
|
|
19
|
my $statcall = '(($dev,$ino,$mode,$nlink,$uid,$gid) = ' |
|
638
|
|
|
|
|
|
|
. $stat . '($_))'; |
|
639
|
3
|
50
|
|
|
|
48
|
if (exists $init{saw_or}) { |
|
640
|
0
|
|
|
|
|
0
|
$tabstring .= "(\$nlink || $statcall) &&\n" . $tabstring; |
|
641
|
|
|
|
|
|
|
} else { |
|
642
|
3
|
|
|
|
|
12
|
$tabstring .= "$statcall &&\n" . $tabstring; |
|
643
|
|
|
|
|
|
|
} |
|
644
|
3
|
|
|
|
|
6
|
$statdone = 1; |
|
645
|
3
|
|
|
|
|
10
|
$init{declarestat} = 1; |
|
646
|
|
|
|
|
|
|
} |
|
647
|
|
|
|
|
|
|
} |
|
648
|
8
|
50
|
|
|
|
25
|
$tabstring =~ s/^\s+/ / if $out =~ /!$/; |
|
649
|
8
|
|
|
|
|
33
|
$tabstring; |
|
650
|
|
|
|
|
|
|
} |
|
651
|
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
sub fileglob_to_re ($) { |
|
653
|
0
|
|
|
0
|
|
0
|
my $x = shift; |
|
654
|
0
|
|
|
|
|
0
|
$x =~ s#([./^\$()+])#\\$1#g; |
|
655
|
0
|
|
|
|
|
0
|
$x =~ s#\*#.*#g; |
|
656
|
0
|
|
|
|
|
0
|
$x =~ s#\?#.#g; |
|
657
|
0
|
|
|
|
|
0
|
"^$x\\z"; |
|
658
|
|
|
|
|
|
|
} |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
sub n ($$) { |
|
661
|
2
|
|
|
2
|
|
8
|
my ($pre, $n) = @_; |
|
662
|
2
|
50
|
66
|
|
|
16
|
$n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /; |
|
663
|
2
|
|
|
|
|
22
|
$n =~ s/ 0*(\d)/ $1/; |
|
664
|
2
|
|
|
|
|
11
|
"($pre $n)"; |
|
665
|
|
|
|
|
|
|
} |
|
666
|
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
sub quote ($) { |
|
668
|
3
|
|
|
3
|
|
10
|
my $string = shift; |
|
669
|
3
|
|
|
|
|
20
|
$string =~ s/\\/\\\\/g; |
|
670
|
3
|
|
|
|
|
9
|
$string =~ s/'/\\'/g; |
|
671
|
3
|
|
|
|
|
12
|
"'$string'"; |
|
672
|
|
|
|
|
|
|
} |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
__END__ |