#define LOG_TAG "LIBBUGREPORT"
+#include "libbugreport.h"
#include "shared/log.h"
#define BUS_NAME "org.tizen.system.crash.livedump"
return conn;
}
-bool livedump_pid(pid_t pid, const char *dump_reason, char *report_path, size_t report_path_len)
+int livedump_pid(pid_t pid, const char *dump_reason, char *report_path, size_t report_path_len)
{
- bool res = true;
+ int res = TIZEN_ERROR_NONE;
GDBusConnection *conn = dbus_init();
if (!conn)
- return false;
+ return TIZEN_ERROR_IO_ERROR;
GVariant *parameters = g_variant_new("(is)", pid, dump_reason);
&error);
if (!reply || error) {
_E("Error while calling livedump_pid via dbus (pid=%d, reason=%s): %s", pid, dump_reason, error ? error->message : "");
- if (error)
+ res = TIZEN_ERROR_IO_ERROR;
+
+ if (error) {
+ if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+ res = TIZEN_ERROR_PERMISSION_DENIED;
+ if (error->code == CS_ERR_NO_PROC)
+ res = TIZEN_ERROR_NO_SUCH_PROCESS;
g_error_free(error);
- res = false;
+ }
goto exit;
}
if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(s)"))) {
_E("reply is not of the correct type (s)");
- res = false;
+ res = TIZEN_ERROR_IO_ERROR;
goto exit;
}
strncpy(report_path, reply_str, report_path_len);
} else {
_E("Report path (%s) is longer than report_path_len", reply_str);
- res = false;
+ res = TIZEN_ERROR_IO_ERROR;
}
exit:
g_object_unref(conn);
* @param dump_reason the reason that should be included in the raport.
* @param report_path pointer to the buffer in which will be saved the report path.
* @param report_path_len lenght of buffer for the report path.
- * @return true on success and false on error.
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TIZEN_ERROR_NONE Success
+ * @retval #TIZEN_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #TIZEN_ERROR_NO_SUCH_PROCESS No such process
+ * @retval #TIZEN_ERROR_IO_ERROR Internal error occurred
*/
-extern bool livedump_pid(pid_t pid, const char *dump_reason, char *report_path, size_t report_path_len);
+extern int livedump_pid(pid_t pid, const char *dump_reason, char *report_path, size_t report_path_len);
pid_t pid = strtol(argv[optind], NULL, 10);
char BUFF[PATH_MAX];
- bool res = livedump_pid(pid, dump_reason, BUFF, PATH_MAX);
- printf("res: %s\nreport_path: %s\n", res ? "true" : "false", BUFF);
+ int res = livedump_pid(pid, dump_reason, BUFF, PATH_MAX);
+ printf("res: %s (%d)\nreport_path: %s\n", res == CS_ERR_NO_ERROR ? "true" : "false", res, BUFF);
return res ? EXIT_SUCCESS : EXIT_FAILURE;
}