Page MenuHomeFreeBSD

gpart: "gpart --libxo:JP list" duplicates attribute keys
AcceptedPublic

Authored by guest-jsollvander on Fri, Dec 5, 9:33 AM.

Details

Reviewers
asomers
Summary

Add leaf-list modifier to attrib as it's possible to have multiple attributes on a gpart provider.

Fixes bug reported in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291377

Sample output:

root@johan_test:/usr/src # gpart list
Geom name: vtbd0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 41942999
first: 40
entries: 128
scheme: GPT
Providers:
1. Name: vtbd0p1
   Mediasize: 272629760 (260M)
   Sectorsize: 512
   Stripesize: 131072
   Stripeoffset: 20480
   Mode: r1w1e2
   efimedia: HD(1,GPT,8b9132f0-ee0e-11ef-ad7e-589cfc022dc5,0x28,0x82000)
   rawuuid: 8b9132f0-ee0e-11ef-ad7e-589cfc022dc5
   rawtype: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
   attrib: bootonce
   attrib: bootme
   label: efiboot0
   length: 272629760
   offset: 20480
   type: efi
   index: 1
   end: 532519
   start: 40
2. Name: vtbd0p2
   Mediasize: 536870912 (512M)
   Sectorsize: 512
   Stripesize: 131072
   Stripeoffset: 0
   Mode: r1w1e0
   efimedia: HD(2,GPT,8b93d798-ee0e-11ef-ad7e-589cfc022dc5,0x82800,0x100000)
   rawuuid: 8b93d798-ee0e-11ef-ad7e-589cfc022dc5
   rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
   label: swap0
   length: 536870912
   offset: 273678336
   type: freebsd-swap
   index: 2
   end: 1583103
   start: 534528
3. Name: vtbd0p3
   Mediasize: 20663238656 (19G)
   Sectorsize: 512
   Stripesize: 131072
   Stripeoffset: 0
   Mode: r1w1e1
   efimedia: HD(3,GPT,8b965967-ee0e-11ef-ad7e-589cfc022dc5,0x182800,0x267d000)
   rawuuid: 8b965967-ee0e-11ef-ad7e-589cfc022dc5
   rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
   label: zfs0
   length: 20663238656
   offset: 810549248
   type: freebsd-zfs
   index: 3
   end: 41940991
   start: 1583104
Consumers:
1. Name: vtbd0
   Mediasize: 21474836480 (20G)
   Sectorsize: 512
   Stripesize: 131072
   Stripeoffset: 0
   Mode: r3w3e6

root@johan_test:/usr/src # gpart --libxo:JP,warn list
{
  "__version": "1",
  "PART": [
    {
      "name": "vtbd0",
      "modified": "false",
      "state": "OK",
      "fwheads": "255",
      "fwsectors": "63",
      "last": "41942999",
      "first": "40",
      "entries": "128",
      "scheme": "GPT",
      "providers": [
        {
          "name": "vtbd0p1",
          "mediasize": 272629760,
          "sectorsize": 512,
          "stripesize": 131072,
          "stripeoffset": 20480,
          "mode": "r1w1e2",
          "efimedia": "HD(1,GPT,8b9132f0-ee0e-11ef-ad7e-589cfc022dc5,0x28,0x82000)",
          "rawuuid": "8b9132f0-ee0e-11ef-ad7e-589cfc022dc5",
          "rawtype": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
          "attribute": [
            "bootonce",
            "bootme"
          ],
          "label": "efiboot0",
          "length": "272629760",
          "offset": "20480",
          "type": "efi",
          "index": "1",
          "end": "532519",
          "start": "40"
        },
        {
          "name": "vtbd0p2",
          "mediasize": 536870912,
          "sectorsize": 512,
          "stripesize": 131072,
          "stripeoffset": 0,
          "mode": "r1w1e0",
          "efimedia": "HD(2,GPT,8b93d798-ee0e-11ef-ad7e-589cfc022dc5,0x82800,0x100000)",
          "rawuuid": "8b93d798-ee0e-11ef-ad7e-589cfc022dc5",
          "rawtype": "516e7cb5-6ecf-11d6-8ff8-00022d09712b",
          "label": "swap0",
          "length": "536870912",
          "offset": "273678336",
          "type": "freebsd-swap",
          "index": "2",
          "end": "1583103",
          "start": "534528"
        },
        {
          "name": "vtbd0p3",
          "mediasize": 20663238656,
          "sectorsize": 512,
          "stripesize": 131072,
          "stripeoffset": 0,
          "mode": "r1w1e1",
          "efimedia": "HD(3,GPT,8b965967-ee0e-11ef-ad7e-589cfc022dc5,0x182800,0x267d000)",
          "rawuuid": "8b965967-ee0e-11ef-ad7e-589cfc022dc5",
          "rawtype": "516e7cba-6ecf-11d6-8ff8-00022d09712b",
          "label": "zfs0",
          "length": "20663238656",
          "offset": "810549248",
          "type": "freebsd-zfs",
          "index": "3",
          "end": "41940991",
          "start": "1583104"
        }
      ],
      "consumers": [
        {
          "name": "vtbd0",
          "mediasize": 21474836480,
          "sectorsize": 512,
          "stripesize": 131072,
          "stripeoffset": 0,
          "mode": "r3w3e6"
        }
      ]
    }
  ]
}

I purposely made it so that the normal output still says "attrib:" just so we don't break any scripts people may be using to parse the output, but the libxo output now says "attribute" just like gpart show will do once https://reviews.freebsd.org/D53950 is merged. But let me know if I should change that.

Test Plan

JSON is valid

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped