Subject: ftruncate
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Robert Dobbs <banshee@gabriella.resort.com>
List: current-users
Date: 07/19/1994 01:22:24
I'm having trouble with ftruncate with current sources on i386 in both
shared and -static modes.

Basically, ftruncate() doesn't work with files opened as "a" or "r+"
(which may be as designed, the man page is vague).  It also fails to
work when the file has had data written to it.  Finally, it always
(even when it works) returns an error and sets errno = 27

I sent a bug report on this in earlier this evening.


#include <stdio.h>
#include <errno.h>
extern int errno;

main()
{
	FILE *fp;

	fp = fopen("foo","w");
	fprintf(fp,"Mom loves you");
	fflush(fp);
printf("%d\n", errno);
printf("trunc: %d\n",ftruncate(fileno(fp),10));
printf("%d\n", errno);
}


------------------------------------------------------------------------------