Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Feb 2005 01:12:22 -0800 (PST)
From:      Yan Yu <yanyu@CS.UCLA.EDU>
To:        freebsd-hackers@freebsd.org
Subject:   Re: confusion on fopen()/falloc() 
Message-ID:  <Pine.GSO.4.58.0502260111400.13229@panther.cs.ucla.edu>
In-Reply-To: <Pine.GSO.4.58.0502260103420.13229@panther.cs.ucla.edu>
References:  <20050226072645.76950.qmail@web26802.mail.ukl.yahoo.com> <Pine.GSO.4.58.0502260043200.12442@panther.cs.ucla.edu> <Pine.GSO.4.58.0502260103420.13229@panther.cs.ucla.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 26 Feb 2005, Yan Yu wrote:

> Hello, all,
> I have a user program as below:
> FILE *fd;
> while (1)
> {
> 	fd= fopen( "tmp", "r" );
> 	if ( fd == NULL )
> 		break;
> }
>
> from my understanding, since i open the same file to read, my process
> should create a new file descriptor each time when fopen is called.
> Therefore, inside the kernel, fdalloc() should be called, NOT falloc()
> (since falloc() allocates a new FILE * struct in addition to a new file
oops, what i really meant is a new FILE struct...


> descriptor),
> BUT based on what i observed (i instrumented falloc() function), it seems
> that falloc() is called each time when fopen() is called.
> I am wondering where i missed?
>
> Any hints is appreciated!
> Best,
> yan
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.58.0502260111400.13229>