From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 26 09:12:22 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B4DF16A4CE for ; Sat, 26 Feb 2005 09:12:22 +0000 (GMT) Received: from panther.cs.ucla.edu (Panther.CS.UCLA.EDU [131.179.128.25]) by mx1.FreeBSD.org (Postfix) with ESMTP id 44F3243D60 for ; Sat, 26 Feb 2005 09:12:22 +0000 (GMT) (envelope-from yanyu@CS.UCLA.EDU) Received: from localhost (yanyu@localhost)j1Q9CMx13565 for ; Sat, 26 Feb 2005 01:12:22 -0800 (PST) Date: Sat, 26 Feb 2005 01:12:22 -0800 (PST) From: Yan Yu To: freebsd-hackers@freebsd.org In-Reply-To: Message-ID: References: <20050226072645.76950.qmail@web26802.mail.ukl.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: confusion on fopen()/falloc() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Feb 2005 09:12:22 -0000 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 > >