0

I need to monitor events on a regular file using file descriptors. I'm working on a machine with CentOS 4.1, and kernel version 2.6.18.128.

After realizing that regular file cannot be monitored using epoll, I found this task can be accomplished using inotify. However, I read elsewhere that the required library interfaces for inotify were added to glibc in version 2.4, and my machine has version 2.3.4 installed. So my kernel has inotify support by not glibc. Unfortunately, I cannot update glibc to a newer version because it would break certain other parts of the project.

So my questions are:

  1. Can I still use inotify to monitor regular file? Could I get a newer version of glibc and place it at a local folder(relative to my code), include the path in my Makefile and use calls associated with inotify? If so, what kind of problems could I run into?
  2. An alternative could be using fstat, by keeping track of the st_mtime member of the struct stat structure. Any caveats against taking this route?

If my questions reveal any lack of understanding with these concepts please bear with me as I just started using them.

SidR
  • 2,964
  • 1
  • 18
  • 32

1 Answers1

1

For 2 glibc see the following post: Multiple glibc libraries on a single host

Otherwise inotify seems straight forward solution.

Community
  • 1
  • 1
Adnan Akbar
  • 718
  • 6
  • 16
  • Thanks for the link! One clarification as I'm still confused on a certain point. Other parts of the project I'm contributing to will be using the older glibc, where as I'm the only one who needs the newer version. Can I use two different versions of glib for building a single project? Will this not cause some issues? – SidR Mar 04 '13 at 06:56
  • Well do you have any specific functionality that require older glibc? You can not link against 2 different library versions it will be ambigous condition for the compiler. – Adnan Akbar Mar 04 '13 at 07:00
  • Just to add you can have 2 different linked applications and controll the calls via ifdef MACRO with GLIBC version. – Adnan Akbar Mar 04 '13 at 07:02
  • Yes there are many functionalities that require the older glibc. One of us tried using the newer glibc once but it gave a lot of errors at runtime, which will take time to sort out. This is why I need both libraries simultaneously. So fstat is my best bet then? – SidR Mar 04 '13 at 07:14
  • If your application is a seperate one You can easily use different glibc by just fixing header files an librariers path otherwise fsstat is the way to go. – Adnan Akbar Mar 04 '13 at 07:16