Deleted Added
full compact
md.c (65176) md.c (65374)
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 *
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 *
9 * $FreeBSD: head/sys/dev/md/md.c 65176 2000-08-28 21:48:13Z dfr $
9 * $FreeBSD: head/sys/dev/md/md.c 65374 2000-09-02 19:17:34Z phk $
10 *
11 */
12
13#include "opt_mfs.h" /* We have adopted some tasks from MFS */
14#include "opt_md.h"
10 *
11 */
12
13#include "opt_mfs.h" /* We have adopted some tasks from MFS */
14#include "opt_md.h"
15#include "opt_devfs.h"
16
17#include <sys/param.h>
18#include <sys/systm.h>
19#include <sys/bio.h>
20#include <sys/conf.h>
21#include <sys/devicestat.h>
22#include <sys/disk.h>
23#include <sys/kernel.h>
24#include <sys/malloc.h>
25#include <sys/sysctl.h>
26#include <sys/linker.h>
27#include <sys/queue.h>
28
15
16#include <sys/param.h>
17#include <sys/systm.h>
18#include <sys/bio.h>
19#include <sys/conf.h>
20#include <sys/devicestat.h>
21#include <sys/disk.h>
22#include <sys/kernel.h>
23#include <sys/malloc.h>
24#include <sys/sysctl.h>
25#include <sys/linker.h>
26#include <sys/queue.h>
27
29#ifdef DEVFS
30#include <sys/eventhandler.h>
31#include <fs/devfs/devfs.h>
32#endif
33
34#ifndef MD_NSECT
35#define MD_NSECT (10000 * 2)
36#endif
37
38MALLOC_DEFINE(M_MD, "MD disk", "Memory Disk");
39MALLOC_DEFINE(M_MDSECT, "MD sectors", "Memory Disk Sectors");
40
41static int md_debug;

--- 77 unchanged lines hidden (view full) ---

119 struct md_s *sc;
120 struct disklabel *dl;
121
122 if (md_debug)
123 printf("mdopen(%s %x %x %p)\n",
124 devtoname(dev), flag, fmt, p);
125
126 sc = dev->si_drv1;
28#ifndef MD_NSECT
29#define MD_NSECT (10000 * 2)
30#endif
31
32MALLOC_DEFINE(M_MD, "MD disk", "Memory Disk");
33MALLOC_DEFINE(M_MDSECT, "MD sectors", "Memory Disk Sectors");
34
35static int md_debug;

--- 77 unchanged lines hidden (view full) ---

113 struct md_s *sc;
114 struct disklabel *dl;
115
116 if (md_debug)
117 printf("mdopen(%s %x %x %p)\n",
118 devtoname(dev), flag, fmt, p);
119
120 sc = dev->si_drv1;
127#ifndef DEVFS
128 if (sc->unit + 1 == mdunits)
121 if ((!devfs_present) && sc->unit + 1 == mdunits)
129 mdcreate_malloc(-1);
122 mdcreate_malloc(-1);
130#endif
131
132 dl = &sc->disk.d_label;
133 bzero(dl, sizeof(*dl));
134 dl->d_secsize = DEV_BSIZE;
135 dl->d_nsectors = 1024;
136 dl->d_ntracks = 1;
137 dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
138 dl->d_secperunit = sc->nsect;

--- 267 unchanged lines hidden (view full) ---

406
407 sc->nsect = MD_NSECT; /* for now */
408 MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK);
409 bzero(sc->secp, sizeof(u_char *));
410 sc->nsecp = 1;
411 printf("md%d: Malloc disk\n", sc->unit);
412}
413
123
124 dl = &sc->disk.d_label;
125 bzero(dl, sizeof(*dl));
126 dl->d_secsize = DEV_BSIZE;
127 dl->d_nsectors = 1024;
128 dl->d_ntracks = 1;
129 dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
130 dl->d_secperunit = sc->nsect;

--- 267 unchanged lines hidden (view full) ---

398
399 sc->nsect = MD_NSECT; /* for now */
400 MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK);
401 bzero(sc->secp, sizeof(u_char *));
402 sc->nsecp = 1;
403 printf("md%d: Malloc disk\n", sc->unit);
404}
405
414#ifdef DEVFS
415static void
416md_clone (void *arg, char *name, int namelen, dev_t *dev)
417{
418 int i, u;
419
420 if (*dev != NODEV)
421 return;
406static void
407md_clone (void *arg, char *name, int namelen, dev_t *dev)
408{
409 int i, u;
410
411 if (*dev != NODEV)
412 return;
422 i = devfs_stdclone(name, NULL, "md", &u);
413 i = dev_stdclone(name, NULL, "md", &u);
423 if (i == 0)
424 return;
425 /* XXX: should check that next char is [\0sa-h] */
426 /*
427 * Now we cheat: We just create the disk, but don't match.
428 * Since we run before it, subr_disk.c::disk_clone() will
429 * find our disk and match the sought for device.
430 */
431 mdcreate_malloc(u);
432 return;
433}
414 if (i == 0)
415 return;
416 /* XXX: should check that next char is [\0sa-h] */
417 /*
418 * Now we cheat: We just create the disk, but don't match.
419 * Since we run before it, subr_disk.c::disk_clone() will
420 * find our disk and match the sought for device.
421 */
422 mdcreate_malloc(u);
423 return;
424}
434#endif
435
436static void
437md_drvinit(void *unused)
438{
439
440 caddr_t mod;
441 caddr_t c;
442 u_char *ptr, *name, *type;

--- 15 unchanged lines hidden (view full) ---

458 c = preload_search_info(mod, MODINFO_ADDR);
459 ptr = *(u_char **)c;
460 c = preload_search_info(mod, MODINFO_SIZE);
461 len = *(unsigned *)c;
462 printf("md%d: Preloaded image <%s> %d bytes at %p\n",
463 mdunits, name, len, ptr);
464 mdcreate_preload(ptr, len);
465 }
425
426static void
427md_drvinit(void *unused)
428{
429
430 caddr_t mod;
431 caddr_t c;
432 u_char *ptr, *name, *type;

--- 15 unchanged lines hidden (view full) ---

448 c = preload_search_info(mod, MODINFO_ADDR);
449 ptr = *(u_char **)c;
450 c = preload_search_info(mod, MODINFO_SIZE);
451 len = *(unsigned *)c;
452 printf("md%d: Preloaded image <%s> %d bytes at %p\n",
453 mdunits, name, len, ptr);
454 mdcreate_preload(ptr, len);
455 }
466#ifdef DEVFS
467 EVENTHANDLER_REGISTER(devfs_clone, md_clone, 0, 999);
468#else
469 mdcreate_malloc(-1);
470#endif
456 EVENTHANDLER_REGISTER(dev_clone, md_clone, 0, 999);
457 if (!devfs_present)
458 mdcreate_malloc(-1);
471}
472
473SYSINIT(mddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, md_drvinit,NULL)
474
475#ifdef MD_ROOT
476static void
477md_takeroot(void *junk)
478{
479 if (mdrootready)
480 rootdevnames[0] = "ufs:/dev/md0c";
481}
482
483SYSINIT(md_root, SI_SUB_MOUNT_ROOT, SI_ORDER_FIRST, md_takeroot, NULL);
484#endif
485
459}
460
461SYSINIT(mddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, md_drvinit,NULL)
462
463#ifdef MD_ROOT
464static void
465md_takeroot(void *junk)
466{
467 if (mdrootready)
468 rootdevnames[0] = "ufs:/dev/md0c";
469}
470
471SYSINIT(md_root, SI_SUB_MOUNT_ROOT, SI_ORDER_FIRST, md_takeroot, NULL);
472#endif
473