![]() Path_of_intererst - The path of the file or directory we are monitoring. Inotify - The file descriptor we got when initialising the inotify instance. Using the file descriptor we will start adding “watches” for each file/directory we want to monitor: int watchFd = inotify_add_watch(inotifyFd, path_of_interest, IN_ACCESS | IN_MODIFY | IN_CREATE | IN_DELETE) The method creates a new instance of inotify and returns us the file descriptor to that instance: int inotifyFd = inotify_init() To initialise inotify we must first call inotify_init(). Since Android was built on top of the linux kernel and this api was not removed by the developers of android, we are able to access it using it’s header which is sys/inotify.h. When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory. Inotify can be used to monitor individual files, or to monitor directories. ![]() ![]() The inotify API provides a mechanism for monitoring filesystem events. The method i want to discuss is linux’s own inotify api. By monitoring the file system on the testing device, we can automate tests that use the changes in the filesystem as indicators to whether the application is operating properly or malfunctioning.
0 Comments
Leave a Reply. |