Subject: port-amiga/2406: port-amiga
To: None <gnats-bugs@NetBSD.ORG>
From: Daniel Oberlin <dan@localhost.cit.cornell.edu>
List: netbsd-bugs
Date: 05/13/1996 14:30:39
>Number:         2406
>Category:       port-amiga
>Synopsis:       fstat() returns 0 for st_size (file lengths)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 13 21:50:01 1996
>Last-Modified:
>Originator:     Daniel Oberlin
>Organization:
Cornell University
>Release:        1.1
>Environment:
	netbsd-amiga 1.1
System: NetBSD amy 1.1 NetBSD 1.1 (AMY) #2: Fri May 3 12:11:37 PDT 1996 dan@amy.cit.cornell.edu:/usr/src/sys/arch/amiga/compile/AMY amiga


>Description:

	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. 


>How-To-Repeat:


/* 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");
		exit(0);
	}

	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);

	fclose(f);
}

>Fix:

	No clue.

>Audit-Trail:
>Unformatted: