For file backed md(4) devices output their source file via
'mdconfig -l -u <unit>'. Bump version number, as this change breaks ABI/API.
This commit is contained in:
parent
4d255ba360
commit
19fc384eb3
@ -115,8 +115,11 @@ main(int argc, char **argv)
|
||||
mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS;
|
||||
cmdline = 2;
|
||||
}
|
||||
mdio.md_file = optarg;
|
||||
fd = open(optarg, O_RDONLY);
|
||||
if (realpath(optarg, mdio.md_file) == NULL) {
|
||||
err(1, "could not find full path for %s",
|
||||
optarg);
|
||||
}
|
||||
fd = open(mdio.md_file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
err(1, "could not open %s", optarg);
|
||||
else if (mdio.md_mediasize == 0) {
|
||||
@ -300,6 +303,8 @@ query(const int fd, const int unit)
|
||||
}
|
||||
printf("\t");
|
||||
prthumanval(mdio.md_mediasize);
|
||||
if (mdio.md_type == MD_VNODE)
|
||||
printf("\t%s", mdio.md_file);
|
||||
printf("\n");
|
||||
|
||||
return (0);
|
||||
|
@ -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)
|
||||
|
@ -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 0
|
||||
#define MDIOVERSION 1
|
||||
|
||||
/*
|
||||
* Before you can use a unit, it must be configured with MDIOCSET.
|
||||
|
Loading…
Reference in New Issue
Block a user