struct file object of a file
up vote
0
down vote
favorite
Whenever a file is created in kernel space, struct file object instantiated. Type of that file does not matter. For device nodes, standard text files etc, a struct file object is created when a file is opened.
What I am wondering is when this object is destroyed. Is the struct file object for that file destroyed when we call close() system call for that file?
Extended Information:
struct file is a data structure of kernel. It cannot be used in user space c programs. Kernel defines an object from this data type to be able to perform some specific file operations. This object is created in kernel space when a user space program calls the system call open().
https://github.com/torvalds/linux/blob/master/include/linux/fs.h
line 901
files filesystem devices
add a comment |
up vote
0
down vote
favorite
Whenever a file is created in kernel space, struct file object instantiated. Type of that file does not matter. For device nodes, standard text files etc, a struct file object is created when a file is opened.
What I am wondering is when this object is destroyed. Is the struct file object for that file destroyed when we call close() system call for that file?
Extended Information:
struct file is a data structure of kernel. It cannot be used in user space c programs. Kernel defines an object from this data type to be able to perform some specific file operations. This object is created in kernel space when a user space program calls the system call open().
https://github.com/torvalds/linux/blob/master/include/linux/fs.h
line 901
files filesystem devices
Don't have an answer, but seems like it could be __close_fd function, which receives struct of files and sets the file descriptors to NULL
– Sergiy Kolodyazhnyy
Nov 27 at 21:58
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Whenever a file is created in kernel space, struct file object instantiated. Type of that file does not matter. For device nodes, standard text files etc, a struct file object is created when a file is opened.
What I am wondering is when this object is destroyed. Is the struct file object for that file destroyed when we call close() system call for that file?
Extended Information:
struct file is a data structure of kernel. It cannot be used in user space c programs. Kernel defines an object from this data type to be able to perform some specific file operations. This object is created in kernel space when a user space program calls the system call open().
https://github.com/torvalds/linux/blob/master/include/linux/fs.h
line 901
files filesystem devices
Whenever a file is created in kernel space, struct file object instantiated. Type of that file does not matter. For device nodes, standard text files etc, a struct file object is created when a file is opened.
What I am wondering is when this object is destroyed. Is the struct file object for that file destroyed when we call close() system call for that file?
Extended Information:
struct file is a data structure of kernel. It cannot be used in user space c programs. Kernel defines an object from this data type to be able to perform some specific file operations. This object is created in kernel space when a user space program calls the system call open().
https://github.com/torvalds/linux/blob/master/include/linux/fs.h
line 901
files filesystem devices
files filesystem devices
edited Nov 27 at 20:56
asked Nov 27 at 20:31
Goktug
1136
1136
Don't have an answer, but seems like it could be __close_fd function, which receives struct of files and sets the file descriptors to NULL
– Sergiy Kolodyazhnyy
Nov 27 at 21:58
add a comment |
Don't have an answer, but seems like it could be __close_fd function, which receives struct of files and sets the file descriptors to NULL
– Sergiy Kolodyazhnyy
Nov 27 at 21:58
Don't have an answer, but seems like it could be __close_fd function, which receives struct of files and sets the file descriptors to NULL
– Sergiy Kolodyazhnyy
Nov 27 at 21:58
Don't have an answer, but seems like it could be __close_fd function, which receives struct of files and sets the file descriptors to NULL
– Sergiy Kolodyazhnyy
Nov 27 at 21:58
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
It would be useful to receive some more specific information in order to answer properly. In what environment you are seeing this struct file object? Searching for struct file object in Google only points to this question.
But generally, a file descriptor in Unix-like operating systems can be created with the library function open which will use the kernel's system calls. The file descriptor can be released and deallocated with a call to library function close which will, again, use appropriate system calls and ensures that no resources will leak.
Okey, I will edit the question.
– Goktug
Nov 27 at 20:50
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
It would be useful to receive some more specific information in order to answer properly. In what environment you are seeing this struct file object? Searching for struct file object in Google only points to this question.
But generally, a file descriptor in Unix-like operating systems can be created with the library function open which will use the kernel's system calls. The file descriptor can be released and deallocated with a call to library function close which will, again, use appropriate system calls and ensures that no resources will leak.
Okey, I will edit the question.
– Goktug
Nov 27 at 20:50
add a comment |
up vote
0
down vote
It would be useful to receive some more specific information in order to answer properly. In what environment you are seeing this struct file object? Searching for struct file object in Google only points to this question.
But generally, a file descriptor in Unix-like operating systems can be created with the library function open which will use the kernel's system calls. The file descriptor can be released and deallocated with a call to library function close which will, again, use appropriate system calls and ensures that no resources will leak.
Okey, I will edit the question.
– Goktug
Nov 27 at 20:50
add a comment |
up vote
0
down vote
up vote
0
down vote
It would be useful to receive some more specific information in order to answer properly. In what environment you are seeing this struct file object? Searching for struct file object in Google only points to this question.
But generally, a file descriptor in Unix-like operating systems can be created with the library function open which will use the kernel's system calls. The file descriptor can be released and deallocated with a call to library function close which will, again, use appropriate system calls and ensures that no resources will leak.
It would be useful to receive some more specific information in order to answer properly. In what environment you are seeing this struct file object? Searching for struct file object in Google only points to this question.
But generally, a file descriptor in Unix-like operating systems can be created with the library function open which will use the kernel's system calls. The file descriptor can be released and deallocated with a call to library function close which will, again, use appropriate system calls and ensures that no resources will leak.
answered Nov 27 at 20:41
borellini
1715
1715
Okey, I will edit the question.
– Goktug
Nov 27 at 20:50
add a comment |
Okey, I will edit the question.
– Goktug
Nov 27 at 20:50
Okey, I will edit the question.
– Goktug
Nov 27 at 20:50
Okey, I will edit the question.
– Goktug
Nov 27 at 20:50
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1096605%2fstruct-file-object-of-a-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Don't have an answer, but seems like it could be __close_fd function, which receives struct of files and sets the file descriptors to NULL
– Sergiy Kolodyazhnyy
Nov 27 at 21:58