4460 "partition_size" tag in ai_manifest.xml template should mention sectors
5655 AI should allow size units to be specified for creating custom slices
--- a/usr/src/cmd/auto-install/ai_manifest.defval.xml Wed Jan 14 13:58:00 2009 +0100
+++ b/usr/src/cmd/auto-install/ai_manifest.defval.xml Thu Jan 15 07:13:03 2009 -0700
@@ -18,7 +18,7 @@
CDDL HEADER END
-Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+Copyright 2009 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
-->
@@ -47,4 +47,12 @@
slim_install
entire
</default>
+ <default nodepath="ai_device_partitioning/partition_size_units"
+ from="value" type="element" missing_parent="skip">
+ mb
+ </default>
+ <default nodepath="ai_device_vtoc_slices/slice_size_units"
+ from="value" type="element" missing_parent="skip">
+ mb
+ </default>
</defaults_and_validation_manifest>
--- a/usr/src/cmd/auto-install/ai_manifest.rng Wed Jan 14 13:58:00 2009 +0100
+++ b/usr/src/cmd/auto-install/ai_manifest.rng Thu Jan 15 07:13:03 2009 -0700
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
CDDL HEADER START
@@ -189,9 +190,13 @@
<element name="partition_type">
<data type="unsignedByte"/>
</element>
+ <optional>
+ <element name="partition_size_units">
+ <ref name="disk_space_size_units"/>
+ </element>
+ </optional>
</interleave>
</define>
-
<!--
=======================================================================
Selections for AI target device vtoc slices specification
@@ -212,6 +217,11 @@
<element name="slice_size">
<data type="unsignedLong"/>
</element>
+ <optional>
+ <element name="slice_size_units">
+ <ref name="disk_space_size_units"/>
+ </element>
+ </optional>
</interleave>
</define>
@@ -316,4 +326,50 @@
</element>
</optional>
</define>
+ <!--
+ =======================================================================
+ General definitions
+ =======================================================================
+ -->
+ <!--
+ =======================================================================
+ Units measuring sizable regions of space on disk drives
+ =======================================================================
+ -->
+ <define name="disk_space_size_units">
+ <choice>
+ <value>sectors</value>
+ <value>secs</value> <!-- disk space sectors (512 bytes) -->
+ <value>sec</value> <!-- disk space sectors (512 bytes) -->
+ <value>s</value>
+ <value>megabytes</value>
+ <value>megabyte</value>
+ <value>mb</value>
+ <value>m</value>
+ <value>gigabytes</value>
+ <value>gigabyte</value>
+ <value>gb</value>
+ <value>g</value>
+ <value>terabytes</value>
+ <value>terabyte</value>
+ <value>tb</value>
+ <value>t</value>
+ <value>SECTORS</value>
+ <value>SECS</value> <!-- disk space sectors (512 bytes) -->
+ <value>SEC</value> <!-- disk space sectors (512 bytes) -->
+ <value>S</value>
+ <value>MEGABYTES</value>
+ <value>MEGABYTE</value>
+ <value>MB</value>
+ <value>M</value>
+ <value>GIGABYTES</value>
+ <value>GIGABYTE</value>
+ <value>GB</value>
+ <value>G</value>
+ <value>TERABYTES</value>
+ <value>TERABYTE</value>
+ <value>TB</value>
+ <value>T</value>
+ </choice>
+ </define>
</grammar>
--- a/usr/src/cmd/auto-install/ai_manifest.xml Wed Jan 14 13:58:00 2009 +0100
+++ b/usr/src/cmd/auto-install/ai_manifest.xml Thu Jan 15 07:13:03 2009 -0700
@@ -50,12 +50,14 @@
<partition_number>4</partition_number>
<partition_start_sector>200</partition_start_sector>
<partition_size>20480</partition_size>
+ <partition_size_units>mb</partition_size_units>
<partition_type>99</partition_type>
</ai_device_partitioning>
<ai_device_vtoc_slices>
<slice_action>create</slice_action>
<slice_number>4</slice_number>
<slice_size>20480</slice_size>
+ <slice_size_units>mb</slice_size_units>
</ai_device_vtoc_slices>
<ai_device_vtoc_slices>
<slice_action>delete</slice_action>
--- a/usr/src/cmd/auto-install/auto_install.c Wed Jan 14 13:58:00 2009 +0100
+++ b/usr/src/cmd/auto-install/auto_install.c Thu Jan 15 07:13:03 2009 -0700
@@ -44,7 +44,10 @@
int install_error = 0;
install_params params;
+
void auto_update_progress(om_callback_info_t *, uintptr_t);
+static boolean_t convert_to_sectors(auto_size_units_t,
+ uint64_t, uint64_t *);
static void
usage()
@@ -276,11 +279,24 @@
auto_modify_target_slices(auto_slice_info *asi, uint8_t install_slice_id)
{
for (; asi->slice_action[0] != '\0'; asi++) {
- auto_debug_print(AUTO_DBGLVL_INFO, "slice action %s\n",
- asi->slice_action);
+ uint64_t slice_size_sec;
+
+ auto_debug_print(AUTO_DBGLVL_INFO,
+ "slice action %s, size=%lld units=%s\n",
+ asi->slice_action, asi->slice_size,
+ CONVERT_UNITS_TO_TEXT(asi->slice_size_units));
+
+ if (!convert_to_sectors(asi->slice_size_units,
+ asi->slice_size, &slice_size_sec)) {
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "conversion failure from %lld %s to sectors\n",
+ asi->slice_size,
+ CONVERT_UNITS_TO_TEXT(asi->slice_size_units));
+ return (AUTO_INSTALL_FAILURE);
+ }
if (strcmp(asi->slice_action, "create") == 0) {
if (!om_create_slice(asi->slice_number,
- asi->slice_size,
+ slice_size_sec,
asi->slice_number == install_slice_id))
return (AUTO_INSTALL_FAILURE);
} else if (strcmp(asi->slice_action, "delete") == 0) {
@@ -294,6 +310,40 @@
return (AUTO_INSTALL_SUCCESS);
}
+/*
+ * convert value to sectors given basic unit size
+ * TODO uint64_t overflow check
+ */
+
+static boolean_t
+convert_to_sectors(auto_size_units_t units, uint64_t src,
+ uint64_t *psecs)
+{
+ if (psecs == NULL)
+ return (B_FALSE);
+ switch (units) {
+ case AI_SIZE_UNITS_SECTORS:
+ *psecs = src;
+ break;
+ case AI_SIZE_UNITS_MEGABYTES:
+ *psecs = src*2048;
+ break;
+ case AI_SIZE_UNITS_GIGABYTES:
+ *psecs = src*2048*1024; /* sec=>MB=>GB */
+ break;
+ case AI_SIZE_UNITS_TERABYTES:
+ *psecs = src*2048*1024*1024; /* sec=>MB=>GB=>TB */
+ break;
+ default:
+ return (B_FALSE);
+ }
+ if (units != AI_SIZE_UNITS_SECTORS)
+ auto_debug_print(AUTO_DBGLVL_INFO,
+ "converting from %lld %s to %lld sectors\n",
+ src, CONVERT_UNITS_TO_TEXT(units), *psecs);
+ return (B_TRUE);
+}
+
#ifndef __sparc
/*
* Create/delete/preserve fdisk partitions as specifed
@@ -303,15 +353,28 @@
auto_modify_target_partitions(auto_partition_info *api)
{
for (; api->partition_action[0] != '\0'; api++) {
- auto_debug_print(AUTO_DBGLVL_INFO, "partition action %s\n",
- api->partition_action);
+ uint64_t partition_size_sec;
+
+ auto_debug_print(AUTO_DBGLVL_INFO,
+ "partition action %s, size=%lld units=%s\n",
+ api->partition_action, api->partition_size,
+ CONVERT_UNITS_TO_TEXT(api->partition_size_units));
+
+ if (!convert_to_sectors(api->partition_size_units,
+ api->partition_size, &partition_size_sec)) {
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "conversion failure from %lld %s to sectors\n",
+ api->partition_size,
+ CONVERT_UNITS_TO_TEXT(api->partition_size_units));
+ return (AUTO_INSTALL_FAILURE);
+ }
if (strcmp(api->partition_action, "create") == 0) {
if (!om_create_partition(api->partition_start_sector,
- api->partition_size, B_FALSE))
+ partition_size_sec, B_FALSE))
return (AUTO_INSTALL_FAILURE);
} else if (strcmp(api->partition_action, "delete") == 0) {
if (!om_delete_partition(api->partition_start_sector,
- api->partition_size))
+ partition_size_sec))
return (AUTO_INSTALL_FAILURE);
}
}
@@ -623,8 +686,7 @@
if (putenv(proxy)) {
auto_debug_print(AUTO_DBGLVL_INFO,
"Setting of http_proxy environment variable failed:"
- "%s\n",
- strerror(errno));
+ " %s\n", strerror(errno));
return (AUTO_INSTALL_FAILURE);
}
}
--- a/usr/src/cmd/auto-install/auto_install.h Wed Jan 14 13:58:00 2009 +0100
+++ b/usr/src/cmd/auto-install/auto_install.h Thu Jan 15 07:13:03 2009 -0700
@@ -72,6 +72,21 @@
#define TEXT_DOMAIN "SUNW_INSTALL_AUTOINSTALL"
+#define CONVERT_UNITS_TO_TEXT(units) \
+ ((units) == AI_SIZE_UNITS_MEGABYTES ? "megabytes": \
+ ((units) == AI_SIZE_UNITS_GIGABYTES ? "gigabytes": \
+ ((units) == AI_SIZE_UNITS_TERABYTES ? "terabytes": \
+ ((units) == AI_SIZE_UNITS_SECTORS ? "sectors": \
+ "(unknown)"))))
+
+/* size units can be user-defined */
+typedef enum {
+ AI_SIZE_UNITS_MEGABYTES = 0,
+ AI_SIZE_UNITS_SECTORS,
+ AI_SIZE_UNITS_GIGABYTES,
+ AI_SIZE_UNITS_TERABYTES
+} auto_size_units_t;
+
typedef struct {
char diskname[MAXNAMELEN];
char disktype[MAXNAMELEN];
@@ -88,12 +103,14 @@
uint64_t partition_start_sector;
uint64_t partition_size;
int partition_type;
+ auto_size_units_t partition_size_units;
} auto_partition_info;
typedef struct {
char slice_action[MAXNAMELEN];
int slice_number;
uint64_t slice_size;
+ auto_size_units_t slice_size_units;
} auto_slice_info;
typedef struct {
--- a/usr/src/cmd/auto-install/auto_parse.c Wed Jan 14 13:58:00 2009 +0100
+++ b/usr/src/cmd/auto-install/auto_parse.c Thu Jan 15 07:13:03 2009 -0700
@@ -27,7 +27,6 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
-#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <locale.h>
@@ -336,6 +335,42 @@
(api + i)->partition_type = atoi(p[i]);
}
+ p = get_manifest_element_array(
+ "ai_manifest/ai_device_partitioning/partition_size_units");
+ /* partition size units can be sectors, GB, TB, or MB (default) */
+ if (p != NULL) {
+ for (i = 0; i < len; i++) {
+ if (p[i] == NULL) { /* default to MB */
+ (api + i)->partition_size_units =
+ AI_SIZE_UNITS_MEGABYTES;
+ continue;
+ }
+ switch (p[i][0]) {
+ case 's':
+ case 'S':
+ (api + i)->partition_size_units =
+ AI_SIZE_UNITS_SECTORS;
+ break;
+ case 'g':
+ case 'G':
+ (api + i)->partition_size_units =
+ AI_SIZE_UNITS_GIGABYTES;
+ break;
+ case 't':
+ case 'T':
+ (api + i)->partition_size_units =
+ AI_SIZE_UNITS_TERABYTES;
+ break;
+ case 'm':
+ case 'M':
+ default:
+ (api + i)->partition_size_units =
+ AI_SIZE_UNITS_MEGABYTES;
+ break;
+ }
+ }
+ }
+
return (api);
}
@@ -375,6 +410,42 @@
for (i = 0; i < len; i++)
(asi + i)->slice_size =
(uint64_t)strtoull(p[i], NULL, 0);
+
+ p = get_manifest_element_array(
+ "ai_manifest/ai_device_vtoc_slices/slice_size_units");
+ /* slice size units can be sectors, GB, TB, or MB (default) */
+ if (p != NULL) {
+ for (i = 0; i < len; i++) {
+ if (p[i] == NULL) { /* default to MB */
+ (asi + i)->slice_size_units =
+ AI_SIZE_UNITS_MEGABYTES;
+ continue;
+ }
+ switch (p[i][0]) {
+ case 's':
+ case 'S':
+ (asi + i)->slice_size_units =
+ AI_SIZE_UNITS_SECTORS;
+ break;
+ case 'g':
+ case 'G':
+ (asi + i)->slice_size_units =
+ AI_SIZE_UNITS_GIGABYTES;
+ break;
+ case 't':
+ case 'T':
+ (asi + i)->slice_size_units =
+ AI_SIZE_UNITS_TERABYTES;
+ break;
+ case 'm':
+ case 'M':
+ default:
+ (asi + i)->slice_size_units =
+ AI_SIZE_UNITS_MEGABYTES;
+ break;
+ }
+ }
+ }
return (asi);
}