return;
}
-void notify_walk(struct notify_context *notify,
- void (*fn)(const char *path,
- struct notify_db_entry *entries,
- size_t num_entries,
- time_t deleted_time, void *private_data),
- void *private_data)
+NTSTATUS notify_walk(struct notify_context *notify,
+ bool (*fn)(const char *path, struct server_id server,
+ const struct notify_instance *instance,
+ void *private_data),
+ void *private_data)
{
- return;
+ struct tevent_context *ev;
+ struct tevent_req *req;
+ struct messaging_rec *rec;
+ uint64_t log_idx;
+ NTSTATUS status;
+ int ret;
+ bool ok;
+
+ ev = samba_tevent_context_init(notify);
+ if (ev == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ req = messaging_read_send(ev, ev, notify->msg_ctx, MSG_SMB_NOTIFY_DB);
+ if (req == NULL) {
+ TALLOC_FREE(ev);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ok = tevent_req_set_endtime(req, ev, timeval_current_ofs(10, 0));
+ if (!ok) {
+ TALLOC_FREE(ev);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = messaging_send_buf(notify->msg_ctx, notify->notifyd,
+ MSG_SMB_NOTIFY_GET_DB, NULL, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("%s: messaging_send_buf failed\n",
+ nt_errstr(status)));
+ TALLOC_FREE(ev);
+ return status;
+ }
+
+ ok = tevent_req_poll(req, ev);
+ if (!ok) {
+ DEBUG(10, ("%s: tevent_req_poll failed\n", __func__));
+ TALLOC_FREE(ev);
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ ret = messaging_read_recv(req, ev, &rec);
+ if (ret != 0) {
+ DEBUG(10, ("%s: messaging_read_recv failed: %s\n",
+ __func__, strerror(ret)));
+ TALLOC_FREE(ev);
+ return map_nt_error_from_unix(ret);
+ }
+
+ ret = notifyd_parse_db(rec->buf.data, rec->buf.length, &log_idx,
+ fn, private_data);
+ if (ret != 0) {
+ DEBUG(10, ("%s: notifyd_parse_db failed: %s\n",
+ __func__, strerror(ret)));
+ TALLOC_FREE(ev);
+ return map_nt_error_from_unix(ret);
+ }
+
+ TALLOC_FREE(ev);
+ return NT_STATUS_OK;
}
void notify_cleanup(struct notify_context *notify)
uint32_t *vnns, size_t num_vnns,
void *private_data),
void *private_data);
-void notify_walk(struct notify_context *notify,
- void (*fn)(const char *path,
- struct notify_db_entry *entries,
- size_t num_entries,
- time_t deleted_time, void *private_data),
- void *private_data);
+
+struct notify_instance;
+NTSTATUS notify_walk(struct notify_context *notify,
+ bool (*fn)(const char *path, struct server_id server,
+ const struct notify_instance *instance,
+ void *private_data),
+ void *private_data);
+
void notify_cleanup(struct notify_context *notify);
/* The following definitions come from smbd/ntquotas.c */
#include "lib/conn_tdb.h"
#include "serverid.h"
#include "status_profile.h"
+#include "smbd/notifyd/notifyd.h"
#define SMB_MAXPIDS 2048
static uid_t Ucrit_uid = 0; /* added by OH */
}
-static void print_notify_recs(const char *path,
- struct notify_db_entry *entries,
- size_t num_entries,
- time_t deleted_time, void *private_data)
+static bool print_notify_rec(const char *path, struct server_id server,
+ const struct notify_instance *instance,
+ void *private_data)
{
- size_t i;
- d_printf("%s\n", path);
+ struct server_id_buf idbuf;
- if (num_entries == 0) {
- d_printf("deleted %s\n", time_to_asc(deleted_time));
- }
-
- for (i=0; i<num_entries; i++) {
- struct notify_db_entry *e = &entries[i];
- struct server_id_buf idbuf;
+ d_printf("%s\\%s\\%x\\%x\n", path, server_id_str_buf(server, &idbuf),
+ (unsigned)instance->filter,
+ (unsigned)instance->subdir_filter);
- printf("%s %x %x\n", server_id_str_buf(e->server, &idbuf),
- (unsigned)e->filter,
- (unsigned)e->subdir_filter);
- }
- printf("\n");
+ return true;
}
int main(int argc, const char *argv[])
};
TALLOC_CTX *frame = talloc_stackframe();
int ret = 0;
- struct messaging_context *msg_ctx;
+ struct messaging_context *msg_ctx = NULL;
char *db_path;
bool ok;
if (show_notify) {
struct notify_context *n;
- n = notify_init(talloc_tos(), NULL, NULL);
+ if (msg_ctx == NULL) {
+ msg_ctx = messaging_init(
+ NULL, samba_tevent_context_init(NULL));
+ if (msg_ctx == NULL) {
+ fprintf(stderr, "messaging_init failed\n");
+ ret = -1;
+ goto done;
+ }
+ }
+
+ n = notify_init(talloc_tos(), msg_ctx,
+ messaging_tevent_context(msg_ctx));
if (n == NULL) {
goto done;
}
- notify_walk(n, print_notify_recs, NULL);
+ notify_walk(n, print_notify_rec, NULL);
TALLOC_FREE(n);
}