#6 Inotify fails on permission denied

closed-fixed
Leo
None
1
2010-04-06
2008-09-02
No

When mediatomb scans a directory using inotify scanning, and it encounters a directory it does not have access to, the inotify thread terminates.

This in turn means that no updating of the directory contents are performed.

The error logged be mediatomb is:

ERROR: Inotify thread caught exception: Permission denied

The attached patch solves this problem, by making Inotify::addWatch return -1, if EACCES is returned by inotify_add_watch. It also logs the access problem to the logfile, using log_warning.

Discussion

  • Klaus S. Madsen

    Klaus S. Madsen - 2008-09-02

    Fix for "Inotify thread caught exception: Permission denied"

     
  • Jin

    Jin - 2008-11-13

    Leo, please have a look if it's OK to return (-1) in addWatch() or if the logic above would need additional fixing.

     
  • Jin

    Jin - 2008-11-13
    • assigned_to: nobody --> lww
     
  • Klaus S. Madsen

    Klaus S. Madsen - 2008-11-14

    I've looked through revision 1944.

    addWatch is called in 4 places, all from autoscan_inotify.cc.

    In addMoveWatch (line 384), where the next line tests if the return value is greater than zero. However, this function will propagate the -1 further out, to watchPathForMoves, which doesn't handle the -1. I'm not entirely sure how that should be done, or even if watchPathForMoves can be called if a permission denied is returned from one of the other callpoints.

    In monitorDirectory (line 619) the return value is also tested, but again the returned value is returned to the callers of monitorDirectory. Checking all the callsites of monitorDirectory, only one of them uses the return value, and in that case it seems to handle it being -1.

    Then there is monitorDirectory (line 663). I doesn't check the return value, but I believe that is a copy-paste error. Because after the call to addWatch which stores the return value in startPointWd, the variable wd is tested for being negative. However we already know that wd is non-negative, as we wouldn't be in this branch of the code otherwise.

    The last callsite is unmonitorDirectory (line 680). Here the return value is checked and not propagated.

    So, as far as I can tell, monitorDirectory needs a patch (I can provide that, but its really just changing wd to startPointWd in line 655), and watchPathForMoves might need one, but I don't know the code intimately enough to determine this.

    Btw. I've used the patch from when I submitted it (i.e. 2.5 months), and the inotify thread haven't crashed on me since.

     
  • Leo

    Leo - 2009-12-21
    • priority: 5 --> 1
    • status: open --> open-fixed
     
  • Jin

    Jin - 2010-04-06
    • status: open-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks