Problems with current file descriptor
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
Quoted 5 lines · Sergio Paracuellos
I have problems to know whats is the current file descriptor.
"
task_struct" have afiles_structstructure 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
Signature · 7 lines
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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
2005/10/26, Sergio Paracuellos <[email protected]>:
Quoted 8 lines
Hi all,
I have problems to know whats is the current file descriptor.
"
task_struct" have afiles_structstructure 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 infd_array?
Quoted 7 lines
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?
Quoted 11 lines · winter
2005/10/26, Sergio Paracuellos <[email protected]>:
Quoted 10 lines
Hi all,
I have problems to know whats is the current file descriptor.
"
task_struct" have afiles_structstructure 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 infd_array?I suppose is something like:
Quoted 7 lines
Quoted 5 lines
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,
Quoted 4 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
2005/10/27, Sergio Paracuellos <[email protected]>:
Quoted 6 lines
Quoted 2 lines
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?
Quoted 11 lines · winter
2005/10/27, Sergio Paracuellos <[email protected]>:
Quoted 6 lines
Quoted 2 lines
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
Quoted 8 lines
// 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
Quoted 4 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 25 lines · Sergio Paracuellos
Quoted 11 lines · winter
2005/10/27, Sergio Paracuellos <[email protected]>:
Quoted 6 lines
Quoted 2 lines
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 atQuoted 8 lines
// 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...
Quoted 8 lines
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
Quoted 9 lines
Quoted 4 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html