summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2020-12-02 10:19:05 -0500
committerDan McDonald <danmcd@joyent.com>2020-12-02 10:19:06 -0500
commitd79b46fa6a6b38bd45268af896a043dde714b38a (patch)
tree60bcbe653139d492d2bfcc23141f3c039457bf38
parent99f76d09704e2a55d2d5fda310f907fdfbdf0684 (diff)
parent7b4214534ccdf6f8aa6e566d7501aab328c72e84 (diff)
downloadillumos-joyent-d79b46fa6a6b38bd45268af896a043dde714b38a.tar.gz
[illumos-gate merge]release-20201203
commit 7b4214534ccdf6f8aa6e566d7501aab328c72e84 13324 struct dk_minfo_ext size differences trigger SSP in libfdisk commit 63f9f2ff473e9cb7f455f032fe3d04a95ec4b537 13332 loader: iterate consoles to draw loader menu screen Conflicts: usr/src/boot/sys/boot/forth/support.4th usr/src/boot/sys/boot/forth/Makefile.inc
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/sys/boot/forth/Makefile.inc3
-rw-r--r--usr/src/boot/sys/boot/forth/beastie.4th14
-rw-r--r--usr/src/boot/sys/boot/forth/brand-illumos.4th18
-rw-r--r--usr/src/boot/sys/boot/forth/brand.4th14
-rw-r--r--usr/src/boot/sys/boot/forth/color.4th18
-rw-r--r--usr/src/boot/sys/boot/forth/illumos-brand.pngbin0 -> 37587 bytes
-rw-r--r--usr/src/boot/sys/boot/forth/illumos-logo.png (renamed from usr/src/boot/sys/boot/forth/illumos.png)bin11979 -> 11979 bytes
-rw-r--r--usr/src/boot/sys/boot/forth/logo-illumos.4th11
-rw-r--r--usr/src/boot/sys/boot/forth/menu.4th2
-rw-r--r--usr/src/boot/sys/boot/forth/support.4th76
-rw-r--r--usr/src/common/ficl/loader.c51
-rw-r--r--usr/src/pkg/manifests/system-boot-loader.mf3
-rw-r--r--usr/src/uts/common/fs/zfs/zvol.c13
-rw-r--r--usr/src/uts/common/io/blkdev/blkdev.c13
-rw-r--r--usr/src/uts/common/io/lofi.c9
-rw-r--r--usr/src/uts/common/io/scsi/targets/sd.c13
-rw-r--r--usr/src/uts/common/sys/dkio.h17
18 files changed, 239 insertions, 38 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index d4000c0baf..fd51c7e769 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -34,4 +34,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)-2020.11.27.1
+BOOT_VERSION = $(LOADER_VERSION)-2020.11.27.2
diff --git a/usr/src/boot/sys/boot/forth/Makefile.inc b/usr/src/boot/sys/boot/forth/Makefile.inc
index 09ff345596..4365fb4610 100644
--- a/usr/src/boot/sys/boot/forth/Makefile.inc
+++ b/usr/src/boot/sys/boot/forth/Makefile.inc
@@ -26,6 +26,7 @@ FORTH += screen.4th
FORTH += shortcuts.4th
FORTH += support.4th
FORTH += version.4th
-FILES += illumos.png
+FILES += illumos-logo.png
+FILES += illumos-brand.png
FILES += joyent.png
FILES += triton.png
diff --git a/usr/src/boot/sys/boot/forth/beastie.4th b/usr/src/boot/sys/boot/forth/beastie.4th
index cba112281a..874e19a9d9 100644
--- a/usr/src/boot/sys/boot/forth/beastie.4th
+++ b/usr/src/boot/sys/boot/forth/beastie.4th
@@ -2,7 +2,7 @@
\ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
\ All rights reserved.
-\
+\
\ Redistribution and use in source and binary forms, with or without
\ modification, are permitted provided that the following conditions
\ are met:
@@ -11,7 +11,7 @@
\ 2. Redistributions in binary form must reproduce the above copyright
\ notice, this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
-\
+\
\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -23,8 +23,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$
marker task-beastie.4th
@@ -40,11 +38,11 @@ variable logoY
\ This function draws any number of beastie logos at (loader_logo_x,
\ loader_logo_y) if defined, else (46,4) (to the right of the menu). To choose
\ your beastie, set the variable `loader_logo' to the respective logo name.
-\
+\
\ NOTE: Each is defined as a logo function in /boot/logo-${loader_logo}.4th
\ NOTE: If `/boot/logo-${loader_logo}.4th' does not exist or does not define
\ a `logo' function, no beastie is drawn.
-\
+\
: draw-beastie ( -- ) \ at (loader_logo_x,loader_logo_y), else (46,4)
s" loader_logo_x" getenv dup -1 <> if
@@ -82,6 +80,10 @@ variable logoY
then
;
+: draw-beastie
+ ['] draw-beastie console-iterate
+;
+
also support-functions
: beastie-start ( -- ) \ starts the menu
diff --git a/usr/src/boot/sys/boot/forth/brand-illumos.4th b/usr/src/boot/sys/boot/forth/brand-illumos.4th
index 9859623aa6..3122af6ec0 100644
--- a/usr/src/boot/sys/boot/forth/brand-illumos.4th
+++ b/usr/src/boot/sys/boot/forth/brand-illumos.4th
@@ -1,6 +1,6 @@
\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
\ All rights reserved.
-\
+\
\ Redistribution and use in source and binary forms, with or without
\ modification, are permitted provided that the following conditions
\ are met:
@@ -9,7 +9,7 @@
\ 2. Redistributions in binary form must reproduce the above copyright
\ notice, this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
-\
+\
\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -21,8 +21,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$
2 brandX ! 1 brandY ! \ Initialize brand placement defaults
@@ -34,6 +32,18 @@
: brand ( x y -- ) \ "illumos" [wide] logo in B/W (5 rows x 39 columns)
+ framebuffer? if
+ s" term-putimage" sfind if
+ \ note, we use 0, 0 for image upper left as origin,
+ \ and 0, 7 for lower right to preserve aspect ratio
+ >r 0 0 0 0 7
+ s" /boot/illumos-brand.png"
+ r> execute if 2drop exit then
+ else
+ drop
+ then
+ then
+
s" _ _ _ " brand+
s" (_)| || | _ _ _ __ ___ ___ ___ " brand+
s" | || || || | | || '_ ` _ \ / _ \ / __|" brand+
diff --git a/usr/src/boot/sys/boot/forth/brand.4th b/usr/src/boot/sys/boot/forth/brand.4th
index 2caadcbaf5..c86b955602 100644
--- a/usr/src/boot/sys/boot/forth/brand.4th
+++ b/usr/src/boot/sys/boot/forth/brand.4th
@@ -1,6 +1,6 @@
\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
\ All rights reserved.
-\
+\
\ Redistribution and use in source and binary forms, with or without
\ modification, are permitted provided that the following conditions
\ are met:
@@ -9,7 +9,7 @@
\ 2. Redistributions in binary form must reproduce the above copyright
\ notice, this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
-\
+\
\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -21,8 +21,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$
marker task-brand.4th
@@ -36,11 +34,11 @@ variable brandY
\ This function draws any number of company brands at (loader_brand_x,
\ loader_brand_y) if defined, or (2,1) (top-left). To choose your brand, set
\ the variable `loader_brand' to the respective brand name.
-\
+\
\ NOTE: Each is defined as a brand function in /boot/brand-${loader_brand}.4th
\ NOTE: If `/boot/brand-${loader_brand}.4th' does not exist or does not define
\ a `brand' function, no brand is drawn.
-\
+\
: draw-brand ( -- ) \ at (loader_brand_x,loader_brand_y), else (2,1)
s" loader_brand_x" getenv dup -1 <> if
@@ -72,3 +70,7 @@ variable brandY
else drop then
then
;
+
+: draw-brand
+ ['] draw-brand console-iterate
+;
diff --git a/usr/src/boot/sys/boot/forth/color.4th b/usr/src/boot/sys/boot/forth/color.4th
index 65e6de905a..09b2c39ebf 100644
--- a/usr/src/boot/sys/boot/forth/color.4th
+++ b/usr/src/boot/sys/boot/forth/color.4th
@@ -1,6 +1,6 @@
\ Copyright (c) 2011-2013 Devin Teske <dteske@FreeBSD.org>
\ All rights reserved.
-\
+\
\ Redistribution and use in source and binary forms, with or without
\ modification, are permitted provided that the following conditions
\ are met:
@@ -9,7 +9,7 @@
\ 2. Redistributions in binary form must reproduce the above copyright
\ notice, this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
-\
+\
\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -21,18 +21,18 @@
\ 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$
+\
marker task-color.4th
\ This function returns FALSE if the `loader_color' environment variable is set
-\ to NO, no, or 0. Otherwise, TRUE is returned (unless booting serial).
-\
+\ to NO, no, or 0. Otherwise, TRUE is returned.
+\
: loader_color? ( -- N )
s" loader_color" getenv dup -1 <> if
-
+ \ `loader_color' is set.
+ \ Check if it is explicitly disabled.
2dup s" NO" compare-insensitive 0= if
2drop
FALSE exit
@@ -44,6 +44,6 @@ marker task-color.4th
drop
then
drop
-
- boot_serial? if FALSE else TRUE then
+ \ It is enabled.
+ TRUE
;
diff --git a/usr/src/boot/sys/boot/forth/illumos-brand.png b/usr/src/boot/sys/boot/forth/illumos-brand.png
new file mode 100644
index 0000000000..0679f0d050
--- /dev/null
+++ b/usr/src/boot/sys/boot/forth/illumos-brand.png
Binary files differ
diff --git a/usr/src/boot/sys/boot/forth/illumos.png b/usr/src/boot/sys/boot/forth/illumos-logo.png
index 3af7a2f360..3af7a2f360 100644
--- a/usr/src/boot/sys/boot/forth/illumos.png
+++ b/usr/src/boot/sys/boot/forth/illumos-logo.png
Binary files differ
diff --git a/usr/src/boot/sys/boot/forth/logo-illumos.4th b/usr/src/boot/sys/boot/forth/logo-illumos.4th
index 84948ec3ad..e64895db08 100644
--- a/usr/src/boot/sys/boot/forth/logo-illumos.4th
+++ b/usr/src/boot/sys/boot/forth/logo-illumos.4th
@@ -36,7 +36,16 @@
: logo ( x y -- ) \ color illumos logo
- 0 0 0 0 0 s" /boot/illumos.png" fb-putimage if 2drop exit then
+ framebuffer? if
+ s" term-putimage" sfind if
+ >r over 0 swap ( x y 0 x )
+ 12 0 22 ( x y 0 x 12 0 22 )
+ s" /boot/illumos-logo.png"
+ r> execute if 2drop exit then
+ else
+ drop
+ then
+ then
s" @[33m,@[m " logo+
s" @[33m,./% @[31m&@[m " logo+
diff --git a/usr/src/boot/sys/boot/forth/menu.4th b/usr/src/boot/sys/boot/forth/menu.4th
index 262fd5ca03..39f03e9cd3 100644
--- a/usr/src/boot/sys/boot/forth/menu.4th
+++ b/usr/src/boot/sys/boot/forth/menu.4th
@@ -941,7 +941,7 @@ only forth definitions also menu-infrastructure
then
menuX !
- menu-box
+ ['] menu-box console-iterate
at-bl
;
diff --git a/usr/src/boot/sys/boot/forth/support.4th b/usr/src/boot/sys/boot/forth/support.4th
index 9f4f9ed4d7..961d3b528a 100644
--- a/usr/src/boot/sys/boot/forth/support.4th
+++ b/usr/src/boot/sys/boot/forth/support.4th
@@ -192,6 +192,25 @@ create last_module_option sizeof module.next allot 0 last_module_option !
0 0
;
+: strspn { addr len addr1 len1 | paddr plen -- addr' len' }
+ begin
+ len
+ while
+ addr1 to paddr
+ len1 to plen
+ begin
+ plen
+ while
+ addr c@ paddr c@ = if addr len exit then
+ paddr 1+ to paddr
+ plen 1- to plen
+ repeat
+ addr 1 + to addr
+ len 1 - to len
+ repeat
+ 0 0
+;
+
: s' \ same as s", allows " in the string
[char] ' parse
state @ if postpone sliteral then
@@ -241,10 +260,51 @@ create last_module_option sizeof module.next allot 0 last_module_option !
\
: append over over >r >r count chars + swap chars move r> r> dup >r c@ + r> c! ;
-\ Returns TRUE if the framebuffer is active, FALSE otherwise
-: framebuffer? ( -- flag )
- \ Use the screen-height variable as a proxy for framebuffer
- s" screen-height" getenv?
+\ execute xt for each device listed in console variable.
+\ this allows us to have device specific output for logos, menu frames etc
+: console-iterate { xt | caddr clen taddr tlen -- }
+ \ get current console and save it
+ s" console" getenv
+ ['] strdup catch if 2drop exit then
+ to clen to caddr
+
+ clen to tlen
+ caddr to taddr
+ begin
+ tlen
+ while
+ taddr tlen s" , " strspn
+ \ we need to handle 3 cases for addr len pairs on stack:
+ \ addr len are 0 0 - there was no comma nor space
+ \ addr len are x 0 - the first char is either comma or space
+ \ addr len are x y.
+ 2dup + 0= if
+ \ there was no comma nor space.
+ 2drop
+ taddr tlen s" console" setenv
+ xt execute
+ 0 to tlen
+ else dup 0= if
+ 2drop
+ else
+ dup ( taddr' tlen' tlen' )
+ tlen swap - dup
+ 0= if \ sequence of comma and space?
+ drop
+ else
+ taddr swap s" console" setenv
+ xt execute
+ then
+ to tlen
+ to taddr
+ then then
+ tlen 0> if \ step over separator
+ tlen 1- to tlen
+ taddr 1+ to taddr
+ then
+ repeat
+ caddr clen s" console" setenv \ restore console setup
+ caddr free drop
;
\ Test if booted in an EFI environment
@@ -300,6 +360,14 @@ create last_module_option sizeof module.next allot 0 last_module_option !
or \ previous boolean ( or ) boot_multicons
;
+: framebuffer? ( -- t )
+ s" console" getenv
+ s" text" compare 0<> if
+ FALSE exit
+ then
+ s" screen-width" getenv?
+;
+
\ Private definitions
vocabulary support-functions
diff --git a/usr/src/common/ficl/loader.c b/usr/src/common/ficl/loader.c
index c41c86c7c2..c1f5c5d0eb 100644
--- a/usr/src/common/ficl/loader.c
+++ b/usr/src/common/ficl/loader.c
@@ -44,6 +44,7 @@
#else
#include <stand.h>
#include <gfx_fb.h>
+#include <sys/tem_impl.h>
#include "bootstrap.h"
#endif
#ifdef _STANDALONE
@@ -71,6 +72,54 @@
* .# ( value -- )
*/
+#ifdef _STANDALONE
+/* Put image using terminal coordinates. ( flags x1 y1 x2 y2 -- flag ) */
+void
+ficl_term_putimage(ficlVm *pVM)
+{
+ char *namep, *name;
+ ficlUnsigned names;
+ ficlInteger ret = FICL_FALSE;
+ uint32_t x1, y1, x2, y2, f;
+ png_t png;
+
+ FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 7, 1);
+
+ names = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
+ namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
+ y2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
+ x2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
+ y1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
+ x1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
+ f = ficlStackPopUnsigned(ficlVmGetDataStack(pVM));
+
+ x1 = tems.ts_p_offset.x + x1 * tems.ts_font.vf_width;
+ y1 = tems.ts_p_offset.y + y1 * tems.ts_font.vf_height;
+ if (x2 != 0) {
+ x2 = tems.ts_p_offset.x +
+ x2 * tems.ts_font.vf_width;
+ }
+ if (y2 != 0) {
+ y2 = tems.ts_p_offset.y +
+ y2 * tems.ts_font.vf_height;
+ }
+
+ name = ficlMalloc(names + 1);
+ if (!name)
+ ficlVmThrowError(pVM, "Error: out of memory");
+ (void) strncpy(name, namep, names);
+ name[names] = '\0';
+
+ if (png_open(&png, name) == PNG_NO_ERROR) {
+ if (gfx_fb_putimage(&png, x1, y1, x2, y2, f) == 0)
+ ret = FICL_TRUE; /* success */
+ (void) png_close(&png);
+ }
+ ficlFree(name);
+ ficlStackPushInteger(ficlVmGetDataStack(pVM), ret);
+}
+#endif
+
/* ( flags x1 y1 x2 y2 -- flag ) */
void
ficl_fb_putimage(ficlVm *pVM)
@@ -1057,6 +1106,8 @@ ficlSystemCompilePlatform(ficlSystem *pSys)
(void) ficlDictionarySetPrimitive(dp, "term-drawrect",
ficl_term_drawrect, FICL_WORD_DEFAULT);
#ifdef _STANDALONE
+ (void) ficlDictionarySetPrimitive(dp, "term-putimage",
+ ficl_term_putimage, FICL_WORD_DEFAULT);
/* Register words from linker set. */
SET_FOREACH(fnpp, Xficl_compile_set)
(*fnpp)(pSys);
diff --git a/usr/src/pkg/manifests/system-boot-loader.mf b/usr/src/pkg/manifests/system-boot-loader.mf
index 97fdeac2d3..2073af2013 100644
--- a/usr/src/pkg/manifests/system-boot-loader.mf
+++ b/usr/src/pkg/manifests/system-boot-loader.mf
@@ -72,7 +72,8 @@ $(i386_ONLY)file path=boot/forth/shortcuts.4th group=sys mode=0444
$(i386_ONLY)file path=boot/forth/support.4th group=sys mode=0444
$(i386_ONLY)file path=boot/forth/version.4th group=sys mode=0444
$(i386_ONLY)file path=boot/gptzfsboot group=sys mode=0444
-$(i386_ONLY)file path=boot/illumos.png group=sys mode=0444
+$(i386_ONLY)file path=boot/illumos-brand.png group=sys mode=0444
+$(i386_ONLY)file path=boot/illumos-logo.png group=sys mode=0444
$(i386_ONLY)file path=boot/isoboot group=sys mode=0444
$(i386_ONLY)file path=boot/loader group=sys mode=0444
$(i386_ONLY)file path=boot/loader.help group=sys mode=0444
diff --git a/usr/src/uts/common/fs/zfs/zvol.c b/usr/src/uts/common/fs/zfs/zvol.c
index 2495fb015d..efc2ba6c2d 100644
--- a/usr/src/uts/common/fs/zfs/zvol.c
+++ b/usr/src/uts/common/fs/zfs/zvol.c
@@ -1767,6 +1767,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
case DKIOCGMEDIAINFOEXT:
{
struct dk_minfo_ext dkmext;
+ size_t len;
bzero(&dkmext, sizeof (dkmext));
dkmext.dki_lbsize = 1U << zv->zv_min_bs;
@@ -1774,7 +1775,17 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
dkmext.dki_capacity = zv->zv_volsize >> zv->zv_min_bs;
dkmext.dki_media_type = DK_UNKNOWN;
mutex_exit(&zfsdev_state_lock);
- if (ddi_copyout(&dkmext, (void *)arg, sizeof (dkmext), flag))
+
+ switch (ddi_model_convert_from(flag & FMODELS)) {
+ case DDI_MODEL_ILP32:
+ len = sizeof (struct dk_minfo_ext32);
+ break;
+ default:
+ len = sizeof (struct dk_minfo_ext);
+ break;
+ }
+
+ if (ddi_copyout(&dkmext, (void *)arg, len, flag))
error = SET_ERROR(EFAULT);
return (error);
}
diff --git a/usr/src/uts/common/io/blkdev/blkdev.c b/usr/src/uts/common/io/blkdev/blkdev.c
index e9734d1672..c0bdb3dab2 100644
--- a/usr/src/uts/common/io/blkdev/blkdev.c
+++ b/usr/src/uts/common/io/blkdev/blkdev.c
@@ -1510,6 +1510,7 @@ bd_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *credp, int *rvalp)
}
case DKIOCGMEDIAINFOEXT: {
struct dk_minfo_ext miext;
+ size_t len;
/* make sure our state information is current */
bd_update_state(bd);
@@ -1518,7 +1519,17 @@ bd_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *credp, int *rvalp)
miext.dki_lbsize = (1U << bd->d_blkshift);
miext.dki_pbsize = (1U << bd->d_pblkshift);
miext.dki_capacity = bd->d_numblks;
- if (ddi_copyout(&miext, ptr, sizeof (miext), flag)) {
+
+ switch (ddi_model_convert_from(flag & FMODELS)) {
+ case DDI_MODEL_ILP32:
+ len = sizeof (struct dk_minfo_ext32);
+ break;
+ default:
+ len = sizeof (struct dk_minfo_ext);
+ break;
+ }
+
+ if (ddi_copyout(&miext, ptr, len, flag)) {
return (EFAULT);
}
return (0);
diff --git a/usr/src/uts/common/io/lofi.c b/usr/src/uts/common/io/lofi.c
index f59c7ec848..4ccef8c3f4 100644
--- a/usr/src/uts/common/io/lofi.c
+++ b/usr/src/uts/common/io/lofi.c
@@ -3340,7 +3340,14 @@ lofi_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *credp,
if (cmd == DKIOCGMEDIAINFOEXT) {
media_info.dki_pbsize = 1U << lsp->ls_pbshift;
- size = sizeof (struct dk_minfo_ext);
+ switch (ddi_model_convert_from(flag & FMODELS)) {
+ case DDI_MODEL_ILP32:
+ size = sizeof (struct dk_minfo_ext32);
+ break;
+ default:
+ size = sizeof (struct dk_minfo_ext);
+ break;
+ }
} else {
size = sizeof (struct dk_minfo);
}
diff --git a/usr/src/uts/common/io/scsi/targets/sd.c b/usr/src/uts/common/io/scsi/targets/sd.c
index eb694bd3bb..4784fdeec4 100644
--- a/usr/src/uts/common/io/scsi/targets/sd.c
+++ b/usr/src/uts/common/io/scsi/targets/sd.c
@@ -24090,13 +24090,24 @@ sd_get_media_info_ext(dev_t dev, caddr_t arg, int flag)
{
struct dk_minfo_ext mie;
int rval = 0;
+ size_t len;
rval = sd_get_media_info_com(dev, &mie.dki_media_type,
&mie.dki_lbsize, &mie.dki_capacity, &mie.dki_pbsize);
if (rval)
return (rval);
- if (ddi_copyout(&mie, arg, sizeof (struct dk_minfo_ext), flag))
+
+ switch (ddi_model_convert_from(flag & FMODELS)) {
+ case DDI_MODEL_ILP32:
+ len = sizeof (struct dk_minfo_ext32);
+ break;
+ default:
+ len = sizeof (struct dk_minfo_ext);
+ break;
+ }
+
+ if (ddi_copyout(&mie, arg, len, flag))
rval = EFAULT;
return (rval);
diff --git a/usr/src/uts/common/sys/dkio.h b/usr/src/uts/common/sys/dkio.h
index 9d88731c5d..e66551fc6d 100644
--- a/usr/src/uts/common/sys/dkio.h
+++ b/usr/src/uts/common/sys/dkio.h
@@ -356,6 +356,23 @@ struct dk_minfo_ext {
uint_t dki_pbsize; /* Physical blocksize of media */
};
+#ifdef _KERNEL
+
+/*
+ * The 32-bit version of the media info API did not end up with a consistent
+ * size in an ILP32 and LP64 interface. While the actual offsets of the members
+ * are the same, the resulting structure size is not.
+ */
+#pragma pack(4)
+struct dk_minfo_ext32 {
+ uint_t dki_media_type; /* Media type or profile info */
+ uint_t dki_lbsize; /* Logical blocksize of media */
+ diskaddr_t dki_capacity; /* Capacity as # of dki_lbsize blks */
+ uint_t dki_pbsize; /* Physical blocksize of media */
+};
+#pragma pack()
+#endif
+
/*
* Media types or profiles known
*/