#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
};
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;
}
f = fopen(LAZY_MOUNT_FILE, "w");
if (!f)
- {
return -errno;
- }
fclose(f);
return 0;
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;
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");
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);