static int snapshot_sync(struct volume *v) { struct file_header sentinel, conf; int next, block = 0; uint32_t seq; next = snapshot_next_free(v, &seq); block = config_find(v, &conf, &sentinel); if (is_config(&conf) && conf.seq != seq) { conf.magic = 0; volume_erase(v, next * v->block_size, 2 * v->block_size); } if (is_config(&sentinel) && (sentinel.seq != seq)) { sentinel.magic = 0; volume_erase(v, block * v->block_size, v->block_size); } if (!is_config(&conf) && !is_config(&sentinel)) { // ULOG_ERR("no config found\n"); } else if (((is_config(&conf) && is_config(&sentinel)) && (memcmp(conf.md5, sentinel.md5, sizeof(conf.md5)) || (conf.seq != sentinel.seq))) || (is_config(&conf) && !is_config(&sentinel))) { uint32_t seq; int next = snapshot_next_free(v, &seq); int ret = snapshot_read_file(v, next, "/tmp/config.tar.gz", CONF); if (ret > 0) { if (sentinel_write(v, conf.seq)) ULOG_ERR("failed to write sentinel data"); } } else if (!is_config(&conf) && is_config(&sentinel) && next) { int ret = snapshot_read_file(v, block, "/tmp/config.tar.gz", CONF); if (ret > 0) if (volatile_write(v, sentinel.seq)) ULOG_ERR("failed to write sentinel data"); } else ULOG_INFO("config in sync\n"); unlink("/tmp/config.tar.gz"); return 0; }
struct usb_interface_descriptor *first_interface(const struct usb_config_descriptor *d, int check_descr) { char *ptr = (char*)d; if (check_descr && !is_config(d)) { return 0; } ptr += d->bLength; return (struct usb_interface_descriptor *)ptr; }
bool ignore(struct file *file) { if ((file->is_config) || is_config(file->filename) || // ideally we trust the manifest but short term reapply check here (file->is_state) || is_state(file->filename) || // ideally we trust the manifest but short term reapply check here (file->is_boot && fix && file->is_deleted) || // shouldn't happen (file->is_boot && !fix && !file->is_deleted) || // default ignore (ignore_orphans && file->is_orphan)) { update_skip++; file->do_not_update = 1; return true; } return false; }
/* Determines whether or not FILE should be ignored for this swupd action. Note * that boot files are ignored only if they are marked as deleted; this does * not happen in current manifests produced by swupd-server, but this check is * enabled in case swupd-server ever allows for deleted boot files in manifests * in the future. */ bool ignore(struct file *file) { if ((OS_IS_STATELESS && file->is_config) || (OS_IS_STATELESS && is_config(file->filename)) || // ideally we trust the manifest but short term reapply check here (file->is_state) || is_state(file->filename) || // ideally we trust the manifest but short term reapply check here (file->is_boot && file->is_deleted) || (ignore_orphans && file->is_orphan) || (file->is_ghosted)) { update_skip++; file->do_not_update = 1; return true; } return false; }
static void config_file_heuristics(struct file *file) { if (is_config(file->filename)) { file->is_config = 1; } }