From admin@dmzpc.bridge.com  Wed Mar 20 15:07:36 1996
Received: from dmzpc.bridge.com (dmzpc.bridge.com.76.167.IN-ADDR.ARPA [167.76.159.150])
          by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id PAA13005
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 20 Mar 1996 15:07:29 -0800 (PST)
Received: (from admin@localhost) by dmzpc.bridge.com (8.6.12/8.6.12) id LAA08177; Wed, 20 Mar 1996 11:06:59 -0600
Message-Id: <199603201706.LAA08177@dmzpc.bridge.com>
Date: Wed, 20 Mar 1996 11:06:59 -0600
From: admin <admin@dmzpc.bridge.com>
Reply-To: admin@dmzpc.bridge.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: trouble with ftruncate(2)
X-Send-Pr-Version: 3.2

>Number:         1092
>Category:       kern
>Synopsis:       ftruncate(2) returns EINVAL
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 20 15:10:02 PST 1996
>Closed-Date:    Thu Jun 13 16:39:33 PDT 1996
>Last-Modified:  Thu Jun 13 16:41:47 PDT 1996
>Originator:     khardy@acm.org
>Release:        FreeBSD 2.1-STABLE i386
>Organization:
>Environment:

	

>Description:

	
	The ftruncate(2) system call always seems to return EINVAL,
	at least in all the ways I've tried it.

>How-To-Repeat:

	

	/* This pgm succeeds on FreeBSD 2.0, BSDI 1.1, and SunOS 4.1.3C, but
	 * fails on FreeBSD 2.1
	 */
	#include <stdio.h>
	#include <fcntl.h>

	main (int argc, char **argv)
	{
		int fd ;
		if (argc != 2) {
			fprintf (stderr, "usage: %s filename\n", argv[0]) ;
			return (-1) ;
		}
		if ( (fd = open (argv[1], O_CREAT|O_TRUNC|O_RDWR, 0600) ) < 0) {
			perror (argv[1]) ;
			return (-1) ;
		}
		if (ftruncate (fd, 0L) ) {
			perror ("truncate(fd,0)") ;
			return (-1) ;
		}
		printf ("OK\n") ;
		return 0 ;
	}


>Fix:
	
	

>Release-Note:
>Audit-Trail:

From: David Greenman <davidg@Root.COM>
To: admin@dmzpc.bridge.com
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/1092: trouble with ftruncate(2) 
Date: Wed, 20 Mar 1996 15:48:39 -0800

 >		if (ftruncate (fd, 0L) ) {
 
    The argument to ftruncate is an off_t which is 64bits. The prototype for
 ftruncate() is in unistd.h...this is clearly documented in the manual page.
 If you bring the prototype in scope by including unistd.h or change the above
 to be "fd, (off_t) 0", I think you'll find that your program works as
 expected.
 
 -DG
 
 David Greenman
 Core-team/Principal Architect, The FreeBSD Project
State-Changed-From-To: open->closed 
State-Changed-By: alex 
State-Changed-When: Thu Jun 13 16:39:33 PDT 1996 
State-Changed-Why:  
As David pointed out, the example given is invalid.  ftruncate works  
properly when the length argument is an off_t. 
>Unformatted:
