truncate("x", -1)

David Luyer (luyer@ucs.uwa.edu.au)
Mon, 19 Apr 1999 14:01:08 +0800


Looks Linux specific from some testing. And doesn't even happen with Linux
NFS to a Linux server.

Digital Unix ADVFS - no problem
Solaris UFS - no problem
Linux 2.0 NFS client against Solaris NFS server (UFS) - no problem
Linux 2.0 NFS client against Linux NFS 2.0 server (EXT2FS) - no problem
Linux 2.0 EXT2FS - PROBLEM
StarOS 4.1.1 TMPFS - no problem
StarOS 4.1.1 UFS - no problem
FreeBSD 3.0 - no problem
NeXTStep 3.3 - no problem

Fortunately, even in the Linux case, it doesn't seem to mess up quotas.

The argument to [f]truncate is meant to be a size_t not a ssize_t, so
probably this is a signed/unsigned bug. The man page says that it should
truncate a file to at most the specified size, so the correct behaviour
should be

truncate("x", -1)
kernel: current size 0 < new size 2^32 - 1
kernel: return success with no action

David.

(NB: StarOS 4.1.1 in the above list is basically SunOS 4.1.1 for one type of
sun4x [the Star 910/VP])

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/