sys/vfs/{ext2fs,ufs}: Add SEEK_HOLE / SEEK_DATA support
Add VOP_BMAP based generic function vn_bmap_seekhole()
for filesystems with .vop_bmap to support SEEK_HOLE / SEEK_DATA.
FreeBSD has optimized version of FIOSEEKDATA for ext2 and ufs,
but this commit only brings in generic version for both.
taken-from: FreeBSD
sys/kern: Add SEEK_HOLE / SEEK_DATA support
No filesystem implements SEEK_HOLE / SEEK_DATA yet.
Filesystems with no .vop_ioctl implementation (e.g. ufs, ext2)
use vop_stdioctl() which simply returns EOF for SEEK_HOLE.
Others usually return EOPNOTSUPP, ENOTTY, etc, depending on what
they have for "default" in a switch case.
taken-from: FreeBSD
libefivar(3): Fix build by using uuid_dec_le() from libc
It was using le_uuid_dec() from source of gpt(8). As a result, this
library no longer depends on the 'gpt.c' file from gpt(8).
While there, fix a typo in comment (taken from FreeBSD).
kernel: Remove obsolete DSO_COMPATMBR from <sys/disk.h>
The last use of this flag was removed in commit
1c3c151b5fca37695bf972f959efb7dda16cfbe6, so this flag has become
effectively obsolete since then. Now just remove it to reduce any
confusion.
ok by dillon.
kernel: Clean up DOSPTYP_* defines in subr_diskmbr.c
* Move DOSPTYP_ONTRACK to <sys/diskmbr.h> where other DOSPTYP_* defines
are located.
* Remove DOSPTYP_{EXTENDED,EXTENDEDX} and use DOSPTYP_{EXT,EXTLBA} from
<sys/diskmbr.h> instead.
gpt(8): Refactor parse_uuid() and support more GPT type aliases
Refactor parse_uuid() to parse GPT type aliases by using an array.
Meanwhile, extend it to support more GPT type aliases, which are defined
in <sys/gpt.h> as well as "/etc/defaults/uuids".
<sys/gpt.h>: Small tweaks
* Reorder the DragonFly entries.
* Move the GPT_ENT_TYPE_PREP_BOOT out of the FreeBSD group; it's used by
the boot partition on some PowerPC systems.
* Remove obsolete description on Linux reusing the
GPT_ENT_TYPE_MS_BASIC_DATA entry.
uuid(3): Improve the description for uuid_to_string()
Document that uuid_to_string() will allocate a buffer to hold the
converted string and free(3) should be called to release the memory.
Several more minor tweaks.
Derived from FreeBSD.
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]
fdisk(8): Support 4096 sector size and recognize pMBR of 4Kn disks
Tweak the fdisk(8) utility to support 4096-byte sector size, so it now
can read the pMBR on GPT-formatted 4Kn (aka 4K native) disks, e.g.,
# fdisk -s vbd0
/dev/vbd0: 14628 cyl 16 hd 56 sec
Part Start Size Type Flags
1: 1 13107199 0xee 0x00
In addition, tweak read_disk() to report the read error message.
fdisk(8): Sync TRIM behavior with gpt(8) and clean up code
The TRIM feature is enabled by default in kernel now, so let fdisk(8)
continue the operation if TRIM if the device doesn't support it, similar
to gpt(8).
Update the man page accordingly.
fdisk(8): Add "vbd0" to search list and order "da0" before "ad0"
The virtio_blk(4) device is now very common, so worth adding it to the
search list.
In addition, order "da0" before "ad0" as SATA/SCSI is much more common
than ATA/IDE.
nrelease: Don't disable syslogd in live CD/USB
We're mounting a tmpfs at /var, so it's okay to write under /var/log.
Don't disable syslogd so that it could write the log files that might
be helpful.
fdisk(8): Calculate ncylinders and warn about mismatch
The virtio_blk(4) disk driver was directly reporting the ncylinders
parameter specified by the QEMU emulator, which however is capped at
16383 (the legacy MBR maximum). That confused fdisk(8) to recognize the
disk to have only ~8GB size instead of the full capacity.
The issue virtio_blk(4) has been fixed in a former commit. This commit
improve fdisk(8) by calculating the ncylinders on its own and comparing
it with the one provided by the disk. If there is a mismatch, emit a
warning message to remind a fix to the disk driver.
Derived from the patch submitted by mikdusan in bug #3369.
Bug: https://bugs.dragonflybsd.org/issues/3369
virtio/block: Fix media_blksize and media_blocks calculation
* Correctly report the media block size instead of hardcoded 512.
* Fix the bug in calculating the media blocks.
fdisk(8): Clear errno in read_disk() to avoid confusing others
For example, even read_disk() succeeded in detecting the sector size and
reading, the errno would remain EIO, which could confuse the later code
that calls err() or others.
fdisk(8): Improve summary show of unintialized disk
For an unintialized disk, "fdisk -s" would simply exit an error without
printing any useful information, e.g.,
# fdisk -s vbd0
fdisk: invalid fdisk partition table found
fdisk: read_s0: Undefined error: 0
This change makes "fdisk -s" print the geometry of the disk before
exiting. In addition, check the "errno" value to avoid the confusing
"read_s0: Undefined error: 0" message.
Derived from the patch submitted by mikdusan in bug #3369.
Bug: https://bugs.dragonflybsd.org/issues/3369
fdisk(8): Clear errno in read_disk() to avoid confusing others
For example, even read_disk() succeeded in detecting the sector size and
reading, the errno would remain EIO, which could confuse the later code
that calls err() or others.
fdisk(8): Add "vbd0" to search list and order "da0" before "ad0"
The virtio_blk(4) device is now very common, so worth adding it to the
search list.
In addition, order "da0" before "ad0" as SATA/SCSI is much more common
than ATA/IDE.
nrelease: Don't disable syslogd in live CD/USB
We're mounting a tmpfs at /var, so it's okay to write under /var/log.
Don't disable syslogd so that it could write the log files that might
be helpful.
fdisk(8): Sync TRIM behavior with gpt(8) and clean up code
The TRIM feature is enabled by default in kernel now, so let fdisk(8)
continue the operation if TRIM if the device doesn't support it, similar
to gpt(8).
Update the man page accordingly.
fdisk(8): Calculate ncylinders and warn about mismatch
The virtio_blk(4) disk driver was directly reporting the ncylinders
parameter specified by the QEMU emulator, which however is capped at
16383 (the legacy MBR maximum). That confused fdisk(8) to recognize the
disk to have only ~8GB size instead of the full capacity.
The issue virtio_blk(4) has been fixed in a former commit. This commit
improve fdisk(8) by calculating the ncylinders on its own and comparing
it with the one provided by the disk. If there is a mismatch, emit a
warning message to remind a fix to the disk driver.
Derived from the patch submitted by mikdusan in bug #3369.
Bug: https://bugs.dragonflybsd.org/issues/3369