mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-04 15:58:22 +00:00
During initialization, print messages for fatal errors
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
@@ -57,11 +57,13 @@ int swupd_curl_init(void)
|
||||
|
||||
curl_ret = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if (curl_ret != CURLE_OK) {
|
||||
printf("Error: failed to initialize CURL environment\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if (curl == NULL) {
|
||||
printf("Error: failed to initialize CURL session\n");
|
||||
curl_global_cleanup();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ int create_required_dirs(void)
|
||||
string_or_die(&cmd, "mkdir -p %s/%s", state_dir, dirs[i]);
|
||||
ret = system(cmd);
|
||||
if (ret) {
|
||||
printf("Error: failed to create %s/%s\n", state_dir, dirs[i]);
|
||||
return -1;
|
||||
}
|
||||
free(cmd);
|
||||
@@ -177,6 +178,7 @@ int create_required_dirs(void)
|
||||
string_or_die(&dir, "%s/%s", state_dir, dirs[i]);
|
||||
ret = chmod(dir, S_IRWXU);
|
||||
if (ret) {
|
||||
printf("Error: failed to set mode for %s/%s\n", state_dir, dirs[i]);
|
||||
return -1;
|
||||
}
|
||||
free(dir);
|
||||
@@ -185,6 +187,7 @@ int create_required_dirs(void)
|
||||
// chmod 700
|
||||
ret = chmod(state_dir, S_IRWXU);
|
||||
if (ret) {
|
||||
printf("Error: failed to set mode for state dir (%s)\n", state_dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -59,18 +59,22 @@ int p_lockfile(void)
|
||||
|
||||
/* open lock file */
|
||||
lock_fd = open(lockfile, O_RDWR | O_CREAT | O_CLOEXEC, 0600);
|
||||
free(lockfile);
|
||||
|
||||
if (lock_fd < 0) {
|
||||
printf("Error: failed to open %s: %s\n", lockfile, strerror(errno));
|
||||
free(lockfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(lockfile);
|
||||
|
||||
/* try to get an advisory region lock for the file */
|
||||
ret = fcntl(lock_fd, F_SETLK, &fl);
|
||||
if (ret == -1) {
|
||||
if ((errno == EAGAIN) || (errno == EACCES)) {
|
||||
ret = -EAGAIN;
|
||||
}
|
||||
printf("Error: cannot acquire lock file. Another swupd process is already running.\n");
|
||||
close(lock_fd);
|
||||
return ret;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user