__convert_hal_to_info(data_hal, data_info, true);
}
-static bool is_system_generator_context(void)
+static bool is_system_generator_context(const char *module_name)
{
char *systemd_scope = NULL;
systemd_scope = getenv("SYSTEMD_SCOPE");
if (!systemd_scope) {
- _E("Reject to create %s, not a generator context",
- compatibility_result_path);
+ _E("%s: Reject to create %s, not a generator context",
+ module_name, compatibility_result_path);
return false;
}
if (strncmp(systemd_scope, "system", sizeof("system")) != 0) {
- _E("Reject to create %s, only system servie manager is allowed to do it",
- compatibility_result_path);
+ _E("%s: Reject to create %s, only system servie manager is allowed to do it",
+ module_name, compatibility_result_path);
return false;
}
}
-static int open_result_file(const char *path, int *fd_out, bool reset)
+static int open_result_file(const char *path, int *fd_out, bool reset, const char *module_name)
{
int ret;
int fd;
ret = create_directory(path);
if (ret < 0) {
errno = -ret;
- _E("Failed to create directory for %s, %m", path);
+ _E("%s: Failed to create directory for %s, %m", module_name, path);
return ret;
}
}
ret = -errno;
- _E("Failed to create %s, %m", path);
+ _E("%s: Failed to create %s, %m", module_name, path);
return ret;
}
ret = ftruncate(fd, sizeof(struct compatibility_info) * HAL_MODULE_END);
if (ret < 0) {
ret = -errno;
- _E("Failed to ftruncate %s, %m", path);
+ _E("%s: Failed to ftruncate %s, %m", module_name, path);
close(fd);
return ret;
}
ret = set_owner(fd);
if (ret < 0) {
errno = -ret;
- _E("Failed to set owner, ret=%d, %m\n", ret);
+ _E("%s: Failed to set owner, ret=%d, %m\n", module_name, ret);
close(fd);
return ret;
}
ssize_t n_write;
off_t offset;
- ret = open_result_file(compatibility_result_path, &fd, false);
+ ret = open_result_file(compatibility_result_path, &fd, false, info->module_name);
if (ret < 0) {
_E("Failed to create open result file %s", compatibility_result_path);
return ret;
n_write = pwrite(fd, info, sizeof(*info), offset);
if (n_write == -1) {
ret = -errno;
- _E("Failed to write info, %m");
+ _E("%s: Failed to write info, %m", info->module_name);
close(fd);
return ret;
}
manifest = NULL;
/* Writing result is only allowed on system generator context */
- if (!is_system_generator_context())
+ if (!is_system_generator_context(info->module_name))
return 0;
/* Incomplete data, no versions. Don't write it */