From patchwork Wed Dec 1 09:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 1562097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=XvMO6db1; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=CBhG7urW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::d3e; helo=mail-io1-xd3e.google.com; envelope-from=swupdate+bncbcl4hcw73qcbbruhtwgqmgqechvacwi@googlegroups.com; receiver=) Received: from mail-io1-xd3e.google.com (mail-io1-xd3e.google.com [IPv6:2607:f8b0:4864:20::d3e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J3vKl2pPtz9sCD for ; Wed, 1 Dec 2021 20:43:37 +1100 (AEDT) Received: by mail-io1-xd3e.google.com with SMTP id k125-20020a6bba83000000b005e7a312f86dsf24756935iof.9 for ; Wed, 01 Dec 2021 01:43:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1638351814; cv=pass; d=google.com; s=arc-20160816; b=Td2I0S8GxwexkculBHGM53sqPTOqepy2x3crSO1ZICTlpSoRoocUfguH+lI0tDPVqr bCuy+rtQ0ehs7pmo3jMOLXdqziYIRME9MHmQ2brrrVePdHLQdlWS1qWPnyRpaGCZOmxo iOVAZ9dQ/QTpHwfFtNhU91LgntSdlr8gVEIepkaYcYxZVR/HJ2UhNsE/4Zdb4+LDQU7Q NcpiSlzrkmYtoSAAnkpl23GFA9EvJyAUd7DYHB0TrBlTm0xB4ihmfIlMd4q9DlsxWsRB AmfZ65JoKrMYNFZCQxFbqAkYm0XMNAKhECZFaJHGW3mcIgHuW3/EkUiqwRzNA/hd+7UY m5ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=+g/HGYZxnAQl+K9Qy1V8xcXODHFveZz2EKVpKNL5ma0=; b=flobJdec4pDRNcCaMFMHNT+rf4pOsPo6zGSRNyFXWlF/EtNfhJq648LNw/MWavOLwS BI/6esUcCV7+I3sZGEcT8xmedn/dLXZoInXxuigQgjfBtGPzgAlqCzvLqms1LGcwipU8 c7JjvtiPNxuk2msa1GfNc2rulEmMYWLH/BvpZoIKZQG3P4lVzon1AU1FRUpuuHO1dfsx ky+L058C2vMIn41pLzIfYHhR1XdFv8gyZ8dG94YyXOifbZHRsEbg05lc7ggOjh0itlE9 BYZ0mYkBxr7bkicylGj7vYQB0xgpsBYqfBPO56ygRazbG/so8iLbO7x8CHzf+u7pyEh3 IuRg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F0ICwwlw; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d34 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=+g/HGYZxnAQl+K9Qy1V8xcXODHFveZz2EKVpKNL5ma0=; b=XvMO6db1Dq/F9JsDp0WZkpXq6hofTYmeGYyYb6jZzZpkvUY7KGBSfhbMiuKyuCaQGK LujPHm+/+5ttJ4QdoTe11nBhFgyrcWx+YBye4ghVcFmkciU7xG4AFOEk9SF4XPV4c0b4 V6mSZQ1FZ0facyFCiCoBRAMLjFSw282jnN5LtroY1ixQ/znZjeSOQX0UtZxDHo+IcroD VM/1do+Otfs1bDpMQoco47UOBAXKAYaBNPcfy6MLPgPyLGWoFAqjQq3ZR3xbOf6f1Imi b7DAGTp6j0/pr4oKRHH7ajWkbSTzuSLyZx9NtrHCCOppIap1aXMObO4bAjFzdvxrLKJt Czxg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=+g/HGYZxnAQl+K9Qy1V8xcXODHFveZz2EKVpKNL5ma0=; b=CBhG7urWwBzra1zQsebMeC0jaGgAaq0tXkop7mQPOLniaUqUAiPDjbNCslTftTEXuJ mW4z/bdYRqFQ3/NVhbwp0E4yy4o0mDCfpvXOG8lIDtktKQHgurBUwEWLZShj4OZzTtl0 opTQ2SjY9wp31dOTpjQ1YVLWK2ULV510AF5U8bys6z4zN8Of3gLhuqq70edN0rl1lpwa SnY3cCKh0n89TWzoMN6Zgeav6MJn6muMfjieSjxReU5xzwm3pQ0yUabgnX8B720Yf/5y w1rio7XCtr26zyYpvIy+VIOpKcj9WmoP3jfdTdjxrA7TQLL/UCnp3wc68Fpn+YntcEa/ 4ltA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=+g/HGYZxnAQl+K9Qy1V8xcXODHFveZz2EKVpKNL5ma0=; b=ou9Z6IeRbsikPQPtRcJWsFxTizaJpAvUFe5XWLSZ42AMij0LlyHaYiB4JftslE/fue h85dnQLXQt8qNDaKESFuuhZW7pNK3kDmUeEJSe7zima9yOFw1Gbugk6AOGuKgs98847q HSesn+5YvcjEm7wqf0jFDM9X3hv68dDPK1rytUtiBxEd5TOD//K7qoFwrOUHNDP9SHMe b9pUAfYqNkje4CSpy9PBIrqZWgGES74PEPFp8tSh7cw9ABaC2+9uFiNQh95x3rrflgl3 fGGt7vgaX+jqXDRty4ZUBMex7ki1312in9y+xlCZ5Gr/WgIYRwxQnjYErYTFa4H21eah 6e1Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531FxVvwq1+u6TgwEouGkyDZgQCLt04eWTjIjB+Di6EdZHnTG1DV iQBtfswuntqlRgu3Uld14Fg= X-Google-Smtp-Source: ABdhPJzdD6+ms6Cu47Qk1whPxivngQNVDpDjQYx5CfPbU8U/i6Yyv0qlVTLfy4aVTrRcz2h66sT0qQ== X-Received: by 2002:a05:6e02:12cc:: with SMTP id i12mr6331006ilm.110.1638351814253; Wed, 01 Dec 2021 01:43:34 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a02:cf81:: with SMTP id w1ls174082jar.9.gmail; Wed, 01 Dec 2021 01:43:33 -0800 (PST) X-Received: by 2002:a05:6638:d08:: with SMTP id q8mr8172252jaj.38.1638351813674; Wed, 01 Dec 2021 01:43:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638351813; cv=none; d=google.com; s=arc-20160816; b=s4kkiUjps6GUHjhg8J62Fl6BxtLOmRgdTdV7Z675rwlWnhuSbyfbcGi15SrBX+jaLd LnSm2CPWQBA0jLFOb0R0wzxKyhPy3++UJtGcP8T+U3ZRVhEGHq91EoyaRI3esmpMw/NM s0V97q1iHlV4ek2kPBtlqpRG2mymbjEzEseDP/HwYISPMeEkEpeOX32+o4zLspUYT0TA cZUvhgFdH0cTYv8mL01/1oBsYZHYQ+K8vKlsch4ClZCReYHQ3EzViRDdSBe51Y8Qr07E tvoVxrA1bgSDRacxNio0lP2F8J9Xy+32ccZqbwI5gJqWTtJIwj15IKjYlNzB2Trdn+vd Ki3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=vpVvnr9neZroWufa0bSFnYQyGc8SLoTlrfFWN3JIbM0=; b=ITdk7Hr8q99Es+L5rkWCKmIih8LFUDCztF+vCUwBdf5fgyxyMDBWEFbPmW18NduPRo swtaKiwkD9eALgKy6htdZ1pCN/WjjS/h1sZjOIkQDSyrfxWSn+y54b/686LyJARj5NOi TtE/t+JYxMgpo64YMi9nFSpskBWVHf5vLjpqqww0+zsftQvQxPep7ATqrVqbIqw/g80P Q7fVHep9B1rTqkivBAX4hmqc3EZkjt2wxDdK1CJwyIDHucg/BY8QTcmk2y2xDZYPNgXu 2b7aYwMENPG26cPu4OGW0y+YDREZfLyKdbM/gl5W8W06fg9Twqp2FKs4N3+g7numJO/h rSHA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F0ICwwlw; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d34 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com. [2607:f8b0:4864:20::d34]) by gmr-mx.google.com with ESMTPS id l7si2304797ilh.5.2021.12.01.01.43.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Dec 2021 01:43:33 -0800 (PST) Received-SPF: pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d34 as permitted sender) client-ip=2607:f8b0:4864:20::d34; Received: by mail-io1-xd34.google.com with SMTP id k21so29936454ioh.4 for ; Wed, 01 Dec 2021 01:43:33 -0800 (PST) X-Received: by 2002:a02:c78e:: with SMTP id n14mr8121458jao.40.1638351813262; Wed, 01 Dec 2021 01:43:33 -0800 (PST) Received: from MacBook-Pro-2.localdomain (71-33-128-47.hlrn.qwest.net. [71.33.128.47]) by smtp.gmail.com with ESMTPSA id j15sm8736055ile.68.2021.12.01.01.43.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Dec 2021 01:43:32 -0800 (PST) From: James Hilliard To: swupdate@googlegroups.com Cc: James Hilliard Subject: [swupdate] [PATCH v2 1/1] diskpart_handler: use existing uuid if not explicitely set Date: Wed, 1 Dec 2021 02:43:26 -0700 Message-Id: <20211201094326.31072-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Original-Sender: james.hilliard1@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F0ICwwlw; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d34 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , When the ability to specifiy a partition UUID was added it also starting enforcing the uuid matches in is_diskpart_different, however in cases where the uuid is not set a new one will be randomly generated. To ensure this doesn't result in a comparison of the partition table being marked as changed due to a different random uuid getting generated, set the UUID based on the existing partition if it exists in cases where one is not specified in the sw-description. Signed-off-by: James Hilliard Reviewed-by: Michael Adler --- handlers/diskpart_handler.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c index a48f4d2..9a712bb 100644 --- a/handlers/diskpart_handler.c +++ b/handlers/diskpart_handler.c @@ -287,7 +287,8 @@ static int diskpart_get_partitions(struct fdisk_context *cxt, struct diskpart_ta static int diskpart_set_partition(struct fdisk_partition *pa, struct partition_data *part, unsigned long sector_size, - struct fdisk_parttype *parttype) + struct fdisk_parttype *parttype, + struct fdisk_table *oldtb) { int ret; @@ -312,8 +313,21 @@ static int diskpart_set_partition(struct fdisk_partition *pa, if (parttype) ret |= fdisk_partition_set_type(pa, parttype); - if (strlen(part->partuuid)) - ret |= fdisk_partition_set_uuid(pa, part->partuuid); + if (strlen(part->partuuid)) { + ret |= fdisk_partition_set_uuid(pa, part->partuuid); + } else { + /* + * If the uuid is not set a random one will be generated, retrieve the + * existing uuid from the on-disk partition if one exists so that we + * don't mark the partition as changed due to a different random uuid. + */ + struct fdisk_partition *oldpart = fdisk_table_get_partition_by_partno(oldtb, part->partno); + if (oldpart) { + const char *uuid = fdisk_partition_get_uuid(oldpart); + if (uuid) + ret |= fdisk_partition_set_uuid(pa, uuid); + } + } return ret; } @@ -496,7 +510,7 @@ static int diskpart_reload_table(struct fdisk_context *cxt, struct fdisk_table * } static int diskpart_fill_table(struct fdisk_context *cxt, struct diskpart_table *tb, - struct partition_data *part, struct hnd_priv priv) + struct diskpart_table *oldtb, struct partition_data *part, struct hnd_priv priv) { struct fdisk_parttype *parttype; struct fdisk_label *lb; @@ -527,7 +541,7 @@ static int diskpart_fill_table(struct fdisk_context *cxt, struct diskpart_table } else { parttype = fdisk_label_get_parttype_from_code(lb, ustrtoull(part->type, 16)); } - ret = diskpart_set_partition(newpa, part, sector_size, parttype); + ret = diskpart_set_partition(newpa, part, sector_size, parttype, oldtb->parent); if (ret) { WARN("I cannot set all partition's parameters"); } @@ -949,7 +963,7 @@ static int diskpart(struct img_type *img, /* * Fill the new in-memory partition table from the partition list. */ - ret = diskpart_fill_table(cxt, tb, part, priv); + ret = diskpart_fill_table(cxt, tb, oldtb, part, priv); if (ret) goto handler_exit;