summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2017-09-12 10:40:16 +0900
committerINSUN PYO <insun.pyo@samsung.com>2017-09-12 01:55:43 +0000
commit7ad7e284c5620d79617c98e7c9edeb4e2b1b1f6f (patch)
tree09ded1d4be2dbfe9b9a087705a7cabaed46b19fa
parent2cf4b2ae63894713b46d01fb46af6d2fbab70123 (diff)
downloadsystem-plugin-7ad7e284c5620d79617c98e7c9edeb4e2b1b1f6f.tar.gz
system-plugin-7ad7e284c5620d79617c98e7c9edeb4e2b1b1f6f.tar.bz2
system-plugin-7ad7e284c5620d79617c98e7c9edeb4e2b1b1f6f.zip
Signed-off-by: INSUN PYO <insun.pyo@samsung.com> Change-Id: I8999b410117069e1370a796b254ee52f7f6eea09 (cherry picked from commit cce23cf0bc507da44bee301de3f8b1955df5cb69)
-rw-r--r--src/liblazymount/lazy_mount_interface.c51
-rw-r--r--src/liblazymount/test_lazymount.c28
2 files changed, 27 insertions, 52 deletions
diff --git a/src/liblazymount/lazy_mount_interface.c b/src/liblazymount/lazy_mount_interface.c
index d7034a7..25fcdea 100644
--- a/src/liblazymount/lazy_mount_interface.c
+++ b/src/liblazymount/lazy_mount_interface.c
@@ -39,12 +39,12 @@
#define LAZY_MOUNT_CHECK_FILE LAZY_MOUNT_CHECK_DIR "/" UNLOCK_MNT_STR
#define EVENT_NAME_MAX 256
-#define EVENT_SIZE ( sizeof (struct inotify_event) )
-#define EVENT_BUF_LEN ( 512 * ( EVENT_SIZE + EVENT_NAME_MAX ) )
+#define EVENT_SIZE (sizeof(struct inotify_event))
+#define EVENT_BUF_LEN (512 * (EVENT_SIZE + EVENT_NAME_MAX))
/* Enumerate list of FDs to poll */
enum {
- FD_POLL_INOTIFY=0,
+ FD_POLL_INOTIFY = 0,
FD_POLL_MAX
};
@@ -53,14 +53,10 @@ int get_need_ui_for_lazy_mount()
int sl_result = 0;
/* get touchkey light duration setting */
if (vconf_get_int(VCONFKEY_SYSTEM_LAZY_MOUNT_SHOW_UI, &sl_result) < 0)
- {
return DEFAULT_VALUE_LAZY_MOUNT_SHOW_UI;
- }
- if(sl_result != 1 && sl_result != 0)
- {
+ if (sl_result != 1 && sl_result != 0)
return DEFAULT_VALUE_LAZY_MOUNT_SHOW_UI;
- }
return sl_result;
}
@@ -71,9 +67,7 @@ int do_mount_user()
f = fopen(LAZY_MOUNT_FILE, "w");
if (!f)
- {
return -errno;
- }
fclose(f);
return 0;
@@ -89,53 +83,42 @@ int wait_mount_user()
fd = access(LAZY_MOUNT_CHECK_FILE, F_OK);
- if(fd == 0)
- {
+ if (fd == 0)
return 0;
- }
fd = inotify_init();
- if(fd < 0)
- {
+ if (fd < 0)
return -errno;
- }
wd = inotify_add_watch(fd, LAZY_MOUNT_CHECK_DIR, IN_CREATE|IN_MODIFY|IN_ATTRIB);
fds[FD_POLL_INOTIFY].fd = fd;
fds[FD_POLL_INOTIFY].events = POLLIN;
- while(1)
- {
- if(poll(fds, FD_POLL_MAX, -1) < 0)
- {
+ while (1) {
+ if (poll(fds, FD_POLL_MAX, -1) < 0) {
inotify_rm_watch(fd, wd);
close(fd);
return -errno;
}
- if(fds[FD_POLL_INOTIFY].revents & POLLIN)
- {
+
+ if (fds[FD_POLL_INOTIFY].revents & POLLIN) {
length = read(fds[FD_POLL_INOTIFY].fd, buffer, EVENT_BUF_LEN);
- if( length < 0 )
- {
+ if (length < 0) {
inotify_rm_watch(fd, wd);
close(fd);
return -errno;
}
i = 0;
- while ( i < length ) {
- struct inotify_event *event = ( struct inotify_event * ) &buffer[ i ];
- if ( event->len > 0 && event->len < EVENT_NAME_MAX)
- {
- if ( event->mask & (IN_CREATE|IN_MODIFY|IN_ATTRIB) )
- {
- if (!(event->mask & IN_ISDIR))
- {
- if(!strncmp(event->name, UNLOCK_MNT_STR, sizeof(UNLOCK_MNT_STR)))
- {
+ while (i < length) {
+ struct inotify_event *event = (struct inotify_event *) &buffer[i];
+ if (event->len > 0 && event->len < EVENT_NAME_MAX) {
+ if (event->mask & (IN_CREATE|IN_MODIFY|IN_ATTRIB)) {
+ if (!(event->mask & IN_ISDIR)) {
+ if (!strncmp(event->name, UNLOCK_MNT_STR, sizeof(UNLOCK_MNT_STR))) {
inotify_rm_watch(fd, wd);
close(fd);
return 0;
diff --git a/src/liblazymount/test_lazymount.c b/src/liblazymount/test_lazymount.c
index 26b0971..c38c4c2 100644
--- a/src/liblazymount/test_lazymount.c
+++ b/src/liblazymount/test_lazymount.c
@@ -9,45 +9,38 @@ int get_input()
int data;
int i = 0;
char c_data[2];
- while(1)
- {
+ while (1) {
data = getchar();
- if( i < 2 )
- {
+ if (i < 2)
c_data[i] = (char)data;
- }
i++;
- if(data == 10 || data == 13)
- {
+ if (data == 10 || data == 13)
break;
- }
}
- if( i > 2 )
- {
+ if (i > 2)
return -1;
- }
+
c_data[1] = 0;
return atoi(c_data);
}
int main(int argc, char **argv)
{
- int data;
+ int data;
int sl_ret;
int i = 0;
if (argc == 2 && strncmp(argv[1], "wait", 5) == 0) {
- for ( i = 0 ; i < 3 ; i++ ) {
+ for (i = 0 ; i < 3 ; i++) {
sl_ret = wait_mount_user();
if (sl_ret != 0) continue;
else break;
}
- if ( i == 3 ) return -1;
+ if (i == 3) return -1;
sd_notify(0, "READY=1");
return 0;
}
- while(1)
- {
+ while (1) {
printf("Test\n");
printf("1. get_need_ui_for_lazy_mount()\n");
printf("2. do_mount_user()\n");
@@ -56,8 +49,7 @@ int main(int argc, char **argv)
printf("Select test : ");
data = get_input();
- switch(data)
- {
+ switch (data) {
case 1:
sl_ret = get_need_ui_for_lazy_mount();
printf("get_need_ui_for_lazy_mount() returns %d\n", sl_ret);