DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-10-28 21:36:59

mb16
New member
Registered: 2008-10-28
Posts: 4

inotify on ch3snas fw1.04rc5

I came to this while trying to get mediatomb inotify support on my device, but this might be interesting to others too...
While configuring mediatomb-0.11.0 i could not get inotify to work. I decided to try with inotify-tools-3.13. I got that compiled (thanks Fonz fun_plug 0.5) but the tools failed to initialize.

Well my device has a 2.6.12 kernel, inotify is supported as from 2.6.13... On the other hand I found /dev/inotify to be existent.
It seems as if on my box the device is up and working, but the syscalls are not existent – or non-standard. Anyway I did not manage to find a working inotify.h file.

After some investigation (following early, basic inotify documentation) I found that the syscalls are not essential. It should be possible to implement the functions based on the device only. I changed inotify.h and implemented the functions static inline:

#include <sys/fcntl.h>
#include <sys/ioctl.h>

struct inotify_watch_request {
       int             fd;             /* fd of filename to watch */
       uint32_t           mask;           /* event mask */
};

#define INOTIFY_IOCTL_MAGIC    'Q'
#define INOTIFY_IOCTL_MAXNR    2

#define INOTIFY_WATCH                  _IOR(INOTIFY_IOCTL_MAGIC, 1, struct inotify_watch_request)
#define INOTIFY_IGNORE                 _IOR(INOTIFY_IOCTL_MAGIC, 2, int)

static inline int inotify_init (void)
{
    return open( "/dev/inotify", O_RDONLY);
}

static inline int inotify_add_watch (int fd, const char *name, uint32_t mask)
{
    int file_fd;
    int wd;
    struct inotify_watch_request req;
    file_fd = open ( name, O_RDONLY);
    if (file_fd < 0) {
        return file_fd;
    }
    req.fd = file_fd;
    req.mask = mask;
    wd = ioctl (fd, INOTIFY_WATCH, &req);
    //close( file_fd); do not close file_fd here - this would delete the watch
    return wd;
}

static inline int inotify_rm_watch (int fd, uint32_t wd)
{
    return ioctl ( wd, INOTIFY_IGNORE, fd);
}

I found inotify-tools to work, mediatomb configure to detect and mediatomb to use inotify nearly perfectly. Only thing found was that it seems not to follow symlinks, I don't know and did no investigation to find out details.

Hmm, I do know nothing about the DNS-323 and other CH3SNAS firmware versions but at least in my case this is working nicely. Someone with better skills than me might take a look at this and implement it in a better way (are static inline functions acceptable here...)

Markus

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB