vfs_mount.c (65051) | vfs_mount.c (65374) |
---|---|
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 --- 11 unchanged lines hidden (view full) --- 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 * | 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 --- 11 unchanged lines hidden (view full) --- 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: head/sys/kern/vfs_mount.c 65051 2000-08-24 15:36:55Z phk $ | 28 * $FreeBSD: head/sys/kern/vfs_mount.c 65374 2000-09-02 19:17:34Z phk $ |
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" | 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#include "opt_devfs.h" | |
47 48#include <sys/param.h> 49#include <sys/kernel.h> 50#include <sys/systm.h> 51#include <sys/proc.h> 52#include <sys/vnode.h> 53#include <sys/mount.h> 54#include <sys/malloc.h> 55#include <sys/reboot.h> 56#include <sys/diskslice.h> 57#include <sys/disklabel.h> 58#include <sys/conf.h> 59#include <sys/cons.h> 60 61#include "opt_ddb.h" 62#ifdef DDB 63#include <ddb/ddb.h> 64#endif 65 | 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/disklabel.h> 57#include <sys/conf.h> 58#include <sys/cons.h> 59 60#include "opt_ddb.h" 61#ifdef DDB 62#include <ddb/ddb.h> 63#endif 64 |
66#ifdef DEVFS 67#include <sys/eventhandler.h> 68#include <fs/devfs/devfs.h> 69#endif 70 | |
71MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure"); 72 73#define ROOTNAME "root_device" 74 75struct vnode *rootvnode; 76 77/* 78 * The root specifiers we will try if RB_CDROM is specified. --- 242 unchanged lines hidden (view full) --- 321} 322 323/* 324 * Convert a given name to the dev_t of the disk-like device 325 * it refers to. 326 */ 327dev_t 328getdiskbyname(char *name) { | 65MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure"); 66 67#define ROOTNAME "root_device" 68 69struct vnode *rootvnode; 70 71/* 72 * The root specifiers we will try if RB_CDROM is specified. --- 242 unchanged lines hidden (view full) --- 315} 316 317/* 318 * Convert a given name to the dev_t of the disk-like device 319 * it refers to. 320 */ 321dev_t 322getdiskbyname(char *name) { |
329#ifdef DEVFS | |
330 char *cp; 331 dev_t dev; 332 333 cp = name; 334 if (!bcmp(cp, "/dev/", 5)) 335 cp += 5; 336 337 dev = NODEV; | 323 char *cp; 324 dev_t dev; 325 326 cp = name; 327 if (!bcmp(cp, "/dev/", 5)) 328 cp += 5; 329 330 dev = NODEV; |
338 EVENTHANDLER_INVOKE(devfs_clone, cp, strlen(cp), &dev); | 331 EVENTHANDLER_INVOKE(dev_clone, cp, strlen(cp), &dev); |
339 return (dev); | 332 return (dev); |
340 341#else 342 char *cp; 343 int cd, unit, slice, part; 344 dev_t dev; 345 346 slice = 0; 347 part = 0; 348 cp = rindex(name, '/'); 349 if (cp != NULL) { 350 name = cp + 1; 351 } 352 cp = name; 353 while (cp != '\0' && (*cp < '0' || *cp > '9')) 354 cp++; 355 if (cp == name) { 356 printf("missing device name\n"); 357 return (NODEV); 358 } 359 if (*cp == '\0') { 360 printf("missing unit number\n"); 361 return (NODEV); 362 } 363 unit = *cp - '0'; 364 *cp++ = '\0'; 365 for (cd = 0; cd < NUMCDEVSW; cd++) { 366 dev = makedev(cd, 0); 367 if (devsw(dev) != NULL && 368 strcmp(devsw(dev)->d_name, name) == 0) 369 goto gotit; 370 } 371 printf("no such device '%s'\n", name); 372 return (NODEV); 373gotit: 374 while (*cp >= '0' && *cp <= '9') 375 unit += 10 * unit + *cp++ - '0'; 376 if (*cp == 's' && cp[1] >= '0' && cp[1] <= '9') { 377 slice = cp[1] - '0' + 1; 378 cp += 2; 379 } 380 if (*cp >= 'a' && *cp <= 'h') { 381 part = *cp - 'a'; 382 cp++; 383 } 384 if (*cp != '\0') { 385 printf("junk after name\n"); 386 return (NODEV); 387 } 388 return (makedev(cd, dkmakeminor(unit, slice, part))); 389#endif | |
390} 391 392/* 393 * Set rootdev to match (name), given that we expect it to 394 * refer to a disk-like device. 395 */ 396static int 397setrootbyname(char *name) --- 28 unchanged lines hidden --- | 333} 334 335/* 336 * Set rootdev to match (name), given that we expect it to 337 * refer to a disk-like device. 338 */ 339static int 340setrootbyname(char *name) --- 28 unchanged lines hidden --- |