1 () ()
2
3
4
5 This file and its contents are supplied under the terms of the Common
6 Development and Distribution License ("CDDL"), version 1.0. You may only use
7 this file in accordance with the terms of version 1.0 of the CDDL. A full
8 copy of the text of the CDDL should have accompanied this source. A copy of
9 the CDDL is also available via the Internet at
10 http://www.illumos.org/license/CDDL.
11
12 Copyright 2017 Toomas Soome <tsoome@me.com> Copyright 2019 OmniOS Community
13 Edition (OmniOSce) Association.
14
15 This module is implementing the beadm user command to support listing and
16 switching Boot Environments (BE) from command line and support words to
17 provide data for BE menu in loader menu system. Note: this module needs an
18 update to provide proper BE vocabulary.
19
20 only forth also support-functions also file-processing also file-processing
21 definitions also parser also line-reading definitions also builtins
22 definitions
23
24 variable page_count variable page_remainder 0 page_count ! 0 page_remainder !
25
26 from menu.4th : +c! ( N C-ADDR/U K -- C-ADDR/U ) 3 pick 3 pick ( n c-
27 addr/u k -- n c-addr/u k n c-addr ) rot + c! ( n c-addr/u k n c-addr -- n
28 c-addr/u ) rot drop ( n c-addr/u -- c-addr/u ) ;
29
30 : get_value ( -- ) eat_space line_pointer skip_to_end_of_line
31 line_pointer over - strdup value_buffer strset ['] exit to
32 parsing_function ;
33
109 beadm_bootfs if ( addr len taddr tlen ) 2dup s"
110 chain" compare 0= if drop free-memory free type
111 2dup dup 6 + allocate if ENOMEM throw
112 then dup >R 0 s" chain " strcat
113 2swap strcat ['] evaluate catch drop We
114 are still there? R> free-memory free chain command
115 drop free-memory free addr exit
116 then drop free-memory free type
117 check last char in the name 2dup + c@ [char] : <>
118 if have dataset and need to get zfs:pool/ROOT/be:
119 dup 5 + allocate if ENOMEM throw then 0
120 s" zfs:" strcat 2swap strcat colon+
121 then 2dup s" currdev" setenv drop
122 free-memory else ." No such BE in menu.lst or menu.lst
123 is missing." cr exit then then
124
125 reset BE menu 0 page_count ! need to do: 0 unload drop
126 free-module-options unset the env variables with kernel arguments
127 s" acpi-user-options" unsetenv s" boot-args" unsetenv s" boot_ask"
128 unsetenv s" boot_single" unsetenv s" boot_verbose" unsetenv s"
129 boot_kmdb" unsetenv s" boot_debug" unsetenv s" boot_reconfigure"
130 unsetenv start load config, kernel and modules ." Current
131 boot device: " s" currdev" getenv type cr ;
132
133 beadm list [device] beadm activate BE [device] | device lists BE's from
134 current or specified device /boot/menu.lst file activates specified BE by
135 unloading modules, setting currdev and running start to load configuration.
136 : beadm ( -- ) ( throws: abort ) 0= if ( interpreted ) get_arguments then
137
138 dup 0= if ." Usage:" cr ." beadm activate {beName
139 [device] | device}" cr ." beadm list [device]" cr ." Use lsdev
140 to get device names." cr drop exit then First argument is
141 0 when we're interprated. See support.4th for get_arguments reading the
142 rest of the line and parsing it stack: argN lenN ... arg1 len1 N rotate
143 arg1 len1, dont use argv[] as we want to get arg1 out of stack -rot 2dup
144
145 s" list" compare-insensitive 0= if ( list ) 2drop argc 1 =
146 if ( list currdev ) add dev to list of args and switch to case
147 2 current-dev rot 1 + then 2 = if ( list
148 device ) list-dev exit then ." too many arguments" cr abort then
149 s" activate" compare-insensitive 0= if ( activate ) argc 1 = if (
150 missing be ) drop ." missing bName" cr abort then
151 argc 2 = if ( activate be ) need to set arg list into
|
1 () ()
2
3
4
5 This file and its contents are supplied under the terms of the Common
6 Development and Distribution License ("CDDL"), version 1.0. You may only use
7 this file in accordance with the terms of version 1.0 of the CDDL. A full
8 copy of the text of the CDDL should have accompanied this source. A copy of
9 the CDDL is also available via the Internet at
10 http://www.illumos.org/license/CDDL.
11
12 Copyright 2017 Toomas Soome <tsoome@me.com> Copyright 2019 OmniOS Community
13 Edition (OmniOSce) Association. Copyright 2019 Joyent, Inc.
14
15 This module is implementing the beadm user command to support listing and
16 switching Boot Environments (BE) from command line and support words to
17 provide data for BE menu in loader menu system. Note: this module needs an
18 update to provide proper BE vocabulary.
19
20 only forth also support-functions also file-processing also file-processing
21 definitions also parser also line-reading definitions also builtins
22 definitions
23
24 variable page_count variable page_remainder 0 page_count ! 0 page_remainder !
25
26 from menu.4th : +c! ( N C-ADDR/U K -- C-ADDR/U ) 3 pick 3 pick ( n c-
27 addr/u k -- n c-addr/u k n c-addr ) rot + c! ( n c-addr/u k n c-addr -- n
28 c-addr/u ) rot drop ( n c-addr/u -- c-addr/u ) ;
29
30 : get_value ( -- ) eat_space line_pointer skip_to_end_of_line
31 line_pointer over - strdup value_buffer strset ['] exit to
32 parsing_function ;
33
109 beadm_bootfs if ( addr len taddr tlen ) 2dup s"
110 chain" compare 0= if drop free-memory free type
111 2dup dup 6 + allocate if ENOMEM throw
112 then dup >R 0 s" chain " strcat
113 2swap strcat ['] evaluate catch drop We
114 are still there? R> free-memory free chain command
115 drop free-memory free addr exit
116 then drop free-memory free type
117 check last char in the name 2dup + c@ [char] : <>
118 if have dataset and need to get zfs:pool/ROOT/be:
119 dup 5 + allocate if ENOMEM throw then 0
120 s" zfs:" strcat 2swap strcat colon+
121 then 2dup s" currdev" setenv drop
122 free-memory else ." No such BE in menu.lst or menu.lst
123 is missing." cr exit then then
124
125 reset BE menu 0 page_count ! need to do: 0 unload drop
126 free-module-options unset the env variables with kernel arguments
127 s" acpi-user-options" unsetenv s" boot-args" unsetenv s" boot_ask"
128 unsetenv s" boot_single" unsetenv s" boot_verbose" unsetenv s"
129 boot_kmdb" unsetenv s" boot_drop_into_kmdb" unsetenv s"
130 boot_reconfigure" unsetenv start load config, kernel and
131 modules ." Current boot device: " s" currdev" getenv type cr ;
132
133 beadm list [device] beadm activate BE [device] | device lists BE's from
134 current or specified device /boot/menu.lst file activates specified BE by
135 unloading modules, setting currdev and running start to load configuration.
136 : beadm ( -- ) ( throws: abort ) 0= if ( interpreted ) get_arguments then
137
138 dup 0= if ." Usage:" cr ." beadm activate {beName
139 [device] | device}" cr ." beadm list [device]" cr ." Use lsdev
140 to get device names." cr drop exit then First argument is
141 0 when we're interprated. See support.4th for get_arguments reading the
142 rest of the line and parsing it stack: argN lenN ... arg1 len1 N rotate
143 arg1 len1, dont use argv[] as we want to get arg1 out of stack -rot 2dup
144
145 s" list" compare-insensitive 0= if ( list ) 2drop argc 1 =
146 if ( list currdev ) add dev to list of args and switch to case
147 2 current-dev rot 1 + then 2 = if ( list
148 device ) list-dev exit then ." too many arguments" cr abort then
149 s" activate" compare-insensitive 0= if ( activate ) argc 1 = if (
150 missing be ) drop ." missing bName" cr abort then
151 argc 2 = if ( activate be ) need to set arg list into
|