* Problems with current file descriptor
@ 2005-10-26 15:43 Sergio Paracuellos
2005-10-26 16:06 ` Jörn Engel
2005-10-27 2:34 ` winter
0 siblings, 2 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2005-10-26 15:43 UTC (permalink / raw)
To: LINUX-Fs-DEVEL
Hi all,
I have problems to know whats is the current file descriptor.
"task_struct" have a files_struct structure which contains all files for
a process in "fd". If I want to get the complete path for one of them,
How can I know what is the correct one in fd_array?
I suppose is something like:
path = d_path(task->files->fd[x]->f_dentry,
task->files->fd[x]->f_vfsmnt, buf, PAGE_SIZE);
But I don't know how to know this x for my correct file (for example the
last file I used).
Thanks in advance...
Cheers,
Sergio
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problems with current file descriptor
2005-10-26 15:43 Problems with current file descriptor Sergio Paracuellos
@ 2005-10-26 16:06 ` Jörn Engel
2005-10-27 2:34 ` winter
1 sibling, 0 replies; 7+ messages in thread
From: Jörn Engel @ 2005-10-26 16:06 UTC (permalink / raw)
To: Sergio Paracuellos; +Cc: LINUX-Fs-DEVEL
On Wed, 26 October 2005 17:43:12 +0200, Sergio Paracuellos wrote:
>
> I have problems to know whats is the current file descriptor.
>
> "task_struct" have a files_struct structure which contains all files for
> a process in "fd". If I want to get the complete path for one of them,
A file descriptor doesn't have an associated patch. Think about
sockets. Think about unlinked files. etc.
Jörn
--
When in doubt, punt. When somebody actually complains, go back and fix it...
The 90% solution is a good thing.
-- Rob Landley
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problems with current file descriptor
2005-10-26 15:43 Problems with current file descriptor Sergio Paracuellos
2005-10-26 16:06 ` Jörn Engel
@ 2005-10-27 2:34 ` winter
2005-10-27 7:20 ` Sergio Paracuellos
1 sibling, 1 reply; 7+ messages in thread
From: winter @ 2005-10-27 2:34 UTC (permalink / raw)
To: Sergio Paracuellos; +Cc: LINUX-Fs-DEVEL
2005/10/26, Sergio Paracuellos <sparacuellos@lock-linux.com>:
> Hi all,
>
> I have problems to know whats is the current file descriptor.
>
> "task_struct" have a files_struct structure which contains all files for
> a process in "fd". If I want to get the complete path for one of them,
> How can I know what is the correct one in fd_array?
>
> I suppose is something like:
>
> path = d_path(task->files->fd[x]->f_dentry,
> task->files->fd[x]->f_vfsmnt, buf, PAGE_SIZE);
>
> But I don't know how to know this x for my correct file (for example the
> last file I used).
current file ?what is meaning?
for exmaple ,you opened 3 file, file1,file2, file3. which is current file?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problems with current file descriptor
2005-10-27 2:34 ` winter
@ 2005-10-27 7:20 ` Sergio Paracuellos
2005-10-27 8:30 ` winter
0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2005-10-27 7:20 UTC (permalink / raw)
To: winter; +Cc: LINUX-Fs-DEVEL
El jue, 27-10-2005 a las 10:34 +0800, winter escribió:
> 2005/10/26, Sergio Paracuellos <sparacuellos@lock-linux.com>:
> > Hi all,
> >
> > I have problems to know whats is the current file descriptor.
> >
> > "task_struct" have a files_struct structure which contains all files for
> > a process in "fd". If I want to get the complete path for one of them,
> > How can I know what is the correct one in fd_array?
> >
> > I suppose is something like:
> >
> > path = d_path(task->files->fd[x]->f_dentry,
> > task->files->fd[x]->f_vfsmnt, buf, PAGE_SIZE);
> >
> > But I don't know how to know this x for my correct file (for example the
> > last file I used).
> 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.
Thanks in advance,
> -
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problems with current file descriptor
2005-10-27 7:20 ` Sergio Paracuellos
@ 2005-10-27 8:30 ` winter
2005-10-27 9:06 ` Sergio Paracuellos
0 siblings, 1 reply; 7+ messages in thread
From: winter @ 2005-10-27 8:30 UTC (permalink / raw)
To: Sergio Paracuellos; +Cc: LINUX-Fs-DEVEL
2005/10/27, Sergio Paracuellos <sparacuellos@lock-linux.com>:
> > 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?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problems with current file descriptor
2005-10-27 8:30 ` winter
@ 2005-10-27 9:06 ` Sergio Paracuellos
2005-10-27 9:26 ` Sergio Paracuellos
0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2005-10-27 9:06 UTC (permalink / raw)
To: LINUX-Fs-DEVEL, winter
El jue, 27-10-2005 a las 16:30 +0800, winter escribió:
> 2005/10/27, Sergio Paracuellos <sparacuellos@lock-linux.com>:
> > > 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?
The problem is I need to get complete path in lookup(). Lookup is the
first thig kernel execute and in lookup I can't get complete path
because I have a dentry structure...
cat foobar was an example I need to get the path in other operations too
like "write..." but always in lookup function.
Any ideas about it?
Thanks in advance,
Sergio
> -
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Problems with current file descriptor
2005-10-27 9:06 ` Sergio Paracuellos
@ 2005-10-27 9:26 ` Sergio Paracuellos
0 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2005-10-27 9:26 UTC (permalink / raw)
To: LINUX-Fs-DEVEL; +Cc: winter
El jue, 27-10-2005 a las 11:06 +0200, Sergio Paracuellos escribió:
> El jue, 27-10-2005 a las 16:30 +0800, winter escribió:
> > 2005/10/27, Sergio Paracuellos <sparacuellos@lock-linux.com>:
> > > > 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?
>
> The problem is I need to get complete path in lookup(). Lookup is the
> first thig kernel execute and in lookup I can't get complete path
> because I have a dentry structure...
>
> cat foobar was an example I need to get the path in other operations too
> like "write..." but always in lookup function.
>
> Any ideas about it?
>
> Thanks in advance,
>
> Sergio
I solve my problem. I was wrong in my code. I was using like dentry
current->fs->pwd but I had to use the dentry in use in lookup function.
Thanks to all.
Cheers,
Sergio
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-10-27 9:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-26 15:43 Problems with current file descriptor Sergio Paracuellos
2005-10-26 16:06 ` Jörn Engel
2005-10-27 2:34 ` winter
2005-10-27 7:20 ` Sergio Paracuellos
2005-10-27 8:30 ` winter
2005-10-27 9:06 ` Sergio Paracuellos
2005-10-27 9:26 ` Sergio Paracuellos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox