summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/sys/boot/common/disk.c29
-rw-r--r--usr/src/boot/sys/boot/common/part.c49
-rw-r--r--usr/src/boot/sys/boot/common/part.h10
4 files changed, 71 insertions, 19 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index 143e416056..f7de1f0e03 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2018.11.05.1
+BOOT_VERSION = $(LOADER_VERSION)-2018.12.11.1
diff --git a/usr/src/boot/sys/boot/common/disk.c b/usr/src/boot/sys/boot/common/disk.c
index 7d48e2842a..15c52c6011 100644
--- a/usr/src/boot/sys/boot/common/disk.c
+++ b/usr/src/boot/sys/boot/common/disk.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org>
* All rights reserved.
@@ -36,16 +36,16 @@
#include "disk.h"
#ifdef DISK_DEBUG
-# define DEBUG(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args)
+#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
#else
-# define DEBUG(fmt, args...)
+#define DEBUG(fmt, args...)
#endif
struct open_disk {
struct ptable *table;
uint64_t mediasize;
uint64_t entrysize;
- u_int sectorsize;
+ uint_t sectorsize;
};
struct print_args {
@@ -56,7 +56,7 @@ struct print_args {
/* Convert size to a human-readable number. */
static char *
-display_size(uint64_t size, u_int sectorsize)
+display_size(uint64_t size, uint_t sectorsize)
{
static char buf[80];
char unit;
@@ -96,7 +96,7 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t offset)
* As the GPT backup partition is located at the end of the disk,
* to avoid reading past disk end, flag bcache not to use RA.
*/
- return (dev->dd.d_dev->dv_strategy(dev, F_READ | F_NORA , offset,
+ return (dev->dd.d_dev->dv_strategy(dev, F_READ | F_NORA, offset,
blocks * od->sectorsize, (char *)buf, NULL));
}
@@ -170,7 +170,7 @@ disk_print(struct disk_devdesc *dev, char *prefix, int verbose)
}
int
-disk_read(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
+disk_read(struct disk_devdesc *dev, void *buf, uint64_t offset, uint_t blocks)
{
struct open_disk *od;
int ret;
@@ -183,7 +183,7 @@ disk_read(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
}
int
-disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
+disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset, uint_t blocks)
{
struct open_disk *od;
int ret;
@@ -196,7 +196,7 @@ disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
}
int
-disk_ioctl(struct disk_devdesc *dev, u_long cmd, void *data)
+disk_ioctl(struct disk_devdesc *dev, unsigned long cmd, void *data)
{
struct open_disk *od = dev->dd.d_opendata;
@@ -205,7 +205,7 @@ disk_ioctl(struct disk_devdesc *dev, u_long cmd, void *data)
switch (cmd) {
case DIOCGSECTORSIZE:
- *(u_int *)data = od->sectorsize;
+ *(uint_t *)data = od->sectorsize;
break;
case DIOCGMEDIASIZE:
if (dev->d_offset == 0)
@@ -221,7 +221,7 @@ disk_ioctl(struct disk_devdesc *dev, u_long cmd, void *data)
}
int
-disk_open(struct disk_devdesc *dev, uint64_t mediasize, u_int sectorsize)
+disk_open(struct disk_devdesc *dev, uint64_t mediasize, uint_t sectorsize)
{
struct open_disk *od;
struct ptable *table;
@@ -237,7 +237,7 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, u_int sectorsize)
table = NULL;
slice = dev->d_slice;
partition = dev->d_partition;
- od = (struct open_disk *)malloc(sizeof(struct open_disk));
+ od = (struct open_disk *)malloc(sizeof (struct open_disk));
if (od == NULL) {
DEBUG("no memory");
return (ENOMEM);
@@ -272,6 +272,9 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, u_int sectorsize)
dev->d_offset = part.start;
od->entrysize = part.end - part.start + 1;
}
+ } else if (ptable_gettype(od->table) == PTABLE_ISO9660) {
+ dev->d_offset = 0;
+ od->entrysize = mediasize;
} else if (slice >= 0) {
/* Try to get information about partition */
if (slice == 0)
@@ -358,7 +361,7 @@ disk_close(struct disk_devdesc *dev)
return (0);
}
-char*
+char *
disk_fmtdev(struct disk_devdesc *dev)
{
static char buf[128];
diff --git a/usr/src/boot/sys/boot/common/part.c b/usr/src/boot/sys/boot/common/part.c
index 25a9cf98a0..0193c9ae14 100644
--- a/usr/src/boot/sys/boot/common/part.c
+++ b/usr/src/boot/sys/boot/common/part.c
@@ -36,6 +36,8 @@
#include <sys/queue.h>
#include <sys/vtoc.h>
+#include <fs/cd9660/iso.h>
+
#include <zlib.h>
#include <part.h>
#include <uuid.h>
@@ -101,6 +103,7 @@ static struct parttypes {
{ PART_LINUX, "Linux" },
{ PART_LINUX_SWAP, "Linux swap" },
{ PART_DOS, "DOS/Windows" },
+ { PART_ISO9660, "ISO9660" },
{ PART_SOLARIS2, "Solaris 2" },
{ PART_ILLUMOS_UFS, "illumos UFS" },
{ PART_ILLUMOS_ZFS, "illumos ZFS" },
@@ -710,6 +713,45 @@ out:
return (table);
}
+#define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / table->sectorsize)
+
+static struct ptable *
+ptable_iso9660read(struct ptable *table, void *dev, diskread_t dread)
+{
+ uint8_t *buf;
+ struct iso_primary_descriptor *vd;
+ struct pentry *entry;
+
+ buf = malloc(table->sectorsize);
+ if (buf == NULL)
+ return (table);
+
+ if (dread(dev, buf, 1, cdb2devb(16)) != 0) {
+ DEBUG("read failed");
+ ptable_close(table);
+ table = NULL;
+ goto out;
+ }
+ vd = (struct iso_primary_descriptor *)buf;
+ if (bcmp(vd->id, ISO_STANDARD_ID, sizeof (vd->id)) != 0)
+ goto out;
+
+ entry = malloc(sizeof (*entry));
+ if (entry == NULL)
+ goto out;
+ entry->part.start = 0;
+ entry->part.end = table->sectors;
+ entry->part.type = PART_ISO9660;
+ entry->part.index = 0;
+ STAILQ_INSERT_TAIL(&table->entries, entry, entry);
+
+ table->type = PTABLE_ISO9660;
+
+out:
+ free(buf);
+ return (table);
+}
+
struct ptable *
ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
{
@@ -740,6 +782,13 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread)
table->type = PTABLE_NONE;
STAILQ_INIT(&table->entries);
+ if (ptable_iso9660read(table, dev, dread) == NULL) {
+ /* Read error. */
+ table = NULL;
+ goto out;
+ } else if (table->type == PTABLE_ISO9660)
+ goto out;
+
if (ptable_dklabelread(table, dev, dread) == NULL) { /* Read error. */
table = NULL;
goto out;
diff --git a/usr/src/boot/sys/boot/common/part.h b/usr/src/boot/sys/boot/common/part.h
index a554016d92..2881c78b64 100644
--- a/usr/src/boot/sys/boot/common/part.h
+++ b/usr/src/boot/sys/boot/common/part.h
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org>
* All rights reserved.
*
@@ -22,8 +22,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#ifndef _PART_H_
@@ -37,7 +35,8 @@ enum ptable_type {
PTABLE_MBR,
PTABLE_GPT,
PTABLE_VTOC8,
- PTABLE_VTOC
+ PTABLE_VTOC,
+ PTABLE_ISO9660
};
enum partition_type {
@@ -53,6 +52,7 @@ enum partition_type {
PART_LINUX,
PART_LINUX_SWAP,
PART_DOS,
+ PART_ISO9660,
PART_SOLARIS2,
PART_ILLUMOS_UFS,
PART_ILLUMOS_ZFS,
@@ -64,7 +64,7 @@ enum partition_type {
PART_VTOC_BACKUP,
PART_VTOC_STAND,
PART_VTOC_VAR,
- PART_VTOC_HOME,
+ PART_VTOC_HOME
};
struct ptable_entry {