Messages in this thread Patch in this message | | | From | Eric Paris <> | Subject | [PATCH =-v3 12/21] fanotify: user interface for access decisions | Date | Wed, 12 Nov 2008 11:11:30 -0500 |
| |
turns out that access decisions are useless if there is no way to do anything about them. So we add an interface. Alan will hate it, but at least it works...
Signed-off-by: Eric Paris <eparis@redhat.com> ---
include/linux/fanotify.h | 7 +++++++ net/fanotify/af_fanotify.c | 9 +++++++++ 2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index efc62e9..7bc15ec 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -76,8 +76,15 @@ struct fanotify_so_fastpath { __u32 mask; } __attribute__((packed)); +/* struct used for FANOTIFY_SEND_RESPONSE */ +struct fanotify_so_access { + __u64 cookie; + __u32 response; +} __attribute__((packed)); + /* fanotify setsockopt optvals */ #define FANOTIFY_SET_FASTPATH 1 +#define FANOTIFY_SEND_RESPONSE 2 #ifdef __KERNEL__ diff --git a/net/fanotify/af_fanotify.c b/net/fanotify/af_fanotify.c index 3b7283e..eef7e2a 100644 --- a/net/fanotify/af_fanotify.c +++ b/net/fanotify/af_fanotify.c @@ -162,6 +162,7 @@ static int fan_setsockopt(struct socket *sock, int level, int optname, char __us struct fanotify_group *group; union { struct fanotify_so_fastpath fastpath; + struct fanotify_so_access access; } data; int ret = 0; @@ -183,6 +184,14 @@ static int fan_setsockopt(struct socket *sock, int level, int optname, char __us return ret; ret = fanotify_fastpath_add(group, data.fastpath.fd, data.fastpath.mask); break; + case FANOTIFY_SEND_RESPONSE: + if (optlen < sizeof(struct fanotify_so_access)) + return -ENOMEM; + ret = copy_from_user(&data.access, optval, sizeof(struct fanotify_so_access)); + if (ret) + return ret; + ret = fanotify_process_access_response(group, data.access.cookie, data.access.response); + break; default: return -ENOPROTOOPT; }
| |