From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 26 09:10:46 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 D6E4C16A4CF for ; Sat, 26 Feb 2005 09:10:46 +0000 (GMT) Received: from panther.cs.ucla.edu (Panther.CS.UCLA.EDU [131.179.128.25]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9A01443D49 for ; Sat, 26 Feb 2005 09:10:46 +0000 (GMT) (envelope-from yanyu@CS.UCLA.EDU) Received: from localhost (yanyu@localhost)j1Q9Ak413448 for ; Sat, 26 Feb 2005 01:10:46 -0800 (PST) Date: Sat, 26 Feb 2005 01:10:46 -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: 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:10:47 -0000 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 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