summaryrefslogtreecommitdiffstats
path: root/sys/dev/md
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-12-27 17:20:06 +0000
committerpjd <pjd@FreeBSD.org>2004-12-27 17:20:06 +0000
commitb19cea505cff9159f9680eb46daaf51d14fb3809 (patch)
tree55fe765c8368400583f00b5c70626fe1601950c0 /sys/dev/md
parentc06a300010399909b6dab3e40803805da5975383 (diff)
downloadFreeBSD-src-b19cea505cff9159f9680eb46daaf51d14fb3809.zip
FreeBSD-src-b19cea505cff9159f9680eb46daaf51d14fb3809.tar.gz
Rewrite piece of code which I committed some time ago that allows to
show file name for 'mdconfig -l -u <x>' command. This allows to preserve API/ABI compatibility with version 0 (that's why I changed version number back to 0) and will allow to merge this change to RELENG_5. MFC after: 5 days
Diffstat (limited to 'sys/dev/md')
-rw-r--r--sys/dev/md/md.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 775728f..8c35d85 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:
OpenPOWER on IntegriCloud