#include "htsp_server.h"
/* inotify limits */
-#define EVENT_SIZE ( sizeof (struct inotify_event) )
-#define EVENT_BUF_LEN ( 10 * ( EVENT_SIZE + 16 ) )
-#define EVENT_MASK IN_DELETE | IN_DELETE_SELF |\
+#define EVENT_SIZE (sizeof(struct inotify_event))
+#define EVENT_BUF_LEN (5 * EVENT_SIZE + NAME_MAX)
+#define EVENT_MASK IN_DELETE | IN_DELETE_SELF | \
IN_MOVE_SELF | IN_MOVED_FROM | IN_MOVED_TO
static int _inot_fd;
const char *from;
int fromfd;
int cookie;
- char from_prev[50];
- int fromfd_prev =0;
- int cookie_prev =0;
-
- from_prev[0] = '\0';
+ struct inotify_event *ev;
+ char from_prev[NAME_MAX + 1] = "";
+ int fromfd_prev = 0;
+ int cookie_prev = 0;
while (tvheadend_is_running()) {
/* Process */
pthread_mutex_lock(&global_lock);
- while ( i < len ) {
- struct inotify_event *ev = (struct inotify_event*)&buf[i];
- tvhdebug(LS_DVR, "inotify: i= %d len= %d ", i, len);
+ while (i < len) {
+ ev = (struct inotify_event *)&buf[i];
+ tvhtrace(LS_DVR_INOTIFY, "i=%d len=%d name=%s", i, len, ev->name);
i += EVENT_SIZE + ev->len;
if (i > len)
break;
from = ev->name;
fromfd = ev->wd;
cookie = ev->cookie;
- tvhdebug(LS_DVR, "inotify: i= %d len= %d from = %s cookie = %d ", i, len, from, cookie);
+ tvhtrace(LS_DVR_INOTIFY, "i=%d len=%d from=%s cookie=%d ", i, len, from, cookie);
continue;
} else if (ev->mask & IN_MOVED_TO) {
- tvhdebug(LS_DVR, "inotify: i= %d len= %d to_cookie= %d from_cookie = %d cookie_prev = %d", i, len, ev->cookie,cookie,cookie_prev);
- if ( from && ev->cookie == cookie) {
+ tvhtrace(LS_DVR_INOTIFY, "i=%d len=%d to_cookie=%d from_cookie=%d cookie_prev=%d", i, len, ev->cookie, cookie, cookie_prev);
+ if (from && ev->cookie == cookie) {
_dvr_inotify_moved(fromfd, from, ev->name, ev->wd);
from = NULL;
cookie = 0;
} else if (ev->mask & IN_DELETE_SELF) {
_dvr_inotify_delete_all(ev->wd);
}
-/*
- if (from) {
- _dvr_inotify_moved(fromfd, from, NULL, -1);
- from = NULL;
- cookie = 0;
- }
-*/
}
- // if still old "from", assume matching "to" is not coming
+ // if still old "from", assume matching "to" is not coming
if (from_prev[0] != '\0') {
_dvr_inotify_moved(fromfd_prev, from_prev, NULL, -1);
from_prev[0] = '\0';
cookie_prev = 0;
}
- // if unmatched "from", save in case matching "to" is coming in next read
+ // if unmatched "from", save in case matching "to" is coming in next read
if (from) {
- strcpy ( from_prev, from);
+ strcpy(from_prev, from);
fromfd_prev = fromfd;
cookie_prev = cookie;
- tvhdebug(LS_DVR, "inotify: i= %d len= %d cookie_prev = %d from_prev = %s fd = %d END OF READ", i, len, cookie_prev, from_prev, fromfd_prev);
+ tvhdebug(LS_DVR_INOTIFY, "i=%d len=%d cookie_prev=%d from_prev=%s fd=%d EOR", i, len, cookie_prev, from_prev, fromfd_prev);
}
pthread_mutex_unlock(&global_lock);
}
[LS_CCCAM] = { "cccam", N_("CWC CCCam Client") },
[LS_DVBCAM] = { "dvbcam", N_("DVB CAM Client") },
[LS_DVR] = { "dvr", N_("Digital Video Recorder") },
+ [LS_DVR_INOTIFY] = { "dvr-inotify", N_("DVR Inotify") },
[LS_EPG] = { "epg", N_("Electronic Program Guide") },
[LS_EPGDB] = { "epgdb", N_("EPG Database") },
[LS_EPGGRAB] = { "epggrab", N_("EPG Grabber") },