Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge patch for #253 #261

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/daemon/mounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,36 @@ void mlist_clear(mlist *m)
m->cnt = 0;
}

void mlist_delete_cur(mlist *m)
{
register mnode* current;

current = m->cur;
if (m->head == m->cur)
{
m->cur = m->cur->next;
m->head = m->cur;
}
else
{
register mnode* previous;

previous = m->head;
while (previous) {
if (previous->next == current)
{
previous->next = current->next;
m->cur = current->next;
break;
}
previous = previous->next;
}
}
if (current)
{
free((void *)current->path);
free((void *)current);
m->cnt--;
}
}

1 change: 1 addition & 0 deletions src/daemon/mounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ void mlist_mark_all_deleted(mlist *l);
int mlist_find(mlist *m, const char *p);
int mlist_append(mlist *m, const char *p);
void mlist_clear(mlist *m);
void mlist_delete_cur(mlist *m);

#endif
12 changes: 3 additions & 9 deletions src/daemon/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,11 @@ int init_fanotify(const conf_t *conf, mlist *m)
deadmans_switch_thread_main, NULL);

mask = FAN_OPEN_PERM | FAN_OPEN_EXEC_PERM;

#if defined HAVE_DECL_FAN_MARK_FILESYSTEM && HAVE_DECL_FAN_MARK_FILESYSTEM != 0
if (conf->allow_filesystem_mark)
mark_flag = FAN_MARK_FILESYSTEM;
mark_flag = FAN_MARK_FILESYSTEM;
else
mark_flag = FAN_MARK_MOUNT;
mark_flag = FAN_MARK_MOUNT;
#else
if (conf->allow_filesystem_mark)
msg(LOG_ERR,
Expand Down Expand Up @@ -167,7 +166,6 @@ void fanotify_update(mlist *m)
if (fd < 0)
return;

mnode *prev = m->head;
mlist_first(m);
while (m->cur) {
if (m->cur->status == ADD) {
Expand All @@ -186,12 +184,8 @@ void fanotify_update(mlist *m)
// Now remove the deleted mount point
if (m->cur->status == DELETE) {
msg(LOG_DEBUG, "Deleted %s mount point", m->cur->path);
prev->next = m->cur->next;
free((void *)m->cur->path);
free((void *)m->cur);
m->cur = prev->next;
mlist_delete_cur(m);
} else {
prev = m->cur;
mlist_next(m);
}
}
Expand Down