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")) {
62 } elsif (0 == system("which getextattr > /dev/null 2>&1")) {
68 #printf ( "eacommand = %d\n", $eacommand ); # debug
70 # parse command line -----------------------------------------------
74 $finderinfo = 0; # 0: unknown 1: file 2: directory
75 while ($arg = shift @ARGV)
77 if ($arg =~ /^(-h|-help|--help)$/ ) {
78 printf ("usage: %s [-a] [FILE|DIR]\n" ,basename($0));
79 printf (" or: %s -e FILE|DIR\n" ,basename($0));
80 printf (" or: %s -f [FILE]\n" ,basename($0));
81 printf (" or: %s -d [FILE]\n" ,basename($0));
82 printf (" or: %s -h|-help|--help\n" ,basename($0));
83 printf (" or: %s -v|-version|--version\n" ,basename($0));
84 printf ("Dump AppleSingle/AppleDouble format data.\n");
85 printf ("With no FILE|DIR, or when FILE|DIR is -, read standard input.\n");
87 printf (" -a (default) Dump a AppleSingle/AppleDouble data for FILE or DIR\n");
88 printf (" automatically.\n");
89 printf (" If FILE is not AppleSingle/AppleDouble format,\n");
90 printf (" look for extended attribute, .AppleDouble/FILE and ._FILE.\n");
91 printf (" If DIR, look for extended attribute,\n");
92 printf (" DIR/.AppleDouble/.Parent and ._DIR.\n");
93 printf (" -e Dump extended attribute of FILE or DIR\n");
94 printf (" -f Dump FILE. Assume FinderInfo to be FileInfo.\n");
95 printf (" -d Dump FILE. Assume FinderInfo to be DirInfo.\n");
96 printf (" -h,-help,--help Display this help and exit\n");
97 printf (" -v,-version,--version Show version and exit\n");
99 printf ("There is no way to detect whether FinderInfo is FileInfo or DirInfo.\n");
100 printf ("By default, %s examins whether file or directory,\n" ,basename($0));
101 printf ("a parent directory is .AppleDouble, filename is ._*, filename is .Parent,\n");
102 printf ("and so on.\n");
103 printf ("If setting option -e, -f or -d, %s assume FinderInfo and doesn't look for\n");
104 printf ("another file.\n");
106 } elsif ($arg =~ /^(-v|-version|--version)$/ ) {
107 printf ("%s \(Netatalk @NETATALK_VERSION@\)\n", basename($0));
109 } elsif ($arg eq "-a") {
111 } elsif ($arg eq "-e") {
112 if ($eacommand == 0) {
113 printf (STDERR "%s: unsupported option -e\n", basename($0));
114 printf (STDERR "because neither getfattr, xattr, runat nor getextattr is found.\n");
118 } elsif ($arg eq "-f") {
120 } elsif ($arg eq "-d") {
122 } elsif ($arg eq "-") {
124 } elsif ($arg =~ /^-/) {
125 printf (STDERR "%s: invalid option %s\n", basename($0), $arg);
126 printf (STDERR "Try \`%s\ -h' for more information.\n", basename($0));
135 } elsif (!( -e $afile)) {
136 printf (STDERR "\"%s\" is not found.\n", $afile);
140 # detect FinderInfo, and search AppleSingle/AppleDouble file --------------
142 $abspath = File::Spec->rel2abs($afile);
143 ($basename, $path, $ext) = fileparse($abspath);
145 if ( $stdinputmode == 1) {
146 ($eatempfh, $openfile) = tempfile(UNLINK => 1);
147 system("cat - > $openfile");
149 $openmessage = "Dumping Standard Input...\n";
150 } elsif ( $eaoption == 1 ) {
153 } elsif ( -d $afile ) {
156 printf (STDERR "unknown error: %s\n", $afile);
159 if ( 0 == checkea($afile) ) {
160 printf (STDERR "\"%s\"'s extended attribute is not found\n", $afile);
163 $openfile = eaopenfile($afile);
164 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
165 } elsif ( $finderinfo != 0 ) {
167 $openmessage = "Dumping \"$openfile\"...\n";
168 } elsif ( -f $afile ) {
169 if ( $basename eq ".Parent") {
171 } elsif ( $path =~ /\/.AppleDouble\/$/ ) {
173 } elsif ( $basename =~ /^._/ ) {
174 if ( -f $path.substr($basename, 2) ) {
176 } elsif ( -d $path.substr($basename, 2) ) {
180 if (!open(INFILE, "<$afile")) {
181 printf (STDERR "cannot open %s\n", $afile);
185 $val = unpack("N", $buf );
187 if ($val == 0x00051600 || $val == 0x00051607) {
189 $openmessage = "Dumping \"$openfile\"...\n";
191 printf ("\"%s\" is not AppleSingle/AppleDouble format.\n", $afile);
194 $netatalkfile = $path.".AppleDouble/".$basename;
195 $osxfile = $path."._".$basename;
197 if ( 1 == checkea($afile) ) {
198 printf ("\"%s\"\'s extended attribute is found.\n", $afile);
200 $openfile = eaopenfile($afile);
201 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
203 if ( -e $netatalkfile ) {
204 printf ("\"%s\" is found.\n", $netatalkfile);
206 $openfile = $netatalkfile;
207 $openmessage = "Dumping \"$openfile\"...\n";
210 printf ("\"%s\" is found.\n", $osxfile);
212 $openfile = $osxfile;
213 $openmessage = "Dumping \"$openfile\"...\n";
215 if ( $adcount == 0 ) {
216 printf ("AppleSingle/AppleDouble data is not found.\n");
219 if ( $adcount != 1 ) {
220 printf ("Specify any one.\n");
224 } elsif ( -d $afile) {
225 printf ("\"%s\" is a directory.\n", $afile);
228 $netatalkfile = $path.$basename."/.AppleDouble/.Parent";
229 $osxfile = $path."._".$basename;
231 if ( 1 == checkea($afile) ) {
232 printf ("\"%s\"\'s extended attribute is found.\n", $afile);
234 $openfile = eaopenfile($afile);
235 $openmessage = "Dumping \"$afile\"'s extended attribute...\n";
237 if ( -e $netatalkfile ) {
238 printf ("\"%s\" is found.\n", $netatalkfile);
240 $openfile= $netatalkfile;
241 $openmessage = "Dumping \"$openfile\"...\n";
244 printf ("\"%s\" is found.\n", $osxfile);
246 $openfile = $osxfile;
247 $openmessage = "Dumping \"$openfile\"...\n";
249 if ( $adcount == 0 ) {
250 printf ("AppleSingle/AppleDouble data is not found.\n");
253 if ( $adcount != 1 ) {
254 printf ("Specify any one.\n");
258 printf (STDERR "unknown error: %s\n", $afile);
262 if (!open(INFILE, "<$openfile")) {
263 printf (STDERR "cannot open %s\n", $openfile);
267 printf ($openmessage);
269 #Dump --------------------------------------------------------
271 # Magic Number -----------------------------------------------
273 print "-------------------------------------------------------------------------------\n";
276 $val = unpack("N", $buf );
277 printf("MagicNumber: %08X", $val);
278 if ( $val == 0x00051600 ) {
279 printf(" : AppleSingle");
281 elsif ( $val == 0x00051607 ) {
282 printf(" : AppleDouble");
285 printf(" : Unknown" );
289 # Version Number ---------------------------------------------
292 $version = unpack("N", $buf );
293 printf("Version : %08X", $version);
294 if ( $version == 0x00010000 ) {
295 printf(" : Version 1");
296 } elsif ( $version == 0x00020000 ) {
297 printf(" : Version 2");
299 printf(" : Unknown" );
303 # v1:Home file system / v2:Filler ----------------------------
305 read(INFILE,$buf,16);
306 if ( $version == 0x00010000 ) {
307 print "HomeFileSys:";
311 hexdump($buf, 16, 16, " ");
313 # Number of entities -----------------------------------------
316 $entnum = unpack("n", $buf );
317 printf("Num. of ent: %04X ", $entnum);
318 printf(" : %d", $entnum);
321 # data -------------------------------------------------------
323 for ( $num = 0 ; $num < $entnum ; $num++) {
325 seek(INFILE, ($num * 12 + 26), 0);
327 # Entry ---------------------------------------------------
330 $entid = unpack("N", $buf );
331 print "\n-------------------------------------------------------------------------------\n";
332 printf("Entry ID : %08X", $entid);
333 if ( $entid == 1 ) { printf(" : Data Fork"); }
334 elsif ( $entid == 2 ) { printf(" : Resource Fork"); }
335 elsif ( $entid == 3 ) { printf(" : Real Name"); }
336 elsif ( $entid == 4 ) { printf(" : Comment"); }
337 elsif ( $entid == 5 ) { printf(" : Icon, B&W"); }
338 elsif ( $entid == 6 ) { printf(" : Icon Color"); }
339 elsif ( $entid == 7 ) { printf(" : File Info"); }
340 elsif ( $entid == 8 ) { printf(" : File Dates Info"); }
341 elsif ( $entid == 9 ) { printf(" : Finder Info"); }
342 elsif ( $entid == 10 ) { printf(" : Macintosh File Info"); }
343 elsif ( $entid == 11 ) { printf(" : ProDOS File Info"); }
344 elsif ( $entid == 12 ) { printf(" : MS-DOS File Info"); }
345 elsif ( $entid == 13 ) { printf(" : Short Name"); }
346 elsif ( $entid == 14 ) { printf(" : AFP File Info"); }
347 elsif ( $entid == 15 ) { printf(" : Directory ID"); }
348 elsif ( $entid == 0x8053567E ) { printf(" : CNID (Netatalk Extended)"); }
349 elsif ( $entid == 0x8053594E ) { printf(" : DB stamp (Netatalk Extended)"); }
350 elsif ( $entid == 0x80444556 ) { printf(" : dev (Netatalk Extended)"); }
351 elsif ( $entid == 0x80494E4F ) { printf(" : inode (Netatalk Extended)"); }
352 else { printf(" : Unknown"); }
355 # Offset -------------------------------------------------
358 $ofst = unpack("N", $buf );
359 printf("Offset : %08X", $ofst);
360 printf(" : %d ", $ofst);
362 # Length -------------------------------------------------
365 $len = unpack("N", $buf );
366 printf("\nLength : %08X", $len);
367 printf(" : %d", $len);
372 # Dump for each Entry ID --------------------------------
374 # if ( $entid == 1 ) { ; } # Data Fork
375 # if ( $entid == 2 ) { ; } # Resource Fork
376 # if ( $entid == 3 ) { ; } # Real Name
377 # if ( $entid == 4 ) { ; } # Comment
378 # if ( $entid == 5 ) { ; } # Icon, B&W
379 # if ( $entid == 6 ) { ; } # Icon Color
380 # if ( $entid == 7 ) { ; } # File Info
381 if ( $entid == 8 ) { filedatesdump($ofst,$len); }
382 elsif ( $entid == 9 ) { finderinfodump($ofst,$len); }
383 # if ( $entid == 10 ) { ; } # Macintosh File Info
384 # if ( $entid == 11 ) { ; } # ProDOS File Info
385 # if ( $entid == 12 ) { ; } # MS-DOS File Info
386 # if ( $entid == 13 ) { ; } # Short Name
387 # if ( $entid == 14 ) { ; } # AFP File Info
388 elsif ( $entid == 15 ) { print "\n"; bedump($ofst,$len); } # Directory ID
389 elsif ( $entid == 0x8053567E ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # CNID (Netatalk Extended)
390 elsif ( $entid == 0x8053594E ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # DB stamp (Netatalk Extended)
391 elsif ( $entid == 0x80444556 ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # dev (Netatalk Extended)
392 elsif ( $entid == 0x80494E4F ) { print "\n"; bedump($ofst,$len); ledump($ofst,$len); } # inode (Netatalk Extended)
394 # RAW Dump ---------------------------------------------------
396 if ( ($quo > 0) || ($rem > 0)) {
398 print "-RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
401 seek(INFILE, $ofst, 0);
409 #sub -----------------------------------------------------------
412 my ($ofst, $len) = @_;
417 @datetype =('create ', 'modify ', 'backup ', 'access ');
419 seek(INFILE, $ofst, 0);
422 printf ("-DATE------: : (GMT) : (Local)\n");
424 for ( $i = 0 ; $i < 4 ; $i++) {
426 $datedata = unpack("N", $buf );
427 if ($datedata < 0x80000000) {
428 $datestr = gmtime( $datedata + 946684800)
430 .localtime( $datedata + 946684800);
431 } elsif ($datedata == 0x80000000) {
432 $datestr = "Unknown or Initial";
434 $datestr = gmtime( $datedata - 3348282496)
436 .localtime( $datedata - 3348282496);
438 printf ("%s : %08X : %s\n",$datetype[$i], $datedata, $datestr);
443 my ($ofst, $len) = @_;
445 seek(INFILE, $ofst, 0);
447 if ($finderinfo == 0) {
449 print "-NOTE------: cannot detect whether FInfo or DInfo. assume FInfo.\n";
452 if ($finderinfo == 0 || $finderinfo == 1) {
453 filefinderinfodump();
454 } elsif ($finderinfo == 2) {
457 print STDERR "unknown FinderInfo type\n"
460 if ($len > 32) { eadump(); }
463 sub filefinderinfodump {
466 print "-FInfo-----:\n";
470 hexdump($buf, 4, 4, "");
474 hexdump($buf, 4, 4, "");
479 $val = unpack("n", $buf );
480 printf("Location v : %04X", $val);
481 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
484 $val = unpack("n", $buf );
485 printf("Location h : %04X", $val);
486 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
490 hexdump($buf, 2, 4, "");
493 print "-FXInfo----:\n";
496 $val = unpack("n", $buf );
497 printf("Rsvd|IconID: %04X", $val);
498 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
502 hexdump($buf, 2, 4, "");
505 hexdump($buf, 2, 4, "");
508 hexdump($buf, 2, 4, "");
513 $val = unpack("n", $buf );
514 printf("Rsvd|commnt: %04X", $val);
515 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
518 $val = unpack("N", $buf );
519 printf("PutAway : %08X", $val);
520 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
524 sub dirfinderinfodump {
527 print "-DInfo-----:\n";
530 $val = unpack("n", $buf );
531 printf("Rect top : %04X", $val);
532 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
535 $val = unpack("n", $buf );
536 printf("Rect left : %04X", $val);
537 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
540 $val = unpack("n", $buf );
541 printf("Rect bottom: %04X", $val);
542 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
545 $val = unpack("n", $buf );
546 printf("Rect right : %04X", $val);
547 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
552 $val = unpack("n", $buf );
553 printf("Location v : %04X", $val);
554 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
557 $val = unpack("n", $buf );
558 printf("Location h : %04X", $val);
559 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
563 hexdump($buf, 2, 4, "");
566 print "-DXInfo----:\n";
569 $val = unpack("n", $buf );
570 printf("Scroll v : %04X", $val);
571 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
574 $val = unpack("n", $buf );
575 printf("Scroll h : %04X", $val);
576 printf(" : %d\n", $val>0x7FFF?$val-0x10000:$val);
579 $val = unpack("N", $buf );
580 printf("Rsvd|OpnChn: %08X", $val);
581 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
587 hexdump($buf, 2, 4, "");
590 $val = unpack("N", $buf );
591 printf("PutAway : %08X", $val);
592 printf(" : %d\n", $val>0x7FFFFFFF?$val-0x100000000:$val); # Why SInt32?
597 @colortype =('none', 'gray', 'green', 'purple', 'blue', 'yellow', 'red', 'orange');
600 $flags = unpack("n", $buf );
601 printf ("isAlias : %d\n", ($flags >> 15) & 1);
602 printf ("Invisible : %d\n", ($flags >> 14) & 1);
603 printf ("hasBundle : %d\n", ($flags >> 13) & 1);
604 printf ("nameLocked : %d\n", ($flags >> 12) & 1);
605 printf ("Stationery : %d\n", ($flags >> 11) & 1);
606 printf ("CustomIcon : %d\n", ($flags >> 10) & 1);
607 printf ("Reserved : %d\n", ($flags >> 9) & 1);
608 printf ("Inited : %d\n", ($flags >> 8) & 1);
609 printf ("NoINITS : %d\n", ($flags >> 7) & 1);
610 printf ("Shared : %d\n", ($flags >> 6) & 1);
611 printf ("SwitchLaunc: %d\n", ($flags >> 5) & 1);
612 printf ("Hidden Ext : %d\n", ($flags >> 4) & 1);
613 printf ("color : %d%d%d : %s\n", ($flags >> 3) & 1,
616 @colortype[($flags & 0xE)>>1]);
617 printf ("isOnDesk : %d\n", ($flags >> 0) & 1);
624 $flags = unpack("n", $buf );
626 if (($flags >> 15) == 1) {
628 hexdump($buf, 1, 4, "");
630 printf ("AreInvalid : %d\n", ($flags >> 15) & 1);
631 printf ("unknown bit: %d\n", ($flags >> 14) & 1);
632 printf ("unknown bit: %d\n", ($flags >> 13) & 1);
633 printf ("unknown bit: %d\n", ($flags >> 12) & 1);
634 printf ("unknown bit: %d\n", ($flags >> 11) & 1);
635 printf ("unknown bit: %d\n", ($flags >> 10) & 1);
636 printf ("unknown bit: %d\n", ($flags >> 9) & 1);
639 printf ("CustomBadge: %d\n", ($flags >> 8) & 1);
640 printf ("ObjctIsBusy: %d\n", ($flags >> 7) & 1);
641 printf ("unknown bit: %d\n", ($flags >> 6) & 1);
642 printf ("unknown bit: %d\n", ($flags >> 5) & 1);
643 printf ("unknown bit: %d\n", ($flags >> 4) & 1);
644 printf ("unknown bit: %d\n", ($flags >> 3) & 1);
645 printf ("RoutingInfo: %d\n", ($flags >> 2) & 1);
646 printf ("unknown bit: %d\n", ($flags >> 1) & 1);
647 printf ("unknown bit: %d\n", ($flags >> 0) & 1);
654 print "-EA--------:\n";
658 hexdump($buf, 2, 4, "");
662 hexdump($buf, 4, 4, "");
665 $ea_debug_tag = unpack("N", $buf );
666 printf("debug_tag : %08X", $ea_debug_tag);
667 printf(" : %d\n", $ea_debug_tag);
670 $ea_total_size = unpack("N", $buf );
671 printf("total_size : %08X", $ea_total_size);
672 printf(" : %d\n", $ea_total_size);
675 $ea_data_start = unpack("N", $buf );
676 printf("data_start : %08X", $ea_data_start);
677 printf(" : %d\n", $ea_data_start);
680 $ea_data_length = unpack("N", $buf );
681 printf("data_length: %08X", $ea_data_length);
682 printf(" : %d\n", $ea_data_length);
685 print "reserved[0]: ";
686 hexdump($buf, 4, 4, "");
689 print "reserved[1]: ";
690 hexdump($buf, 4, 4, "");
693 print "reserved[2]: ";
694 hexdump($buf, 4, 4, "");
698 hexdump($buf, 2, 4, "");
701 $ea_num_attrs = unpack("n", $buf );
702 printf("num_attrs : %04X", $ea_num_attrs);
703 printf(" : %d\n", $ea_num_attrs);
707 for ($i = 0 ; $i < $ea_num_attrs ; $i++) {
709 $pos = (($pos & 0x3) == 0) ? ($pos) : ((($pos >> 2) + 1) << 2);
710 seek(INFILE, $pos, 0);
712 print "-EA ENTRY--:\n";
715 $ea_offset = unpack("N", $buf );
716 printf("offset : %08X", $ea_offset);
717 printf(" : %d\n", $ea_offset);
720 $ea_length = unpack("N", $buf );
721 printf("length : %08X", $ea_length);
722 printf(" : %d\n", $ea_length);
726 hexdump($buf, 2, 4, "");
729 $ea_namelen = unpack("C", $buf );
730 printf("namelen : %02X", $ea_namelen);
731 printf(" : %d\n", $ea_namelen);
733 $ea_namequo = $ea_namelen >> 4;
734 $ea_namerem = $ea_namelen & 0xF;
735 print "-EA NAME---: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
736 rawdump($ea_namequo, $ea_namerem);
740 seek(INFILE, $ea_offset, 0);
741 $ea_quo = $ea_length >> 4;
742 $ea_rem = $ea_length & 0xF;
743 print "-EA VALUE--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)\n";
744 rawdump($ea_quo, $ea_rem);
749 my ($ofst, $len) = @_;
753 seek(INFILE, $ofst, 0);
755 printf("%2dbit-BE : ", $len * 8 );
758 for ( $i=0 ; $i < $len ; $i++ ) {
760 $bytedata[$i] = unpack("C", $buf );
761 $value += $bytedata[$i] << (($len - $i -1) * 8) ;
764 for ( $i=0 ; $i < $len ; $i++ ) {
765 printf("%02X", $bytedata[$i]);
768 printf(" : %s", $value);
773 my ($ofst, $len) = @_;
777 seek(INFILE, $ofst, 0);
779 printf("%2dbit-LE : ", $len * 8 );
782 for ( $i=0 ; $i < $len ; $i++ ) {
784 $bytedata[$len - $i - 1] = unpack("C", $buf );
785 $value += $bytedata[$len - $i -1] << ($i * 8) ;
788 for ( $i=0 ; $i < $len ; $i++ ) {
789 printf("%02X", $bytedata[$i]);
792 printf(" : %s", $value);
797 my ($quo, $rem) = @_;
798 my ($addrs, $line, $buf);
801 for ( $line = 0 ; $line < $quo ; $line++) {
802 read(INFILE, $buf, 16);
803 printf ( "%08X :", $addrs);
804 hexdump($buf, 16, 16, " ");
805 $addrs = $addrs + 0x10;
808 read(INFILE, $buf, $rem);
809 printf ( "%08X :", $addrs);
810 hexdump($buf, $rem, 16, " ");
815 my ($buf, $len, $col, $delimit) = @_;
821 for ( $i=0 ; $i < $len ; $i++ ) {
822 $val = substr($buf, $i, 1);
824 $hexstr .= sprintf("%s%02X", $delimit, $ascval);
826 if (($ascval < 32) || ( $ascval > 126 )) {
831 for ( ; $i < $col ; $i++) {
832 $hexstr .= " ".$delimit;
836 printf("%s : %s", $hexstr,$ascstr);
844 $file =~ s/\\/\\\\/g;
845 $file =~ s/\"/\\\"/g;
846 $file =~ s/\$/\\\$/g;
847 $file =~ s/\`/\\\`/g;
848 if ( $eacommand == 1 ) {
849 open(EALIST, "getfattr \"$file\" |");
851 if ( $_ eq "user.org.netatalk.Metadata\n" ) {
858 } elsif ( $eacommand == 2 ) {
859 open(EALIST, "attr -q -l \"$file\" |");
861 if ( $_ eq "org.netatalk.Metadata\n" ) {
868 } elsif ( $eacommand == 3 ) {
869 open(EALIST, "runat \"$file\" ls -1 |");
871 if ( $_ eq "org.netatalk.Metadata\n" ) {
878 } elsif ( $eacommand == 4 ) {
879 open(EALIST, "lsextattr -q user \"$file\" |");
882 if ( $_ =~ /\torg\.netatalk\.Metadata[\n\t]/ ) {
897 $file =~ s/\\/\\\\/g;
898 $file =~ s/\"/\\\"/g;
899 $file =~ s/\$/\\\$/g;
900 $file =~ s/\`/\\\`/g;
901 ($eatempfh, $eatempfile) = tempfile(UNLINK => 1);
903 if ( $eacommand == 1 ) {
904 system("getfattr --only-values -n user.org.netatalk.Metadata \"$file\" > $eatempfile");
905 } elsif ( $eacommand == 2 ) {
906 system("attr -q -g org.netatalk.Metadata \"$file\" > $eatempfile");
907 } elsif ( $eacommand == 3 ) {
908 system("runat \"$file\" cat org.netatalk.Metadata > $eatempfile");
909 } elsif ( $eacommand == 4 ) {
910 system("getextattr -q user org.netatalk.Metadata \"$file\" > $eatempfile");