DragonFlyBSD/src d842a1esbin/gpt show.c Makefile

gpt(8): Improve "show" command to print a disk summary line

Before print the partition entries, print a disk summary line like:
"Disk /dev/da0: 50.0GB (104857600 512-byte sectors)".

In addition, add a blank line between disks.

Example new output:
```
$ sudo gpt show /dev/da0 ad0
Disk /dev/da0: 50.0GB (104857600 512-byte sectors)
      start       size  index  contents
          0          1      -  PMBR
          1          1      -  Pri GPT header
          2         32      -  Pri GPT table
         34       2014      -  Unused
       2048     262144      0  GPT part - EFI System
     264192  104591360      1  GPT part - DragonFly Label64
  104855552       2015      -  Unused

    [14 lines not shown]
DeltaFile
+12-6sbin/gpt/show.c
+3-1sbin/gpt/Makefile
+15-72 files

DragonFlyBSD/src ff803d9etc/defaults uuids

etc: Sync entries from <sys/gpt.h>

Some of the GPT type names are derived from FreeBSD's gpart(8) man page.
DeltaFile
+60-11etc/defaults/uuids
+60-111 files

DragonFlyBSD/src 9df0696sbin/gpt show.c

gpt(8): Improve "show" command to print humanized size of partitions

Before:
Disk da0: 50.0GB (104857600 512-byte sectors)
      start       size  index  contents
          0          1      -  PMBR
          1          1      -  Pri GPT header
          2         32      -  Pri GPT table
         34       2014      -  Unused
       2048     262144      0  GPT part - EFI System
     264192  104591360      1  GPT part - DragonFly Label64
  104855552       2015      -  Unused
  104857567         32      -  Sec GPT table
  104857599          1      -  Sec GPT header

After:
Disk da0: 50.0GB (104857600 512-byte sectors)
      Start    Sectors    Size  Index  Contents
          0          1    512B      -  PMBR

    [8 lines not shown]
DeltaFile
+8-3sbin/gpt/show.c
+8-31 files

DragonFlyBSD/src 3ed4e32sbin/gpt gpt.c

gpt(8): Print a warning message when gpt_write() fails

gpt_write() is used in many places and all of them don't handle the
writing failure, so update gpt_write() to print a warning message when
it fails.
DeltaFile
+3-0sbin/gpt/gpt.c
+3-01 files

DragonFlyBSD/src 1460767sbin/gpt gpt.c

gpt(8): Refactor utf8_to_utf16() to be better understandable

Credit: ChatGPT (https://chatgpt.com/)
DeltaFile
+49-50sbin/gpt/gpt.c
+49-501 files

DragonFlyBSD/src c795974sbin/gpt gpt.c

gpt(8): Fix surrogate pair handling bug in utf16_to_utf8()

* The old code mishandled surrogate pairs and thus failed to recognize
  valid UTF-16 characters and would replace them with 0xFFFD.  Fix the
  code to correctly handle the surrogate pairs.

* Fix an out-of-bound access in the old code when it tried to handle the
  surrogate pairs.  Check `s16idx < s16len` before accessing it with
  `le16toh(s16[s16idx])`.

* Remove the `if (utfchar < 0x200000)` branch, because it's impossible
  for `utfchar` exceeding 0x200000.

* Tweak the `while` loop conditional to clean up the code.

Credit: ChatGPT (https://chatgpt.com/)
DeltaFile
+25-15sbin/gpt/gpt.c
+25-151 files

DragonFlyBSD/src b517f3fsbin/gpt gpt.c gpt.h

gpt(8): Change utf8_to_utf16/utf16_to_utf8() to use 'char *'

Use 'char *' instead of 'uint8_t *' for NUL-terminated UTF-8 strings,
making it easier for callers.
DeltaFile
+19-17sbin/gpt/gpt.c
+2-2sbin/gpt/gpt.h
+2-2sbin/gpt/show.c
+1-1sbin/gpt/label.c
+24-224 files

DragonFlyBSD/src 184a102sbin/gpt gpt.c

gpt(8): Fix bugs in utf8_to_utf16()

- The 'utfchar' was incorrectly reinitialized to zero on every loop
  iteration and thus destroyed the decoding state of multi-byte UTF-8
  sequences.  Fix it.
- Fix the endianness by adding the missing htole16() calls.

Obtained-from: NetBSD
DeltaFile
+7-5sbin/gpt/gpt.c
+7-51 files

DragonFlyBSD/src 6320fd3sbin/gpt gpt.c

gpt(8): Improve utf8_to_utf16()

- No need to NUL-terminate the UTF-16 string when it needs truncation.
- Pad the remaining characters with zeros. (obtained from NetBSD)
DeltaFile
+12-8sbin/gpt/gpt.c
+12-81 files

DragonFlyBSD/src 0bfd094sbin/gpt gpt.c show.c

gpt(8): Improve utf16_to_utf8()

- Let caller pass the buffer and thus avoid memory allocation.
- Handle the case that there is no NUL termination, i.e., the partition
  name is exactly 36 characters, which is allowed by the specification.

Obtained-from: NetBSD
DeltaFile
+22-14sbin/gpt/gpt.c
+6-3sbin/gpt/show.c
+1-1sbin/gpt/gpt.h
+29-183 files

DragonFlyBSD/src 176e90asbin/gpt gpt.c

gpt(8): Fix gpt_read() to report partial read error

A partial read() wouldn't touch 'errno', so the caller was unable to
know the error reason.  This caused the program to print an error
message like:
```
gpt show: unable to open device 'vn4': Undefined error: 0
```

Fix gpt_read() to return E2BIG (I couldn't find a better choice) for a
partial read(), so the above error becomes:
```
gpt show: unable to open device 'vn4': Argument list too long
```

Still a bit weird, but better, I guess.
DeltaFile
+12-5sbin/gpt/gpt.c
+12-51 files

DragonFlyBSD/src 94f4175sbin/gpt gpt.c

gpt(8): Clear errno before retrying open() in gpt_open()

Otherwise, the stale errno would go through gpt_read() when it failed
with a partial read, and the program would print a weird error message
like:
```
gpt show: unable to open device 'vn4': No such file or directory
```

Suggested-by: swildner
DeltaFile
+1-0sbin/gpt/gpt.c
+1-01 files

DragonFlyBSD/src d6a39f6sbin/gpt add.c gpt.8

gpt(8): Improve '-s size' parsing and add '-a alignment' for "add" cmd

* Improve the '-s' size parsing to accept the following suffixes:
  - s, S: sectors
  - b, B: bytes
  - k, K: KB
  - m, M: MB
  - g, G: GB
  - t, T: TB
  - p, P: PB
* Add the '-a' option to specify a custom alignment for partition size
  and position.

Referred-to: NetBSD
DeltaFile
+122-9sbin/gpt/add.c
+39-16sbin/gpt/gpt.8
+161-252 files

DragonFlyBSD/src f097125sbin/gpt map.c add.c

gpt(8): Extend map_alloc() to accept a custom alignment

This is required to extend the "add" command to specify a custom
alignment.
DeltaFile
+33-20sbin/gpt/map.c
+5-2sbin/gpt/add.c
+4-2sbin/gpt/boot.c
+1-1sbin/gpt/map.h
+43-254 files

DragonFlyBSD/src 8c96c7dsbin/gpt gpt.8

gpt.8: Document the existing "recover" command
DeltaFile
+6-0sbin/gpt/gpt.8
+6-01 files

DragonFlyBSD/src 9bd7115sbin/gpt recover.c

gpt(8): Remove the wrong "-r" option for "recover" command

It doesn't make sense that the "recover" command takes the "-r"
(recoverable) option, so just remove it.  I believe it was copied from
the "destroy" command.
DeltaFile
+1-6sbin/gpt/recover.c
+1-61 files

DragonFlyBSD/src 9a33560sys/kern subr_disk.c

kernel: Clean the disklabel packname similar to serno

Reuse the disk_cleanserial() function to clean the disklabel's packname,
which is used to create the device aliases under /dev/by-label/ and
/dev/part-by-label/.

Meanwhile, rename disk_cleanserial() to disk_cleanname() to make it more
intuitive.
DeltaFile
+8-6sys/kern/subr_disk.c
+8-61 files

DragonFlyBSD/src e387f2fsys/kern subr_disk.c

kernel: Fix disk_probe() to find device by the same name as creation

The name passed to devfs_find_device_by_name() previously did not check
for DSO_DEVICEMAPPER, which might be different from the name passed to
make_dev_covering().  Introduce the 'name_buf' to store the name with
DSO_DEVICEMAPPER accounted, and pass it to both functions.
DeltaFile
+8-4sys/kern/subr_disk.c
+8-41 files

DragonFlyBSD/src d4aec64sbin/gpt gpt.8

gpt.8: Add back the old hybrid MBR example using disklabels

In addition, improve the old example:
- Update to use HAMMER2 instead of the deprecated HAMMER;
- Add a note about the hybrid MBR/GPT setup;
- Add steps to remove unwanted files copied from an installation CD;
- Add steps to update password and remove the 'installer' user.

Requested-by: peeterm
DeltaFile
+68-2sbin/gpt/gpt.8
+68-21 files

DragonFlyBSD/src 4f238fbsbin/gpt gpt.8

gpt.8: Improve comments for the UEFI booting example

Add partition/slice numbers to the comments, and add the example
'vfs.root.mountfrom' configuration to the comment.

Suggested-by: peeterm
DeltaFile
+6-5sbin/gpt/gpt.8
+6-51 files

DragonFlyBSD/src 7b59e4bsys/kern subr_rman.c

kernel/rman: Fix error return in sysctl_rman().

Matt changed the error handling in 869748ea0626d3966a0b0e1a8223de70ef05
but forgot to return 'error' from now on.

This fixes devinfo -r (show hardware resource information).
DeltaFile
+1-1sys/kern/subr_rman.c
+1-11 files

DragonFlyBSD/src 996c838sys/dev/netif/age if_age.c, sys/dev/netif/ale if_ale.c

kernel/netif: Fix some comments.
DeltaFile
+1-1sys/dev/netif/bfe/if_bfe.c
+1-1sys/dev/netif/age/if_age.c
+1-1sys/dev/netif/ale/if_ale.c
+1-1sys/dev/netif/bge/if_bge.c
+1-1sys/dev/netif/bnx/if_bnx.c
+1-1sys/dev/netif/et/if_et.c
+6-62 files not shown
+8-88 files

DragonFlyBSD/src 1ab20bdsbin/fdisk fdisk.c

fdisk(8): Silence "invalid fdisk partition table" warning

When we're initializing the disk (i.e., with -i or -I flag), silence the
"invalid fdisk partition table found" warning.
DeltaFile
+2-1sbin/fdisk/fdisk.c
+2-11 files

DragonFlyBSD/src ed9442bsbin/gpt migrate.c

gpt(8): Check map_add() errors in migrate()
DeltaFile
+4-0sbin/gpt/migrate.c
+4-01 files

DragonFlyBSD/src 72e9a85sbin/gpt migrate.c

gpt(8): Recognize FS_MSDOS in convert_fstype() for migration
DeltaFile
+3-0sbin/gpt/migrate.c
+3-01 files

DragonFlyBSD/src ee4b184sbin/gpt show.c

gpt(8): Show names for the recognized DOS partitions
DeltaFile
+16-4sbin/gpt/show.c
+16-41 files

DragonFlyBSD/src 41d898asbin/gpt migrate.c show.c

gpt(8): Minor cleanups to migrate() and show()
DeltaFile
+6-5sbin/gpt/migrate.c
+1-3sbin/gpt/show.c
+7-82 files

DragonFlyBSD/src 844a5a6sbin/gpt create.c

gpt(8): Fix "create" on MBR-formatted disk without free space at end

When to invoke "create" on MBR-formatted disk without free space at the
end, gpt(8) would fail with error of "no room for the backup header";
e.g.,

    $ sudo gpt show vn5
    Disk vn5: 1024MB (2097152 512-byte sectors)
        Start  Sectors    Size  Index  Contents
            0        1    512B      -  MBR
            1       31  15.5KB      -  Unused
           32  2097120  1024MB      0  MBR part 108 (active)

    $ sudo gpt -vvv create -f vn5
    gpt create: vn5: mediasize=1073741824; sectorsize=512; blocks=2097152
    gpt create: vn5: MBR at sector 0
    gpt create: vn5: MBR part: type=108, start=32, size=2097120
    gpt create: vn5: error: no room for the backup header


    [2 lines not shown]
DeltaFile
+33-47sbin/gpt/create.c
+33-471 files

DragonFlyBSD/src 9ff9c70sbin/gpt gpt.8

gpt.8: Minor fixes and style tweaks
DeltaFile
+13-12sbin/gpt/gpt.8
+13-121 files

DragonFlyBSD/src 9e24ffbsbin/gpt recover.c gpt.c

gpt(8): Rename MAP_TYPE_* constants for consistency

No functional change.
DeltaFile
+8-8sbin/gpt/recover.c
+7-7sbin/gpt/gpt.c
+6-6sbin/gpt/migrate.c
+6-6sbin/gpt/create.c
+6-6sbin/gpt/expand.c
+4-4sbin/gpt/label.c
+37-376 files not shown
+59-5912 files