aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/md/md.c18
-rw-r--r--sys/sys/mdioctl.h4
2 files changed, 10 insertions, 12 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 775728f2ed0f..8c35d8561df8 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -862,10 +862,9 @@ mdcreate_vnode(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
struct nameidata nd;
int error, flags;
- if (strlcpy(sc->file, mdio->md_file, sizeof(sc->file)) >=
- sizeof(sc->file)) {
- return (ENAMETOOLONG);
- }
+ error = copyinstr(mdio->md_file, sc->file, sizeof(sc->file), NULL);
+ if (error != 0)
+ return (error);
flags = FREAD|FWRITE;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, sc->file, td);
error = vn_open(&nd, &flags, 0, -1);
@@ -1087,8 +1086,7 @@ mdctlioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread
case MDIOCDETACH:
if (mdio->md_version != MDIOVERSION)
return (EINVAL);
- if (mdio->md_file[0] != '\0' || mdio->md_mediasize != 0 ||
- mdio->md_options != 0)
+ if (mdio->md_mediasize != 0 || mdio->md_options != 0)
return (EINVAL);
return (mddetach(mdio->md_unit, td));
case MDIOCQUERY:
@@ -1102,10 +1100,10 @@ mdctlioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread
mdio->md_mediasize = sc->mediasize;
mdio->md_sectorsize = sc->sectorsize;
if (sc->type == MD_VNODE) {
- if (strlcpy(mdio->md_file, sc->file,
- sizeof(mdio->md_file)) >= sizeof(mdio->md_file)) {
- return (ENAMETOOLONG);
- }
+ error = copyout(sc->file, mdio->md_file,
+ strlen(sc->file) + 1);
+ if (error != 0)
+ return (error);
}
return (0);
case MDIOCLIST:
diff --git a/sys/sys/mdioctl.h b/sys/sys/mdioctl.h
index afc0cb8e51d2..e45c096085ea 100644
--- a/sys/sys/mdioctl.h
+++ b/sys/sys/mdioctl.h
@@ -54,20 +54,20 @@ struct md_ioctl {
unsigned md_version; /* Structure layout version */
unsigned md_unit; /* unit number */
enum md_types md_type ; /* type of disk */
+ char *md_file; /* pathname of file to mount */
off_t md_mediasize; /* size of disk in bytes */
unsigned md_sectorsize; /* sectorsize */
unsigned md_options; /* options */
u_int64_t md_base; /* base address */
int md_fwheads; /* firmware heads */
int md_fwsectors; /* firmware sectors */
- char md_file[PATH_MAX]; /* pathname of file to mount */
int md_pad[MDNPAD]; /* padding for future ideas */
};
#define MD_NAME "md"
#define MD_MODNAME "g_md"
#define MDCTL_NAME "mdctl"
-#define MDIOVERSION 1
+#define MDIOVERSION 0
/*
* Before you can use a unit, it must be configured with MDIOCSET.