History log of /freebsd-current/usr.sbin/bsdinstall/partedit/partedit.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# cd724c25 03-Feb-2024 Mariusz Zaborski <oshogbo@FreeBSD.org>

bsdinstall: complete whitelabeling the installer

The commit 147585b4893bc38698aaa971af336b241477eac3 introduces
whitlabeling. This commit addresses couple more places where the
os name was missed.

Reviewed by: imp, asiciliano, brd
Differential Revision: https://reviews.freebsd.org/D43638


# 6e8bf240 16-Oct-2023 John Baldwin <jhb@FreeBSD.org>

bsdinstall partedit: Use snprintf instead of sprintf for error messages

When generating a message for a dialog box into a static buffer, use
snprintf instead of sprintf to avoid buffer overflows.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D42240


# a8676bf3 16-Oct-2023 John Baldwin <jhb@FreeBSD.org>

bsdinstall partedit: Use asprintf to build wrapper command for newfs

Don't abuse the message[] static buffer used elsewhere for error
messages to generate the command that actually newfs's each
filesystem. Use asprintf to a more aptly-named 'char *command'
variable to construct the string instead. This avoids potential bugs
from truncation of the command string.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D42239


# 51749e05 16-Oct-2023 John Baldwin <jhb@FreeBSD.org>

bsdinstall partedit: Replace malloc + sprintf with asprintf

This avoids potential bugs with the length passed to malloc not
matching the string written via sprintf.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D42238


# 5307bbcc 16-Oct-2023 John Baldwin <jhb@FreeBSD.org>

bsdinstall partedit: Apply changes from scripted installs

I got a check inverted in a previous cleanup commit and as a result
partedit was only applying GEOM changes (and generating an /etc/fstab)
if it got an error reading the current GEOM mesh. Instead, it needed
to do those actions if it succeeded in reading the mesh.

The lack of /etc/fstab meant that bsdinstall mount didn't mount
anything in a scripted install.

PR: 273723
Reported by: Andrey Fesenko <andrey@bsdnir.info>
Reported by: Michal Nowak <mnowak@startmail.com>
Reviewed by: cognet, brooks
Fixes: 230990991965 bsdinstall: Handle errors from geom_gettree.
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42236


# 61ba55bc 04-Oct-2023 Baptiste Daroussin <bapt@FreeBSD.org>

bsddialog: import version 1.0


# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

# 23099099 28-Jun-2023 John Baldwin <jhb@FreeBSD.org>

bsdinstall: Handle errors from geom_gettree.

geom_gettree probably never fails, and if it does there isn't much of
a fallback other than aborting partitioning. However, a few places
were checking the return value and not doing anything with it
triggering a unused-but-set-variable warning. Checking the errors
resolves the warning.

While here, check for errors in other places that weren't checking for
them at all, remove a spurious double call (the second call overwrote
the mesh structure leaking all the pointers from the first), and close
a few resource leaks on error paths.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D40779

# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

# 147585b4 13-May-2022 Brad Davis <brd@FreeBSD.org>

bsdinstall: allow whitelabeling the installer

Override OSNAME to change the name of the OS in the installer.

This is a first step, the shell changes will be separate.

Reviewed by: allanjude
Approved by: allanjude
Differential Revision: https://reviews.freebsd.org/D34878
Sponsored by: Rubicon Communications, LLC ("Netgate")

# 50e24496 03-Apr-2022 Alfonso S. Siciliano <asiciliano@FreeBSD.org>

bsdinstall/partedit: Replace libdialog with libbsddialog

bsdinstall/partedit: Replace (LGPL) libdialog with (BSD-2-Clause)
libbsddialog. Rewrite diskeditor.c and rename diskmenu.c because
it uses an API for menu totally incompatible with libbsddialog.
This is a User Interface change everything else is unchanged.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34639

# b07b7aec 26-Mar-2021 Ryan Moeller <freqlabs@FreeBSD.org>

bsdinstall: Drop vestigial bsdinstall-esps cleanup

This is not needed after 0b7472b3d8d2f1e90fade5236b44fd98d8e396c2.

MFC after: 3 days
Sponsored by: iXsystems, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29325

# c2f16c59 23-Mar-2021 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Fix scripted installs on EFI systems after default mounting of the ESP.

Because the ESP mount point (/boot/efi) is in mtree, tar will attempt to
extract a directory at that point post-mount when the system is installed.
Normally, this is fine, since tar can happily set whatever properties it
wants. For FAT32 file systems, however, like the ESP, tar will attempt to
set mtime on the root directory, which FAT does not support, and tar will
interpret this as a fatal error, breaking the install (see
https://github.com/libarchive/libarchive/issues/1516). This issue would
also break scripted installs on bare-metal POWER8, POWER9, and PS3
systems, as well as some ARM systems.

This patch solves the problem in two ways:
- If stdout is a TTY, use the distextract stage instead of tar, as in
interactive installs. distextract solves this problem internally and
provides a nicer UI to boot, but requires a TTY.
- If stdout is not a TTY, use tar but, as a stopgap for 13.0, exclude
boot/efi from tarball extraction and then add it by hand. This is a
hack, and better solutions (as in the libarchive ticket above) will
obsolete it, but it solves the most common case, leaving only
unattended TTY-less installs on a few tier-2 platforms broken.

In addition, fix a bug with fstab generation uncovered once the tar issue
is fixed that umount(8) can depend on the ordering of lines in fstab in a
way that mount(8) does not. The partition editor now writes out fstab in
mount order, making sure umount (run at the end of scripted, but not
interactive, installs) succeeds.

PR: 254395
Reviewed by: gjb, imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29380

# 2d482628 17-Jan-2020 Ben Woods <woodsb02@FreeBSD.org>

Fix regression in bsdinstall post r356740 - partedit errno(2) 21 EISDIR

This resulted in the partitioning step failing if either of the
"Auto (UFS)" or "Manual" options were selected.

Reason: partedit was attempting to open a directory (TMPDIR) read/write,
which resulted in errno(2) 21 - EISDIR - Is a directory.

Reported by: Clay Daniels <clay.daniels.jr@gmail.com>
Reviewed by: Ryan Moeller <ryan@freqlabs.com>
Approved by: emaste, bcran
Differential Revision: https://reviews.freebsd.org/D23232

# a107ddbb 14-Jan-2020 Rebecca Cran <bcran@FreeBSD.org>

bsdinstall: Use TMPDIR if set

Submitted by: Ryan Moeller <ryan@freqlabs.com>
Reviewed by: bcran, Nick Wolff <darkfiberiru@gmail.com>
Differential Revision: https://reviews.freebsd.org/D22979/

# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.

# 4e7e2cad 26-Apr-2016 Ed Schouten <ed@FreeBSD.org>

Remove unportable calls to basename().

The POSIX version of basename() doesn't use a 'const char *' argument;
the function may overwrite its input buffer. Instead of copying the
input string, let's just simplify this code by using our getprogname()
function that already returns the name of the application in the right
format.

Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D6094

# 7059fa6f 18-Jul-2015 Allan Jude <allanjude@FreeBSD.org>

Add support for two workarounds for known issues booting GPT in legacy mode on some hardware

For Lenovo laptops with buggy bios (x220, t420, t520):
Write the 0xee entry into the second slot in the pmbr instead of the first

For some Dell and HP models:
The BIOS gives a warning message when booting in legacy mode from a GPT partitioned disk where the 0xee partition in the pmbr is not flagged active
For models known to have this problem, mark the pmbr active during installation

Use smbios data to identify machines known to be affected by any of the above, and offer the user the option to apply the workaround

In bsdinstall's ufs auto mode (autopart partition wizard):
Allow users to select which type of partition table to use
Keep current defaults: MBR for BIOS, GPT for UEFI
This allows users to choose GPT for legacy boot if they wish

PR: 184910
PR: 194359
Reviewed by: Michael Dexter
Approved by: marcel
MFC after: 3 days
X-MFC-With: r285594
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D3091

# 6e15678a 13-Sep-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add ZFS support to the bsdinstall partition editor and sade.

Submitted by: Kurt Lidl (original version)
MFC after: 6 weeks

# f0ddc92d 22-Jan-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Improve error handling and remove an unnecessary check on geom provider
type. GEOM provider names can't duplicate (or shouldn't -- devfs will either
break or only use the first one if they do) so using the first provider
by that name is a sufficient check. This also lets the scripted partitioner
install onto gmirror and geli and such things.

# 5eca7e06 20-Jan-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add a simple scripted partitioner. Documentation and more scripting support
will come soon. This lets the install process have a line like:

bsdinstall scriptedpart 'ada0 GPT {1.5G freebsd-ufs /, 10G freebsd-swap,
auto freebsd-ufs /usr}'

to set up a system with a 1.5GB /, some swap space, and a /usr using the
rest of ada0.

MFC after: 1 month

# 4f5fcf8d 30-Dec-2012 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

If invoked as sade, don't complain about having a filesystem on / already
-- it's something you expect (and indeed hope for).

MFC after: 1 week

# 6fe359f2 18-Jan-2012 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Warn if trying to install over an existing partition, which usually fails
anyway due to libarchive not being able to overwrite schg flags.

PR: bin/164278
MFC after: 4 days

# 07d76626 25-Oct-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Provide an error message instead of silent failure if no disks are present
in the system.

PR: bin/161950
MFC after: 3 days

# bcc25b7e 21-Aug-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Implement support for GRAID volumes in the installer partition editor,
rename a few options, clarify some help text, and add help text for the
buttons on the main partition editor screen.

Approved by: re (kib)

# 26092385 06-Jul-2011 Kevin Lo <kevlo@FreeBSD.org>

Add an extra tab between fs_file and fs_vfstype

Reviewed by: nwhitehorn

# 3b613c28 07-Mar-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Only validate the partition setup when the user presses "Save". If the user
wants to exit without saving, it's not a problem if the disk is set up
in an invalid way.

# 2118f387 18-Feb-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Import bsdinstall. This is meant to be (eventually in conjunction with
pc-sysinstall) a replacement for sysinstall in the 9.0 release and beyond.
Currently supported platforms are sparc64, pc98, i386, amd64, powerpc, and
powerpc64. Integration into the build system will occur in the coming
weeks.

Merging with pc-sysinstall will use this code as a frontend, while
temporarily retaining the interactive partition editor here. This work
will be done in parallel with improvements on this code and release
integration.

Thanks to all who have provided testing and comments!

# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 23099099 28-Jun-2023 John Baldwin <jhb@FreeBSD.org>

bsdinstall: Handle errors from geom_gettree.

geom_gettree probably never fails, and if it does there isn't much of
a fallback other than aborting partitioning. However, a few places
were checking the return value and not doing anything with it
triggering a unused-but-set-variable warning. Checking the errors
resolves the warning.

While here, check for errors in other places that weren't checking for
them at all, remove a spurious double call (the second call overwrote
the mesh structure leaking all the pointers from the first), and close
a few resource leaks on error paths.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D40779


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 147585b4 13-May-2022 Brad Davis <brd@FreeBSD.org>

bsdinstall: allow whitelabeling the installer

Override OSNAME to change the name of the OS in the installer.

This is a first step, the shell changes will be separate.

Reviewed by: allanjude
Approved by: allanjude
Differential Revision: https://reviews.freebsd.org/D34878
Sponsored by: Rubicon Communications, LLC ("Netgate")


# 50e24496 03-Apr-2022 Alfonso S. Siciliano <asiciliano@FreeBSD.org>

bsdinstall/partedit: Replace libdialog with libbsddialog

bsdinstall/partedit: Replace (LGPL) libdialog with (BSD-2-Clause)
libbsddialog. Rewrite diskeditor.c and rename diskmenu.c because
it uses an API for menu totally incompatible with libbsddialog.
This is a User Interface change everything else is unchanged.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34639


# b07b7aec 26-Mar-2021 Ryan Moeller <freqlabs@FreeBSD.org>

bsdinstall: Drop vestigial bsdinstall-esps cleanup

This is not needed after 0b7472b3d8d2f1e90fade5236b44fd98d8e396c2.

MFC after: 3 days
Sponsored by: iXsystems, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29325


# c2f16c59 23-Mar-2021 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Fix scripted installs on EFI systems after default mounting of the ESP.

Because the ESP mount point (/boot/efi) is in mtree, tar will attempt to
extract a directory at that point post-mount when the system is installed.
Normally, this is fine, since tar can happily set whatever properties it
wants. For FAT32 file systems, however, like the ESP, tar will attempt to
set mtime on the root directory, which FAT does not support, and tar will
interpret this as a fatal error, breaking the install (see
https://github.com/libarchive/libarchive/issues/1516). This issue would
also break scripted installs on bare-metal POWER8, POWER9, and PS3
systems, as well as some ARM systems.

This patch solves the problem in two ways:
- If stdout is a TTY, use the distextract stage instead of tar, as in
interactive installs. distextract solves this problem internally and
provides a nicer UI to boot, but requires a TTY.
- If stdout is not a TTY, use tar but, as a stopgap for 13.0, exclude
boot/efi from tarball extraction and then add it by hand. This is a
hack, and better solutions (as in the libarchive ticket above) will
obsolete it, but it solves the most common case, leaving only
unattended TTY-less installs on a few tier-2 platforms broken.

In addition, fix a bug with fstab generation uncovered once the tar issue
is fixed that umount(8) can depend on the ordering of lines in fstab in a
way that mount(8) does not. The partition editor now writes out fstab in
mount order, making sure umount (run at the end of scripted, but not
interactive, installs) succeeds.

PR: 254395
Reviewed by: gjb, imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29380


# 2d482628 17-Jan-2020 Ben Woods <woodsb02@FreeBSD.org>

Fix regression in bsdinstall post r356740 - partedit errno(2) 21 EISDIR

This resulted in the partitioning step failing if either of the
"Auto (UFS)" or "Manual" options were selected.

Reason: partedit was attempting to open a directory (TMPDIR) read/write,
which resulted in errno(2) 21 - EISDIR - Is a directory.

Reported by: Clay Daniels <clay.daniels.jr@gmail.com>
Reviewed by: Ryan Moeller <ryan@freqlabs.com>
Approved by: emaste, bcran
Differential Revision: https://reviews.freebsd.org/D23232


# a107ddbb 14-Jan-2020 Rebecca Cran <bcran@FreeBSD.org>

bsdinstall: Use TMPDIR if set

Submitted by: Ryan Moeller <ryan@freqlabs.com>
Reviewed by: bcran, Nick Wolff <darkfiberiru@gmail.com>
Differential Revision: https://reviews.freebsd.org/D22979/


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 4e7e2cad 26-Apr-2016 Ed Schouten <ed@FreeBSD.org>

Remove unportable calls to basename().

The POSIX version of basename() doesn't use a 'const char *' argument;
the function may overwrite its input buffer. Instead of copying the
input string, let's just simplify this code by using our getprogname()
function that already returns the name of the application in the right
format.

Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D6094


# 7059fa6f 18-Jul-2015 Allan Jude <allanjude@FreeBSD.org>

Add support for two workarounds for known issues booting GPT in legacy mode on some hardware

For Lenovo laptops with buggy bios (x220, t420, t520):
Write the 0xee entry into the second slot in the pmbr instead of the first

For some Dell and HP models:
The BIOS gives a warning message when booting in legacy mode from a GPT partitioned disk where the 0xee partition in the pmbr is not flagged active
For models known to have this problem, mark the pmbr active during installation

Use smbios data to identify machines known to be affected by any of the above, and offer the user the option to apply the workaround

In bsdinstall's ufs auto mode (autopart partition wizard):
Allow users to select which type of partition table to use
Keep current defaults: MBR for BIOS, GPT for UEFI
This allows users to choose GPT for legacy boot if they wish

PR: 184910
PR: 194359
Reviewed by: Michael Dexter
Approved by: marcel
MFC after: 3 days
X-MFC-With: r285594
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D3091


# 6e15678a 13-Sep-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add ZFS support to the bsdinstall partition editor and sade.

Submitted by: Kurt Lidl (original version)
MFC after: 6 weeks


# f0ddc92d 22-Jan-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Improve error handling and remove an unnecessary check on geom provider
type. GEOM provider names can't duplicate (or shouldn't -- devfs will either
break or only use the first one if they do) so using the first provider
by that name is a sufficient check. This also lets the scripted partitioner
install onto gmirror and geli and such things.


# 5eca7e06 20-Jan-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add a simple scripted partitioner. Documentation and more scripting support
will come soon. This lets the install process have a line like:

bsdinstall scriptedpart 'ada0 GPT {1.5G freebsd-ufs /, 10G freebsd-swap,
auto freebsd-ufs /usr}'

to set up a system with a 1.5GB /, some swap space, and a /usr using the
rest of ada0.

MFC after: 1 month


# 4f5fcf8d 30-Dec-2012 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

If invoked as sade, don't complain about having a filesystem on / already
-- it's something you expect (and indeed hope for).

MFC after: 1 week


# 6fe359f2 18-Jan-2012 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Warn if trying to install over an existing partition, which usually fails
anyway due to libarchive not being able to overwrite schg flags.

PR: bin/164278
MFC after: 4 days


# 07d76626 25-Oct-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Provide an error message instead of silent failure if no disks are present
in the system.

PR: bin/161950
MFC after: 3 days


# bcc25b7e 21-Aug-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Implement support for GRAID volumes in the installer partition editor,
rename a few options, clarify some help text, and add help text for the
buttons on the main partition editor screen.

Approved by: re (kib)


# 26092385 06-Jul-2011 Kevin Lo <kevlo@FreeBSD.org>

Add an extra tab between fs_file and fs_vfstype

Reviewed by: nwhitehorn


# 3b613c28 07-Mar-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Only validate the partition setup when the user presses "Save". If the user
wants to exit without saving, it's not a problem if the disk is set up
in an invalid way.


# 2118f387 18-Feb-2011 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Import bsdinstall. This is meant to be (eventually in conjunction with
pc-sysinstall) a replacement for sysinstall in the 9.0 release and beyond.
Currently supported platforms are sparc64, pc98, i386, amd64, powerpc, and
powerpc64. Integration into the build system will occur in the coming
weeks.

Merging with pc-sysinstall will use this code as a frontend, while
temporarily retaining the interactive partition editor here. This work
will be done in parallel with improvements on this code and release
integration.

Thanks to all who have provided testing and comments!