diff options
author | pjd <pjd@FreeBSD.org> | 2004-11-06 13:07:02 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2004-11-06 13:07:02 +0000 |
commit | d18ec52c7546f2c9d388a7ea50c53e7fe5c40659 (patch) | |
tree | 1082e170109a097c61a61bf73ce9f89781b9a66c /sys/dev/md | |
parent | 2b775a8633a9fd57b9fe564ed98292d3b7fac655 (diff) | |
download | FreeBSD-src-d18ec52c7546f2c9d388a7ea50c53e7fe5c40659.zip FreeBSD-src-d18ec52c7546f2c9d388a7ea50c53e7fe5c40659.tar.gz |
For file backed md(4) devices output their source file via
'mdconfig -l -u <unit>'.
Bump version number, as this change breaks ABI/API.
Diffstat (limited to 'sys/dev/md')
-rw-r--r-- | sys/dev/md/md.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 22e4a11..29bed2c 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -174,6 +174,7 @@ struct md_s { /* MD_VNODE related fields */ struct vnode *vnode; + char file[PATH_MAX]; struct ucred *cred; /* MD_SWAP related fields */ @@ -861,15 +862,19 @@ 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); + } flags = FREAD|FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, sc->file, td); error = vn_open(&nd, &flags, 0, -1); if (error) { NDFREE(&nd, NDF_ONLY_PNBUF); if (error != EACCES && error != EPERM && error != EROFS) return (error); flags &= ~FWRITE; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td); + NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, sc->file, td); error = vn_open(&nd, &flags, 0, -1); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1097,11 +1102,15 @@ 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) { - /* XXX fill this in */ - mdio->md_file = NULL; + if (strlcpy(mdio->md_file, sc->file, + sizeof(mdio->md_file)) >= sizeof(mdio->md_file)) { + return (ENAMETOOLONG); + } } return (0); case MDIOCLIST: + if (mdio->md_version != MDIOVERSION) + return (EINVAL); i = 1; LIST_FOREACH(sc, &md_softc_list, list) { if (i == MDNPAD - 1) |