notify_inotify: Move mapping table to top of file
authorChristof Schmitt <cs@samba.org>
Fri, 15 Jul 2016 19:15:15 +0000 (12:15 -0700)
committerVolker Lendecke <vl@samba.org>
Mon, 18 Jul 2016 13:14:12 +0000 (15:14 +0200)
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/notify_inotify.c

index 88a54eca99532656488bde47afa37870c199d757..f7034f1f3551d91accc8bcddb52836ea38a3cc68 100644 (file)
@@ -57,6 +57,36 @@ struct inotify_watch_context {
 };
 
 
+/*
+  map from a change notify mask to a inotify mask. Remove any bits
+  which we can handle
+*/
+static const struct {
+       uint32_t notify_mask;
+       uint32_t inotify_mask;
+} inotify_mapping[] = {
+       {FILE_NOTIFY_CHANGE_FILE_NAME,   IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
+       {FILE_NOTIFY_CHANGE_DIR_NAME,    IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
+       {FILE_NOTIFY_CHANGE_ATTRIBUTES,  IN_ATTRIB|IN_MOVED_TO|IN_MOVED_FROM|IN_MODIFY},
+       {FILE_NOTIFY_CHANGE_LAST_WRITE,  IN_ATTRIB},
+       {FILE_NOTIFY_CHANGE_LAST_ACCESS, IN_ATTRIB},
+       {FILE_NOTIFY_CHANGE_EA,          IN_ATTRIB},
+       {FILE_NOTIFY_CHANGE_SECURITY,    IN_ATTRIB}
+};
+
+static uint32_t inotify_map(uint32_t *filter)
+{
+       int i;
+       uint32_t out=0;
+       for (i=0;i<ARRAY_SIZE(inotify_mapping);i++) {
+               if (inotify_mapping[i].notify_mask & *filter) {
+                       out |= inotify_mapping[i].inotify_mask;
+                       *filter &= ~inotify_mapping[i].notify_mask;
+               }
+       }
+       return out;
+}
+
 /*
   destroy the inotify private context
 */
@@ -288,37 +318,6 @@ static int inotify_setup(struct sys_notify_context *ctx)
        return 0;
 }
 
-
-/*
-  map from a change notify mask to a inotify mask. Remove any bits
-  which we can handle
-*/
-static const struct {
-       uint32_t notify_mask;
-       uint32_t inotify_mask;
-} inotify_mapping[] = {
-       {FILE_NOTIFY_CHANGE_FILE_NAME,   IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
-       {FILE_NOTIFY_CHANGE_DIR_NAME,    IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
-       {FILE_NOTIFY_CHANGE_ATTRIBUTES,  IN_ATTRIB|IN_MOVED_TO|IN_MOVED_FROM|IN_MODIFY},
-       {FILE_NOTIFY_CHANGE_LAST_WRITE,  IN_ATTRIB},
-       {FILE_NOTIFY_CHANGE_LAST_ACCESS, IN_ATTRIB},
-       {FILE_NOTIFY_CHANGE_EA,          IN_ATTRIB},
-       {FILE_NOTIFY_CHANGE_SECURITY,    IN_ATTRIB}
-};
-
-static uint32_t inotify_map(uint32_t *filter)
-{
-       int i;
-       uint32_t out=0;
-       for (i=0;i<ARRAY_SIZE(inotify_mapping);i++) {
-               if (inotify_mapping[i].notify_mask & *filter) {
-                       out |= inotify_mapping[i].inotify_mask;
-                       *filter &= ~inotify_mapping[i].notify_mask;
-               }
-       }
-       return out;
-}
-
 /*
   destroy a watch
 */