svn commit: r217198 - in user/nwhitehorn/bsdinstall: partedit
scripts
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Sun Jan 9 16:32:44 UTC 2011
Author: nwhitehorn
Date: Sun Jan 9 16:32:44 2011
New Revision: 217198
URL: http://svn.freebsd.org/changeset/base/217198
Log:
Make it slightly more difficult to shoot yourself in the foot by not
specifying mountpoints, not making a / partition, or having a partition
mounted deep in the hierarchy.
Suggested by: Michael Ross <michael dot ross at gmx dot net>
Modified:
user/nwhitehorn/bsdinstall/partedit/gpart_ops.c
user/nwhitehorn/bsdinstall/partedit/partedit.c
user/nwhitehorn/bsdinstall/scripts/mount
Modified: user/nwhitehorn/bsdinstall/partedit/gpart_ops.c
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Sun Jan 9 15:59:52 2011 (r217197)
+++ user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Sun Jan 9 16:32:44 2011 (r217198)
@@ -268,7 +268,7 @@ gpart_edit(struct gprovider *pp)
"megabytes or gigabytes.", FALSE},
{0, "Mountpoint:", 11, 2, 0, FALSE, "", 11, 2, 12, 15, 0,
FALSE, "Path at which to mount this partition (leave blank "
- "for swap)", FALSE},
+ "for swap, set to / for root filesystem)", FALSE},
{0, "Label:", 7, 3, 0, FALSE, "", 11, 3, 12, 15, 0, FALSE,
"Partition name. Not all partition schemes support this.",
FALSE},
@@ -514,8 +514,8 @@ gpart_create(struct gprovider *pp)
FALSE, "Partition size. Append K, M, G for kilobytes, "
"megabytes or gigabytes.", FALSE},
{0, "Mountpoint:", 11, 2, 0, FALSE, "", 11, 2, 12, 15, 0,
- FALSE, "Path at which to mount this partition (leave blank "
- "for swap)", FALSE},
+ FALSE, "Path at which to mount partition (blank for "
+ "swap, / for root filesystem)", FALSE},
{0, "Label:", 7, 3, 0, FALSE, "", 11, 3, 12, 15, 0, FALSE,
"Partition name. Not all partition schemes support this.",
FALSE},
@@ -575,13 +575,12 @@ gpart_create(struct gprovider *pp)
intmax_t partend;
partend = strtoimax(gc->lg_val, NULL, 0);
if (partend > firstfree)
- firstfree = partend;
+ firstfree = partend + 1;
}
}
}
/* Compute beginning of new partition and maximum available space */
- firstfree++;
if (stripe > 0 && (firstfree*sector % stripe) != 0)
firstfree += (stripe - ((firstfree*sector) % stripe)) / sector;
@@ -628,6 +627,21 @@ addpartform:
size = MIN((intmax_t)(bytes/sector), maxsize);
}
+ /* Warn if no mountpoint set */
+ if (strcmp(items[0].text, "freebsd-ufs") == 0 &&
+ items[2].text[0] != '/') {
+ dialog_vars.defaultno = TRUE;
+ choice = dialog_yesno("Warning",
+ "This partition does not have a valid mountpoint "
+ "(for the partition from which you intend to boot the "
+ "operating system, the mountpoint should be /). Are you "
+ "sure you want to continue?"
+ , 0, 0);
+ dialog_vars.defaultno = FALSE;
+ if (choice == 1) /* cancel */
+ goto addpartform;
+ }
+
/* If this is the root partition, check that this scheme is bootable */
if (strcmp(items[2].text, "/") == 0 && !is_scheme_bootable(scheme)) {
char message[512];
Modified: user/nwhitehorn/bsdinstall/partedit/partedit.c
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/partedit.c Sun Jan 9 15:59:52 2011 (r217197)
+++ user/nwhitehorn/bsdinstall/partedit/partedit.c Sun Jan 9 16:32:44 2011 (r217198)
@@ -19,6 +19,7 @@ static void add_geom_children(struct gge
struct partedit_item **items, int *nitems);
static void init_fstab_metadata(void);
static void get_mount_points(struct partedit_item *items, int nitems);
+static int validate_setup(void);
int
main(void) {
@@ -84,7 +85,7 @@ main(void) {
}
error = 0;
- if (op == 4) { /* Finished */
+ if (op == 4 && validate_setup()) { /* Finished */
dialog_vars.extra_button = TRUE;
dialog_vars.extra_label = "Don't Save";
dialog_vars.ok_label = "Save";
@@ -159,7 +160,30 @@ delete_part_metadata(const char *name) {
}
}
}
-
+
+static int
+validate_setup(void)
+{
+ struct partition_metadata *md;
+ int root_found = FALSE;
+
+ TAILQ_FOREACH(md, &part_metadata, metadata) {
+ if (md->fstab != NULL && strcmp(md->fstab->fs_file, "/") == 0)
+ root_found = TRUE;
+
+ /* XXX: Check for duplicate mountpoints */
+ }
+
+ if (!root_found) {
+ dialog_msgbox("Error", "No root partition was found. "
+ "The root FreeBSD partition must have a mountpoint of '/'.",
+ 0, 0, TRUE);
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
static int
apply_changes(struct gmesh *mesh)
{
Modified: user/nwhitehorn/bsdinstall/scripts/mount
==============================================================================
--- user/nwhitehorn/bsdinstall/scripts/mount Sun Jan 9 15:59:52 2011 (r217197)
+++ user/nwhitehorn/bsdinstall/scripts/mount Sun Jan 9 16:32:44 2011 (r217198)
@@ -15,7 +15,7 @@ cat $PATH_FSTAB | awk -v BSDINSTALL_CHRO
FILESYSTEMS=`cat $TMP_FSTAB | awk '/^[^#].*/ {if ($2 ~ "^/.*") printf("%s\n", $2);}' | sort -t /`
for i in $FILESYSTEMS; do
- mkdir $i 2>/dev/null
+ mkdir -p $i 2>/dev/null
MNTERROR=`mount -F $TMP_FSTAB $i 2>&1`
if [ $? -ne 0 ]; then
cdialog --backtitle "FreeBSD Installer" --title "Error" \
More information about the svn-src-user
mailing list