mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-01 02:34:43 +00:00
Apply changes from clang-format
Running: clang-format -i -style=file src/*.[ch] src/lib/*.[ch] \ src/3rd_party/*.[ch] src/cmds/*.[ch] src/swupd_lib/*.[ch] \ src/verifytime/*.[ch] with clang v15 Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
committed by
William Douglas
parent
a425393c87
commit
dbeb3662a4
Vendored
+1
-1
@@ -17,8 +17,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "swupd.h"
|
||||
#include "cmds/swupd_cmds.h"
|
||||
#include "swupd.h"
|
||||
|
||||
#ifdef THIRDPARTY
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -22,8 +22,8 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "3rd_party_repos.h"
|
||||
#include "swupd_lib/signature.h"
|
||||
#include "swupd.h"
|
||||
#include "swupd_lib/signature.h"
|
||||
|
||||
#ifdef THIRDPARTY
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
|
||||
#include "3rd_party_repos.h"
|
||||
#include "swupd_lib/signature.h"
|
||||
#include "swupd.h"
|
||||
#include "swupd_lib/signature.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -260,7 +260,7 @@ int third_party_remove_repo_directory(const char *repo_name)
|
||||
int ret = 0;
|
||||
int ret_code = 0;
|
||||
|
||||
//TODO: use a global function to get this value
|
||||
// TODO: use a global function to get this value
|
||||
repo_dir = get_repo_content_path(repo_name);
|
||||
ret = sys_rm_recursive(repo_dir);
|
||||
if (ret < 0 && ret != -ENOENT) {
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "swupd_lib/alias.h"
|
||||
#include "swupd.h"
|
||||
#include "swupd_lib/target_root.h"
|
||||
#include "swupd_lib/alias.h"
|
||||
#include "swupd_lib/heuristics.h"
|
||||
#include "swupd_lib/target_root.h"
|
||||
|
||||
#define MODE_RW_O (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
|
||||
#define VERIFY_NOPICKY 0
|
||||
|
||||
@@ -329,10 +329,10 @@ out:
|
||||
}
|
||||
|
||||
/*
|
||||
* list_installable_bundles()
|
||||
* Parse the full manifest for the current version of the OS and print
|
||||
* all available bundles.
|
||||
*/
|
||||
* list_installable_bundles()
|
||||
* Parse the full manifest for the current version of the OS and print
|
||||
* all available bundles.
|
||||
*/
|
||||
static enum swupd_code list_installable_bundles(int version)
|
||||
{
|
||||
char *name;
|
||||
|
||||
@@ -36,7 +36,7 @@ static void print_help(void)
|
||||
print("Checks whether an update is available and prints out the information if so\n\n");
|
||||
print("Usage:\n");
|
||||
print(" swupd check-update [OPTION...]\n\n");
|
||||
//TODO: Add documentation explaining this command
|
||||
// TODO: Add documentation explaining this command
|
||||
|
||||
global_print_help();
|
||||
}
|
||||
|
||||
+6
-6
@@ -468,7 +468,7 @@ static int remove_irrelevant_file(const char *filename, const struct stat *st, i
|
||||
relevant_path = statedir_get_cache_url_dir();
|
||||
ret = str_starts_with(filename, relevant_path);
|
||||
FREE(relevant_path);
|
||||
if (ret == 0){
|
||||
if (ret == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ static int remove_irrelevant_file(const char *filename, const struct stat *st, i
|
||||
}
|
||||
}
|
||||
stats.files_removed++;
|
||||
stats.bytes_removed+=long_to_ulong(st->st_size);
|
||||
stats.bytes_removed += long_to_ulong(st->st_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -493,7 +493,7 @@ static int count_file(const char *filename, const struct stat *st, int type __at
|
||||
print("%s\n", filename);
|
||||
}
|
||||
stats.files_removed++;
|
||||
stats.bytes_removed+=long_to_ulong(st->st_size);
|
||||
stats.bytes_removed += long_to_ulong(st->st_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ static enum swupd_code remove_cache_directory(const char *dir)
|
||||
enum swupd_code ret_code;
|
||||
int ret;
|
||||
|
||||
if (!sys_is_dir(dir)){
|
||||
if (!sys_is_dir(dir)) {
|
||||
return SWUPD_OK;
|
||||
}
|
||||
|
||||
@@ -678,13 +678,13 @@ enum swupd_code clean_cachedir(void)
|
||||
}
|
||||
ret_code = clean_staged_manifests(dir, options.dry_run, false);
|
||||
FREE(dir);
|
||||
if(ret_code) {
|
||||
if (ret_code) {
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
// remove all cache from other mirror URLs
|
||||
ret_code = clean_irrelevant_cache();
|
||||
if(ret_code) {
|
||||
if (ret_code) {
|
||||
return ret_code;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,9 +32,9 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "swupd.h"
|
||||
#include "swupd_lib/heuristics.h"
|
||||
#include "swupd_lib/signature.h"
|
||||
#include "swupd_lib/target_root.h"
|
||||
#include "swupd_lib/heuristics.h"
|
||||
|
||||
#define FLAG_DOWNLOAD_ONLY 2000
|
||||
#define FLAG_UPDATE_SEARCH_FILE_INDEX 2001
|
||||
@@ -80,7 +80,7 @@ bool update_get_option_download_only(void)
|
||||
static void save_swupd_binary_path()
|
||||
{
|
||||
/* we need to resolve the whole path to swupd first, proc/self/exe
|
||||
* is a symbolic link to the executable that is running the current process */
|
||||
* is a symbolic link to the executable that is running the current process */
|
||||
ssize_t path_length;
|
||||
path_length = readlink("/proc/self/exe", swupd_binary, sizeof(swupd_binary));
|
||||
if (path_length <= 0 || path_length >= LINE_MAX) {
|
||||
|
||||
+4
-4
@@ -33,9 +33,9 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "swupd.h"
|
||||
#include "swupd_lib/heuristics.h"
|
||||
#include "swupd_lib/signature.h"
|
||||
#include "swupd_lib/target_root.h"
|
||||
#include "swupd_lib/heuristics.h"
|
||||
|
||||
#define FLAG_EXTRA_FILES_ONLY 2000
|
||||
#define FLAG_FILE 2001
|
||||
@@ -299,7 +299,7 @@ static int get_required_files(struct manifest *official_manifest, struct list *r
|
||||
* Only called when a file has failed to be fixed during a verify or install.
|
||||
* If a low-space warning has been printed, don't check again,
|
||||
* but just warn the user and return.
|
||||
*/
|
||||
*/
|
||||
static void check_warn_freespace(struct file *file)
|
||||
{
|
||||
long fs_free;
|
||||
@@ -611,7 +611,7 @@ static void remove_orphaned_files(struct list *files_to_verify, bool repair)
|
||||
if (errno != ENOTEMPTY) {
|
||||
print(" -> not deleted (%s)\n", strerror(errno));
|
||||
} else {
|
||||
//FIXME: Add force removal option?
|
||||
// FIXME: Add force removal option?
|
||||
print(" -> not deleted (not empty)\n");
|
||||
}
|
||||
} else {
|
||||
@@ -922,7 +922,7 @@ enum swupd_code execute_verify_extra(extra_proc_fn_t post_verify_fn)
|
||||
bool invalid_bundle = false;
|
||||
|
||||
/* Unless we are installing a new bundle and the --skip-optional flag is not
|
||||
* set we shoudn't include optional bundles to the bundle list */
|
||||
* set we shoudn't include optional bundles to the bundle list */
|
||||
if (!cmdline_option_install || cmdline_option_skip_optional) {
|
||||
globals.skip_optional_bundles = true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ static struct list *hashmap_get_internal(struct hashmap *hashmap, const void *ke
|
||||
if (hashmap->equal(key, i->data)) {
|
||||
void *data = i->data;
|
||||
if (remove) {
|
||||
//If it's the first element of the list, update head
|
||||
// If it's the first element of the list, update head
|
||||
if (i == *items) {
|
||||
*items = i->next;
|
||||
}
|
||||
|
||||
+2
-2
@@ -453,8 +453,8 @@ void *list_remove(void *item_to_remove, struct list **list, comparison_fn_t comp
|
||||
void list_move_item(void *item_to_move, struct list **list1, struct list **list2, comparison_fn_t comparison_fn)
|
||||
{
|
||||
void *item;
|
||||
//TODO: Improve eficience of this function. We are calling list_head()
|
||||
// on list1 for all iterations on while()
|
||||
// TODO: Improve eficience of this function. We are calling list_head()
|
||||
// on list1 for all iterations on while()
|
||||
|
||||
item = list_remove(item_to_move, list1, comparison_fn);
|
||||
while (item) {
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ char *str_join(const char *separator, struct list *strings)
|
||||
printed = snprintf(str, str_size, "%s%s",
|
||||
i == strings ? "" : separator, (char *)i->data);
|
||||
if (printed < 0 || int_to_uint(printed) >= str_size) {
|
||||
goto error; //shouldn't happen
|
||||
goto error; // shouldn't happen
|
||||
}
|
||||
str_size -= int_to_uint(printed);
|
||||
str += int_to_uint(printed);
|
||||
|
||||
+4
-4
@@ -392,7 +392,7 @@ int systemctl_daemon_reload(void)
|
||||
bool systemd_in_container(void)
|
||||
{
|
||||
/* systemd-detect-virt -c does container detection only *
|
||||
* The return code is zero if the system is in a container */
|
||||
* The return code is zero if the system is in a container */
|
||||
return !run_command("/usr/bin/systemd-detect-virt", "-c", NULL);
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ char *sys_path_join(const char *fmt, ...)
|
||||
/* remove all duplicated PATH_SEPARATOR from the path */
|
||||
for (i = j = 0; i < len; i++) {
|
||||
if (path[i] == PATH_SEPARATOR && // Is separator and
|
||||
// Next is also a separator or
|
||||
// Next is also a separator or
|
||||
(path[i + 1] == PATH_SEPARATOR ||
|
||||
// Is a trailing separator, but not root
|
||||
(path[i + 1] == '\0' && j != 0))) {
|
||||
@@ -758,8 +758,8 @@ struct list *sys_get_mounted_directories(void)
|
||||
while (mnt != NULL) {
|
||||
if (n == 4) {
|
||||
/* The "4" assumes today's mountinfo form of:
|
||||
* 16 36 0:3 / /proc rw,relatime master:7 - proc proc rw
|
||||
* where the fifth field is the mountpoint. */
|
||||
* 16 36 0:3 / /proc rw,relatime master:7 - proc proc rw
|
||||
* where the fifth field is the mountpoint. */
|
||||
if (str_cmp(mnt, "/") != 0) {
|
||||
mounted = list_append_data(mounted, sys_path_join("%s", mnt));
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ struct tp *tp_start(int num_threads)
|
||||
|
||||
tp->num_threads = num_threads;
|
||||
if (num_threads == 0) {
|
||||
//We don't need to create threads
|
||||
// We don't need to create threads
|
||||
return tp;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,6 @@ void tp_complete(struct tp *tp);
|
||||
*/
|
||||
int tp_get_num_threads(struct tp *tp);
|
||||
|
||||
//TODO: Implement a tp_wait() function
|
||||
// TODO: Implement a tp_wait() function
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,8 +15,8 @@ enum swupd_code {
|
||||
/** 0 success */
|
||||
SWUPD_OK = 0,
|
||||
/** 1 used by swupd to respond "No" in different situations:
|
||||
- if used with check-update it means no update is available
|
||||
- if used with autoupdate it means automatic updating is disabled */
|
||||
- if used with check-update it means no update is available
|
||||
- if used with autoupdate it means automatic updating is disabled */
|
||||
SWUPD_NO,
|
||||
/** 2 a required bundle is missing or was attempted to be removed */
|
||||
SWUPD_REQUIRED_BUNDLE_ERROR,
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "swupd_lib/alias.h"
|
||||
#include "swupd.h"
|
||||
#include "swupd_lib/alias.h"
|
||||
|
||||
#define MODE_RW_O (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
|
||||
|
||||
/* Finds out whether bundle_name is installed bundle on
|
||||
* current system.
|
||||
*/
|
||||
* current system.
|
||||
*/
|
||||
bool is_installed_bundle(const char *bundle_name)
|
||||
{
|
||||
char *filename = NULL;
|
||||
|
||||
@@ -586,7 +586,7 @@ exit:
|
||||
// Reset variable
|
||||
memset(&local, 0, sizeof(local));
|
||||
|
||||
//Disable download resume
|
||||
// Disable download resume
|
||||
resume_download_supported = false;
|
||||
goto restart_download;
|
||||
}
|
||||
@@ -762,11 +762,11 @@ CURLcode swupd_curl_set_basic_options(CURL *curl, const char *url, bool fail_on_
|
||||
goto exit;
|
||||
}
|
||||
|
||||
//TODO: Introduce code back on bug is fixed on curl
|
||||
//curl_ret = curl_easy_setopt(curl, CURLOPT_PIPEWAIT, 1);
|
||||
//if (curl_ret != CURLE_OK && curl_ret != CURLE_UNKNOWN_OPTION) {
|
||||
// TODO: Introduce code back on bug is fixed on curl
|
||||
// curl_ret = curl_easy_setopt(curl, CURLOPT_PIPEWAIT, 1);
|
||||
// if (curl_ret != CURLE_OK && curl_ret != CURLE_UNKNOWN_OPTION) {
|
||||
// goto exit;
|
||||
//}
|
||||
// }
|
||||
|
||||
curl_ret = curl_easy_setopt(curl, CURLOPT_USERAGENT, PACKAGE "/" VERSION);
|
||||
if (curl_ret != CURLE_OK && curl_ret != CURLE_UNKNOWN_OPTION) {
|
||||
@@ -782,7 +782,7 @@ CURLcode swupd_curl_set_basic_options(CURL *curl, const char *url, bool fail_on_
|
||||
}
|
||||
|
||||
if (str_starts_with(url, "https://") == 0) {
|
||||
//TODO: Fix "SECURITY HOLE since we can't SSL pin arbitrary servers"
|
||||
// TODO: Fix "SECURITY HOLE since we can't SSL pin arbitrary servers"
|
||||
curl_ret = swupd_curl_set_security_opts(curl);
|
||||
if (curl_ret != CURLE_OK) {
|
||||
goto exit;
|
||||
|
||||
@@ -302,7 +302,7 @@ static int perform_curl_io_and_complete(struct swupd_curl_parallel_handle *h, si
|
||||
file->callback = h->success_cb;
|
||||
tp_task_schedule(h->thpool, (void *)success_callback_wrapper, (void *)file);
|
||||
} else {
|
||||
//Check if user can handle errors
|
||||
// Check if user can handle errors
|
||||
bool error_handled = h->error_cb && h->error_cb(file->status, file->data);
|
||||
enum retry_strategy strategy = determine_strategy(file->status);
|
||||
|
||||
@@ -312,7 +312,7 @@ static int perform_curl_io_and_complete(struct swupd_curl_parallel_handle *h, si
|
||||
file->cb_retval = true;
|
||||
h->failed = list_prepend_data(h->failed, file);
|
||||
} else {
|
||||
//Download resume isn't supported. Disabling it for next try
|
||||
// Download resume isn't supported. Disabling it for next try
|
||||
if (file->status == DOWNLOAD_STATUS_RANGE_ERROR) {
|
||||
h->resume_failed = true;
|
||||
}
|
||||
@@ -614,7 +614,7 @@ int swupd_curl_parallel_download_end(struct swupd_curl_parallel_handle *h, int *
|
||||
// The multi-stack is now emptied.
|
||||
perform_curl_io_and_complete(h, h->mcurl_size);
|
||||
|
||||
//Retry failed downloads
|
||||
// Retry failed downloads
|
||||
for (l = h->failed; l;) {
|
||||
file = l->data;
|
||||
|
||||
@@ -624,7 +624,7 @@ int swupd_curl_parallel_download_end(struct swupd_curl_parallel_handle *h, int *
|
||||
|
||||
file->retries++;
|
||||
|
||||
//Remove item
|
||||
// Remove item
|
||||
if (l == h->failed) {
|
||||
h->failed = l->next;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ enum swupd_code walk_tree(struct manifest *manifest, const char *start, bool fix
|
||||
}
|
||||
|
||||
size_t skip_len = 0; /* Length of directory name we are skipping
|
||||
* could have used str_len(skip_dir), but speed! */
|
||||
* could have used str_len(skip_dir), but speed! */
|
||||
/* list files/directories which are extra.
|
||||
* This is reverse so that files are removed before their parent dirs */
|
||||
for (int i = nF - 1; i >= 0; i--) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "swupd.h"
|
||||
|
||||
/* hysteresis thresholds */
|
||||
//FIXME #562
|
||||
// FIXME #562
|
||||
#define MAX_XFER 15
|
||||
|
||||
static int download_file(struct swupd_curl_parallel_handle *download_handle, struct file *file)
|
||||
|
||||
@@ -194,7 +194,7 @@ enum swupd_code compute_hash(struct file *file, char *filename)
|
||||
hmac_sha256_for_string(file->hash,
|
||||
(const unsigned char *)key,
|
||||
key_len,
|
||||
SWUPD_HASH_DIRNAME); //Make independent of dirname
|
||||
SWUPD_HASH_DIRNAME); // Make independent of dirname
|
||||
return SWUPD_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,15 +258,15 @@ static bool adjust_system_time()
|
||||
}
|
||||
|
||||
/* this function is intended to encapsulate the basic swupd
|
||||
* initializations for the majority of commands, that is:
|
||||
* - Make sure root is the user running the code
|
||||
* - Initialize globals
|
||||
* - initialize mounted directories
|
||||
* - Create necessary directories
|
||||
* - Get the lock
|
||||
* - Initialize curl
|
||||
* - Initialize signature checking
|
||||
*/
|
||||
* initializations for the majority of commands, that is:
|
||||
* - Make sure root is the user running the code
|
||||
* - Initialize globals
|
||||
* - initialize mounted directories
|
||||
* - Create necessary directories
|
||||
* - Get the lock
|
||||
* - Initialize curl
|
||||
* - Initialize signature checking
|
||||
*/
|
||||
enum swupd_code swupd_init(enum swupd_init_config config)
|
||||
{
|
||||
enum swupd_code ret = SWUPD_OK;
|
||||
|
||||
+26
-26
@@ -26,8 +26,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "swupd.h"
|
||||
#include "heuristics.h"
|
||||
#include "swupd.h"
|
||||
|
||||
typedef int (*compare_fn_t)(const char *s1, const char *s2);
|
||||
typedef void (*apply_fn_t)(struct file *f);
|
||||
@@ -95,39 +95,39 @@ static int h_strcmp(const char *s1, const char *s2)
|
||||
|
||||
static const struct rule heuristic_rules[] = {
|
||||
// Boot Files
|
||||
{"/boot/", h_starts_with, apply_boot, false },
|
||||
{"/usr/lib/modules/", h_starts_with, apply_boot, false },
|
||||
{ "/boot/", h_starts_with, apply_boot, false },
|
||||
{ "/usr/lib/modules/", h_starts_with, apply_boot, false },
|
||||
|
||||
// State files
|
||||
{"/data", h_starts_with, apply_state, false },
|
||||
{"/dev/", h_starts_with, apply_state, false },
|
||||
{"/home/", h_starts_with, apply_state, false },
|
||||
{"/lost+found", h_starts_with, apply_state, false },
|
||||
{"/proc/", h_starts_with, apply_state, false },
|
||||
{"/root/", h_starts_with, apply_state, false },
|
||||
{"/run/", h_starts_with, apply_state, false },
|
||||
{"/sys/", h_starts_with, apply_state, false },
|
||||
{"/tmp/", h_starts_with, apply_state, false },
|
||||
{"/var/", h_starts_with, apply_state, false },
|
||||
{ "/data", h_starts_with, apply_state, false },
|
||||
{ "/dev/", h_starts_with, apply_state, false },
|
||||
{ "/home/", h_starts_with, apply_state, false },
|
||||
{ "/lost+found", h_starts_with, apply_state, false },
|
||||
{ "/proc/", h_starts_with, apply_state, false },
|
||||
{ "/root/", h_starts_with, apply_state, false },
|
||||
{ "/run/", h_starts_with, apply_state, false },
|
||||
{ "/sys/", h_starts_with, apply_state, false },
|
||||
{ "/tmp/", h_starts_with, apply_state, false },
|
||||
{ "/var/", h_starts_with, apply_state, false },
|
||||
|
||||
// Filtered state on /usr/src
|
||||
{"/usr/src/", h_starts_with, apply_src_state, false },
|
||||
{ "/usr/src/", h_starts_with, apply_src_state, false },
|
||||
|
||||
// Config files
|
||||
{"/etc/", h_starts_with, apply_config, false },
|
||||
{ "/etc/", h_starts_with, apply_config, false },
|
||||
|
||||
// Boot managers
|
||||
{"/usr/bin/bootctl", h_strcmp, apply_bootmanager, false },
|
||||
{"/usr/bin/clr-boot-manager", h_strcmp, apply_bootmanager, false },
|
||||
{"/usr/bin/gummiboot", h_strcmp, apply_bootmanager, false },
|
||||
{"/usr/lib/gummiboot", h_strcmp, apply_bootmanager, false },
|
||||
{"/usr/share/syslinux/ldlinux.c32", h_strcmp, apply_bootmanager, false },
|
||||
{ "/usr/bin/bootctl", h_strcmp, apply_bootmanager, false },
|
||||
{ "/usr/bin/clr-boot-manager", h_strcmp, apply_bootmanager, false },
|
||||
{ "/usr/bin/gummiboot", h_strcmp, apply_bootmanager, false },
|
||||
{ "/usr/lib/gummiboot", h_strcmp, apply_bootmanager, false },
|
||||
{ "/usr/share/syslinux/ldlinux.c32", h_strcmp, apply_bootmanager, false },
|
||||
|
||||
{"/usr/lib/kernel/", h_starts_with, apply_boot_and_bootmanager, false },
|
||||
{"/usr/lib/systemd/boot", h_starts_with, apply_boot_and_bootmanager, false },
|
||||
{ "/usr/lib/kernel/", h_starts_with, apply_boot_and_bootmanager, false },
|
||||
{ "/usr/lib/systemd/boot", h_starts_with, apply_boot_and_bootmanager, false },
|
||||
|
||||
// Systemd
|
||||
{"/usr/lib/systemd/systemd", h_strcmp, apply_systemd, false},
|
||||
{ "/usr/lib/systemd/systemd", h_strcmp, apply_systemd, false },
|
||||
|
||||
{ 0 }
|
||||
};
|
||||
@@ -151,7 +151,7 @@ static void check_ignore_file(struct file *file)
|
||||
|
||||
static struct rule *dup_rule(const struct rule *r)
|
||||
{
|
||||
struct rule * rule;
|
||||
struct rule *rule;
|
||||
|
||||
rule = malloc_or_die(sizeof(struct rule));
|
||||
|
||||
@@ -162,7 +162,7 @@ static struct rule *dup_rule(const struct rule *r)
|
||||
|
||||
static struct rule *create_rule(char *str, compare_fn_t cmp, apply_fn_t apply)
|
||||
{
|
||||
struct rule * rule;
|
||||
struct rule *rule;
|
||||
|
||||
rule = malloc_or_die(sizeof(struct rule));
|
||||
|
||||
@@ -194,7 +194,7 @@ static struct list *create_rules_from_mounted_dirs(void)
|
||||
// sed s/^path_prefix/\//
|
||||
filename = sys_path_join("/%s", iter->data + path_prefix_len);
|
||||
rules = list_prepend_data(rules,
|
||||
create_rule(filename, h_strcmp, apply_state));
|
||||
create_rule(filename, h_strcmp, apply_state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
static int lock_fd = -1;
|
||||
|
||||
/* Try to get a write lock region on the lock file. Returns:
|
||||
* >= 0 an fcntl region lock'd fd or exits with a positive error
|
||||
* code and a recommended course of action for user.
|
||||
*/
|
||||
* >= 0 an fcntl region lock'd fd or exits with a positive error
|
||||
* code and a recommended course of action for user.
|
||||
*/
|
||||
int p_lockfile(void)
|
||||
{
|
||||
if (lock_fd > 0) {
|
||||
|
||||
+16
-16
@@ -876,21 +876,21 @@ void remove_files_in_manifest_from_fs(struct manifest *m)
|
||||
}
|
||||
|
||||
/* free all files found in m1 that happens to be
|
||||
* duplicated on m2.
|
||||
*
|
||||
* Is _mandatory_ to have both manifests files lists ordered by filename before
|
||||
* calling this function.
|
||||
*
|
||||
* This function frees (removes) all duplicated files matching those in m2 from
|
||||
* m1, the resulting m1 file list will be unique respect to files
|
||||
* contained on m2.
|
||||
*
|
||||
* Although we can generate a third manifest containing the unique file list
|
||||
* to be more simple in code, this approach pops out and free each duplicated
|
||||
* from m1 in place, this means a gain on space and speed, since it does not
|
||||
* need to allocate new manifest file list, and since it frees duplicates here,
|
||||
* it does not need to free more elements later.
|
||||
*/
|
||||
* duplicated on m2.
|
||||
*
|
||||
* Is _mandatory_ to have both manifests files lists ordered by filename before
|
||||
* calling this function.
|
||||
*
|
||||
* This function frees (removes) all duplicated files matching those in m2 from
|
||||
* m1, the resulting m1 file list will be unique respect to files
|
||||
* contained on m2.
|
||||
*
|
||||
* Although we can generate a third manifest containing the unique file list
|
||||
* to be more simple in code, this approach pops out and free each duplicated
|
||||
* from m1 in place, this means a gain on space and speed, since it does not
|
||||
* need to allocate new manifest file list, and since it frees duplicates here,
|
||||
* it does not need to free more elements later.
|
||||
*/
|
||||
void deduplicate_files_from_manifest(struct manifest **m1, struct manifest *m2)
|
||||
{
|
||||
struct list *iter1, *iter2, *cur_file, *preserver = NULL;
|
||||
@@ -1031,7 +1031,7 @@ int mom_get_manifests_list(struct manifest *mom, struct list **manifest_list, fi
|
||||
manifest = load_manifest_file(mom, file, &err);
|
||||
complete++;
|
||||
if (!manifest) {
|
||||
info("\n"); //Progress bar
|
||||
info("\n"); // Progress bar
|
||||
error("Cannot load %s manifest for version %i\n",
|
||||
file->filename, file->last_change);
|
||||
last_error = err;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
* time. This value is set to 1 because of a bug that causes a dowload problem
|
||||
* when extrating a large file while other is being downloaded. Set this value
|
||||
* to a larger number, to be defined by tests, after bug is fixed.
|
||||
*/
|
||||
*/
|
||||
#define MAX_XFER 1
|
||||
|
||||
struct pack_data {
|
||||
@@ -307,7 +307,7 @@ int download_subscribed_packs(struct list *subs, struct manifest *mom, bool requ
|
||||
err = download_pack(download_handle, sub->oldversion, sub->version, sub->component);
|
||||
|
||||
/* fall back for progress reporting when the download size
|
||||
* could not be determined */
|
||||
* could not be determined */
|
||||
if (download_progress.total_download_size == 0) {
|
||||
complete++;
|
||||
progress_report(complete, list_length);
|
||||
|
||||
@@ -406,7 +406,7 @@ static int validate_certificate(X509 *cert, const char *certificate_path, const
|
||||
X509_LOOKUP *lookup = NULL;
|
||||
X509_STORE_CTX *verify_ctx = NULL;
|
||||
|
||||
//TODO: Implement a chain verification when required
|
||||
// TODO: Implement a chain verification when required
|
||||
|
||||
/* create the cert store and set the verify callback */
|
||||
if (!(store = X509_STORE_new())) {
|
||||
|
||||
@@ -74,7 +74,7 @@ bool signature_verify_data(const void *data, size_t data_len, const void *sig_da
|
||||
*
|
||||
* Currently printing Issuer, Subject and the dump of the certificate data.
|
||||
* Init is not required to run this function.
|
||||
*
|
||||
*
|
||||
* @param path the path to the certificate to be printed.
|
||||
*/
|
||||
void signature_print_info(const char *path);
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
/* Permissions for a directory readable by users */
|
||||
#define WORLD_READABLE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
||||
|
||||
|
||||
/* ******************** */
|
||||
/* Data (state) section */
|
||||
/* ******************** */
|
||||
@@ -181,7 +180,7 @@ char *statedir_get_download_dir(void)
|
||||
return dir;
|
||||
}
|
||||
|
||||
char *statedir_get_download_file(char * filename)
|
||||
char *statedir_get_download_file(char *filename)
|
||||
{
|
||||
char *url = get_url();
|
||||
char *path = sys_path_join("%s/%s/%s/%s/%s", globals.cache_dir, CACHE_DIR, url, DOWNLOAD_DIR, filename);
|
||||
@@ -273,7 +272,6 @@ char *statedir_get_manifest_delta(char *bundle, int from_version, int to_version
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
char *statedir_get_staged_dir(void)
|
||||
{
|
||||
char *url = get_url();
|
||||
@@ -286,7 +284,7 @@ char *statedir_get_staged_dir(void)
|
||||
static char *get_staged_file(char *state, char *file_hash)
|
||||
{
|
||||
char *url = get_url();
|
||||
char *path = sys_path_join("%s/%s/%s/%s/%s", state, CACHE_DIR, url, STAGED_DIR, file_hash);
|
||||
char *path = sys_path_join("%s/%s/%s/%s/%s", state, CACHE_DIR, url, STAGED_DIR, file_hash);
|
||||
FREE(url);
|
||||
|
||||
return path;
|
||||
@@ -338,7 +336,6 @@ char *statedir_get_temp_file(char *filename)
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/* *************** */
|
||||
/* Setup functions */
|
||||
/* *************** */
|
||||
@@ -478,7 +475,7 @@ int statedir_create_dirs(bool include_all)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool set_state_path(char** state, char *path)
|
||||
static bool set_state_path(char **state, char *path)
|
||||
{
|
||||
struct stat statbuf;
|
||||
int ret;
|
||||
|
||||
+15
-16
@@ -15,8 +15,8 @@ extern "C" {
|
||||
/* ******************** */
|
||||
|
||||
/**
|
||||
* @brief Gets the path to the bundle tracking directory in the datadir.
|
||||
*/
|
||||
* @brief Gets the path to the bundle tracking directory in the datadir.
|
||||
*/
|
||||
char *statedir_get_tracking_dir(void);
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,6 @@ char *statedir_get_swupd_lock(void);
|
||||
*/
|
||||
char *statedir_get_version(void);
|
||||
|
||||
|
||||
/* ************* */
|
||||
/* Cache section */
|
||||
/* ************* */
|
||||
@@ -59,8 +58,8 @@ char *statedir_get_cache_dir(void);
|
||||
char *statedir_get_cache_url_dir(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the path to the delta directory in the cachedir.
|
||||
*/
|
||||
* @brief Gets the path to the delta directory in the cachedir.
|
||||
*/
|
||||
char *statedir_get_delta_dir(void);
|
||||
|
||||
/**
|
||||
@@ -80,15 +79,15 @@ char *statedir_get_delta_pack_dir(void);
|
||||
char *statedir_get_delta_pack(char *bundle, int from_version, int to_version);
|
||||
|
||||
/**
|
||||
* @brief Gets the path to the download directory in the cachedir.
|
||||
*/
|
||||
* @brief Gets the path to the download directory in the cachedir.
|
||||
*/
|
||||
char *statedir_get_download_dir(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the path to a downloaded file in the cachedir.
|
||||
* @param filename, the name of the file to get
|
||||
*/
|
||||
char *statedir_get_download_file(char * filename);
|
||||
* @brief Gets the path to a downloaded file in the cachedir.
|
||||
* @param filename, the name of the file to get
|
||||
*/
|
||||
char *statedir_get_download_file(char *filename);
|
||||
|
||||
/**
|
||||
* @brief Gets the path to the directory where manifests are organized
|
||||
@@ -132,8 +131,8 @@ char *statedir_get_manifest(int version, char *component);
|
||||
char *statedir_dup_get_manifest(int version, char *component);
|
||||
|
||||
/**
|
||||
* @brief Gets the path to the staged directory in the cachedir.
|
||||
*/
|
||||
* @brief Gets the path to the staged directory in the cachedir.
|
||||
*/
|
||||
char *statedir_get_staged_dir(void);
|
||||
|
||||
/**
|
||||
@@ -178,8 +177,8 @@ char *statedir_get_manifest_tar(int version, char *component);
|
||||
char *statedir_get_manifest_with_hash(int version, char *component, char *manifest_hash);
|
||||
|
||||
/**
|
||||
* @brief Gets the path to the manifest delta directory in the cachedir.
|
||||
*/
|
||||
* @brief Gets the path to the manifest delta directory in the cachedir.
|
||||
*/
|
||||
char *statedir_get_manifest_delta_dir(void);
|
||||
|
||||
/**
|
||||
@@ -230,7 +229,7 @@ char *statedir_get_temp_file(char *filename);
|
||||
/**
|
||||
* @brief Creates the required directories in the datadir and cachedir.
|
||||
*
|
||||
* @param include_all If set to true, all directories normally used
|
||||
* @param include_all If set to true, all directories normally used
|
||||
* for upstream content will be included in the statedir, otherwise
|
||||
* a subset that includes only directories used for 3rd-party repositories
|
||||
* will be created.
|
||||
|
||||
@@ -331,7 +331,7 @@ static enum swupd_code install_dir(const char *fullfile_path, const char *target
|
||||
}
|
||||
|
||||
/* Do the staging of new files into the filesystem */
|
||||
//TODO: "stage_single_file is currently not able to be run in parallel"
|
||||
// TODO: "stage_single_file is currently not able to be run in parallel"
|
||||
/* Consider adding a remove_leftovers() that runs in verify/fix in order to
|
||||
* allow this function to mkdtemp create folders for parallel build */
|
||||
static enum swupd_code stage_single_file(struct file *file, struct manifest *mom)
|
||||
|
||||
+10
-10
@@ -14,19 +14,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Install files from 'files' into the system.
|
||||
*
|
||||
* @param files The list of files to be installed.
|
||||
* @param mom MoM to be used to create missing directories
|
||||
*/
|
||||
* @brief Install files from 'files' into the system.
|
||||
*
|
||||
* @param files The list of files to be installed.
|
||||
* @param mom MoM to be used to create missing directories
|
||||
*/
|
||||
enum swupd_code target_root_install_files(struct list *files, struct manifest *mom);
|
||||
|
||||
/**
|
||||
* @brief Install a single file into the system.
|
||||
*
|
||||
* @param file The file to be installed
|
||||
* @param mom MoM to be used to create missing directories
|
||||
*/
|
||||
* @brief Install a single file into the system.
|
||||
*
|
||||
* @param file The file to be installed
|
||||
* @param mom MoM to be used to create missing directories
|
||||
*/
|
||||
enum swupd_code target_root_install_single_file(struct file *file, struct manifest *mom);
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,7 @@ static char *sys_path_join(const char *fmt, ...)
|
||||
/* remove all duplicated PATH_SEPARATOR from the path */
|
||||
for (i = j = 0; i < len; i++) {
|
||||
if (path[i] == PATH_SEPARATOR && // Is separator and
|
||||
// Next is also a separator or
|
||||
// Next is also a separator or
|
||||
(path[i + 1] == PATH_SEPARATOR ||
|
||||
// Is a trailing separator, but not root
|
||||
(path[i + 1] == '\0' && j != 0))) {
|
||||
|
||||
Reference in New Issue
Block a user