Deleted Added
full compact
md.c (102291) md.c (103714)
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 102291 2002-08-22 21:24:01Z archie $
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;
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 struct disklabel *dl;
364
365 if (md_debug)
366 printf("mdopen(%s %x %x %p)\n",
367 devtoname(dev), flag, fmt, td);
368
369 sc = dev->si_drv1;
370
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
371 dl = &sc->disk.d_label;
372 bzero(dl, sizeof(*dl));
373 dl->d_secsize = sc->secsize;
374 dl->d_nsectors = sc->nsect > 63 ? 63 : sc->nsect;
375 dl->d_ntracks = 1;
376 dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
377 dl->d_secperunit = sc->nsect;
378 dl->d_ncylinders = dl->d_secperunit / dl->d_secpercyl;
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;
379 sc->opencount++;
380 return (0);
381}
382
383static int
384mdclose(dev_t dev, int flags, int fmt, struct thread *td)
385{
386 struct md_s *sc = dev->si_drv1;

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

641 /* XXX: UNLOCK(unique unit numbers) */
642 return (NULL);
643 }
644 if (sc->unit > max)
645 max = sc->unit;
646 }
647 if (unit == -1)
648 unit = max + 1;
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;
649 if (unit > DKMAXUNIT)
644 if (unit > 255)
650 return (NULL);
651 sc = (struct md_s *)malloc(sizeof *sc, M_MD, M_WAITOK | M_ZERO);
652 sc->unit = unit;
653 sprintf(sc->name, "md%d", unit);
654 error = kthread_create(md_kthread, sc, &sc->procp, 0, "%s", sc->name);
655 if (error) {
656 free(sc, M_MD);
657 return (NULL);

--- 499 unchanged lines hidden ---
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 ---