From owner-svn-src-user@FreeBSD.ORG Sat Sep 13 06:29:38 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A98B9DAF; Sat, 13 Sep 2014 06:29:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 94D9B197; Sat, 13 Sep 2014 06:29:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8D6Tcwj022609; Sat, 13 Sep 2014 06:29:38 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8D6TcPP022608; Sat, 13 Sep 2014 06:29:38 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201409130629.s8D6TcPP022608@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Sat, 13 Sep 2014 06:29:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r271499 - user/nwhitehorn/bsdinstall_zfspartedit/partedit X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Sep 2014 06:29:38 -0000 Author: nwhitehorn Date: Sat Sep 13 06:29:38 2014 New Revision: 271499 URL: http://svnweb.freebsd.org/changeset/base/271499 Log: Derive the zpool name from its mountpoint for lack of a better alternative. We could conceivably use the label field for this, but that isn't present for MBR or BSD. This lets the partition editor (and sade) produce working ZFS systems. The next task is making it so that the installer knows that only sparc64 and BIOS-booted x86 systems can have / on ZFS. Modified: user/nwhitehorn/bsdinstall_zfspartedit/partedit/gpart_ops.c Modified: user/nwhitehorn/bsdinstall_zfspartedit/partedit/gpart_ops.c ============================================================================== --- user/nwhitehorn/bsdinstall_zfspartedit/partedit/gpart_ops.c Sat Sep 13 06:13:55 2014 (r271498) +++ user/nwhitehorn/bsdinstall_zfspartedit/partedit/gpart_ops.c Sat Sep 13 06:29:38 2014 (r271499) @@ -38,7 +38,6 @@ #include "partedit.h" #define GPART_FLAGS "x" /* Do not commit changes by default */ -#define DEFAULT_ZPOOL_NAME "sys" /* default name for zpool */ static void gpart_show_error(const char *title, const char *explanation, const char *errstr) @@ -159,8 +158,6 @@ newfs_command(const char *fstype, char * else if (strcmp(items[i].name, "atime") == 0) strcat(command, "-O atime=off "); } - strcat(command, DEFAULT_ZPOOL_NAME); - strcat(command, " "); } else if (strcmp(fstype, "fat32") == 0 || strcmp(fstype, "efi") == 0) { int i; DIALOG_LISTITEM items[] = { @@ -607,6 +604,8 @@ set_default_part_metadata(const char *na const char *type, const char *mountpoint, const char *newfs) { struct partition_metadata *md; + char *zpool_name = NULL; + int i; /* Set part metadata */ md = get_part_metadata(name, 1); @@ -619,8 +618,17 @@ set_default_part_metadata(const char *na if (newfs != NULL && newfs[0] != '\0') { md->newfs = malloc(strlen(newfs) + strlen(" /dev/") + - strlen(name) + 1); - sprintf(md->newfs, "%s /dev/%s", newfs, name); + strlen(mountpoint) + 1 + strlen(name) + 1); + if (strcmp("freebsd-zfs", type) == 0) { + zpool_name = strdup(&mountpoint[1]); + for (i = 0; zpool_name[i] != 0; i++) + if (!isalnum(zpool_name[i])) + zpool_name[i] = '_'; + sprintf(md->newfs, "%s %s /dev/%s", newfs, + zpool_name, name); + } else { + sprintf(md->newfs, "%s /dev/%s", newfs, name); + } } } @@ -654,8 +662,13 @@ set_default_part_metadata(const char *na free(md->fstab->fs_mntops); free(md->fstab->fs_type); } - md->fstab->fs_spec = malloc(strlen(name) + strlen("/dev/") + 1); - sprintf(md->fstab->fs_spec, "/dev/%s", name); + if (strcmp("freebsd-zfs", type) == 0) { + md->fstab->fs_spec = strdup(zpool_name); + } else { + md->fstab->fs_spec = malloc(strlen(name) + + strlen("/dev/") + 1); + sprintf(md->fstab->fs_spec, "/dev/%s", name); + } md->fstab->fs_file = strdup(mountpoint); /* Get VFS from text after freebsd-, if possible */ if (strncmp("freebsd-", type, 8) == 0) @@ -669,15 +682,7 @@ set_default_part_metadata(const char *na md->fstab->fs_freq = 0; md->fstab->fs_passno = 0; } else { - if (strcmp(md->fstab->fs_vfstype, "zfs") == 0) { - md->fstab->fs_type = strdup(FSTAB_XX ",noauto"); - free(md->fstab->fs_spec); - md->fstab->fs_spec = malloc(strlen(name) + - strlen("#/dev/") + 1); - sprintf(md->fstab->fs_spec, "#/dev/%s", name); - } else { - md->fstab->fs_type = strdup(FSTAB_RW); - } + md->fstab->fs_type = strdup(FSTAB_RW); if (strcmp(mountpoint, "/") == 0) { md->fstab->fs_freq = 1; md->fstab->fs_passno = 1; @@ -688,6 +693,9 @@ set_default_part_metadata(const char *na } md->fstab->fs_mntops = strdup(md->fstab->fs_type); } + + if (zpool_name != NULL) + free(zpool_name); } static