c++ - Is there a way to get call back in linux if file/directory size increases above configured level -


am looking thing programatically in c/c++ using linux system call,

char * filename="/tmp/testdirectory"; fd = open(filename, o_creat | o_rdwr);  setmaxfilesize(fd,"4mb");         //<== looking api this. registerforcallback(mycallback);  //<== looking api   void mycallback(void * arg) {  /* delete old files inside directory have space new files*/ } 

yes, not directly on file size know.

take at: https://lwn.net/articles/604686/

this give startpoint how interact file notifications. after file change handler can notified. in handler can check size , job.

excerpt: there dnotify works syscall fcntl(fd, f_notify, mask); dnotify seams outdated ( linux distro has no support dnotify anymore )

inotify comes own api. see man inotify. watching file change can done int inotify_add_watch(int fd, const char *pathname, uint32_t mask); mask can in_modify see modifications on file. if handler called here, request file size , actions.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -