From b329ea1cf35cfe151ac026eefc8ff82b2dfd711c Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Fri, 20 Feb 2009 13:23:53 -0800 Subject: s3: Modifications to generic notify structures to allow implementation of OneFS notify. The OneFS kernel based change notify system takes an fd of the directory to watch in it's initialization syscall. Since we already have this directory open, this commit plumbs that fd down to the VFS layer via the notify_entry struct. We also need to know if the watch is taken out on a snapshot directory. The full file_id struct is also passed down to make this determination. The file_id marshalling wrappers are hand written here, but should eventually be auto-generated by moving the struct file_id into the idl. --- source3/include/proto.h | 3 +++ source3/librpc/gen_ndr/ndr_notify.c | 8 ++++++++ source3/librpc/gen_ndr/notify.h | 2 ++ source3/librpc/idl/notify.idl | 2 ++ source3/librpc/ndr/util.c | 39 +++++++++++++++++++++++++++++++++++++ source3/smbd/notify.c | 2 ++ 6 files changed, 56 insertions(+) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index ab1f2f4f4f..1ac2ac23fb 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2283,6 +2283,9 @@ ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r); enum ndr_err_code ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r); void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r); +enum ndr_err_code ndr_push_file_id(struct ndr_push *ndr, int ndr_flags, const struct file_id *r); +enum ndr_err_code ndr_pull_file_id(struct ndr_pull *ndr, int ndr_flags, struct file_id *r); +void ndr_print_file_id(struct ndr_print *ndr, const char *name, const struct file_id *r); _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b); _PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss); const char *ndr_errstr(enum ndr_err_code err); diff --git a/source3/librpc/gen_ndr/ndr_notify.c b/source3/librpc/gen_ndr/ndr_notify.c index 00ba8bc293..d4ac42e961 100644 --- a/source3/librpc/gen_ndr/ndr_notify.c +++ b/source3/librpc/gen_ndr/ndr_notify.c @@ -10,6 +10,8 @@ _PUBLIC_ enum ndr_err_code ndr_push_notify_entry(struct ndr_push *ndr, int ndr_f NDR_CHECK(ndr_push_server_id(ndr, NDR_SCALARS, &r->server)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->filter)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->subdir_filter)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->dir_fd)); + NDR_CHECK(ndr_push_file_id(ndr, NDR_SCALARS, &r->dir_id)); { uint32_t _flags_save_string = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); @@ -21,6 +23,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_notify_entry(struct ndr_push *ndr, int ndr_f } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_push_server_id(ndr, NDR_BUFFERS, &r->server)); + NDR_CHECK(ndr_push_file_id(ndr, NDR_BUFFERS, &r->dir_id)); } return NDR_ERR_SUCCESS; } @@ -32,6 +35,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_notify_entry(struct ndr_pull *ndr, int ndr_f NDR_CHECK(ndr_pull_server_id(ndr, NDR_SCALARS, &r->server)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->filter)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->subdir_filter)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dir_fd)); + NDR_CHECK(ndr_pull_file_id(ndr, NDR_SCALARS, &r->dir_id)); { uint32_t _flags_save_string = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); @@ -43,6 +48,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_notify_entry(struct ndr_pull *ndr, int ndr_f } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_pull_server_id(ndr, NDR_BUFFERS, &r->server)); + NDR_CHECK(ndr_pull_file_id(ndr, NDR_BUFFERS, &r->dir_id)); } return NDR_ERR_SUCCESS; } @@ -54,6 +60,8 @@ _PUBLIC_ void ndr_print_notify_entry(struct ndr_print *ndr, const char *name, co ndr_print_server_id(ndr, "server", &r->server); ndr_print_uint32(ndr, "filter", r->filter); ndr_print_uint32(ndr, "subdir_filter", r->subdir_filter); + ndr_print_uint32(ndr, "dir_fd", r->dir_fd); + ndr_print_file_id(ndr, "dir_id", &r->dir_id); ndr_print_string(ndr, "path", r->path); ndr_print_uint32(ndr, "path_len", r->path_len); ndr_print_pointer(ndr, "private_data", r->private_data); diff --git a/source3/librpc/gen_ndr/notify.h b/source3/librpc/gen_ndr/notify.h index c809702e5d..a5ec4a46e6 100644 --- a/source3/librpc/gen_ndr/notify.h +++ b/source3/librpc/gen_ndr/notify.h @@ -9,6 +9,8 @@ struct notify_entry { struct server_id server; uint32_t filter; uint32_t subdir_filter; + uint32_t dir_fd; + struct file_id dir_id; const char * path;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ uint32_t path_len; void* private_data; diff --git a/source3/librpc/idl/notify.idl b/source3/librpc/idl/notify.idl index c4e633c254..550783b5cd 100644 --- a/source3/librpc/idl/notify.idl +++ b/source3/librpc/idl/notify.idl @@ -18,6 +18,8 @@ interface notify server_id server; uint32 filter; /* filter to apply in this directory */ uint32 subdir_filter; /* filter to apply in child directories */ + uint32 dir_fd; /* fd of open directory */ + file_id dir_id; /* file_id of open directory */ utf8string path; uint32 path_len; /* saves some computation on search */ pointer private_data; diff --git a/source3/librpc/ndr/util.c b/source3/librpc/ndr/util.c index 5afc4f4f5a..8fac5eadd4 100644 --- a/source3/librpc/ndr/util.c +++ b/source3/librpc/ndr/util.c @@ -155,6 +155,45 @@ void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct s ndr->depth--; } +enum ndr_err_code ndr_push_file_id(struct ndr_push *ndr, int ndr_flags, const struct file_id *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, + (uint64_t)r->devid)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, + (uint64_t)r->inode)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, + (uint64_t)r->extid)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_file_id(struct ndr_pull *ndr, int ndr_flags, struct file_id *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->devid)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->inode)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->extid)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +void ndr_print_file_id(struct ndr_print *ndr, const char *name, const struct file_id *r) +{ + ndr_print_struct(ndr, name, "file_id"); + ndr->depth++; + ndr_print_udlong(ndr, "devid", (uint64_t)r->devid); + ndr_print_udlong(ndr, "inode", (uint64_t)r->inode); + ndr_print_udlong(ndr, "extid", (uint64_t)r->extid); + ndr->depth--; +} + _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b) { ndr->print(ndr, "%-25s: %s", name, b?"true":"false"); diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index 1d4f5e8c5b..e360af9ef5 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -214,6 +214,8 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter, ZERO_STRUCT(e); e.path = fullpath; + e.dir_fd = fsp->fh->fd; + e.dir_id = fsp->file_id; e.filter = filter; e.subdir_filter = 0; if (recursive) { -- cgit