3 # AppleSingle/AppleDouble dump
5 # (c) 2009-2012 by HAT <hat@fa2.so-net.ne.jp>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
21 # Applesingle and AppleDouble format internals (version 1)
22 # http://users.phg-online.de/tk/netatalk/doc/Apple/v1/
24 # AppleSingle/AppleDouble Formats for Foreign Files Developer's Note (version2)
25 # http://users.phg-online.de/tk/netatalk/doc/Apple/v2/AppleSingle_AppleDouble.pdf
27 # Inside Macintosh: Macintosh Toolbox Essentials /
28 # Chapter 7 - Finder Interface / Finder Interface Reference
29 # http://developer.apple.com/legacy/mac/library/documentation/mac/toolbox/Toolbox-463.html
31 # Finder Interface Reference
32 # http://developer.apple.com/legacy/mac/library/documentation/Carbon/Reference/Finder_Interface/Reference/reference.html
34 # Technical Note TN1150 HFS Plus Volume Format
35 # http://developer.apple.com/mac/library/technotes/tn/tn1150.html#FinderInfo
37 # CarbonHeaders source
38 # http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-8A428/Finder.h
39 # http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-9A581/Finder.h
43 # /usr/bin/GetFileInfo
45 # Mac OS X 10.6.2 kernel source
46 # http://www.opensource.apple.com/source/xnu/xnu-1486.2.11/bsd/vfs/vfs_xattr.c
51 use File::Temp qw /tempfile/;
52 use bigint; # require perl >= 5.8
54 # check command for extended attributes -----------------------------------
56 if ( 0 == system("which getfattr > /dev/null 2>&1")) {
58 } elsif (0 == system("which xattr > /dev/null 2>&1")) {
60 } elsif (0 == system("which runat > /dev/null 2>&1")) {
66 #printf ( "eacommand = %d\n", $eacommand ); # debug
68 # parse command line -----------------------------------------------
71 $finderinfo = 0; # 0: unknown 1: file 2: directory
72 while ($arg = shift @ARGV)
74 if ($arg =~ /^(-h|-help|--help)$/ ) {
75 printf ("usage: %s [-a] FILE|DIR\n" ,basename($0));
76 printf (" or: %s -e FILE|DIR\n" ,basename($0));
77 printf (" or: %s -f FILE\n" ,basename($0));
78 printf (" or: %s -d FILE\n" ,basename($0));
79 printf (" or: %s -h|-help|--help\n" ,basename($0));
80 printf (" or: %s -v|-version|--version\n" ,basename($0));
81 printf ("Dump AppleSingle/AppleDouble format data.\n");
83 printf (" -a (default) Dump a AppleSingle/AppleDouble data for FILE or DIR\n");
84 printf (" automatically.\n");
85 printf (" If FILE is not AppleSingle/AppleDouble format,\n");
86 printf (" look for extended attribute, .AppleDouble/FILE and ._FILE.\n");
87 printf (" If DIR, look for extended attribute,\n");
88 printf (" DIR/.AppleDouble/.Parent and ._DIR.\n");
89 printf (" -e Dump extended attribute of FILE or DIR\n");
90 printf (" -f Dump FILE. Assume FinderInfo to be FileInfo.\n");
91 printf (" -d Dump FILE. Assume FinderInfo to be DirInfo.\n");
92 printf (" -h,-help,--help Display this help and exit\n");
93 printf (" -v,-version,--version Show version and exit\n");
95 printf ("There is no way to detect whether FinderInfo is FileInfo or DirInfo.\n");
96 printf ("By default, %s examins whether file or directory,\n" ,basename($0));
97 printf ("a parent directory is .AppleDouble, filename is ._*, filename is .Parent,\n");
98 printf ("and so on.\n");
99 printf ("If setting option -e, -f or -d, %s assume FinderInfo and doesn't look for\n");
100 printf ("another file.\n");
102 } elsif ($arg =~ /^(-v|-version|--version)$/ ) {
103 printf ("%s \(Netatalk @NETATALK_VERSION@\)\n", basename($0));
105 } elsif ($arg eq "-a") {
107 } elsif ($arg eq "-e") {
108 if ($eacommand == 0) {
109 printf (STDERR "%s: unsupported option -e\n", basename($0));
110 printf (STDERR "because neither getfattr, xattr nor runat is found.\n");
114 } elsif ($arg eq "-f") {
116 } elsif ($arg eq "-d") {
118 } elsif ($arg =~ /^-/) {
119 printf (STDERR "%s: invalid option %s\n", basename($0), $arg);
120 printf (STDERR "Try \`%s\ -h' for more information.\n", basename($0));
128 printf (STDERR "missing file operand.\n");
132 printf (STDERR "\"%s\" is not found.\n", $afile);
136 # detect FinderInfo, and search AppleSingle/AppleDouble file --------------
138 $abspath = File::Spec->rel2abs($afile);
139 ($basename, $path, $ext) = fileparse($abspath);
141 if ( $eaoption == 1 ) {
144 } elsif ( -d $afile ) {
147 printf (STDERR "unknown error: %s\n", $afile);
150 if ( 0 == checkea($afile) ) {
151 printf (STDERR "\"%s\"'s extended attribute is not found\n", $afile);
154 $openfile = eaopenfile($afile);
155 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
156 } elsif ( $finderinfo != 0 ) {
158 $openmessage = "Dumping \"$openfile\"...\n";
159 } elsif ( -f $afile ) {
160 if ( $basename eq ".Parent") {
162 } elsif ( $path =~ /\/.AppleDouble\/$/ ) {
164 } elsif ( $basename =~ /^._/ ) {
165 if ( -f $path.substr($basename, 2) ) {
167 } elsif ( -d $path.substr($basename, 2) ) {
171 if (!open(INFILE, "<$afile")) {
172 printf (STDERR "cannot open %s\n", $afile);
176 $val = unpack("N", $buf );
178 if ($val == 0x00051600 || $val == 0x00051607) {
180 $openmessage = "Dumping \"$openfile\"...\n";
182 printf ("\"%s\" is not AppleSingle/AppleDouble format.\n", $afile);
185 $netatalkfile = $path.".AppleDouble/".$basename;
186 $osxfile = $path."._".$basename;
188 if ( 1 == checkea($afile) ) {
189 printf ("\"%s\"\'s extended attribute is found.\n", $afile);
191 $openfile = eaopenfile($afile);
192 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
194 if ( -e $netatalkfile ) {
195 printf ("\"%s\" is found.\n", $netatalkfile);
197 $openfile = $netatalkfile;
198 $openmessage = "Dumping \"$openfile\"...\n";
201 printf ("\"%s\" is found.\n", $osxfile);
203 $openfile = $osxfile;
204 $openmessage = "Dumping \"$openfile\"...\n";
206 if ( $adcount == 0 ) {
207 printf ("AppleSingle/AppleDouble data is not found.\n");
210 if ( $adcount != 1 ) {
211 printf ("Specify any one.\n");
215 } elsif ( -d $afile) {
216 printf ("\"%s\" is a directory.\n", $afile);
219 $netatalkfile = $path.$basename."/.AppleDouble/.Parent";
220 $osxfile = $path."._".$basename;
222 if ( 1 == checkea($afile) ) {
223 printf ("\"%s\"\'s extended attribute is found.\n", $afile);
225 $openfile = eaopenfile($afile);
226 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
228 if ( -e $netatalkfile ) {
229 printf ("\"%s\" is found.\n", $netatalkfile);
231 $openfile= $netatalkfile;
232 $openmessage = "Dumping \"$openfile\"...\n";
235 printf ("\"%s\" is found.\n", $osxfile);
237 $openfile = $osxfile;
238 $openmessage = "Dumping \"$openfile\"...\n";
240 if ( $adcount == 0 ) {
241 printf ("AppleSingle/AppleDouble data is not found.\n");
244 if ( $adcount != 1 ) {
245 printf ("Specify any one.\n");
249 printf (STDERR "unknown error: %s\n", $afile);
253 if (!open(INFILE, "<$openfile")) {
254 printf (STDERR "cannot open %s\n", $openfile);
258 printf ($openmessage);
260 #Dump --------------------------------------------------------
262 # Magic Number -----------------------------------------------
264 print "-------------------------------------------------------------------------------\n";
267 $val = unpack("N", $buf );
268 printf("MagicNumber: %08X", $val);
269 if ( $val == 0x00051600 ) {
270 printf(" : AppleSingle");
272 elsif ( $val == 0x00051607 ) {
273 printf(" : AppleDouble");
276 printf(" : Unknown" );
280 # Version Number ---------------------------------------------
283 $version = unpack("N", $buf );
284 printf("Version : %08X", $version);
285 if ( $version == 0x00010000 ) {
286 printf(" : Version 1");
287 } elsif ( $version == 0x00020000 ) {
288 printf(" : Version 2");
290 printf(" : Unknown" );
294 # v1:Home file system / v2:Filler ----------------------------
296 read(INFILE,$buf,16);
297 if ( $version == 0x00010000 ) {
298 print "HomeFileSys:";
302 hexdump($buf, 16, 16, " ");
304 # Number of entities -----------------------------------------
307 $entnum = unpack("n", $buf );
308 printf("Num. of ent: %04X ", $entnum);
309 printf(" : %d", $entnum);
312 # data -------------------------------------------------------
314 for ( $num = 0 ; $num < $entnum ; $num++) {
316 seek(INFILE, ($num * 12 + 26), 0);
318 # Entry ---------------------------------------------------
321 $entid = unpack("N", $buf );
322 print "\n-------------------------------------------------------------------------------\n";
323 printf("Entry ID : %08X", $entid);
324 if ( $entid == 1 ) { printf(" : Data Fork"); }
325 elsif ( $entid == 2 ) { printf(" : Resource Fork"); }
326 elsif ( $entid == 3 ) { printf(" : Real Name"); }
327 elsif ( $entid == 4 ) { printf(" : Comment"); }
328 elsif ( $entid == 5 ) { printf(" : Icon, B&W"); }
329 elsif ( $entid == 6 ) { printf(" : Icon Color"); }
330 elsif ( $entid == 7 ) { printf(" : File Info"); }
331 elsif ( $entid == 8 ) { printf(" : File Dates Info"); }
332 elsif ( $entid == 9 ) { printf(" : Finder Info"); }
333 elsif ( $entid == 10 ) { printf(" : Macintosh File Info"); }
334 elsif ( $entid == 11 ) { printf(" : ProDOS File Info"); }
335 elsif ( $entid == 12 ) { printf(" : MS-DOS File Info"); }
336 elsif ( $entid == 13 ) { printf(" : Short Name"); }
337 elsif ( $entid == 14 ) { printf(" : AFP File Info"); }
338 elsif ( $entid == 15 ) { printf(" : Directory ID"); }
339 elsif ( $entid == 0x8053567E ) { printf(" : CNID (Netatalk Extended)"); }
340 elsif ( $entid == 0x8053594E ) { printf(" : DB stamp (Netatalk Extended)"); }
341 elsif ( $entid == 0x80444556 ) { printf(" : dev (Netatalk Extended)"); }
342 elsif ( $entid == 0x80494E4F ) { printf(" : inode (Netatalk Extended)"); }
343 else { printf(" : Unknown"); }
346 # Offset -------------------------------------------------
349 $ofst = unpack("N", $buf );
350 printf("Offset : %08X", $ofst);
351 printf(" : %d ", $ofst);
353 # Length -------------------------------------------------
356 $len = unpack("N", $buf );
357 printf("\nLength : %08X", $len);
358 printf(" : %d", $len);
363 # Dump for each Entry ID --------------------------------
365 # if ( $entid == 1 ) { ; } # Data Fork
366 # if ( $entid == 2 ) { ; } # Resource Fork
367 # if ( $entid == 3 ) { ; } # Real Name
368 # if ( $entid == 4 ) { ; } # Comment
369 # if ( $entid == 5 ) { ; } # Icon, B&W
370 # if ( $entid == 6 ) { ; } # Icon Color
371 # if ( $entid == 7 ) { ; } # File Info
372 if ( $entid == 8 ) { filedatesdump($ofst,$len); }
373 elsif ( $entid == 9 ) { finderinfodump($ofst,$len); }
374 # if ( $entid == 10 ) { ; } # Macintosh File Info
375 # if ( $entid == 11 ) { ; } # ProDOS File Info
376 # if ( $entid == 12 ) { ; } # MS-DOS File Info
377 # if ( $entid == 13 ) { ; } # Short Name
378 # if ( $entid == 14 ) { ; } # AFP File Info
379 elsif ( $entid == 15 ) { print "\n"; bedump($ofst,$len); } # Directory ID
380 elsif ( $entid == 0x8053567E ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # CNID (Netatalk Extended)
381 elsif ( $entid == 0x8053594E ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # DB stamp (Netatalk Extended)
382 elsif ( $entid == 0x80444556 ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # dev (Netatalk Extended)
383 elsif ( $entid == 0x80494E4F ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # inode (Netatalk Extended)
385 # RAW Dump ---------------------------------------------------
387 if ( ($quo > 0) || ($rem > 0)) {
389 print "-RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
392 seek(INFILE, $ofst, 0);
400 #sub -----------------------------------------------------------
403 my ($ofst, $len) = @_;
408 @datetype =('create ', 'modify ', 'backup ', 'access ');
410 seek(INFILE, $ofst, 0);
413 printf ("-DATE------: : (GMT) : (Local)\n");
415 for ( $i = 0 ; $i < 4 ; $i++) {
417 $datedata = unpack("N", $buf );
418 if ($datedata < 0x80000000) {
419 $datestr = gmtime( $datedata + 946684800)
421 .localtime( $datedata + 946684800);
422 } elsif ($datedata == 0x80000000) {
423 $datestr = "Unknown or Initial";
425 $datestr = gmtime( $datedata - 3348282496)
427 .localtime( $datedata - 3348282496);
429 printf ("%s : %08X : %s\n",$datetype[$i], $datedata, $datestr);
434 my ($ofst, $len) = @_;
436 seek(INFILE, $ofst, 0);
438 if ($finderinfo == 0) {
440 print "-NOTE------: cannot detect whether FInfo or DInfo. assume FInfo.\n";
443 if ($finderinfo == 0 || $finderinfo == 1) {
444 filefinderinfodump();
445 } elsif ($finderinfo == 2) {
448 print STDERR "unknown FinderInfo type\n"
451 if ($len > 32) { eadump(); }
454 sub filefinderinfodump {
457 print "-FInfo-----:\n";
461 hexdump($buf, 4, 4, "");
465 hexdump($buf, 4, 4, "");
470 $val = unpack("n", $buf );
471 printf("Location v : %04X", $val);
472 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
475 $val = unpack("n", $buf );
476 printf("Location h : %04X", $val);
477 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
481 hexdump($buf, 2, 4, "");
484 print "-FXInfo----:\n";
487 $val = unpack("n", $buf );
488 printf("Rsvd|IconID: %04X", $val);
489 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
493 hexdump($buf, 2, 4, "");
496 hexdump($buf, 2, 4, "");
499 hexdump($buf, 2, 4, "");
504 $val = unpack("n", $buf );
505 printf("Rsvd|commnt: %04X", $val);
506 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
509 $val = unpack("N", $buf );
510 printf("PutAway : %08X", $val);
511 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
515 sub dirfinderinfodump {
518 print "-DInfo-----:\n";
521 $val = unpack("n", $buf );
522 printf("Rect top : %04X", $val);
523 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
526 $val = unpack("n", $buf );
527 printf("Rect left : %04X", $val);
528 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
531 $val = unpack("n", $buf );
532 printf("Rect bottom: %04X", $val);
533 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
536 $val = unpack("n", $buf );
537 printf("Rect right : %04X", $val);
538 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
543 $val = unpack("n", $buf );
544 printf("Location v : %04X", $val);
545 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
548 $val = unpack("n", $buf );
549 printf("Location h : %04X", $val);
550 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
554 hexdump($buf, 2, 4, "");
557 print "-DXInfo----:\n";
560 $val = unpack("n", $buf );
561 printf("Scroll v : %04X", $val);
562 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
565 $val = unpack("n", $buf );
566 printf("Scroll h : %04X", $val);
567 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
570 $val = unpack("N", $buf );
571 printf("Rsvd|OpnChn: %08X", $val);
572 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
578 hexdump($buf, 2, 4, "");
581 $val = unpack("N", $buf );
582 printf("PutAway : %08X", $val);
583 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
588 @colortype =('none', 'gray', 'green', 'purple', 'blue', 'yellow', 'red', 'orange');
591 $flags = unpack("n", $buf );
592 printf ("isAlias : %d\n", ($flags >> 15) & 1);
593 printf ("Invisible : %d\n", ($flags >> 14) & 1);
594 printf ("hasBundle : %d\n", ($flags >> 13) & 1);
595 printf ("nameLocked : %d\n", ($flags >> 12) & 1);
596 printf ("Stationery : %d\n", ($flags >> 11) & 1);
597 printf ("CustomIcon : %d\n", ($flags >> 10) & 1);
598 printf ("Reserved : %d\n", ($flags >> 9) & 1);
599 printf ("Inited : %d\n", ($flags >> 8) & 1);
600 printf ("NoINITS : %d\n", ($flags >> 7) & 1);
601 printf ("Shared : %d\n", ($flags >> 6) & 1);
602 printf ("SwitchLaunc: %d\n", ($flags >> 5) & 1);
603 printf ("Hidden Ext : %d\n", ($flags >> 4) & 1);
604 printf ("color : %d%d%d : %s\n", ($flags >> 3) & 1,
607 @colortype[($flags & 0xE)>>1]);
608 printf ("isOnDesk : %d\n", ($flags >> 0) & 1);
615 $flags = unpack("n", $buf );
617 if (($flags >> 15) == 1) {
619 hexdump($buf, 1, 4, "");
621 printf ("AreInvalid : %d\n", ($flags >> 15) & 1);
622 printf ("unknown bit: %d\n", ($flags >> 14) & 1);
623 printf ("unknown bit: %d\n", ($flags >> 13) & 1);
624 printf ("unknown bit: %d\n", ($flags >> 12) & 1);
625 printf ("unknown bit: %d\n", ($flags >> 11) & 1);
626 printf ("unknown bit: %d\n", ($flags >> 10) & 1);
627 printf ("unknown bit: %d\n", ($flags >> 9) & 1);
630 printf ("CustomBadge: %d\n", ($flags >> 8) & 1);
631 printf ("ObjctIsBusy: %d\n", ($flags >> 7) & 1);
632 printf ("unknown bit: %d\n", ($flags >> 6) & 1);
633 printf ("unknown bit: %d\n", ($flags >> 5) & 1);
634 printf ("unknown bit: %d\n", ($flags >> 4) & 1);
635 printf ("unknown bit: %d\n", ($flags >> 3) & 1);
636 printf ("RoutingInfo: %d\n", ($flags >> 2) & 1);
637 printf ("unknown bit: %d\n", ($flags >> 1) & 1);
638 printf ("unknown bit: %d\n", ($flags >> 0) & 1);
645 print "-EA--------:\n";
649 hexdump($buf, 2, 4, "");
653 hexdump($buf, 4, 4, "");
656 $ea_debug_tag = unpack("N", $buf );
657 printf("debug_tag : %08X", $ea_debug_tag);
658 printf(" : %d\n", $ea_debug_tag);
661 $ea_total_size = unpack("N", $buf );
662 printf("total_size : %08X", $ea_total_size);
663 printf(" : %d\n", $ea_total_size);
666 $ea_data_start = unpack("N", $buf );
667 printf("data_start : %08X", $ea_data_start);
668 printf(" : %d\n", $ea_data_start);
671 $ea_data_length = unpack("N", $buf );
672 printf("data_length: %08X", $ea_data_length);
673 printf(" : %d\n", $ea_data_length);
676 print "reserved[0]: ";
677 hexdump($buf, 4, 4, "");
680 print "reserved[1]: ";
681 hexdump($buf, 4, 4, "");
684 print "reserved[2]: ";
685 hexdump($buf, 4, 4, "");
689 hexdump($buf, 2, 4, "");
692 $ea_num_attrs = unpack("n", $buf );
693 printf("num_attrs : %04X", $ea_num_attrs);
694 printf(" : %d\n", $ea_num_attrs);
698 for ($i = 0 ; $i < $ea_num_attrs ; $i++) {
700 $pos = (($pos & 0x3) == 0) ? ($pos) : ((($pos >> 2) + 1) << 2);
701 seek(INFILE, $pos, 0);
703 print "-EA ENTRY--:\n";
706 $ea_offset = unpack("N", $buf );
707 printf("offset : %08X", $ea_offset);
708 printf(" : %d\n", $ea_offset);
711 $ea_length = unpack("N", $buf );
712 printf("length : %08X", $ea_length);
713 printf(" : %d\n", $ea_length);
717 hexdump($buf, 2, 4, "");
720 $ea_namelen = unpack("C", $buf );
721 printf("namelen : %02X", $ea_namelen);
722 printf(" : %d\n", $ea_namelen);
724 $ea_namequo = $ea_namelen >> 4;
725 $ea_namerem = $ea_namelen & 0xF;
726 print "-EA NAME---: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
727 rawdump($ea_namequo, $ea_namerem);
731 seek(INFILE, $ea_offset, 0);
732 $ea_quo = $ea_length >> 4;
733 $ea_rem = $ea_length & 0xF;
734 print "-EA VALUE--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
735 rawdump($ea_quo, $ea_rem);
740 my ($ofst, $len) = @_;
744 seek(INFILE, $ofst, 0);
746 printf("%2dbit-BE : ", $len * 8 );
749 for ( $i=0 ; $i < $len ; $i++ ) {
751 $bytedata[$i] = unpack("C", $buf );
752 $value += $bytedata[$i] << (($len - $i -1) * 8) ;
755 for ( $i=0 ; $i < $len ; $i++ ) {
756 printf("%02X", $bytedata[$i]);
759 printf(" : %s", $value);
764 my ($ofst, $len) = @_;
768 seek(INFILE, $ofst, 0);
770 printf("%2dbit-LE : ", $len * 8 );
773 for ( $i=0 ; $i < $len ; $i++ ) {
775 $bytedata[$len - $i - 1] = unpack("C", $buf );
776 $value += $bytedata[$len - $i -1] << ($i * 8) ;
779 for ( $i=0 ; $i < $len ; $i++ ) {
780 printf("%02X", $bytedata[$i]);
783 printf(" : %s", $value);
788 my ($quo, $rem) = @_;
789 my ($addrs, $line, $buf);
792 for ( $line = 0 ; $line < $quo ; $line++) {
793 read(INFILE, $buf, 16);
794 printf ( "%08X :", $addrs);
795 hexdump($buf, 16, 16, " ");
796 $addrs = $addrs + 0x10;
799 read(INFILE, $buf, $rem);
800 printf ( "%08X :", $addrs);
801 hexdump($buf, $rem, 16, " ");
806 my ($buf, $len, $col, $delimit) = @_;
812 for ( $i=0 ; $i < $len ; $i++ ) {
813 $val = substr($buf, $i, 1);
815 $hexstr .= sprintf("%s%02X", $delimit, $ascval);
817 if (($ascval < 32) || ( $ascval > 126 )) {
822 for ( ; $i < $col ; $i++) {
823 $hexstr .= " ".$delimit;
827 printf("%s : %s", $hexstr,$ascstr);
835 $file =~ s/\\/\\\\/g;
836 $file =~ s/\"/\\\"/g;
837 $file =~ s/\$/\\\$/g;
838 $file =~ s/\`/\\\`/g;
839 if ( $eacommand == 1 ) {
840 open(EALIST, "getfattr \"$file\" |");
842 if ( $_ eq "user.org.netatalk.Metadata\n" ) {
849 } elsif ( $eacommand == 2 ) {
850 open(EALIST, "attr -q -l \"$file\" |");
852 if ( $_ eq "org.netatalk.Metadata\n" ) {
859 } elsif ( $eacommand == 3 ) {
860 open(EALIST, "runat \"$file\" ls -1 |");
862 if ( $_ eq "org.netatalk.Metadata\n" ) {
877 $file =~ s/\\/\\\\/g;
878 $file =~ s/\"/\\\"/g;
879 $file =~ s/\$/\\\$/g;
880 $file =~ s/\`/\\\`/g;
881 ($eatempfh, $eatempfile) = tempfile(UNLINK => 1);
883 if ( $eacommand == 1 ) {
884 system("getfattr --only-values -n user.org.netatalk.Metadata \"$file\" > $eatempfile");
885 } elsif ( $eacommand == 2 ) {
886 system("attr -q -g org.netatalk.Metadata \"$file\" > $eatempfile");
887 } elsif ( $eacommand == 3 ) {
888 system("runat \"$file\" cat org.netatalk.Metadata > $eatempfile");