Subject: None
To: None <netbsd-bugs@NetBSD.ORG>
From: Benjamin Kenobi <>
List: netbsd-bugs
Date: 05/13/1996 21:37:35
>Submitter-Id:	net
>Originator:	Daniel Oberlin
>Organization:  Cornell University
>Confidential:	no
>Synopsis:      fstat() returns 0 for st_size (file lengths) 
>Severity:	serious
>Priority:	high
>Category:	port-amiga	
>Class:		sw-bug
>Release:	1.1
	netbsd-amiga 1.1
System: NetBSD amy 1.1 NetBSD 1.1 (AMY) #2: Fri May 3 12:11:37 PDT 1996 amiga


	fstat() and stat() return 0 for the file length in the stat
	structure.  It may be that they return other incorrect values
	as well.  Please let me know what you find. 


/* Compile and run this program.  It always seems to return 0 for the
 * file size.  I encountered this bug when attempting to compile the
 * program XPilot.  The program "msub" in XPilot failed because of a
 * call to fstat().  I worked around it and got the program to work
 * anyway. */

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

void main( void )

	char file_name[100];
	FILE *f;
	struct stat st;
	int rv, fd;	

	printf("Enter filename to stat : ");
	scanf("%s", &file_name);

	f = fopen(file_name, "r"); 

	if ( !f )
		printf("fopen() failed\n");

	fd = fileno(f);
	printf("fileno() returned %d\n", fd);

	rv = fstat(fd, &st);
	printf("fstat() returned %d\n", rv);

	printf("st.st_size = %d\n", st.st_size);



	No clue.