From mboxrd@z Thu Jan 1 00:00:00 1970 From: winter Subject: Re: Problems with current file descriptor Date: Thu, 27 Oct 2005 16:30:40 +0800 Message-ID: <16f1140f0510270130t1609905as@mail.gmail.com> References: <1130341392.3278.0.camel@localhost.localdomain> <16f1140f0510261934i51c53da1m@mail.gmail.com> <1130397606.2864.4.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Cc: LINUX-Fs-DEVEL Return-path: Received: from xproxy.gmail.com ([66.249.82.192]:19098 "EHLO xproxy.gmail.com") by vger.kernel.org with ESMTP id S964995AbVJ0Ial convert rfc822-to-8bit (ORCPT ); Thu, 27 Oct 2005 04:30:41 -0400 Received: by xproxy.gmail.com with SMTP id i30so649711wxd for ; Thu, 27 Oct 2005 01:30:41 -0700 (PDT) To: Sergio Paracuellos In-Reply-To: <1130397606.2864.4.camel@localhost.localdomain> Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 2005/10/27, Sergio Paracuellos : > > current file ?what is meaning? > > for exmaple ,you opened 3 file, file1,file2, file3. which is current file? > > Sorry, I want the last file I used. For example if I just have done "cat > foobar" the file I want is this. > if you used the command "cat foobar", the linux kernel's do the following 3 phase for you: 1. open() --> sys_open() // in this phase, the filp struct is create and save at // current->files->fd[x]. the x=fd. 2. read() --> sys_read() // in this phase, read file's data, the fd is not changed. 3. close() --> sys_close() // in this phase, free the filp struct. the result is // current->files->fd[fd] = 0. so it is, kernel can not save the last file which you opend. which phase you want get the path at?