How deletion of an opened file works internally?

55 views Asked by At

Under Linux Kernel, Lets say we have two process (p1 and p2) reading same file (/file.txt)

If im not wrong, there will be an task_struct pointing to files_struct which in-turns points to an entry in file (file table).

file table reference count will be incremented if the file /file.txt opened by other process (p2). when we delete a file /file.txt (via process3), since the reference_count > 0. We can access the file content from process1 and process2.

What happens when p1 and p2 closes the file. How exactly kernel finds out it needs to deleted rather than normal use-case.

0

There are 0 answers