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










share|improve this question
























  • 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















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










share|improve this question
























  • 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













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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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










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.






share|improve this answer





















  • Okey, I will edit the question.
    – Goktug
    Nov 27 at 20:50











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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.






share|improve this answer





















  • Okey, I will edit the question.
    – Goktug
    Nov 27 at 20:50















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.






share|improve this answer





















  • Okey, I will edit the question.
    – Goktug
    Nov 27 at 20:50













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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 27 at 20:41









borellini

1715




1715












  • 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




Okey, I will edit the question.
– Goktug
Nov 27 at 20:50


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Mont Emei

Province de Neuquén

Journaliste