summaryrefslogtreecommitdiff
path: root/sys/ufs/mfs
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2012-09-10 11:11:01 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2012-09-10 11:11:01 +0000
commit2a1c47f2d9f2d1433ae48f64ec368b211b6786e2 (patch)
tree00a3a03b9a29a5e072374ac5b732685089b0c708 /sys/ufs/mfs
parentcf8106e329fdb32752921ec5380a309d42f22134 (diff)
Cleanup VFS mount string handling:
- Avoid using copyinstr() without checking the return value. - sys_mount() has already copied the path in, so pass this to the filesystem mount code so that it does not have to copy it in again. - Avoid copyinstr()/bzero() dance when we can simply bzero() and strlcpy(). ok krw@
Diffstat (limited to 'sys/ufs/mfs')
-rw-r--r--sys/ufs/mfs/mfs_vfsops.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c
index ab362a02ef8..29a941d5b94 100644
--- a/sys/ufs/mfs/mfs_vfsops.c
+++ b/sys/ufs/mfs/mfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfs_vfsops.c,v 1.42 2010/12/21 20:14:44 thib Exp $ */
+/* $OpenBSD: mfs_vfsops.c,v 1.43 2012/09/10 11:11:00 jsing Exp $ */
/* $NetBSD: mfs_vfsops.c,v 1.10 1996/02/09 22:31:28 christos Exp $ */
/*
@@ -91,10 +91,10 @@ mfs_mount(struct mount *mp, const char *path, void *data,
struct ufsmount *ump;
struct fs *fs;
struct mfsnode *mfsp;
- size_t size;
+ char fspec[MNAMELEN];
int flags, error;
- error = copyin(data, (caddr_t)&args, sizeof (struct mfs_args));
+ error = copyin(data, (caddr_t)&args, sizeof(struct mfs_args));
if (error)
return (error);
@@ -116,12 +116,15 @@ mfs_mount(struct mount *mp, const char *path, void *data,
if (fs->fs_ronly && (mp->mnt_flag & MNT_WANTRDWR))
fs->fs_ronly = 0;
#ifdef EXPORTMFS
- if (args.fspec == 0)
+ if (args.fspec == NULL)
return (vfs_export(mp, &ump->um_export,
&args.export_info));
#endif
return (0);
}
+ error = copyinstr(args.fspec, fspec, sizeof(fspec), NULL);
+ if (error)
+ return (error);
error = getnewvnode(VT_MFS, NULL, &mfs_vops, &devvp);
if (error)
return (error);
@@ -143,13 +146,14 @@ mfs_mount(struct mount *mp, const char *path, void *data,
}
ump = VFSTOUFS(mp);
fs = ump->um_fs;
- (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size);
- bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size);
+
+ bzero(fs->fs_fsmnt, sizeof(fs->fs_fsmnt));
+ strlcpy(fs->fs_fsmnt, path, sizeof(fs->fs_fsmnt));
bcopy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname, MNAMELEN);
- (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
+ bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
+ strlcpy(mp->mnt_stat.f_mntfromname, fspec, MNAMELEN);
bcopy(&args, &mp->mnt_stat.mount_info.mfs_args, sizeof(args));
+
return (0);
}