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 103714 2002-09-20 19:36:05Z phk $ |
10 * 11 */ 12 13/* 14 * The following functions are based in the vn(4) driver: mdstart_swap(), 15 * mdstart_vnode(), mdcreate_swap(), mdcreate_vnode() and mddestroy(), 16 * and as such under the following copyright: 17 * --- 337 unchanged lines hidden (view full) --- 355 } 356 return (0); 357} 358 359static int 360mdopen(dev_t dev, int flag, int fmt, struct thread *td) 361{ 362 struct md_s *sc; |
363 364 if (md_debug) 365 printf("mdopen(%s %x %x %p)\n", 366 devtoname(dev), flag, fmt, td); 367 368 sc = dev->si_drv1; 369 |
370 sc->disk.d_sectorsize = sc->secsize; 371 sc->disk.d_mediasize = (off_t)sc->nsect * sc->secsize; 372 sc->disk.d_fwsectors = 0; 373 sc->disk.d_fwheads = 0; |
374 sc->opencount++; 375 return (0); 376} 377 378static int 379mdclose(dev_t dev, int flags, int fmt, struct thread *td) 380{ 381 struct md_s *sc = dev->si_drv1; --- 254 unchanged lines hidden (view full) --- 636 /* XXX: UNLOCK(unique unit numbers) */ 637 return (NULL); 638 } 639 if (sc->unit > max) 640 max = sc->unit; 641 } 642 if (unit == -1) 643 unit = max + 1; |
644 if (unit > 255) |
645 return (NULL); 646 sc = (struct md_s *)malloc(sizeof *sc, M_MD, M_WAITOK | M_ZERO); 647 sc->unit = unit; 648 sprintf(sc->name, "md%d", unit); 649 error = kthread_create(md_kthread, sc, &sc->procp, 0, "%s", sc->name); 650 if (error) { 651 free(sc, M_MD); 652 return (NULL); --- 499 unchanged lines hidden --- |