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 } elsif ( -f $afile ) {
159 if ( $basename eq ".Parent") {
161 } elsif ( $path =~ /\/.AppleDouble\/$/ ) {
163 } elsif ( $basename =~ /^._/ ) {
164 if ( -f $path.substr($basename, 2) ) {
166 } elsif ( -d $path.substr($basename, 2) ) {
170 if (!open(INFILE, "<$afile")) {
171 printf (STDERR "cannot open %s\n", $afile);
175 $val = unpack("N", $buf );
177 if ($val == 0x00051600 || $val == 0x00051607) {
179 $openmessage = "Dumping \"$openfile\"...\n";
181 printf ("\"%s\" is not AppleSingle/AppleDouble format.\n", $afile);
184 $netatalkfile = $path.".AppleDouble/".$basename;
185 $osxfile = $path."._".$basename;
187 if ( 1 == checkea($afile) ) {
188 printf ("\"%s\"\'s extended attribute is found.\n", $afile);
190 $openfile = eaopenfile($afile);
191 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
193 if ( -e $netatalkfile ) {
194 printf ("\"%s\" is found.\n", $netatalkfile);
195 $openfile = $netatalkfile;
196 $openmessage = "Dumping \"$openfile\"...\n";
199 printf ("\"%s\" is found.\n", $osxfile);
201 $openfile = $osxfile;
202 $openmessage = "Dumping \"$openfile\"...\n";
204 if ( $adcount == 0 ) {
205 printf ("AppleSingle/AppleDouble data is not found.\n");
208 if ( $adcount != 1 ) {
209 printf ("Specify any one.\n");
213 } elsif ( -d $afile) {
214 printf ("\"%s\" is a directory.\n", $afile);
217 $netatalkfile = $path.$basename."/.AppleDouble/.Parent";
218 $osxfile = $path."._".$basename;
220 if ( 1 == checkea($afile) ) {
221 printf ("\"%s\"\'s extended attribute is found.\n", $afile);
223 $openfile = eaopenfile($afile);
224 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
226 if ( -e $netatalkfile ) {
227 printf ("\"%s\" is found.\n", $netatalkfile);
229 $openfile= $netatalkfile;
230 $openmessage = "Dumping \"$openfile\"...\n";
233 printf ("\"%s\" is found.\n", $osxfile);
235 $openfile = $osxfile;
236 $openmessage = "Dumping \"$openfile\"...\n";
238 if ( $adcount == 0 ) {
239 printf ("AppleSingle/AppleDouble data is not found.\n");
242 if ( $adcount != 1 ) {
243 printf ("Specify any one.\n");
247 printf (STDERR "unknown error: %s\n", $afile);
251 if (!open(INFILE, "<$openfile")) {
252 printf (STDERR "cannot open %s\n", $openfile);
256 printf ($openmessage);
258 #Dump --------------------------------------------------------
260 # Magic Number -----------------------------------------------
262 print "-------------------------------------------------------------------------------\n";
265 $val = unpack("N", $buf );
266 printf("MagicNumber: %08X", $val);
267 if ( $val == 0x00051600 ) {
268 printf(" : AppleSingle");
270 elsif ( $val == 0x00051607 ) {
271 printf(" : AppleDouble");
274 printf(" : Unknown" );
278 # Version Number ---------------------------------------------
281 $version = unpack("N", $buf );
282 printf("Version : %08X", $version);
283 if ( $version == 0x00010000 ) {
284 printf(" : Version 1");
285 } elsif ( $version == 0x00020000 ) {
286 printf(" : Version 2");
288 printf(" : Unknown" );
292 # v1:Home file system / v2:Filler ----------------------------
294 read(INFILE,$buf,16);
295 if ( $version == 0x00010000 ) {
296 print "HomeFileSys:";
300 hexdump($buf, 16, 16, " ");
302 # Number of entities -----------------------------------------
305 $entnum = unpack("n", $buf );
306 printf("Num. of ent: %04X ", $entnum);
307 printf(" : %d", $entnum);
310 # data -------------------------------------------------------
312 for ( $num = 0 ; $num < $entnum ; $num++) {
314 seek(INFILE, ($num * 12 + 26), 0);
316 # Entry ---------------------------------------------------
319 $entid = unpack("N", $buf );
320 print "\n-------------------------------------------------------------------------------\n";
321 printf("Entry ID : %08X", $entid);
322 if ( $entid == 1 ) { printf(" : Data Fork"); }
323 elsif ( $entid == 2 ) { printf(" : Resource Fork"); }
324 elsif ( $entid == 3 ) { printf(" : Real Name"); }
325 elsif ( $entid == 4 ) { printf(" : Comment"); }
326 elsif ( $entid == 5 ) { printf(" : Icon, B&W"); }
327 elsif ( $entid == 6 ) { printf(" : Icon Color"); }
328 elsif ( $entid == 7 ) { printf(" : File Info"); }
329 elsif ( $entid == 8 ) { printf(" : File Dates Info"); }
330 elsif ( $entid == 9 ) { printf(" : Finder Info"); }
331 elsif ( $entid == 10 ) { printf(" : Macintosh File Info"); }
332 elsif ( $entid == 11 ) { printf(" : ProDOS File Info"); }
333 elsif ( $entid == 12 ) { printf(" : MS-DOS File Info"); }
334 elsif ( $entid == 13 ) { printf(" : Short Name"); }
335 elsif ( $entid == 14 ) { printf(" : AFP File Info"); }
336 elsif ( $entid == 15 ) { printf(" : Directory ID"); }
337 elsif ( $entid == 0x8053567E ) { printf(" : CNID (Netatalk Extended)"); }
338 elsif ( $entid == 0x8053594E ) { printf(" : DB stamp (Netatalk Extended)"); }
339 elsif ( $entid == 0x80444556 ) { printf(" : dev (Netatalk Extended)"); }
340 elsif ( $entid == 0x80494E4F ) { printf(" : inode (Netatalk Extended)"); }
341 else { printf(" : Unknown"); }
344 # Offset -------------------------------------------------
347 $ofst = unpack("N", $buf );
348 printf("Offset : %08X", $ofst);
349 printf(" : %d ", $ofst);
351 # Length -------------------------------------------------
354 $len = unpack("N", $buf );
355 printf("\nLength : %08X", $len);
356 printf(" : %d", $len);
361 # Dump for each Entry ID --------------------------------
363 # if ( $entid == 1 ) { ; } # Data Fork
364 # if ( $entid == 2 ) { ; } # Resource Fork
365 # if ( $entid == 3 ) { ; } # Real Name
366 # if ( $entid == 4 ) { ; } # Comment
367 # if ( $entid == 5 ) { ; } # Icon, B&W
368 # if ( $entid == 6 ) { ; } # Icon Color
369 # if ( $entid == 7 ) { ; } # File Info
370 if ( $entid == 8 ) { filedatesdump($ofst,$len); }
371 elsif ( $entid == 9 ) { finderinfodump($ofst,$len); }
372 # if ( $entid == 10 ) { ; } # Macintosh File Info
373 # if ( $entid == 11 ) { ; } # ProDOS File Info
374 # if ( $entid == 12 ) { ; } # MS-DOS File Info
375 # if ( $entid == 13 ) { ; } # Short Name
376 # if ( $entid == 14 ) { ; } # AFP File Info
377 elsif ( $entid == 15 ) { print "\n"; bedump($ofst,$len); } # Directory ID
378 elsif ( $entid == 0x8053567E ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # CNID (Netatalk Extended)
379 elsif ( $entid == 0x8053594E ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # DB stamp (Netatalk Extended)
380 elsif ( $entid == 0x80444556 ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # dev (Netatalk Extended)
381 elsif ( $entid == 0x80494E4F ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # inode (Netatalk Extended)
383 # RAW Dump ---------------------------------------------------
385 if ( ($quo > 0) || ($rem > 0)) {
387 print "-RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
390 seek(INFILE, $ofst, 0);
398 #sub -----------------------------------------------------------
401 my ($ofst, $len) = @_;
406 @datetype =('create ', 'modify ', 'backup ', 'access ');
408 seek(INFILE, $ofst, 0);
411 printf ("-DATE------: : (GMT) : (Local)\n");
413 for ( $i = 0 ; $i < 4 ; $i++) {
415 $datedata = unpack("N", $buf );
416 if ($datedata < 0x80000000) {
417 $datestr = gmtime( $datedata + 946684800)
419 .localtime( $datedata + 946684800);
420 } elsif ($datedata == 0x80000000) {
421 $datestr = "Unknown or Initial";
423 $datestr = gmtime( $datedata - 3348282496)
425 .localtime( $datedata - 3348282496);
427 printf ("%s : %08X : %s\n",$datetype[$i], $datedata, $datestr);
432 my ($ofst, $len) = @_;
434 seek(INFILE, $ofst, 0);
436 if ($finderinfo == 0) {
438 print "-NOTE------: cannot detect whether FInfo or DInfo. assume FInfo.\n";
441 if ($finderinfo == 0 || $finderinfo == 1) {
442 filefinderinfodump();
443 } elsif ($finderinfo == 2) {
446 print STDERR "unknown FinderInfo type\n"
449 if ($len > 32) { eadump(); }
452 sub filefinderinfodump {
455 print "-FInfo-----:\n";
459 hexdump($buf, 4, 4, "");
463 hexdump($buf, 4, 4, "");
468 $val = unpack("n", $buf );
469 printf("Location v : %04X", $val);
470 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
473 $val = unpack("n", $buf );
474 printf("Location h : %04X", $val);
475 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
479 hexdump($buf, 2, 4, "");
482 print "-FXInfo----:\n";
485 $val = unpack("n", $buf );
486 printf("Rsvd|IconID: %04X", $val);
487 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
491 hexdump($buf, 2, 4, "");
494 hexdump($buf, 2, 4, "");
497 hexdump($buf, 2, 4, "");
502 $val = unpack("n", $buf );
503 printf("Rsvd|commnt: %04X", $val);
504 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
507 $val = unpack("N", $buf );
508 printf("PutAway : %08X", $val);
509 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
513 sub dirfinderinfodump {
516 print "-DInfo-----:\n";
519 $val = unpack("n", $buf );
520 printf("Rect top : %04X", $val);
521 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
524 $val = unpack("n", $buf );
525 printf("Rect left : %04X", $val);
526 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
529 $val = unpack("n", $buf );
530 printf("Rect bottom: %04X", $val);
531 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
534 $val = unpack("n", $buf );
535 printf("Rect right : %04X", $val);
536 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
541 $val = unpack("n", $buf );
542 printf("Location v : %04X", $val);
543 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
546 $val = unpack("n", $buf );
547 printf("Location h : %04X", $val);
548 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
552 hexdump($buf, 2, 4, "");
555 print "-DXInfo----:\n";
558 $val = unpack("n", $buf );
559 printf("Scroll v : %04X", $val);
560 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
563 $val = unpack("n", $buf );
564 printf("Scroll h : %04X", $val);
565 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
568 $val = unpack("N", $buf );
569 printf("Rsvd|OpnChn: %08X", $val);
570 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
576 hexdump($buf, 2, 4, "");
579 $val = unpack("N", $buf );
580 printf("PutAway : %08X", $val);
581 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
586 @colortype =('none', 'gray', 'green', 'purple', 'blue', 'yellow', 'red', 'orange');
589 $flags = unpack("n", $buf );
590 printf ("isAlias : %d\n", ($flags >> 15) & 1);
591 printf ("Invisible : %d\n", ($flags >> 14) & 1);
592 printf ("hasBundle : %d\n", ($flags >> 13) & 1);
593 printf ("nameLocked : %d\n", ($flags >> 12) & 1);
594 printf ("Stationery : %d\n", ($flags >> 11) & 1);
595 printf ("CustomIcon : %d\n", ($flags >> 10) & 1);
596 printf ("Reserved : %d\n", ($flags >> 9) & 1);
597 printf ("Inited : %d\n", ($flags >> 8) & 1);
598 printf ("NoINITS : %d\n", ($flags >> 7) & 1);
599 printf ("Shared : %d\n", ($flags >> 6) & 1);
600 printf ("SwitchLaunc: %d\n", ($flags >> 5) & 1);
601 printf ("Hidden Ext : %d\n", ($flags >> 4) & 1);
602 printf ("color : %d%d%d : %s\n", ($flags >> 3) & 1,
605 @colortype[($flags & 0xE)>>1]);
606 printf ("isOnDesk : %d\n", ($flags >> 0) & 1);
613 $flags = unpack("n", $buf );
615 if (($flags >> 15) == 1) {
617 hexdump($buf, 1, 4, "");
619 printf ("AreInvalid : %d\n", ($flags >> 15) & 1);
620 printf ("unknown bit: %d\n", ($flags >> 14) & 1);
621 printf ("unknown bit: %d\n", ($flags >> 13) & 1);
622 printf ("unknown bit: %d\n", ($flags >> 12) & 1);
623 printf ("unknown bit: %d\n", ($flags >> 11) & 1);
624 printf ("unknown bit: %d\n", ($flags >> 10) & 1);
625 printf ("unknown bit: %d\n", ($flags >> 9) & 1);
628 printf ("CustomBadge: %d\n", ($flags >> 8) & 1);
629 printf ("ObjctIsBusy: %d\n", ($flags >> 7) & 1);
630 printf ("unknown bit: %d\n", ($flags >> 6) & 1);
631 printf ("unknown bit: %d\n", ($flags >> 5) & 1);
632 printf ("unknown bit: %d\n", ($flags >> 4) & 1);
633 printf ("unknown bit: %d\n", ($flags >> 3) & 1);
634 printf ("RoutingInfo: %d\n", ($flags >> 2) & 1);
635 printf ("unknown bit: %d\n", ($flags >> 1) & 1);
636 printf ("unknown bit: %d\n", ($flags >> 0) & 1);
643 print "-EA--------:\n";
647 hexdump($buf, 2, 4, "");
651 hexdump($buf, 4, 4, "");
654 $ea_debug_tag = unpack("N", $buf );
655 printf("debug_tag : %08X", $ea_debug_tag);
656 printf(" : %d\n", $ea_debug_tag);
659 $ea_total_size = unpack("N", $buf );
660 printf("total_size : %08X", $ea_total_size);
661 printf(" : %d\n", $ea_total_size);
664 $ea_data_start = unpack("N", $buf );
665 printf("data_start : %08X", $ea_data_start);
666 printf(" : %d\n", $ea_data_start);
669 $ea_data_length = unpack("N", $buf );
670 printf("data_length: %08X", $ea_data_length);
671 printf(" : %d\n", $ea_data_length);
674 print "reserved[0]: ";
675 hexdump($buf, 4, 4, "");
678 print "reserved[1]: ";
679 hexdump($buf, 4, 4, "");
682 print "reserved[2]: ";
683 hexdump($buf, 4, 4, "");
687 hexdump($buf, 2, 4, "");
690 $ea_num_attrs = unpack("n", $buf );
691 printf("num_attrs : %04X", $ea_num_attrs);
692 printf(" : %d\n", $ea_num_attrs);
696 for ($i = 0 ; $i < $ea_num_attrs ; $i++) {
698 $pos = (($pos & 0x3) == 0) ? ($pos) : ((($pos >> 2) + 1) << 2);
699 seek(INFILE, $pos, 0);
701 print "-EA ENTRY--:\n";
704 $ea_offset = unpack("N", $buf );
705 printf("offset : %08X", $ea_offset);
706 printf(" : %d\n", $ea_offset);
709 $ea_length = unpack("N", $buf );
710 printf("length : %08X", $ea_length);
711 printf(" : %d\n", $ea_length);
715 hexdump($buf, 2, 4, "");
718 $ea_namelen = unpack("C", $buf );
719 printf("namelen : %02X", $ea_namelen);
720 printf(" : %d\n", $ea_namelen);
722 $ea_namequo = $ea_namelen >> 4;
723 $ea_namerem = $ea_namelen & 0xF;
724 print "-EA NAME---: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
725 rawdump($ea_namequo, $ea_namerem);
729 seek(INFILE, $ea_offset, 0);
730 $ea_quo = $ea_length >> 4;
731 $ea_rem = $ea_length & 0xF;
732 print "-EA VALUE--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
733 rawdump($ea_quo, $ea_rem);
738 my ($ofst, $len) = @_;
742 seek(INFILE, $ofst, 0);
744 printf("%2dbit-BE : ", $len * 8 );
747 for ( $i=0 ; $i < $len ; $i++ ) {
749 $bytedata[$i] = unpack("C", $buf );
750 $value += $bytedata[$i] << (($len - $i -1) * 8) ;
753 for ( $i=0 ; $i < $len ; $i++ ) {
754 printf("%02X", $bytedata[$i]);
757 printf(" : %s", $value);
762 my ($ofst, $len) = @_;
766 seek(INFILE, $ofst, 0);
768 printf("%2dbit-LE : ", $len * 8 );
771 for ( $i=0 ; $i < $len ; $i++ ) {
773 $bytedata[$len - $i - 1] = unpack("C", $buf );
774 $value += $bytedata[$len - $i -1] << ($i * 8) ;
777 for ( $i=0 ; $i < $len ; $i++ ) {
778 printf("%02X", $bytedata[$i]);
781 printf(" : %s", $value);
786 my ($quo, $rem) = @_;
787 my ($addrs, $line, $buf);
790 for ( $line = 0 ; $line < $quo ; $line++) {
791 read(INFILE, $buf, 16);
792 printf ( "%08X :", $addrs);
793 hexdump($buf, 16, 16, " ");
794 $addrs = $addrs + 0x10;
797 read(INFILE, $buf, $rem);
798 printf ( "%08X :", $addrs);
799 hexdump($buf, $rem, 16, " ");
804 my ($buf, $len, $col, $delimit) = @_;
810 for ( $i=0 ; $i < $len ; $i++ ) {
811 $val = substr($buf, $i, 1);
813 $hexstr .= sprintf("%s%02X", $delimit, $ascval);
815 if (($ascval < 32) || ( $ascval > 126 )) {
820 for ( ; $i < $col ; $i++) {
821 $hexstr .= " ".$delimit;
825 printf("%s : %s", $hexstr,$ascstr);
833 $file =~ s/\\/\\\\/g;
834 $file =~ s/\"/\\\"/g;
835 $file =~ s/\$/\\\$/g;
836 $file =~ s/\`/\\\`/g;
837 if ( $eacommand == 1 ) {
838 open(EALIST, "getfattr \"$file\" |");
840 if ( $_ eq "user.org.netatalk.Metadata\n" ) {
847 } elsif ( $eacommand == 2 ) {
848 open(EALIST, "attr -q -l \"$file\" |");
850 if ( $_ eq "org.netatalk.Metadata\n" ) {
857 } elsif ( $eacommand == 3 ) {
858 open(EALIST, "runat \"$file\" ls -1 |");
860 if ( $_ eq "org.netatalk.Metadata\n" ) {
875 $file =~ s/\\/\\\\/g;
876 $file =~ s/\"/\\\"/g;
877 $file =~ s/\$/\\\$/g;
878 $file =~ s/\`/\\\`/g;
879 ($eatempfh, $eatempfile) = tempfile(UNLINK => 1);
881 if ( $eacommand == 1 ) {
882 system("getfattr --only-values -n user.org.netatalk.Metadata \"$file\" > $eatempfile");
883 } elsif ( $eacommand == 2 ) {
884 system("attr -q -g org.netatalk.Metadata \"$file\" > $eatempfile");
885 } elsif ( $eacommand == 3 ) {
886 system("runat \"$file\" cat org.netatalk.Metadata > $eatempfile");