const char *remote_hostname;
struct tevent_context *ev_ctx;
struct messaging_context *msg_ctx;
+ struct sys_notify_context *sys_notify_ctx;
struct notify_context *notify_ctx;
struct {
bool got_session;
notify_fsp(fsp, e->action, e->path);
}
+static void sys_notify_callback(struct sys_notify_context *ctx,
+ void *private_data,
+ struct notify_event *e)
+{
+ files_struct *fsp = (files_struct *)private_data;
+ DEBUG(10, ("sys_notify_callback called for %s\n", fsp_str_dbg(fsp)));
+ notify_fsp(fsp, e->action, e->path);
+}
+
NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
bool recursive)
{
char *fullpath;
size_t len;
struct notify_entry e;
- NTSTATUS status;
+ NTSTATUS status = NT_STATUS_NOT_IMPLEMENTED;
if (fsp->notify != NULL) {
DEBUG(1, ("change_notify_create: fsp->notify != NULL, "
e.subdir_filter = filter;
}
- status = notify_add(fsp->conn->sconn->notify_ctx, fsp->conn, &e,
- notify_callback, fsp);
- TALLOC_FREE(fullpath);
+ if (fsp->conn->sconn->sys_notify_ctx != NULL) {
+ void *sys_notify_handle = NULL;
+
+ status = SMB_VFS_NOTIFY_WATCH(
+ fsp->conn, fsp->conn->sconn->sys_notify_ctx,
+ &e, e.path, sys_notify_callback, fsp,
+ &sys_notify_handle);
+
+ if (NT_STATUS_IS_OK(status)) {
+ talloc_steal(fsp->notify, sys_notify_handle);
+ }
+ }
+ if ((e.filter != 0) || (e.subdir_filter != 0)) {
+ status = notify_add(fsp->conn->sconn->notify_ctx, fsp->conn,
+ &e, notify_callback, fsp);
+ }
+ TALLOC_FREE(fullpath);
return status;
}
ctx->private_data = NULL;
return ctx;
}
-
-NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
- connection_struct *conn,
- struct notify_entry *e,
- const char *path,
- void (*callback)(struct sys_notify_context *ctx,
- void *private_data,
- struct notify_event *ev),
- void *private_data, void *handle)
-{
- return SMB_VFS_NOTIFY_WATCH(conn, ctx, e, path, callback,
- private_data, handle);
-}
-
struct notify_list *list;
struct notify_array *array;
int seqnum;
- struct sys_notify_context *sys_notify_ctx;
TDB_DATA key;
};
struct notify_list *next, *prev;
void *private_data;
void (*callback)(void *, const struct notify_event *);
- void *sys_notify_handle;
int depth;
};
messaging_register(notify->messaging_ctx, notify,
MSG_PVFS_NOTIFY, notify_handler);
- notify->sys_notify_ctx = sys_notify_context_create(notify, ev);
-
return notify;
}
talloc_free(tmp_ctx);
}
-/*
- callback from sys_notify telling us about changes from the OS
-*/
-static void sys_notify_callback(struct sys_notify_context *ctx,
- void *ptr, struct notify_event *ev)
-{
- struct notify_list *listel = talloc_get_type(ptr, struct notify_list);
- ev->private_data = listel;
- DEBUG(10, ("sys_notify_callback called with action=%d, for %s\n",
- ev->action, ev->path));
- listel->callback(listel->private_data, ev);
-}
-
/*
add an entry to the notify array
*/
listel->depth = depth;
DLIST_ADD(notify->list, listel);
- /* ignore failures from sys_notify */
- if (notify->sys_notify_ctx != NULL) {
- /*
- this call will modify e.filter and e.subdir_filter
- to remove bits handled by the backend
- */
- status = sys_notify_watch(notify->sys_notify_ctx, conn,
- &e, e.path,
- sys_notify_callback, listel,
- &listel->sys_notify_handle);
- if (NT_STATUS_IS_OK(status)) {
- talloc_steal(listel, listel->sys_notify_handle);
- }
- }
-
if (e.filter != 0) {
notify_add_onelevel(notify, &e, private_data);
status = NT_STATUS_OK;
char *notify_filter_string(TALLOC_CTX *mem_ctx, uint32 filter);
struct sys_notify_context *sys_notify_context_create(TALLOC_CTX *mem_ctx,
struct event_context *ev);
-NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
- connection_struct *conn,
- struct notify_entry *e,
- const char *path,
- void (*callback)(struct sys_notify_context *ctx,
- void *private_data,
- struct notify_event *ev),
- void *private_data, void *handle);
/* The following definitions come from smbd/notify_inotify.c */
on_err_call_dis_hook = true;
if ((!conn->printer) && (!conn->ipc) &&
- lp_change_notify(conn->params) &&
- sconn->notify_ctx == NULL) {
- sconn->notify_ctx = notify_init(sconn,
- sconn->msg_ctx,
- sconn->ev_ctx);
+ lp_change_notify(conn->params)) {
+ if (sconn->notify_ctx == NULL) {
+ sconn->notify_ctx = notify_init(
+ sconn, sconn->msg_ctx, sconn->ev_ctx);
+ }
+ if (sconn->sys_notify_ctx == NULL) {
+ sconn->sys_notify_ctx = sys_notify_context_create(
+ sconn, sconn->ev_ctx);
+ }
}
/*