如果文件/目录大小增加以上,有没有办法在Linux中重新呼叫
Is there a way to get call back in linux if file/directory size increases above configured level
正在使用Linux系统调用,在C/C 中寻找类似此类的内容,
char * filename="/tmp/testDirectory";
fd = open(filename, O_CREAT | O_RDWR);
setmaxfilesize(fd,"4mb"); //<== looking for some API to do this.
registerforCallback(mycallback); //<== looking for some API to do this
void mycallback(void * arg)
{
/* Delete old files inside directory to have space for new files*/
}
是的,但不直接在我所知的文件大小上。
看一下:https://lwn.net/articles/604686/
这将为您提供一个很好的起点,如何与文件通知进行交互。文件更改后,可以通知您的处理程序。在处理程序中,您可以检查大小并完成工作。
摘录:有dnotify
基本上与SYSCALL fcntl(fd, F_NOTIFY, mask);
一起使用dnotify接缝要过时(我的Linux发行版不再支持DNOTIFY)
inotify
带有自己的API。参见man inotify
。可以使用int inotify_add_watch(int fd, const char *pathname, uint32_t mask);
来观察文件更改,其中可以在其中掩码为IN_MODIFY
,以查看文件上的所有修改。如果从此处调用您的处理程序,请请求文件大小并执行您的操作。
相关文章:
- 一个32位版本的应用程序,建立在CentOS 6 x64上,当在较新的Linux上启动时,在"dl_itera
- 如何在 Linux 中访问新页面时减少延迟
- 销毁放置新中的呼叫
- 打开Unix,Linux系统呼叫许可,拒绝Arduino Uno
- 在 Linux 上阅读系统呼叫永远
- 如何使用64-Linux上的C 中的新操作员动态分配大型内存,例如10 g
- 如果文件/目录大小增加以上,有没有办法在Linux中重新呼叫
- 新的Linux程序员 - 尝试开发库
- 如何在linux上的新终端上执行新线程
- Linux 中的新功能后没有变化
- Linux 使用标志MSG_DONTWAIT发送呼叫
- 如何在 Linux 中的单独/包含目录中编译额外/更新的库以及新程序
- 删除 [] 在 Linux 中放置新对象失败
- Qt Creator 2.8.1 Qt 5.1.1 Qt Designer Linux 显示新表单
- 我如何使用 linux perf 获得 libc6 符号(例如 _int_malloc)的呼叫父母
- linux的新功能:C++打开和关闭usb端口的问题
- Linux-有没有一种方法可以在不分叉新进程的情况下调用系统调用(bash脚本)
- 如果我用较新版本的gcc编译二进制文件,我如何找到需要在客户机linux机器上安装的库?
- c++在linux下启动新进程并终止当前进程
- Linux c++新操作慢得令人难以置信