D
D
dariasweetsun2021-08-10 17:52:16
API
dariasweetsun, 2021-08-10 17:52:16

Is there a POSIX API that can help track attempts to access certain files (C/C++)?

The task is as follows:
There is a list of files (for example, paths to files as command line arguments), actions on which need to be tracked. For example, if a process tries to do something with a file (read / write or delete it altogether), then let's say you need to find out the PID and interrupt its work. It is desirable that all this work in the background.

I would really like to understand what posix api is that could help with this. I know a thing or two about stat() and file descriptor tables. It's not clear just how stat() can help in "preventing" file access and how file descriptor tables can help (not to scan proc/PID/fd for all processes). There are many more different apis for working with files, but for some reason there weren’t those “suitable” ones that could help with this.

In general, it is not clear in which direction to look at all and which posix api could be suitable for these purposes.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2021-08-10
@firedragon

https://ostechnix.com/monitor-file-changes-using-f...
What do you understand by Posix?
And so in almost any OS there are such mechanisms

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question