Name: sdbd
Summary: SDB daemon
-Version: 3.0.9
+Version: 3.0.10
Release: 0
License: Apache-2.0
Summary: SDB daemon
#define SYNC_TIMEOUT 15
-#define APP_INSTALL_PATH_PREFIX1 tzplatform_getenv(TZ_SYS_RW_APP)
-#define APP_INSTALL_PATH_PREFIX2 tzplatform_mkpath(TZ_SDK_HOME, "apps_rw")
-
struct sync_permit_rule
{
const char *name;
- const char *regx;
+ char *regx;
int mode; // 0:push, 1: pull, 2: push&push
};
void init_sdk_sync_permit_rule_regx(void)
{
- asprintf(&sdk_sync_permit_rule[0].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,50}\\.xml$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2);
- asprintf(&sdk_sync_permit_rule[1].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/+(.)*\\.gcda$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2);
- asprintf(&sdk_sync_permit_rule[2].regx, "^(/tmp/da/)*+[a-zA-Z0-9_\\-\\.]{1,50}\\.png$");
+ int ret;
+ ret = asprintf(&sdk_sync_permit_rule[0].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/[a-zA-Z0-9_\\-]{1,50}\\.xml$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2);
+ if(ret < 0) {
+ D("failed to run asprintf for unittest\n");
+ }
+ ret = asprintf(&sdk_sync_permit_rule[1].regx, "^((/tmp)|(%s)|(%s))/[a-zA-Z0-9]{10}/data/+(.)*\\.gcda$", APP_INSTALL_PATH_PREFIX1, APP_INSTALL_PATH_PREFIX2);
+ if (ret < 0) {
+ D("failed to run asprintf for codecoverage\n");
+ }
+ ret = asprintf(&sdk_sync_permit_rule[2].regx, "^(/tmp/da/)*+[a-zA-Z0-9_\\-\\.]{1,50}\\.png$");
+ if (ret < 0) {
+ D("failed to run asprintf for da\n");
+ }
}
static void set_syncfile_smack_label(char *src) {
static int fail_errno(int s)
{
- char buf[512];
+ char* ret_str;
+ char buf[512];
- strerror_r(s, buf, sizeof(buf));
+ ret_str = strerror_r(s, buf, sizeof(buf));
- return fail_message(s, buf);
+ return fail_message(s, (const char*)ret_str);
}
// FIXME: should get the following paths with api later but, do it for simple and not having dependency on other packages
}
if (strstr(path, MEDIA_CONTENTS_PATH1) != NULL) {
- char *arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH1, NULL};
- spawn(CMD_MEDIADB_UPDATE, arg_list);
+ const char * const arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH1, NULL};
+ spawn(CMD_MEDIADB_UPDATE, (char * const*)arg_list);
D("media db update done to %s\n", MEDIA_CONTENTS_PATH1);
} else if (strstr(path, MEDIA_CONTENTS_PATH2) != NULL) {
- char *arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH2, NULL};
- spawn(CMD_MEDIADB_UPDATE, arg_list);
+ const char * const arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH2, NULL};
+ spawn(CMD_MEDIADB_UPDATE, (char * const*)arg_list);
D("media db update done to %s\n", MEDIA_CONTENTS_PATH2);
} else if (strstr(path, MEDIA_CONTENTS_PATH3) != NULL) {
- char *arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH3, NULL};
- spawn(CMD_MEDIADB_UPDATE, arg_list);
+ const char * const arg_list[] = {CMD_MEDIADB_UPDATE, "-r", MEDIA_CONTENTS_PATH3, NULL};
+ spawn(CMD_MEDIADB_UPDATE, (char * const*)arg_list);
D("media db update done to %s\n", MEDIA_CONTENTS_PATH3);
}
return;
{
char *tmp;
mode_t mode;
- int is_link, ret;
+ int ret;
+#ifdef HAVE_SYMLINKS
+ int is_link;
+#endif
// Check the capability for file push support.
if(!is_support_push()) {
*tmp = 0;
errno = 0;
mode = strtoul(tmp + 1, NULL, 0);
-#ifndef HAVE_SYMLINKS
- is_link = 0;
-#else
+#ifdef HAVE_SYMLINKS
is_link = S_ISLNK(mode);
#endif
// extracts file permission from stat.mode. (ex 100644 & 0777 = 644);
}
if(!tmp || errno) {
mode = 0644; // set default permission value in most of unix system.
+#ifdef HAVE_SYMLINKS
is_link = 0;
+#endif
}
if (is_pkg_file_path(path)) {
mode = 0644;
+#ifdef HAVE_SYMLINKS
is_link = 0;
+#endif
}
// sdb does not allow to check that file exists or not. After deleting old file and creating new file again unconditionally.
}
}
regfree(®ex);
- for (i = 0; i <= 3; i++){
+ for (i=0; sdk_sync_permit_rule[i].regx != NULL; i++){
free(sdk_sync_permit_rule[i].regx);
}
return 0;
void (*usb_init)() = NULL;
void (*usb_cleanup)() = NULL;
int (*usb_write)(usb_handle *h, const void *data, int len) = NULL;
-int (*usb_read)(usb_handle *h, void *data, int len) = NULL;
+int (*usb_read)(usb_handle *h, void *data, size_t len) = NULL;
int (*usb_close)(usb_handle *h) = NULL;
void (*usb_kick)(usb_handle *h) = NULL;
if (access(SDB_PIDPATH, F_OK) == 0)
sdb_unlink(SDB_PIDPATH);
#endif
- char *cmd1_args[] = {"/usr/bin/killall", "/usr/bin/debug_launchpad_preloading_preinitializing_daemon", NULL};
+ char * const cmd1_args[] = {"/usr/bin/killall", "/usr/bin/debug_launchpad_preloading_preinitializing_daemon", NULL};
spawn("/usr/bin/killall", cmd1_args);
sdb_sleep_ms(1000);
}
char rule[MAX_LOCAL_BUFSZ];
GMainLoop *mainloop;
+/* g_type_init() is deprecated for glib version 2.35.0 or greater, */
+#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init();
+#endif
dbus_error_init(&error);
bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
if (!bus) {
D("Failed to connect to the D-BUS daemon: %s", error.message);
dbus_error_free(&error);
- return -1;
+ return NULL;
}
dbus_connection_setup_with_g_main(bus, NULL);
if (dbus_error_is_set(&error)) {
D("Fail to rule set: %s", error.message);
dbus_error_free(&error);
- return -1;
+ return NULL;
}
if (dbus_connection_add_filter(bus, __sdbd_dbus_signal_filter, NULL, NULL)
== FALSE)
- return -1;
+ return NULL;
D("booting signal initialized\n");
mainloop = g_main_loop_new(NULL, FALSE);
D("dbus loop exited");
- return 0;
+ return NULL;
}
void register_bootdone_cb() {
}
static void execute_required_process() {
- char *cmd_args[] = {"/usr/bin/debug_launchpad_preloading_preinitializing_daemon",NULL};
+ char * const cmd_args[] = {"/usr/bin/debug_launchpad_preloading_preinitializing_daemon",NULL};
spawn("/usr/bin/debug_launchpad_preloading_preinitializing_daemon", cmd_args);
}
void usb_init();
void usb_cleanup();
int usb_write(usb_handle *h, const void *data, int len);
-int usb_read(usb_handle *h, void *data, int len);
+int usb_read(usb_handle *h, void *data, size_t len);
int usb_close(usb_handle *h);
void usb_kick(usb_handle *h);
#else
extern void (*usb_init)();
extern void (*usb_cleanup)();
extern int (*usb_write)(usb_handle *h, const void *data, int len);
-extern int (*usb_read)(usb_handle *h, void *data, int len);
+extern int (*usb_read)(usb_handle *h, void *data, size_t len);
extern int (*usb_close)(usb_handle *h);
extern void (*usb_kick)(usb_handle *h);
void ffs_usb_init();
void ffs_usb_cleanup();
int ffs_usb_write(usb_handle *h, const void *data, int len);
-int ffs_usb_read(usb_handle *h, void *data, int len);
+int ffs_usb_read(usb_handle *h, void *data, size_t len);
int ffs_usb_close(usb_handle *h);
void ffs_usb_kick(usb_handle *h);
void linux_usb_init();
void linux_usb_cleanup();
int linux_usb_write(usb_handle *h, const void *data, int len);
-int linux_usb_read(usb_handle *h, void *data, unsigned len);
+int linux_usb_read(usb_handle *h, void *data, size_t len);
int linux_usb_close(usb_handle *h);
void linux_usb_kick(usb_handle *h);
}
},
/* end */
- { NULL, NULL, NULL }
+ { NULL, NULL, {NULL} }
};
-static struct command_suffix
+struct command_suffix
{
const char *name; // comments for human
const char *suffix; //pattern
#define SDK_LAUNCH_PATH "/usr/sbin/sdk_launch"
#define APP_INSTALL_PATH_PREFIX1 tzplatform_getenv(TZ_SYS_RW_APP)
-#define APP_INSTALL_PATH_PREFIX2 tzplatform_getenv(TZ_USER_APP)
+#define APP_INSTALL_PATH_PREFIX2 tzplatform_mkpath(TZ_SDK_HOME, "apps_rw")
#define DEV_INSTALL_PATH_PREFIX tzplatform_getenv(TZ_SDK_TOOLS)
#define GDBSERVER_PATH tzplatform_mkpath(TZ_SDK_TOOLS,"gdbserver/gdbserver")
#define GDBSERVER_PLATFORM_PATH tzplatform_mkpath(TZ_SDK_TOOLS,"gdbserver-platform/gdbserver")
#if !SDB_HOST
-static void redirect_and_exec(int pts, const char *cmd, const char *argv[], const char *envp[])
+static void redirect_and_exec(int pts, const char *cmd, char * const argv[], char * const envp[])
{
dup2(pts, 0);
dup2(pts, 1);
execve(cmd, argv, envp);
}
-static int create_subprocess(const char *cmd, pid_t *pid, const char *argv[], const char *envp[])
+static int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * const envp[])
{
char devname[64];
int ptm;
{
FILE *fp;
char buf[1024];
- int i;
char *s, *e, *value;
fp = fopen (LOGIN_CONFIG, "r");
};
args[2] = new_cmd;
- ret_fd = create_subprocess(SHELL_COMMAND, &pid, args, envp);
+ ret_fd = create_subprocess(SHELL_COMMAND, &pid, (char * const*)args, (char * const*)envp);
free(new_cmd);
} else { // in case of shell interactively
// Check the capability for interactive shell support.
return -1;
}
- char *args[] = {
+ char * const args[] = {
SHELL_COMMAND,
"-",
NULL,
};
- ret_fd = create_subprocess(SHELL_COMMAND, &pid, args, envp);
+ ret_fd = create_subprocess(SHELL_COMMAND, &pid, (char * const*)args, (char * const*)envp);
#if 0 // FIXME: should call login command instead of /bin/sh
if (should_drop_privileges()) {
char *args[] = {
const unsigned COMMAND_TIMEOUT = 10000;
void get_boot(int fd, void *cookie) {
char buf[2] = { 0, };
- char *mode = (char*) cookie;
int time = 0;
int interval = 1000;
while (time < COMMAND_TIMEOUT) {
}
} else if(!strncmp(name, "shellconf:", 10)){
if(!strncmp(name+10, "syncwinsz:", 10)){
- ret = create_service_thread(sync_windowsize, name+20);
+ ret = create_service_thread(sync_windowsize, (void *)name+20);
}
}
transport_read_action(int fd, struct tmsg* m)
{
char *p = (char*)m;
- int len = sizeof(*m);
+ size_t len = sizeof(*m);
int r;
while(len > 0) {
transport_write_action(int fd, struct tmsg* m)
{
char *p = (char*)m;
- int len = sizeof(*m);
+ size_t len = sizeof(*m);
int r;
while(len > 0) {
{
atransport *t;
atransport *result = NULL;
- int ambiguous = 0;
if (error_out)
*error_out = "device not found";
if (result) {
if (error_out)
*error_out = "more than one device";
- ambiguous = 1;
result = NULL;
break;
}
if (result) {
if (error_out)
*error_out = "more than one emulator";
- ambiguous = 1;
result = NULL;
break;
}
if (result) {
if (error_out)
*error_out = "more than one device and emulator";
- ambiguous = 1;
result = NULL;
break;
}
char *p = ptr;
int r;
#if SDB_TRACE
- int len0 = len;
+ size_t len0 = len;
#endif
- D("readx: fd=%d wanted=%d\n", fd, (int)len);
+ D("readx: fd=%d wanted=%d\n", fd, len);
while(len > 0) {
r = sdb_read(fd, p, len);
if(r > 0) {
int r;
#if SDB_TRACE
- D("writex: fd=%d len=%d: ", fd, (int)len);
+ D("writex: fd=%d len=%d: ", fd, len);
dump_hex( ptr, len );
#endif
while(len > 0) {
#endif // !SDB_HOST
#endif
-/*!
- * static int send_msg_to_host_from_guest(const char *hostname, int host_port, char *request, int sock_type)
- * @brief Sends \c request to host using specified protocol
- *
- * @param hostname Hostname -- could be domain name or IP
- * @param host_port Host port
- * @param request Message to be sent to host
- * @param protocol IP protocol to be used: IPPROTO_TCP or IPPROTO_UDP
- *
- * @returns 0 on success, -1 otherwise
- *
- * @note SOCK_STREAM will be used for IPPROTO_TCP as socket type
- * and SOCK_DGRAM for IPPROTO_UDP
- */
-static int send_msg_to_host_from_guest(const char *hostname, int host_port, char *request, int protocol) {
- int sock = -1;
- int PORT_SIZE = 32;
- char port[PORT_SIZE]; /* string decimal representation for getaddrinfo */
- struct addrinfo hints = {0};
- struct addrinfo *addresses, *curr_addr;
- int getaddr_ret;
- const char *protocol_name = "unknown"; /* for debug message */
-
- switch(protocol) {
- case IPPROTO_TCP:
- protocol_name = "tcp";
- hints.ai_socktype = SOCK_STREAM;
- break;
- case IPPROTO_UDP:
- protocol_name = "udp";
- hints.ai_socktype = SOCK_DGRAM;
- break;
- default:
- D("unsupported protocol: %d", protocol);
- return -1;
- }
-
- D("try to send notification to host(%s:%d) using %s:[%s]\n", hostname, host_port, protocol_name, request);
-
- hints.ai_family = AF_INET;
-
- snprintf(port, PORT_SIZE, "%d", host_port);
- getaddr_ret = getaddrinfo(hostname, port, &hints, &addresses);
-
- if (getaddr_ret != 0) {
- D("could not resolve %s\n", hostname);
- return -1;
- }
-
- for(curr_addr = addresses; curr_addr != NULL; curr_addr = curr_addr->ai_next) {
- sock = socket(curr_addr->ai_family, curr_addr->ai_socktype, curr_addr->ai_protocol);
- if (sock == -1)
- continue;
-
- if (connect(sock, curr_addr->ai_addr, curr_addr->ai_addrlen) != -1)
- break; /* Success */
-
- sdb_close(sock);
- }
-
- if(curr_addr == NULL) { /* No address succeeded */
- freeaddrinfo(addresses);
- D("could not connect to server\n");
- return -1;
- }
-
- freeaddrinfo(addresses);
-
- if (sdb_write(sock, request, strlen(request)) < 0) {
- D("could not send notification request to host\n");
- sdb_close(sock);
- return -1;
- }
- sdb_close(sock);
- D("sent notification request to host\n");
-
- return 0;
-}
-
int connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen,
int nsec) {
int flags, n, error;
}
// send the "emulator" request to sdbserver
-static void notify_sdbd_startup_thread() {
+static void* notify_sdbd_startup_thread(void* ptr) {
char buffer[512];
char request[512];
int time = 0;
//int try_limit_time = -1; // try_limit_time < 0 if unlimited
if (sensors_port < 0 || emulator_port < 0 || r < 0) {
- return;
+ return NULL;
}
if (get_emulator_hostip(host_ip, sizeof host_ip) == -1) {
D("failed to get emulator host ip\n");
- return;
+ return NULL;
}
// XXX: Known issue - log collision
while (1) {
/* Read events from control endpoint
Fortunately, FunctionFS guarantees reading of full event (or nothing),
so we're not bothered with ret < sizeof(read_event) */
- ret = sdb_read(usb->control, &read_event, sizeof(read_event));
+ ret = sdb_read(usb->control, (void *)&read_event, sizeof(read_event));
if (ret < 0) {
/* EAGAIN support will be useful, when non-blocking ep0 reads
are supported in FunctionFS */
*
* @returns 0 on success and -1 on failure (errno is set)
*/
-int ffs_usb_read(usb_handle *h, void *data, int len)
+int ffs_usb_read(usb_handle *h, void *data, size_t len)
{
int n;
}
int
-usb_read(struct usb_handle *uh, void *_data, int len)
+usb_read(struct usb_handle *uh, void *_data, size_t len)
{
unsigned char *data = (unsigned char*) _data;
int n;
return 0;
}
-int usb_read(usb_handle *h, void *_data, int len)
+int usb_read(usb_handle *h, void *_data, size_t len)
{
unsigned char *data = (unsigned char*) _data;
int n;
return 0;
}
-int linux_usb_read(usb_handle *h, void *data, unsigned len)
+int linux_usb_read(usb_handle *h, void *data, size_t len)
{
int n;
return str;
}
-int spawn(char* program, char** arg_list)
+int spawn(const char* program, char* const arg_list[])
{
pid_t pid;
int ret;
// init takes the process, and the process is not able to be zombie
exit(0);
}
- execvp (program, arg_list);
+ execvp(program, arg_list);
fprintf(stderr, "failed to spawn: never reach here!:%s\n", program);
exit(0);
}
* spawn a process and returns the process id of the new spawned process.
* it is working as async.
*/
-int spawn(char* program, char** arg_list);
+int spawn(const char* program, char * const arg_list[]);
char** str_split(char* a_str, const char a_delim);