[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnupod] mktunes: Same settings & version, different databases
From: |
Nuno J. Silva |
Subject: |
Re: [Bug-gnupod] mktunes: Same settings & version, different databases |
Date: |
Fri, 15 Oct 2010 22:00:51 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
address@hidden (Nuno J. Silva) writes:
> As far as I can tell, _Pretender (in Hash58.pm, the file I've been
> looking at), writes at different places: in the computer which generates
> the good db, it writes at the specified offsets, in the other, it
> appends some values to the end of the file instead of doing it at the
> given offset (but it might be doing some writes on the right place).
>
> Strange enough, I've been using the debug technique known as
> debug-by-printf and it seems the offsets are okay...
>
> I'll dive deeper into this and then I'll say what's going on (I hope I
> can find that out).
I found it out: it is seek() who is behaving differently: on one
computer (the one on which mktunes.pl works fine), it reacts as
expected, it actually seeks, while on the other after doing a syswrite,
seeking has no effect and a future syswrite writes to the end of the
file.
As the perl documentation for seek ($ perldoc -f seek) says seek
shouldn't be used with sysread/write, I changed all the calls to seek so
that sysseek is used instead.
(The docs also say sysseek doesn't mix well with other non-sys*
functions, like read and write - I checked and those are not used in
Hash58, so I suppose that's not a problem.)
Doing this fixed the issue and now the problematic computer is able to
generate an iTunesDB my iPod accepts.
The testing I made in perl shows no issues with sysseek on the computer
where seek works, but I'll try the changes I made to Hash58.pm on that
computer too, just to check if it doesn't break what was working.
I don't know if the developers want to change the code to use sysseek or
if they prefer to keep seek instead. I'm attaching the patch I wrote,
just in case someone wants to play with it.
The patch is against GNUpod 0.99.8.
diff -uNr gnupod-0.99.8.orig/src/ext/Hash58.pm gnupod-0.99.8/src/ext/Hash58.pm
--- gnupod-0.99.8.orig/src/ext/Hash58.pm 2010-10-15 21:14:04.000000000
+0100
+++ gnupod-0.99.8/src/ext/Hash58.pm 2010-10-15 21:17:28.000000000 +0100
@@ -195,16 +195,16 @@
my $size = $wl->{$k}->{size};
if(defined($fill_with)) {
- seek($fd,$k,0) or die "Unable to seek to $k : $!\n";
+ sysseek($fd,$k,0) or die "Unable to seek to $k : $!\n";
my $br = sysread($fd, $wl->{$k}->{write}, $size);
die "Failed to read $size bytes, got only $br\n" if $br
!= $size;
$writeback = chr($fill_with) x $size;
}
- seek($fd,$k,0) or die "Unable to seek to $k : $!\n";
+ sysseek($fd,$k,0) or die "Unable to seek to $k : $!\n";
my $bw = syswrite($fd, $writeback, $size);
die "Failed to write $size bytes, only wrote $bw\n" if $bw !=
$size;
}
- seek($fd,0,0); # Doesn't hurt :-)
+ sysseek($fd,0,0); # Doesn't hurt :-)
}
--
Nuno J. Silva
gopher://sdf-eu.org/1/users/njsg
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases, Nuno J. Silva, 2010/10/15
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases, Nuno J. Silva, 2010/10/15
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases, Nuno J. Silva, 2010/10/15
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases,
Nuno J. Silva <=
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases, Nuno J. Silva, 2010/10/15
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases, H. Langos, 2010/10/16
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases, Nuno J. Silva, 2010/10/16
- Re: [Bug-gnupod] mktunes: Same settings & version, different databases, Nuno J. Silva, 2010/10/16