1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /* ONC_PLUS EXTRACT START */
22 /*
23 * Copyright (c) 1982, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25 /* ONC_PLUS EXTRACT END */
26
27 /*
28 * Configure root, swap and dump devices.
29 */
30
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <sys/sysmacros.h>
34 #include <sys/signal.h>
35 #include <sys/cred.h>
36 #include <sys/proc.h>
37 #include <sys/user.h>
38 #include <sys/conf.h>
39 #include <sys/buf.h>
40 #include <sys/systm.h>
41 #include <sys/vm.h>
42 #include <sys/reboot.h>
43 #include <sys/file.h>
44 #include <sys/vfs.h>
45 #include <sys/vnode.h>
309 if (boothowto & RB_ASKNAME) {
310 printf("%s name: ", askfor);
311 console_gets(name, namelen);
312 }
313 }
314
315 /*ARGSUSED1*/
316 static int
317 preload_module(struct sysparam *sysp, void *p)
318 {
319 static char *wmesg = "forceload of %s failed";
320 char *name;
321
322 name = sysp->sys_ptr;
323 BMDPRINTF(("preload_module: %s\n", name));
324 if (modloadonly(NULL, name) < 0)
325 cmn_err(CE_WARN, wmesg, name);
326 return (0);
327 }
328
329 /* ONC_PLUS EXTRACT START */
330 /*
331 * We want to load all the modules needed to mount the root filesystem,
332 * so that when we start the ball rolling in 'getrootdev', every module
333 * should already be in memory, just waiting to be init-ed.
334 */
335
336 int
337 loadrootmodules(void)
338 {
339 struct vfssw *vsw;
340 char *this;
341 char *name;
342 int err;
343 /* ONC_PLUS EXTRACT END */
344 int i, proplen;
345 extern char *impl_module_list[];
346 extern char *platform_module_list[];
347
348 /* Make sure that the PROM's devinfo tree has been created */
349 ASSERT(ddi_root_node());
350
351 BMDPRINTF(("loadrootmodules: fstype %s\n", rootfs.bo_fstype));
352 BMDPRINTF(("loadrootmodules: name %s\n", rootfs.bo_name));
353 BMDPRINTF(("loadrootmodules: flags 0x%x\n", rootfs.bo_flags));
354
355 /*
356 * zzz We need to honor what's in rootfs if it's not null.
357 * non-null means use what's there. This way we can
358 * change rootfs with /etc/system AND with tunetool.
359 */
360 if (root_is_svm) {
361 /* user replaced rootdev, record obp_bootpath */
362 obp_bootpath[0] = '\0';
363 (void) getphysdev("root", obp_bootpath, BO_MAXOBJNAME);
466 if (proplen > 0) {
467 netdev_path = kmem_zalloc(proplen, KM_SLEEP);
468 if (BOP_GETPROP(bootops, "netdev-path",
469 (uchar_t *)netdev_path) == -1) {
470 cmn_err(CE_WARN, "BOP_GETPROP of "
471 "\"netdev-path\" failed\n");
472 kmem_free(netdev_path, proplen);
473 goto out;
474 }
475 }
476 }
477
478 /*
479 * Preload (load-only, no init) all modules which
480 * were added to the /etc/system file with the
481 * FORCELOAD keyword.
482 */
483 BMDPRINTF(("loadrootmodules: preload_module\n"));
484 (void) mod_sysctl_type(MOD_FORCELOAD, preload_module, NULL);
485
486 /* ONC_PLUS EXTRACT START */
487 /*
488 * If we booted otw then load in the plumbing
489 * routine now while we still can. If we didn't
490 * boot otw then we will load strplumb in main().
491 *
492 * NFS is actually a set of modules, the core routines,
493 * a diskless helper module, rpcmod, and the tli interface. Load
494 * them now while we still can.
495 *
496 * Because we glomb all versions of nfs into a single module
497 * we check based on the initial string "nfs".
498 *
499 * XXX: A better test for this is to see if device_type
500 * XXX: from the PROM is "network".
501 */
502
503 if (strncmp(rootfs.bo_fstype, "nfs", 3) == 0) {
504 ++netboot;
505
506 /*
565 }
566 if ((err = modload("misc", "strplumb")) < 0) {
567 cmn_err(CE_CONT, "Cannot load misc/strplumb\n");
568 goto out;
569 }
570 if ((err = strplumb_load()) < 0) {
571 goto out;
572 }
573 }
574 /*
575 * Preload modules needed for booting as a cluster.
576 */
577 err = clboot_loadrootmodules();
578
579 out:
580 if (err != 0 && (boothowto & RB_ASKNAME))
581 goto loop;
582
583 return (err);
584 }
585 /* ONC_PLUS EXTRACT END */
586
587 static int
588 get_bootpath_prop(char *bootpath)
589 {
590 if (root_is_ramdisk) {
591 if (BOP_GETPROP(bootops, "bootarchive", bootpath) == -1)
592 return (-1);
593 (void) strlcat(bootpath, ":a", BO_MAXOBJNAME);
594 } else {
595 /*
596 * Look for the 1275 compliant name 'bootpath' first,
597 * but make certain it has a non-NULL value as well.
598 */
599 if ((BOP_GETPROP(bootops, "bootpath", bootpath) == -1) ||
600 strlen(bootpath) == 0) {
601 if (BOP_GETPROP(bootops,
602 "boot-path", bootpath) == -1)
603 return (-1);
604 }
605 if (memcmp(bootpath, BP_ISCSI_DISK,
|
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 1982, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 /*
26 * Configure root, swap and dump devices.
27 */
28
29 #include <sys/types.h>
30 #include <sys/param.h>
31 #include <sys/sysmacros.h>
32 #include <sys/signal.h>
33 #include <sys/cred.h>
34 #include <sys/proc.h>
35 #include <sys/user.h>
36 #include <sys/conf.h>
37 #include <sys/buf.h>
38 #include <sys/systm.h>
39 #include <sys/vm.h>
40 #include <sys/reboot.h>
41 #include <sys/file.h>
42 #include <sys/vfs.h>
43 #include <sys/vnode.h>
307 if (boothowto & RB_ASKNAME) {
308 printf("%s name: ", askfor);
309 console_gets(name, namelen);
310 }
311 }
312
313 /*ARGSUSED1*/
314 static int
315 preload_module(struct sysparam *sysp, void *p)
316 {
317 static char *wmesg = "forceload of %s failed";
318 char *name;
319
320 name = sysp->sys_ptr;
321 BMDPRINTF(("preload_module: %s\n", name));
322 if (modloadonly(NULL, name) < 0)
323 cmn_err(CE_WARN, wmesg, name);
324 return (0);
325 }
326
327 /*
328 * We want to load all the modules needed to mount the root filesystem,
329 * so that when we start the ball rolling in 'getrootdev', every module
330 * should already be in memory, just waiting to be init-ed.
331 */
332
333 int
334 loadrootmodules(void)
335 {
336 struct vfssw *vsw;
337 char *this;
338 char *name;
339 int err;
340 int i, proplen;
341 extern char *impl_module_list[];
342 extern char *platform_module_list[];
343
344 /* Make sure that the PROM's devinfo tree has been created */
345 ASSERT(ddi_root_node());
346
347 BMDPRINTF(("loadrootmodules: fstype %s\n", rootfs.bo_fstype));
348 BMDPRINTF(("loadrootmodules: name %s\n", rootfs.bo_name));
349 BMDPRINTF(("loadrootmodules: flags 0x%x\n", rootfs.bo_flags));
350
351 /*
352 * zzz We need to honor what's in rootfs if it's not null.
353 * non-null means use what's there. This way we can
354 * change rootfs with /etc/system AND with tunetool.
355 */
356 if (root_is_svm) {
357 /* user replaced rootdev, record obp_bootpath */
358 obp_bootpath[0] = '\0';
359 (void) getphysdev("root", obp_bootpath, BO_MAXOBJNAME);
462 if (proplen > 0) {
463 netdev_path = kmem_zalloc(proplen, KM_SLEEP);
464 if (BOP_GETPROP(bootops, "netdev-path",
465 (uchar_t *)netdev_path) == -1) {
466 cmn_err(CE_WARN, "BOP_GETPROP of "
467 "\"netdev-path\" failed\n");
468 kmem_free(netdev_path, proplen);
469 goto out;
470 }
471 }
472 }
473
474 /*
475 * Preload (load-only, no init) all modules which
476 * were added to the /etc/system file with the
477 * FORCELOAD keyword.
478 */
479 BMDPRINTF(("loadrootmodules: preload_module\n"));
480 (void) mod_sysctl_type(MOD_FORCELOAD, preload_module, NULL);
481
482 /*
483 * If we booted otw then load in the plumbing
484 * routine now while we still can. If we didn't
485 * boot otw then we will load strplumb in main().
486 *
487 * NFS is actually a set of modules, the core routines,
488 * a diskless helper module, rpcmod, and the tli interface. Load
489 * them now while we still can.
490 *
491 * Because we glomb all versions of nfs into a single module
492 * we check based on the initial string "nfs".
493 *
494 * XXX: A better test for this is to see if device_type
495 * XXX: from the PROM is "network".
496 */
497
498 if (strncmp(rootfs.bo_fstype, "nfs", 3) == 0) {
499 ++netboot;
500
501 /*
560 }
561 if ((err = modload("misc", "strplumb")) < 0) {
562 cmn_err(CE_CONT, "Cannot load misc/strplumb\n");
563 goto out;
564 }
565 if ((err = strplumb_load()) < 0) {
566 goto out;
567 }
568 }
569 /*
570 * Preload modules needed for booting as a cluster.
571 */
572 err = clboot_loadrootmodules();
573
574 out:
575 if (err != 0 && (boothowto & RB_ASKNAME))
576 goto loop;
577
578 return (err);
579 }
580
581 static int
582 get_bootpath_prop(char *bootpath)
583 {
584 if (root_is_ramdisk) {
585 if (BOP_GETPROP(bootops, "bootarchive", bootpath) == -1)
586 return (-1);
587 (void) strlcat(bootpath, ":a", BO_MAXOBJNAME);
588 } else {
589 /*
590 * Look for the 1275 compliant name 'bootpath' first,
591 * but make certain it has a non-NULL value as well.
592 */
593 if ((BOP_GETPROP(bootops, "bootpath", bootpath) == -1) ||
594 strlen(bootpath) == 0) {
595 if (BOP_GETPROP(bootops,
596 "boot-path", bootpath) == -1)
597 return (-1);
598 }
599 if (memcmp(bootpath, BP_ISCSI_DISK,
|