1 /*- 2 * Copyright (c) 1999 Michael Smith 3 * All rights reserved. 4 * Copyright (c) 1999 Poul-Henning Kamp 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: src/sys/kern/vfs_conf.c,v 1.49.2.5 2003/01/07 11:56:53 joerg Exp $ 29 */ 30 31 /* 32 * Locate and mount the root filesystem. 33 * 34 * The root filesystem is detailed in the kernel environment variable 35 * vfs.root.mountfrom, which is expected to be in the general format 36 * 37 * <vfsname>:[<path>] 38 * vfsname := the name of a VFS known to the kernel and capable 39 * of being mounted as root 40 * path := disk device name or other data used by the filesystem 41 * to locate its physical store 42 * 43 */ 44 45 #include "opt_rootdevname.h" 46 47 #include <sys/param.h> 48 #include <sys/kernel.h> 49 #include <sys/systm.h> 50 #include <sys/proc.h> 51 #include <sys/vnode.h> 52 #include <sys/mount.h> 53 #include <sys/malloc.h> 54 #include <sys/reboot.h> 55 #include <sys/diskslice.h> 56 #include <sys/conf.h> 57 #include <sys/cons.h> 58 #include <sys/kbio.h> 59 #include <sys/device.h> 60 #include <sys/disk.h> 61 #include <sys/namecache.h> 62 #include <sys/paths.h> 63 #include <sys/thread2.h> 64 #include <sys/nlookup.h> 65 #include <sys/devfs.h> 66 #include <sys/sysctl.h> 67 68 #include "opt_ddb.h" 69 #ifdef DDB 70 #include <ddb/ddb.h> 71 #endif 72 73 MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure"); 74 75 #define ROOTNAME "root_device" 76 77 struct vnode *rootvnode; 78 struct nchandle rootnch; 79 80 /* 81 * The root specifiers we will try if RB_CDROM is specified. Note that 82 * with DEVFS we do not use the compatibility slice's whole-disk 'c' 83 * partition. Instead we just use the whole disk, e.g. cd0 or cd0s0. 84 */ 85 static char *cdrom_rootdevnames[] = { 86 "cd9660:cd0", /* SCSI (including AHCI and SILI) */ 87 "cd9660:acd0", /* NATA */ 88 "cd9660:cd1", /* SCSI (including AHCI and SILI) */ 89 "cd9660:acd1", /* NATA */ 90 "cd9660:cd8", /* USB */ 91 "cd9660:cd9", /* USB */ 92 NULL 93 }; 94 95 int vfs_mountroot_devfs(void); 96 static void vfs_mountroot(void *junk); 97 static int vfs_mountroot_try(const char *mountfrom); 98 static int vfs_mountroot_ask(void); 99 static int get_line(char *cp, int limit); 100 101 /* legacy find-root code */ 102 char *rootdevnames[2] = {NULL, NULL}; 103 static int setrootbyname(char *name); 104 105 SYSINIT(mountroot, SI_SUB_MOUNT_ROOT, SI_ORDER_SECOND, vfs_mountroot, NULL); 106 107 static int wakedelay = 2; /* delay before mounting root in seconds */ 108 TUNABLE_INT("vfs.root.wakedelay", &wakedelay); 109 110 /* 111 * Find and mount the root filesystem 112 */ 113 static void 114 vfs_mountroot(void *junk) 115 { 116 cdev_t save_rootdev = rootdev; 117 int i; 118 int dummy; 119 120 /* 121 * Make sure all disk devices created so far have also been probed, 122 * and also make sure that the newly created device nodes for 123 * probed disks are ready, too. 124 * 125 * Messages can fly around here so get good synchronization 126 * coverage. 127 * 128 * XXX - Delay some more (default: 2s) to help drivers which pickup 129 * devices asynchronously and are not caught by CAM's initial 130 * probe. 131 */ 132 sync_devs(); 133 tsleep(&dummy, 0, "syncer", hz * wakedelay); 134 135 136 /* 137 * The root filesystem information is compiled in, and we are 138 * booted with instructions to use it. 139 */ 140 #ifdef ROOTDEVNAME 141 if ((boothowto & RB_DFLTROOT) && 142 !vfs_mountroot_try(ROOTDEVNAME)) 143 return; 144 #endif 145 /* 146 * We are booted with instructions to prompt for the root filesystem, 147 * or to use the compiled-in default when it doesn't exist. 148 */ 149 if (boothowto & (RB_DFLTROOT | RB_ASKNAME)) { 150 if (!vfs_mountroot_ask()) 151 return; 152 } 153 154 /* 155 * We've been given the generic "use CDROM as root" flag. This is 156 * necessary because one media may be used in many different 157 * devices, so we need to search for them. 158 */ 159 if (boothowto & RB_CDROM) { 160 for (i = 0; cdrom_rootdevnames[i] != NULL; i++) { 161 if (!vfs_mountroot_try(cdrom_rootdevnames[i])) 162 return; 163 } 164 } 165 166 /* 167 * Try to use the value read by the loader from /etc/fstab, or 168 * supplied via some other means. This is the preferred 169 * mechanism. 170 */ 171 if (!vfs_mountroot_try(kgetenv("vfs.root.mountfrom"))) 172 return; 173 174 /* 175 * If a vfs set rootdev, try it (XXX VINUM HACK!) 176 */ 177 if (save_rootdev != NULL) { 178 rootdev = save_rootdev; 179 if (!vfs_mountroot_try("")) 180 return; 181 } 182 183 /* 184 * Try values that may have been computed by the machine-dependant 185 * legacy code. 186 */ 187 if (rootdevnames[0] && !vfs_mountroot_try(rootdevnames[0])) 188 return; 189 if (rootdevnames[1] && !vfs_mountroot_try(rootdevnames[1])) 190 return; 191 192 /* 193 * If we have a compiled-in default, and haven't already tried it, try 194 * it now. 195 */ 196 #ifdef ROOTDEVNAME 197 if (!(boothowto & RB_DFLTROOT)) 198 if (!vfs_mountroot_try(ROOTDEVNAME)) 199 return; 200 #endif 201 202 /* 203 * Everything so far has failed, prompt on the console if we haven't 204 * already tried that. 205 */ 206 if (!(boothowto & (RB_DFLTROOT | RB_ASKNAME)) && !vfs_mountroot_ask()) 207 return; 208 panic("Root mount failed, startup aborted."); 209 } 210 211 212 int 213 vfs_mountroot_devfs(void) 214 { 215 struct vnode *vp; 216 struct nchandle nch; 217 struct nlookupdata nd; 218 struct mount *mp; 219 struct vfsconf *vfsp; 220 int error; 221 struct ucred *cred = proc0.p_ucred; 222 const char *devfs_path, *init_chroot; 223 char *dev_malloced = NULL; 224 225 if ((init_chroot = kgetenv("init_chroot")) != NULL) { 226 size_t l; 227 228 l = strlen(init_chroot) + sizeof("/dev"); 229 dev_malloced = kmalloc(l, M_MOUNT, M_WAITOK); 230 ksnprintf(dev_malloced, l, "%s/dev", init_chroot); 231 devfs_path = dev_malloced; 232 } else { 233 devfs_path = "/dev"; 234 } 235 /* 236 * Lookup the requested path and extract the nch and vnode. 237 */ 238 error = nlookup_init_raw(&nd, devfs_path, UIO_SYSSPACE, 239 NLC_FOLLOW, cred, &rootnch); 240 241 if (error == 0) { 242 devfs_debug(DEVFS_DEBUG_DEBUG, 243 "vfs_mountroot_devfs: nlookup_init is ok...\n"); 244 if ((error = nlookup(&nd)) == 0) { 245 devfs_debug(DEVFS_DEBUG_DEBUG, 246 "vfs_mountroot_devfs: nlookup is ok...\n"); 247 if (nd.nl_nch.ncp->nc_vp == NULL) { 248 devfs_debug(DEVFS_DEBUG_SHOW, 249 "vfs_mountroot_devfs: nlookup: " 250 "simply not found\n"); 251 error = ENOENT; 252 } 253 } 254 } 255 if (dev_malloced != NULL) 256 kfree(dev_malloced, M_MOUNT), dev_malloced = NULL; 257 devfs_path = NULL; 258 if (error) { 259 nlookup_done(&nd); 260 devfs_debug(DEVFS_DEBUG_SHOW, 261 "vfs_mountroot_devfs: nlookup failed, error: %d\n", 262 error); 263 return (error); 264 } 265 266 /* 267 * Extract the locked+refd ncp and cleanup the nd structure 268 */ 269 nch = nd.nl_nch; 270 cache_zero(&nd.nl_nch); 271 nlookup_done(&nd); 272 273 /* 274 * now we have the locked ref'd nch and unreferenced vnode. 275 */ 276 vp = nch.ncp->nc_vp; 277 if ((error = vget(vp, LK_EXCLUSIVE)) != 0) { 278 cache_put(&nch); 279 devfs_debug(DEVFS_DEBUG_SHOW, 280 "vfs_mountroot_devfs: vget failed\n"); 281 return (error); 282 } 283 cache_unlock(&nch); 284 285 if ((error = vinvalbuf(vp, V_SAVE, 0, 0)) != 0) { 286 cache_drop(&nch); 287 vput(vp); 288 devfs_debug(DEVFS_DEBUG_SHOW, 289 "vfs_mountroot_devfs: vinvalbuf failed\n"); 290 return (error); 291 } 292 if (vp->v_type != VDIR) { 293 cache_drop(&nch); 294 vput(vp); 295 devfs_debug(DEVFS_DEBUG_SHOW, 296 "vfs_mountroot_devfs: vp is not VDIR\n"); 297 return (ENOTDIR); 298 } 299 300 vfsp = vfsconf_find_by_name("devfs"); 301 302 /* 303 * Allocate and initialize the filesystem. 304 */ 305 mp = kmalloc(sizeof(struct mount), M_MOUNT, M_ZERO|M_WAITOK); 306 mount_init(mp); 307 vfs_busy(mp, LK_NOWAIT); 308 mp->mnt_op = vfsp->vfc_vfsops; 309 mp->mnt_vfc = vfsp; 310 mp->mnt_pbuf_count = nswbuf_kva / NSWBUF_SPLIT; 311 vfsp->vfc_refcount++; 312 mp->mnt_stat.f_type = vfsp->vfc_typenum; 313 mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK; 314 if (vfsp->vfc_flags & VFCF_MPSAFE) 315 mp->mnt_kern_flag |= MNTK_ALL_MPSAFE; 316 strncpy(mp->mnt_stat.f_fstypename, vfsp->vfc_name, MFSNAMELEN); 317 mp->mnt_stat.f_owner = cred->cr_uid; 318 mp->mnt_ncmounton = nch; 319 vn_unlock(vp); 320 321 /* 322 * Mount the filesystem. 323 */ 324 error = VFS_MOUNT(mp, "/dev", NULL, cred); 325 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); 326 327 /* 328 * Put the new filesystem on the mount list after root. The mount 329 * point gets its own mnt_ncmountpt (unless the VFS already set one 330 * up) which represents the root of the mount. The lookup code 331 * detects the mount point going forward and checks the root of 332 * the mount going backwards. 333 * 334 * It is not necessary to invalidate or purge the vnode underneath 335 * because elements under the mount will be given their own glue 336 * namecache record. 337 */ 338 if (!error) { 339 if (mp->mnt_ncmountpt.ncp == NULL) { 340 /* 341 * allocate, then unlock, but leave the ref intact 342 */ 343 cache_allocroot(&mp->mnt_ncmountpt, mp, NULL); 344 cache_unlock(&mp->mnt_ncmountpt); 345 } 346 vn_unlock(vp); 347 cache_lock(&nch); 348 nch.ncp->nc_flag |= NCF_ISMOUNTPT; 349 cache_unlock(&nch); 350 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); 351 352 /* 353 * XXX get the root of the fs and 354 * cache_setvp(mnt_ncmountpt...) 355 */ 356 mountlist_insert(mp, MNTINS_LAST); 357 vn_unlock(vp); 358 //checkdirs(&mp->mnt_ncmounton, &mp->mnt_ncmountpt); 359 error = vfs_allocate_syncvnode(mp); 360 if (error) { 361 devfs_debug(DEVFS_DEBUG_SHOW, 362 "vfs_mountroot_devfs: " 363 "vfs_allocate_syncvnode failed\n"); 364 } 365 vfs_unbusy(mp); 366 error = VFS_START(mp, 0); 367 vrele(vp); 368 } else { 369 bzero(&mp->mnt_ncmounton, sizeof(mp->mnt_ncmounton)); 370 vn_syncer_thr_stop(mp); 371 vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_coherency_ops); 372 vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_journal_ops); 373 vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_norm_ops); 374 vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_spec_ops); 375 vfs_rm_vnodeops(mp, NULL, &mp->mnt_vn_fifo_ops); 376 mp->mnt_vfc->vfc_refcount--; 377 vfs_unbusy(mp); 378 kfree(mp, M_MOUNT); 379 cache_drop(&nch); 380 vput(vp); 381 devfs_debug(DEVFS_DEBUG_SHOW, 382 "vfs_mountroot_devfs: mount failed\n"); 383 } 384 385 devfs_debug(DEVFS_DEBUG_DEBUG, 386 "rootmount_devfs done with error: %d\n", error); 387 return (error); 388 } 389 390 391 /* 392 * Mount (mountfrom) as the root filesystem. 393 */ 394 static int 395 vfs_mountroot_try(const char *mountfrom) 396 { 397 struct mount *mp; 398 char *vfsname, *devname; 399 int error; 400 char patt[32]; 401 const char *cp, *ep; 402 char *mf; 403 struct proc *p; 404 struct vnode *vp; 405 406 vfsname = NULL; 407 devname = NULL; 408 mp = NULL; 409 error = EINVAL; 410 411 if (mountfrom == NULL) 412 return(error); /* don't complain */ 413 414 crit_enter(); 415 kprintf("Mounting root from %s\n", mountfrom); 416 crit_exit(); 417 418 cp = mountfrom; 419 /* parse vfs name and devname */ 420 vfsname = kmalloc(MFSNAMELEN, M_MOUNT, M_WAITOK); 421 devname = kmalloc(MNAMELEN, M_MOUNT, M_WAITOK); 422 mf = kmalloc(MFSNAMELEN+MNAMELEN, M_MOUNT, M_WAITOK); 423 for(;;) { 424 for (ep = cp; (*ep != 0) && (*ep != ';'); ep++); 425 bzero(vfsname, MFSNAMELEN); 426 bzero(devname, MNAMELEN); 427 bzero(mf, MFSNAMELEN+MNAMELEN); 428 strncpy(mf, cp, MFSNAMELEN+MNAMELEN); 429 430 vfsname[0] = devname[0] = 0; 431 ksprintf(patt, "%%%d[a-z0-9]:%%%ds", MFSNAMELEN, MNAMELEN); 432 if (ksscanf(mf, patt, vfsname, devname) < 1) 433 goto end; 434 435 /* allocate a root mount */ 436 error = vfs_rootmountalloc(vfsname, 437 devname[0] != 0 ? devname : ROOTNAME, &mp); 438 if (error != 0) { 439 kprintf("Can't allocate root mount for filesystem '%s': %d\n", 440 vfsname, error); 441 goto end; 442 } 443 mp->mnt_flag |= MNT_ROOTFS; 444 445 /* do our best to set rootdev (really just for UFS) */ 446 if (strcmp(vfsname, "hammer") != 0 && 447 strcmp(vfsname, "hammer2") != 0 && 448 (devname[0] != 0) && setrootbyname(devname)) { 449 kprintf("setrootbyname failed\n"); 450 } 451 452 /* If the root device is a type "memory disk", mount RW */ 453 if (rootdev != NULL && dev_is_good(rootdev) && 454 (dev_dflags(rootdev) & D_MEMDISK)) { 455 mp->mnt_flag &= ~MNT_RDONLY; 456 } 457 458 error = VFS_MOUNT(mp, NULL, NULL, proc0.p_ucred); 459 460 if (!error) 461 break; 462 end: 463 if(*ep == 0) 464 break; 465 cp = ep + 1; 466 } 467 468 if (vfsname != NULL) 469 kfree(vfsname, M_MOUNT); 470 if (devname != NULL) 471 kfree(devname, M_MOUNT); 472 if (mf != NULL) 473 kfree(mf, M_MOUNT); 474 if (error == 0) { 475 /* register with list of mounted filesystems */ 476 mountlist_insert(mp, MNTINS_FIRST); 477 478 /* sanity check system clock against root fs timestamp */ 479 inittodr(mp->mnt_time); 480 481 /* Get the vnode for '/'. Set p->p_fd->fd_cdir to reference it. */ 482 mp = mountlist_boot_getfirst(); 483 if (VFS_ROOT(mp, &vp)) 484 panic("cannot find root vnode"); 485 if (mp->mnt_ncmountpt.ncp == NULL) { 486 cache_allocroot(&mp->mnt_ncmountpt, mp, vp); 487 cache_unlock(&mp->mnt_ncmountpt); /* leave ref intact */ 488 } 489 p = curproc; 490 p->p_fd->fd_cdir = vp; 491 vref(p->p_fd->fd_cdir); 492 p->p_fd->fd_rdir = vp; 493 vref(p->p_fd->fd_rdir); 494 vfs_cache_setroot(vp, cache_hold(&mp->mnt_ncmountpt)); 495 vn_unlock(vp); /* leave ref intact */ 496 cache_copy(&mp->mnt_ncmountpt, &p->p_fd->fd_ncdir); 497 cache_copy(&mp->mnt_ncmountpt, &p->p_fd->fd_nrdir); 498 499 vfs_unbusy(mp); 500 if (mp->mnt_syncer == NULL) { 501 error = vfs_allocate_syncvnode(mp); 502 if (error) 503 kprintf("Warning: no syncer vp for root!\n"); 504 error = 0; 505 } 506 VFS_START( mp, 0 ); 507 } else { 508 if (mp != NULL) { 509 vn_syncer_thr_stop(mp); 510 vfs_unbusy(mp); 511 kfree(mp, M_MOUNT); 512 } 513 kprintf("Root mount failed: %d\n", error); 514 } 515 return(error); 516 } 517 518 519 static void 520 vfs_mountroot_ask_callback(char *name, cdev_t dev, bool is_alias, 521 void *arg __unused) 522 { 523 if (!is_alias && dev_is_good(dev) && (dev_dflags(dev) & D_DISK)) 524 kprintf(" \"%s\" ", name); 525 } 526 527 528 /* 529 * Spin prompting on the console for a suitable root filesystem 530 */ 531 static int 532 vfs_mountroot_ask(void) 533 { 534 char name[128]; 535 int llimit = 100; 536 537 kprintf("\nManual root filesystem specification:\n"); 538 kprintf(" <fstype>:<device> Specify root (e.g. ufs:da0s1a)\n"); 539 kprintf(" ? List valid disk boot devices\n"); 540 kprintf(" panic Just panic\n"); 541 kprintf(" abort Abort manual input\n"); 542 while (llimit--) { 543 kprintf("\nmountroot> "); 544 545 if (get_line(name, 128) < 0) 546 break; 547 if (name[0] == 0) { 548 ; 549 } else if (name[0] == '?') { 550 kprintf("Possibly valid devices for root FS:\n"); 551 //enumerate all disk devices 552 devfs_scan_callback(vfs_mountroot_ask_callback, NULL); 553 kprintf("\n"); 554 continue; 555 } else if (strcmp(name, "panic") == 0) { 556 panic("panic from console"); 557 } else if (strcmp(name, "abort") == 0) { 558 break; 559 } else if (vfs_mountroot_try(name) == 0) { 560 return(0); 561 } 562 } 563 return(1); 564 } 565 566 567 static int 568 get_line(char *cp, int limit) 569 { 570 char *lp; 571 int dummy; 572 int c; 573 574 lp = cp; 575 cnpoll(TRUE); 576 for (;;) { 577 c = cncheckc(); 578 579 switch (c) { 580 case NOKEY: 581 tsleep(&dummy, 0, "cnpoll", hz / 25); 582 break; 583 case -1: 584 goto done; 585 case '\n': 586 case '\r': 587 kprintf("\n"); 588 *lp++ = '\0'; 589 c = 0; 590 goto done; 591 case '\b': 592 case '\177': 593 if (lp > cp) { 594 kprintf("\b \b"); 595 lp--; 596 } else { 597 kprintf("%c", 7); 598 } 599 continue; 600 case '#': 601 kprintf("#"); 602 lp--; 603 if (lp < cp) 604 lp = cp; 605 continue; 606 case 'u' & 037: 607 /* NOTE: '@' no longer processed here, used for H2 */ 608 lp = cp; 609 kprintf("%c", '\n'); 610 continue; 611 default: 612 if (lp - cp >= limit - 1) { 613 kprintf("%c", 7); 614 } else { 615 kprintf("%c", c); 616 *lp++ = c; 617 } 618 continue; 619 } 620 } 621 done: 622 cnpoll(FALSE); 623 return c; 624 } 625 626 /* 627 * Convert a given name to the cdev_t of the disk-like device 628 * it refers to. 629 */ 630 cdev_t 631 kgetdiskbyname(const char *name) 632 { 633 cdev_t rdev; 634 635 /* 636 * Get the base name of the device 637 */ 638 if (strncmp(name, __SYS_PATH_DEV, sizeof(__SYS_PATH_DEV) - 1) == 0) 639 name += sizeof(__SYS_PATH_DEV) - 1; 640 641 /* 642 * Locate the device 643 */ 644 rdev = devfs_find_device_by_name("%s", name); 645 if (rdev == NULL) { 646 kprintf("no disk named '%s'\n", name); 647 } 648 /* 649 * FOUND DEVICE 650 */ 651 return(rdev); 652 } 653 654 /* 655 * Set rootdev to match (name), given that we expect it to 656 * refer to a disk-like device. 657 */ 658 static int 659 setrootbyname(char *name) 660 { 661 cdev_t diskdev; 662 663 diskdev = kgetdiskbyname(name); 664 if (diskdev != NULL) { 665 rootdev = diskdev; 666 return (0); 667 } 668 /* set to NULL if kgetdiskbyname() fails so that if the first rootdev is 669 * found by fails to mount and the second one isn't found, mountroot_try 670 * doesn't try again with the first one 671 */ 672 rootdev = NULL; 673 return (1); 674 } 675 676 #ifdef DDB 677 DB_SHOW_COMMAND(disk, db_getdiskbyname) 678 { 679 cdev_t dev; 680 681 if (modif[0] == '\0') { 682 db_error("usage: show disk/devicename"); 683 return; 684 } 685 dev = kgetdiskbyname(modif); 686 if (dev != NULL) 687 db_printf("cdev_t = %p\n", dev); 688 else 689 db_printf("No disk device matched.\n"); 690 } 691 #endif 692 693 static int 694 vfs_sysctl_real_root(SYSCTL_HANDLER_ARGS) 695 { 696 char *real_root; 697 size_t len; 698 int error; 699 700 real_root = kgetenv("vfs.root.realroot"); 701 702 if (real_root == NULL) 703 real_root = ""; 704 705 len = strlen(real_root) + 1; 706 707 error = sysctl_handle_string(oidp, real_root, len, req); 708 709 return error; 710 } 711 712 SYSCTL_PROC(_vfs, OID_AUTO, real_root, 713 CTLTYPE_STRING | CTLFLAG_RD, 0, 0, vfs_sysctl_real_root, 714 "A", "Real root mount string"); 715