Re: [netatalk-admins] help me find the afpd code... ?


Subject: Re: [netatalk-admins] help me find the afpd code... ?
From: Steven N. Hirsch (shirsch@adelphia.net)
Date: Sat Jan 30 1999 - 15:21:03 EST


On Sat, 30 Jan 1999, Brian Reid wrote:

> I absolutely have to find the place in 1.4b2+asun2.1.1 where afpd is
> checking the magic number and disable the check, or I am completely
> #&#^$ed. I can't go back to older netatalk and attempts to read some of
> the older files cause the share to dismount from the desktop.

It's not in afpd, per se. Look in ./libatalk/adouble/ad_open.c for the
action..

> I have a million files to move. I don't mind if 5% of them move over as
> unusable junk, but I can't live with having afpd abort every time I try
> to open a file with a bad magic number.

If you have a backup, this script will recurse through an entire netatalk
tree and insert magic numbers in the files under .AppleDouble. It's been
used only under Unix, but should be portable.

I believe Adrian's latest and greatest release has a switch to turn off
magic number checking as well.

Steve

------------------------ Cut Here ---------------------
: # -*-perl-*-
eval 'exec perl -w -S $0 ${1+"$@"}'
    if 0;

# fixad - A forcible remedy to .AppleDouble files missing magic numbers.

use strict;
use POSIX qw(fcntl_h);
use IO::File;
use File::Find;
use Cwd;

# Traverse desired filesystems

my $magic = pack "C4", 0x00, 0x05, 0x16, 0x07;
my $adVersion = pack "C4", 0x00, 0x01, 0x00, 0x00;

sub fixADFiles {
  my $curdir = cwd();
  chdir('.AppleDouble');
  foreach ( glob '*' ) {
    my $fh = new IO::File;
    print "$_\n";
    $fh->open($_, O_WRONLY) || die "Can't open $File::Find::name: $!\n";
    $fh->print($magic);
    $fh->print($adVersion);
    $fh->close;
  }
  chdir($curdir);
}

sub wanted {
  my $globalSave = $_;

    (my ($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    -d _ &&
    /^\.AppleDouble$/ &&
    fixADFiles();

  $_ = $globalSave;
}

@ARGV == 1 || die "Usage: fixad <dir>\n";

my $dir = shift;

find(\&wanted, $dir);

exit;

--------------------------- Cut Here --------------------------



This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:16:17 EST