c - How to detect when one file is modified inside a symbolic link directory in Linux -
i have symbolic link 1 directory this
root@beaglebone:/sys/class/drm# lrwxrwxrwx 1 root root 0 sat jan 1 00:00:01 2000 card0-hdmi-a-1 -> /sys/devices/ocp.3/4830e000.lcdc/drm/card0/card0-hdmi-a-1
how can detect/watch when 1 file modified inside real path (/sys/devices/ocp.3/4830e000.lcdc/drm/card0/card0-hdmi-a-1) symbolic link (/sys/class/drm/card0-hdmi-a-1) points to.
(i prefer c program this).
thanks much.
the command looking stat. stat
retrieves data file (in *nix, directory kind of file). when used on symbolic link, stat
return data on link points to, not link itself. stat
populates struct stat
, st_mtime
member time of last modification, directory, update when contents change.
struct stat file_info; if ( stat ( "/sys/class/drm/card0-hdmi-a-1", &file_info ) == 0 ) { /* stat succeeded, file_info.st_mtime real directory's mod time */ } else { /* stat failed reason. consult man page info error codes */ }
Comments
Post a Comment