Do not copy by field when converting struct oexport_args to struct
export_args on mount update, bzero() is consistent with vfs_oexport_conv(). Make the code structure more explicit by using switch. Return EINVAL if export option layout (deduced from size) is unknown. Based on the submission by: bde Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
e53d0abf73
commit
76c404fce5
@ -880,10 +880,10 @@ vfs_domount_update(
|
||||
struct vfsoptlist **optlist /* Options local to the filesystem. */
|
||||
)
|
||||
{
|
||||
struct oexport_args oexport;
|
||||
struct export_args export;
|
||||
void *bufp;
|
||||
struct mount *mp;
|
||||
int error, export_error;
|
||||
int error, export_error, len;
|
||||
uint64_t flag;
|
||||
|
||||
ASSERT_VOP_ELOCKED(vp, __func__);
|
||||
@ -951,23 +951,21 @@ vfs_domount_update(
|
||||
error = VFS_MOUNT(mp);
|
||||
|
||||
export_error = 0;
|
||||
if (error == 0) {
|
||||
/* Process the export option. */
|
||||
if (vfs_copyopt(mp->mnt_optnew, "export", &export,
|
||||
sizeof(export)) == 0) {
|
||||
export_error = vfs_export(mp, &export);
|
||||
} else if (vfs_copyopt(mp->mnt_optnew, "export", &oexport,
|
||||
sizeof(oexport)) == 0) {
|
||||
export.ex_flags = oexport.ex_flags;
|
||||
export.ex_root = oexport.ex_root;
|
||||
export.ex_anon = oexport.ex_anon;
|
||||
export.ex_addr = oexport.ex_addr;
|
||||
export.ex_addrlen = oexport.ex_addrlen;
|
||||
export.ex_mask = oexport.ex_mask;
|
||||
export.ex_masklen = oexport.ex_masklen;
|
||||
export.ex_indexfile = oexport.ex_indexfile;
|
||||
export.ex_numsecflavors = 0;
|
||||
/* Process the export option. */
|
||||
if (error == 0 && vfs_getopt(mp->mnt_optnew, "export", &bufp,
|
||||
&len) == 0) {
|
||||
/* Assume that there is only 1 ABI for each length. */
|
||||
switch (len) {
|
||||
case (sizeof(struct oexport_args)):
|
||||
bzero(&export, sizeof(export));
|
||||
/* FALLTHROUGH */
|
||||
case (sizeof(export)):
|
||||
bcopy(bufp, &export, len);
|
||||
export_error = vfs_export(mp, &export);
|
||||
break;
|
||||
default:
|
||||
export_error = EINVAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user