aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2001-02-25 13:12:57 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2001-02-25 13:12:57 +0000
commit174b5e9aec22c10f68ac439a58d5d04bf9df144f (patch)
tree65af0854ab7e433a47691f0e124fc5ccf3ef17d5 /sys
parenta4539b3e5695e35c1265dc19fd0061a5932ea289 (diff)
downloadsrc-174b5e9aec22c10f68ac439a58d5d04bf9df144f.tar.gz
src-174b5e9aec22c10f68ac439a58d5d04bf9df144f.zip
Make "md" and "mdctl" macroized parameters.
Implement "-l" option to mdconfig which can list one or all md devices. Submitted by: Dima Dorfman <dima@unixfreak.org>
Notes
Notes: svn path=/head/; revision=73026
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/md/md.c32
-rw-r--r--sys/sys/mdioctl.h3
2 files changed, 31 insertions, 4 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 48ff0b35f57c..dc53517a2591 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -133,7 +133,7 @@ static struct cdevsw md_cdevsw = {
/* poll */ nopoll,
/* mmap */ nommap,
/* strategy */ mdstrategy,
- /* name */ "md",
+ /* name */ MD_NAME,
/* maj */ CDEV_MAJOR,
/* dump */ nodump,
/* psize */ nopsize,
@@ -149,7 +149,7 @@ static struct cdevsw mdctl_cdevsw = {
/* poll */ nopoll,
/* mmap */ nommap,
/* strategy */ nostrategy,
- /* name */ "md",
+ /* name */ MD_NAME,
/* maj */ CDEV_MAJOR
};
@@ -533,7 +533,7 @@ mdinit(struct md_s *sc)
{
bioq_init(&sc->bio_queue);
- devstat_add_entry(&sc->stats, "md", sc->unit, sc->secsize,
+ devstat_add_entry(&sc->stats, MD_NAME, sc->unit, sc->secsize,
DEVSTAT_NO_ORDERED_TAGS,
DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER,
DEVSTAT_PRIORITY_OTHER);
@@ -608,7 +608,7 @@ mdcreate_malloc(struct md_ioctl *mdio)
for (u = 0; u < sc->nsect; u++)
MALLOC(sc->secp[u], u_char *, DEV_BSIZE, M_MDSECT, M_WAITOK | M_ZERO);
}
- printf("md%d: Malloc disk\n", sc->unit);
+ printf("%s%d: Malloc disk\n", MD_NAME, sc->unit);
mdinit(sc);
return (0);
}
@@ -833,6 +833,30 @@ mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
default:
return (EOPNOTSUPP);
}
+ case MDIOCQUERY:
+ sc = mdfind(mdio->md_unit);
+ if (sc == NULL)
+ return (ENOENT);
+ mdio->md_type = sc->type;
+ mdio->md_options = sc->flags;
+ switch (sc->type) {
+ case MD_MALLOC:
+ mdio->md_size = sc->nsect;
+ break;
+ case MD_PRELOAD:
+ mdio->md_size = sc->nsect;
+ (u_char *)(uintptr_t)mdio->md_base = sc->pl_ptr;
+ break;
+ case MD_SWAP:
+ mdio->md_size = sc->nsect * (PAGE_SIZE / DEV_BSIZE);
+ break;
+ case MD_VNODE:
+ mdio->md_size = sc->nsect;
+ /* XXX fill this in */
+ mdio->md_file = NULL;
+ break;
+ }
+ return (0);
default:
return (ENOIOCTL);
};
diff --git a/sys/sys/mdioctl.h b/sys/sys/mdioctl.h
index 1507e6f2d714..6ebda6b8dfaf 100644
--- a/sys/sys/mdioctl.h
+++ b/sys/sys/mdioctl.h
@@ -64,6 +64,8 @@ struct md_ioctl {
int pad[100]; /* padding for future ideas */
};
+#define MD_NAME "md"
+#define MDCTL_NAME "mdctl"
#define MDIOVERSION 1
/*
@@ -75,6 +77,7 @@ struct md_ioctl {
#define MDIOCATTACH _IOWR('m', 0, struct md_ioctl) /* attach disk */
#define MDIOCDETACH _IOWR('m', 1, struct md_ioctl) /* detach disk */
+#define MDIOCQUERY _IOWR('m', 2, struct md_ioctl) /* query status */
#define MD_CLUSTER 0x01 /* Don't cluster */
#define MD_RESERVE 0x02 /* Pre-reserve swap */