diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2010-06-09 12:58:58 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2010-06-09 12:58:58 +0000 |
commit | c5fdd2a6f7dd2911343fdf6fcc81d6a0cddb3d75 (patch) | |
tree | 1bc3d332b88ffe877c32009c0d4261fef821c271 /sys/ufs/ffs/ffs_vfsops.c | |
parent | 09b51e337955688b088f6d4bbed524f0fcb192a9 (diff) |
Teach FFS mounts about disklabel UIDs. This allows file systems to be
mounted by specifying a disklabel UID followed by a dot and a partition.
For example:
mount -t ffs 0123456789abcdef.a /mnt
ok otto@
Diffstat (limited to 'sys/ufs/ffs/ffs_vfsops.c')
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 339eb2fad4f..0fe9ba1ce94 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.122 2010/05/18 04:41:14 dlg Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.123 2010/06/09 12:58:57 jsing Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -50,6 +50,7 @@ #include <sys/sysctl.h> #include <sys/pool.h> #include <sys/dkio.h> +#include <sys/disk.h> #include <dev/rndvar.h> @@ -173,6 +174,7 @@ ffs_mount(struct mount *mp, const char *path, void *data, int ronly; mode_t accessmode; size_t size; + char *fspec = NULL; error = copyin(data, &args, sizeof (struct ufs_args)); if (error) @@ -327,11 +329,16 @@ ffs_mount(struct mount *mp, const char *path, void *data, goto success; } } + /* * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); + fspec = malloc(MNAMELEN, M_MOUNT, M_WAITOK); + copyinstr(args.fspec, fspec, MNAMELEN - 1, &size); + disk_map(fspec, fspec, MNAMELEN, DM_OPENBLCK); + + NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, p); if ((error = namei(ndp)) != 0) goto error_1; @@ -384,10 +391,8 @@ ffs_mount(struct mount *mp, const char *path, void *data, /* * Save "mounted from" info for mount point (NULL pad) */ - copyinstr(args.fspec, - mp->mnt_stat.f_mntfromname, - MNAMELEN - 1, - &size); + size = strlcpy(mp->mnt_stat.f_mntfromname, fspec, + MNAMELEN - 1); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); } @@ -406,10 +411,7 @@ ffs_mount(struct mount *mp, const char *path, void *data, bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); /* Save "mounted from" info for mount point (NULL pad)*/ - copyinstr(args.fspec, /* device name*/ - mp->mnt_stat.f_mntfromname, /* save area*/ - MNAMELEN - 1, /* max size*/ - &size); /* real size*/ + size = strlcpy(mp->mnt_stat.f_mntfromname, fspec, MNAMELEN - 1); bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); error = ffs_mountfs(devvp, mp, p); @@ -450,7 +452,12 @@ success: error_2: /* error with devvp held */ vrele (devvp); + error_1: /* no state to back out */ + + if (fspec) + free(fspec, M_MOUNT); + return (error); } |