service: fix a bug in crash report service 13/152213/1
authorJinhyung Jo <jinhyung.jo@samsung.com>
Mon, 25 Sep 2017 08:36:20 +0000 (17:36 +0900)
committerJinhyung Jo <jinhyung.jo@samsung.com>
Mon, 25 Sep 2017 08:53:20 +0000 (17:53 +0900)
Added to watch for the move event.

Change-Id: I1e2a8e39217f25d19bc9c84c3dab663311fb5523
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
src/services.c

index ea991c2..2976230 100644 (file)
@@ -227,7 +227,7 @@ void inoti_service(int fd, void *arg)
         return;
     }
 
-    wd = inotify_add_watch( ifd, CS_PATH, IN_CREATE);
+    wd = inotify_add_watch(ifd, CS_PATH, IN_CREATE | IN_MOVE);
     if ( wd < 0 ) {
         D("inotify_add_watch failed (errno :%d)\n", errno);
         sdb_close(ifd);
@@ -259,6 +259,18 @@ void inoti_service(int fd, void *arg)
                             D( "asprintf was failed\n" );
                         }
                     }
+                } else if (event->mask & IN_MOVE) {
+                    if (!(event->mask & IN_ISDIR)) {
+                        char *cspath = NULL;
+                        int len = asprintf(&cspath, "%s/%s", CS_PATH, event->name);
+                        if (len >= 0) {
+                            D("The file %s was moved.\n", cspath);
+                            writex(fd, cspath, len);
+                            free(cspath);
+                        } else {
+                            D("asprintf was failed\n");
+                        }
+                    }
                 }
             }
             if (i + EVENT_SIZE + event->len < event->len) { // in case of integer overflow