#include "lib/util/server_id_db.h"
#include "smbd/notifyd/notifyd.h"
-struct notify_list {
- struct notify_list *next, *prev;
- void *private_data;
-};
-
struct notify_context {
struct server_id notifyd;
struct messaging_context *msg_ctx;
- struct notify_list *list;
struct smbd_server_connection *sconn;
void (*callback)(struct smbd_server_connection *sconn,
return NULL;
}
ctx->msg_ctx = msg;
- ctx->list = NULL;
ctx->sconn = sconn;
ctx->callback = callback;
private_data, struct notify_context);
struct notify_event_msg *event_msg;
struct notify_event event;
- struct notify_list *listel;
if (data->length < offsetof(struct notify_event_msg, path) + 1) {
DEBUG(1, ("message too short: %u\n", (unsigned)data->length));
"path=%s\n", __func__, (unsigned)event.action,
event.private_data, event.path));
- for (listel = ctx->list; listel != NULL; listel = listel->next) {
- if (listel->private_data == event.private_data) {
- ctx->callback(ctx->sconn, listel->private_data,
- event_msg->when, &event);
- break;
- }
- }
+ ctx->callback(ctx->sconn, event.private_data, event_msg->when, &event);
}
NTSTATUS notify_add(struct notify_context *ctx,
const char *path, uint32_t filter, uint32_t subdir_filter,
void *private_data)
{
- struct notify_list *listel;
struct notify_rec_change_msg msg = {};
struct iovec iov[2];
size_t pathlen;
pathlen = strlen(path)+1;
- listel = (struct notify_list *)talloc(ctx, struct notify_list);
- if (listel == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- listel->private_data = private_data;
-
clock_gettime_mono(&msg.instance.creation_time);
msg.instance.filter = filter;
msg.instance.subdir_filter = subdir_filter;
iov, ARRAY_SIZE(iov), NULL, 0);
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(listel);
DEBUG(10, ("messaging_send_iov returned %s\n",
nt_errstr(status)));
return status;
}
- DLIST_ADD(ctx->list, listel);
return NT_STATUS_OK;
}
NTSTATUS notify_remove(struct notify_context *ctx, void *private_data,
char *path)
{
- struct notify_list *listel;
struct notify_rec_change_msg msg = {};
struct iovec iov[2];
NTSTATUS status;
return NT_STATUS_NOT_IMPLEMENTED;
}
- for (listel = ctx->list; listel != NULL; listel = listel->next) {
- if (listel->private_data == private_data) {
- DLIST_REMOVE(ctx->list, listel);
- break;
- }
- }
- if (listel == NULL) {
- DEBUG(10, ("%p not found\n", private_data));
- return NT_STATUS_NOT_FOUND;
- }
-
msg.instance.private_data = private_data;
iov[0].iov_base = &msg;
ctx->msg_ctx, ctx->notifyd, MSG_SMB_NOTIFY_REC_CHANGE,
iov, ARRAY_SIZE(iov), NULL, 0);
- TALLOC_FREE(listel);
return status;
}