From patchwork Thu May 13 10:12:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 1477998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::43b; helo=mail-pf1-x43b.google.com; envelope-from=swupdate+bncbcl4hcw73qcbbghx6ocamgqehfmvyki@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=rl8gWyN7; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=mL3JuQtA; dkim-atps=neutral Received: from mail-pf1-x43b.google.com (mail-pf1-x43b.google.com [IPv6:2607:f8b0:4864:20::43b]) (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 ozlabs.org (Postfix) with ESMTPS id 4FgnXY5jfTz9sWP for ; Thu, 13 May 2021 20:12:43 +1000 (AEST) Received: by mail-pf1-x43b.google.com with SMTP id w195-20020a627bcc0000b029028e75db9c52sf17172624pfc.5 for ; Thu, 13 May 2021 03:12:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620900760; cv=pass; d=google.com; s=arc-20160816; b=Gm7Mx2eKM5nvJrnwNAtoIPg16Lk8+omlAZD0o45qutKuXPXrDmO9ijUDUxwHQbE1La O3AgwuvOTsPT8QRKz+g6gL4Az6+zrgZ91PjRsS9p4E839dojCO8Iyb6yOiQhkoUxysOp rubKsBtw6eo6in2+mfQ0lw/FJBd90eBgWpfhIJRrrJDmNwj5H03yTNq3jo9pxjMZwJRH iddJB0gI1mrNU/5QWfburCrWcjmHnd8NLDuASoeDIgaYS13x3htHtGD1tGvHR7C2SEGS pH/A7DACh3A/pnmbKp1lBIFmqxpRQC6MF0mFPrPjTKnI077uQM+CzhrVakG07M5VSFEY j8mQ== 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=mT2JdWmKP8jGwhyESh6BILpIFHV1hVRDYXzAmiJeEXc=; b=G+BdSdzePzR4qXg3OJaw9y9NxDIk9NdDVDvbCmgDGkXyqCeifD2JG6vF9vJq2DezCy 5yOv5Z9PYUGfe4bTlStSdK0adEJ/4sSozKluZm4zHspvnBuQy9myUOXqZfqTwFIMU8Gf oR74p92VKUNCM+KhOCiz6mJF/pw7mrFxq7XGsz+rFLy6/2eRLiLYLPaKMDeNlj0+wTZb Kgw8nxn/GDYjmu1A5O7y0MHKzIogo1B4R6wbMPQCVdPAia+chzWj8GECtjcBbZwstRwG 2cbpCQ6ZdUSZ9efgWRz9tYU3xe3fTqRYm+T6WoGS5+tik6mxkRp+GV9rGxfVwutKvTXL W+TA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dWDdfTmV; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::12a 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=20161025; 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=mT2JdWmKP8jGwhyESh6BILpIFHV1hVRDYXzAmiJeEXc=; b=rl8gWyN7TGEgfiWoSp8IY8tv2Lg7qAo8QXtuYsCnqtlxpiZ3jowlu9E/4ZDRkOOS4S aKg/UlJuppKb8kkTO3j7KXZ57RRioZP/0ELM4z9hUNv/DWPSVKVy7w9TKwwwI/xY53yE BH4LAItMDGj61SdiXQjGji7qFtF1rtZMdM6jYq30Xp1MMermg0YHsS5jTD1MkKqwiROo C3KHAww/+iqnfdYbkJbcGTvHn04hqDh7I4RtshK3x9pQIAZTQ69W6ZKv5TFd8Weekm6O CLVmwlzqm5tkA4Fq2mT3JKE/FI4ZOUdFrmnQG1VvXN1+s1QOsIFEiooM2GFSFMvkXv3v uBtQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; 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=mT2JdWmKP8jGwhyESh6BILpIFHV1hVRDYXzAmiJeEXc=; b=mL3JuQtAqTKRMHjKaE+UvEyHwzx9ITa7FtA8seB1hmgzkNCxvmi12wJBGRz4FA9ETg L74ojUNex5uNX8c8BRTdPBM5Py2Wb5MFEO3DF8Y03i6WowUywjty9P0zNTzy8TAEIEJu 44GNHTleUIojQUqhS5y5skJNIblzvakZmMHr298h6w/IwNjoQ4Rjt3Ex+FVz+L0WTnjc tuIEifrtUbv0qqY10jPKu5xfdEmNZwwUCUwEbjfdNa/KOxW3M7Mmcj19AuAhtpyqzTkr Y+v9FVbJFJiwIrYUUHZSIV5GGb1LrRi0OBBiKIJihTLSQLr6NysiBWJgYosg+Jh26YSu wOxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=mT2JdWmKP8jGwhyESh6BILpIFHV1hVRDYXzAmiJeEXc=; b=mFC+azuGAucoeVjN396pZdcMBPJmzl6bDyBsEjCbvfwpyevfvT3ZcPyr+jzfk3fJan /rc6r7XOZmduiZriFnkTrXnNHZyQQspA5u4cck3c80hmXe6saeDi+2/0+GUbLg077ZrK Qg569DBgOf95Cs4z0+RhuR4YVgW/pbSnqWa2d3GwNy8edEZ5RFGW/rkIJXL8Arx6/gkN J+p+dNKidwzzXn08LMobxNQPlwehMDjbdBpl9vhwSQwdN52pH72pISDLQ1UeNFlBo6Po ITDryZvt6cYIS9r4ZwMJY1kiZ54hPQ1UwmlvNhYPt4Zm3xwIcE7MXwqDGoIQLIfymWp0 yajw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533Cm4wKdmsXsXRQf38tHIla/fqUlr5cBeHRVXry3YRBhYYK8LfD qo+MU7440YMGbEp5/0t62zc= X-Google-Smtp-Source: ABdhPJyYMtu3OWFwjWYCUm7B+vtZMXj5Vigu53TYgpLaYl/vsmY4BgpRixS6d0LhVNpbY2Wh40sg7w== X-Received: by 2002:a62:6544:0:b029:261:14cc:b11d with SMTP id z65-20020a6265440000b029026114ccb11dmr39883592pfb.12.1620900760654; Thu, 13 May 2021 03:12:40 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:90a:ba08:: with SMTP id s8ls3370016pjr.1.gmail; Thu, 13 May 2021 03:12:40 -0700 (PDT) X-Received: by 2002:a17:902:724c:b029:ef:571f:8894 with SMTP id c12-20020a170902724cb02900ef571f8894mr13830105pll.49.1620900760031; Thu, 13 May 2021 03:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620900760; cv=none; d=google.com; s=arc-20160816; b=0jl7cbkBelK8bLbzpiMirwj+85AioDuO0uzcERPBWGpy8yUSd2yXwJ69jYfLQpKPnE 1r3tFHzbt3SlOSL+IKYqlEdCIHD90AyWpMUWwOqPSzg7LJKiA1QN63qawxc22+xPd2us KVeuxjEuLP6+o5qHmwTo020/i4sbO40r19E0i0hqKB4eyMbGWx//S3H5Ap50pu6fmtMn bf0bNhZ8Yyf25byLHQRfiAgGp+x834JpKw+INSjyqwjwtsDkmb3+FVNh9FBbG9n29B0N Q0WKr1J3lyaqMRWu/Q9A+H8e8CINEg3vDj7vx7/h8cYvKUg3LPdwMNENwFh56560VJHc u3Iw== 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=ittWEHy1xan6zPDeH9dbhlZtEQcNLfzy+Me45XFrr84=; b=1IUee70F2f4vvkTK/d2VbgcmASiu2Kd7ktCFPItRBou3ITDhHdXGQzNzz80FPcZoeu VBMaQcBKXQSEBX4tVqWY9TlXn3yHbJ2c4t+ZjRgsVTGmVHatA8hf8YrWc3j9ern7Kn/m kvJpLoTsb/V/yNW09pyXI12vZF+F+vu9dUEoYJed/snoAs+2UiuwWZ/9AhRHTIu1Kuiu UqVwOxQAJZcuqlgxQWlI5VCz5DST8HtQPzsKDo1PhBDV/x0A4vwRldcphZmQWMLrhf8W YM8BwWEFXyGqXiJOPKaD4l2JCLpO0oxHJGfpzJMBqyZgb9jlsu6K2briYnJFVyuUemFD 3TpA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dWDdfTmV; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::12a as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com. [2607:f8b0:4864:20::12a]) by gmr-mx.google.com with ESMTPS id k15si852030pjq.3.2021.05.13.03.12.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 May 2021 03:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::12a as permitted sender) client-ip=2607:f8b0:4864:20::12a; Received: by mail-il1-x12a.google.com with SMTP id w7so5877152ilg.13 for ; Thu, 13 May 2021 03:12:40 -0700 (PDT) X-Received: by 2002:a05:6e02:20ce:: with SMTP id 14mr35090127ilq.102.1620900759330; Thu, 13 May 2021 03:12:39 -0700 (PDT) Received: from MacBook-Pro.localdomain ([143.131.13.66]) by smtp.gmail.com with ESMTPSA id x13sm1196898ilv.88.2021.05.13.03.12.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 May 2021 03:12:38 -0700 (PDT) From: James Hilliard To: swupdate@googlegroups.com Cc: James Hilliard Subject: [swupdate] [PATCH 1/1] diskpart: improve partition diff logging Date: Thu, 13 May 2021 04:12:33 -0600 Message-Id: <20210513101233.87119-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.31.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=20161025 header.b=dWDdfTmV; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::12a 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: , Signed-off-by: James Hilliard --- handlers/diskpart_handler.c | 43 +++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c index 65010c1..3013b80 100644 --- a/handlers/diskpart_handler.c +++ b/handlers/diskpart_handler.c @@ -131,10 +131,29 @@ static int diskpart_set_partition(struct fdisk_partition *pa, return ret; } +static void diskpart_partition_info(const char *name, struct fdisk_partition *pa, struct fdisk_context *cxt, + size_t nids, int *ids, struct fdisk_label *lb) +{ + size_t i; + TRACE("%s:", name); + for (i = 0; i < nids; i++) { + const struct fdisk_field *field = + fdisk_label_get_field(lb, ids[i]); + char *data = NULL; + if (!field) + continue; + if (fdisk_partition_to_string(pa, cxt, ids[i], &data)) + continue; + TRACE("\t%s: %s", fdisk_field_get_name(field), data); + free(data); + } +} + /* * Return true if partition differs */ -static bool diskpart_partition_cmp(const char *lbtype, struct fdisk_partition *firstpa, struct fdisk_partition *secondpa) +static bool diskpart_partition_cmp(const char *lbtype, struct fdisk_context *cxt, + struct fdisk_partition *firstpa, struct fdisk_partition *secondpa) { if (!firstpa || !secondpa) return true; @@ -151,11 +170,21 @@ static bool diskpart_partition_cmp(const char *lbtype, struct fdisk_partition *f fdisk_parttype_get_code(fdisk_partition_get_type(firstpa)) != fdisk_parttype_get_code(fdisk_partition_get_type(secondpa))) || fdisk_partition_get_size(firstpa) != fdisk_partition_get_size(secondpa))) { - TRACE("Partition differ : %s(%llu) <--> %s(%llu)", - fdisk_partition_get_name (firstpa) ? fdisk_partition_get_name(firstpa) : "", - (long long unsigned)fdisk_partition_get_size(firstpa), - fdisk_partition_get_name(secondpa) ? fdisk_partition_get_name(secondpa) : "", - (long long unsigned)fdisk_partition_get_size(secondpa)); + struct fdisk_label *lb; + int *ids = NULL; + size_t nids = 0; + lb = fdisk_get_label(cxt, NULL); + fdisk_label_get_fields_ids(lb, cxt, &ids, &nids); + TRACE("Partition differ:"); + if (ids && lb) { + diskpart_partition_info("Original", firstpa, cxt, nids, ids, lb); + diskpart_partition_info("New", secondpa, cxt, nids, ids, lb); + } else { + if (!ids) + ERROR("Failed to load field ids"); + if (!lb) + ERROR("Failed to load label"); + } return true; } return false; @@ -376,7 +405,7 @@ static int diskpart(struct img_type *img, ret = -EFAULT; goto handler_exit; } - if (diskpart_partition_cmp(lbtype, pa, newpa)) { + if (diskpart_partition_cmp(lbtype, cxt, pa, newpa)) { createtable = true; }