Date: Sat, 13 Sep 2014 06:29:38 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r271499 - user/nwhitehorn/bsdinstall_zfspartedit/partedit Message-ID: <201409130629.s8D6TcPP022608@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409130629.s8D6TcPP022608>