From 9bd148fedb51a9fc6672b64c7a9f2346c45cb458 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 10 Jun 2018 19:08:18 -0500
Subject: [PATCH 37/83] server: Implement esync_map_access().

---
 server/esync.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/server/esync.c b/server/esync.c
index 1f9602a43..62e6df30b 100644
--- a/server/esync.c
+++ b/server/esync.c
@@ -60,6 +60,7 @@ struct esync
 };
 
 static void esync_dump( struct object *obj, int verbose );
+static unsigned int esync_map_access( struct object *obj, unsigned int access );
 static void esync_destroy( struct object *obj );
 
 const struct object_ops esync_ops =
@@ -74,7 +75,7 @@ const struct object_ops esync_ops =
     NULL,                      /* satisfied */
     no_signal,                 /* signal */
     no_get_fd,                 /* get_fd */
-    no_map_access,             /* map_access */
+    esync_map_access,          /* map_access */
     default_get_sd,            /* get_sd */
     default_set_sd,            /* set_sd */
     no_lookup_name,            /* lookup_name */
@@ -93,6 +94,16 @@ static void esync_dump( struct object *obj, int verbose )
     fprintf( stderr, "esync fd=%d\n", esync->fd );
 }
 
+static unsigned int esync_map_access( struct object *obj, unsigned int access )
+{
+    /* Sync objects have the same flags. */
+    if (access & GENERIC_READ)    access |= STANDARD_RIGHTS_READ | EVENT_QUERY_STATE;
+    if (access & GENERIC_WRITE)   access |= STANDARD_RIGHTS_WRITE | EVENT_MODIFY_STATE;
+    if (access & GENERIC_EXECUTE) access |= STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE;
+    if (access & GENERIC_ALL)     access |= STANDARD_RIGHTS_ALL | EVENT_QUERY_STATE | EVENT_MODIFY_STATE;
+    return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
+}
+
 static void esync_destroy( struct object *obj )
 {
     struct esync *esync = (struct esync *)obj;
-- 
2.20.1

