[plug] python head+wall issue

Cameron Patrick cameron at patrick.wattle.id.au
Mon Dec 29 20:14:45 WST 2003


On Mon, Dec 29, 2003 at 07:53:40PM +0800, Craig Ringer wrote:

| I've been trying to figure out why I can't truncate a file in Python. 
| I'm sure it's obvious, but if someone could supply the appropriate 
| clue-bat that'd be handy.

It looks to me like a screwy glibc/kernel problem with ftruncate64.  Out
of curiosity, are you running Linux 2.6?  I am.  Also, which
distribution and glibc version do you have?  (Debian sid, glibc
2.3.2.ds1-10 in my case.)  I've been meaning to switch back to 2.4 (due
to annoyance with 2.6) so I might reboot soon and see if that affects
anything.

I can confirm your problem, both in Python and with C:

$ cat foo.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main()
{
        int fd = open("bar", O_RDWR);
        if (fd < 0) perror("open");
        if (ftruncate64(fd, 0) < 0) perror("ftruncate64");
        if (ftruncate(fd, 0) < 0) perror("ftruncate");
        if (close(fd) < 0) perror("close");
}
$ gcc foo.c -o foo
$ echo asdf > bar
$ ./foo
ftruncate64: File too large

The ftruncate following it works fine.  The results are the same when
testing just ftruncate64 or ftruncate on their own.

Cameron.




More information about the plug mailing list