Subject: Re: netbsd32_mount: one possible solution
To: None <tech-kern@netbsd.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 07/22/2005 18:23:18
--sCNd3Ivk/oijKKf1
Content-Type: multipart/mixed; boundary="gBYU9MM4gf8jKg2V"
Content-Disposition: inline
--gBYU9MM4gf8jKg2V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, Jul 22, 2005 at 09:28:16AM +0200, Quentin Garnier wrote:
> On Fri, Jul 22, 2005 at 09:15:05AM +0900, YAMAMOTO Takashi wrote:
> > > The other way I could find is much less intrusive, and simply burn a
> > > MNT_* flag to do that task. I'm attaching a proposed patch using that
> > > method which allows netbsd32_mount() to work for mount_msdos(8).
> >=20
> > i object against mixing (more) operational flags in mnt_flag.
> > see PR/29898.
>=20
> Ok, I see your point.
>=20
> What about using a mnt_iflag? For that I'd only change the prototype of
> mount1() to take an additional flag.
>=20
> I can also add a field to struct mount for that purpose, too. I don't
> think there would be any side-effect other than having to bump the
> kernel version.
>=20
> What would be best?
Actually, I think the best is simply to add a paramater to vfs_mount.
See the attached patch (no, it doesn't list the changes to all the other
_mount() prototypes).
--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.
--gBYU9MM4gf8jKg2V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mount.diff"
Content-Transfer-Encoding: quoted-printable
Index: compat/netbsd32/files.netbsd32
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/sys/compat/netbsd32/files.netbsd32,v
retrieving revision 1.17
diff -u -r1.17 files.netbsd32
--- compat/netbsd32/files.netbsd32 2004/06/17 18:29:40 1.17
+++ compat/netbsd32/files.netbsd32 2005/07/21 21:02:50
@@ -10,11 +10,12 @@
file compat/netbsd32/netbsd32_exec_elf32.c compat_netbsd32 & exec_elf32
file compat/netbsd32/netbsd32_exec_aout.c compat_netbsd32 & exec_aout
file compat/netbsd32/netbsd32_netbsd.c compat_netbsd32
file compat/netbsd32/netbsd32_execve.c compat_netbsd32
file compat/netbsd32/netbsd32_fs.c compat_netbsd32
file compat/netbsd32/netbsd32_ioctl.c compat_netbsd32
file compat/netbsd32/netbsd32_ipc.c compat_netbsd32
+file compat/netbsd32/netbsd32_mount.c compat_netbsd32
file compat/netbsd32/netbsd32_select.c compat_netbsd32
file compat/netbsd32/netbsd32_signal.c compat_netbsd32
file compat/netbsd32/netbsd32_socket.c compat_netbsd32
file compat/netbsd32/netbsd32_sysctl.c compat_netbsd32
Index: compat/netbsd32/netbsd32_netbsd.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/sys/compat/netbsd32/netbsd32_netbsd.c,v
retrieving revision 1.97
diff -u -r1.97 netbsd32_netbsd.c
--- compat/netbsd32/netbsd32_netbsd.c 2005/07/12 15:06:17 1.97
+++ compat/netbsd32/netbsd32_netbsd.c 2005/07/21 21:40:18
@@ -396,27 +396,6 @@
}
=20
int
-netbsd32_mount(l, v, retval)
- struct lwp *l;
- void *v;
- register_t *retval;
-{
- struct netbsd32_mount_args /* {
- syscallarg(const netbsd32_charp) type;
- syscallarg(const netbsd32_charp) path;
- syscallarg(int) flags;
- syscallarg(netbsd32_voidp) data;
- } */ *uap =3D v;
- struct sys_mount_args ua;
-
- NETBSD32TOP_UAP(type, const char);
- NETBSD32TOP_UAP(path, const char);
- NETBSD32TO64_UAP(flags);
- NETBSD32TOP_UAP(data, void);
- return (sys_mount(l, &ua, retval));
-}
-
-int
netbsd32_unmount(l, v, retval)
struct lwp *l;
void *v;
Index: kern/vfs_syscalls.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.226
diff -u -r1.226 vfs_syscalls.c
--- kern/vfs_syscalls.c 2005/07/16 22:47:18 1.226
+++ kern/vfs_syscalls.c 2005/07/22 16:19:14
@@ -125,6 +125,12 @@
int
sys_mount(struct lwp *l, void *v, register_t *retval)
{
+ return mount1(l, v, retval, MNT_USER_DATA);
+}
+
+int
+mount1(struct lwp *l, void *v, register_t *retval, int dtype)
+{
struct sys_mount_args /* {
syscallarg(const char *) type;
syscallarg(const char *) path;
@@ -343,7 +349,8 @@
/*
* Mount the filesystem.
*/
- error =3D VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, p);
+ error =3D VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, p,
+ dtype);
if (mp->mnt_flag & (MNT_UPDATE | MNT_GETARGS)) {
if (mp->mnt_iflag & IMNT_WANTRDWR)
mp->mnt_flag &=3D ~MNT_RDONLY;
Index: sys/mount.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/sys/sys/mount.h,v
retrieving revision 1.129
diff -u -r1.129 mount.h
--- sys/mount.h 2005/05/29 21:19:41 1.129
+++ sys/mount.h 2005/07/22 16:07:01
@@ -221,10 +221,13 @@
struct vnodeopv_desc;
#endif
=20
+#define MNT_USER_DATA 0
+#define MNT_SYS_DATA 1
+
struct vfsops {
const char *vfs_name;
int (*vfs_mount) (struct mount *, const char *, void *,
- struct nameidata *, struct proc *);
+ struct nameidata *, struct proc *, int);
int (*vfs_start) (struct mount *, int, struct proc *);
int (*vfs_unmount) (struct mount *, int, struct proc *);
int (*vfs_root) (struct mount *, struct vnode **);
@@ -257,8 +260,8 @@
=20
#define VFS_ATTACH(vfs) __link_set_add_data(vfsops, vfs)
=20
-#define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
- (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
+#define VFS_MOUNT(MP, PATH, DATA, NDP, P, D) \
+ (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P, D)
#define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
#define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, =
P)
#define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP)
@@ -370,6 +373,24 @@
=20
LIST_HEAD(vfs_list_head, vfsops);
extern struct vfs_list_head vfs_list;
+
+#define MOUNT_COPYIN_DATA(error, space, src, dst, size) do { \
+ if ((space) =3D=3D MNT_SYS_DATA) { \
+ memcpy((dst), (src), (size)); \
+ error =3D 0; \
+ } else \
+ (error) =3D copyin((src), (dst), (size)); \
+ } while (0);
+
+#define MOUNT_COPYOUT_DATA(error, space, src, dst, size) do { \
+ if ((space) =3D=3D MNT_SYS_DATA) { \
+ memcpy((dst), (src), (size)); \
+ error =3D 0; \
+ } else \
+ (error) =3D copyout((src), (dst), (size)); \
+ } while (0);
+
+int mount1(struct lwp *, void *, register_t *, int);
=20
#else /* _KERNEL */
=20
Index: fs/msdosfs/msdosfs_vfsops.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/sys/fs/msdosfs/msdosfs_vfsops.c,v
retrieving revision 1.24
diff -u -r1.24 msdosfs_vfsops.c
--- fs/msdosfs/msdosfs_vfsops.c 2005/05/29 21:00:29 1.24
+++ fs/msdosfs/msdosfs_vfsops.c 2005/07/22 15:40:42
@@ -86,7 +86,7 @@
=20
int msdosfs_mountroot __P((void));
int msdosfs_mount __P((struct mount *, const char *, void *,
- struct nameidata *, struct proc *));
+ struct nameidata *, struct proc *, int));
int msdosfs_start __P((struct mount *, int, struct proc *));
int msdosfs_unmount __P((struct mount *, int, struct proc *));
int msdosfs_root __P((struct mount *, struct vnode **));
@@ -239,12 +239,13 @@
* special file to treat as a filesystem.
*/
int
-msdosfs_mount(mp, path, data, ndp, p)
+msdosfs_mount(mp, path, data, ndp, p, dtype)
struct mount *mp;
const char *path;
void *data;
struct nameidata *ndp;
struct proc *p;
+ int dtype;
{
struct vnode *devvp; /* vnode for blk device to mount */
struct msdosfs_args args; /* will hold data from mount request */
@@ -266,9 +267,10 @@
args.dirmask =3D pmp->pm_dirmask;
args.gmtoff =3D pmp->pm_gmtoff;
vfs_showexport(mp, &args.export, &pmp->pm_export);
- return copyout(&args, data, sizeof(args));
+ MOUNT_COPYOUT_DATA(error, dtype, &args, data, sizeof(args));
+ return error;
}
- error =3D copyin(data, &args, sizeof(struct msdosfs_args));
+ MOUNT_COPYIN_DATA(error, dtype, data, &args, sizeof(struct msdosfs_args));
if (error)
return (error);
=20
--gBYU9MM4gf8jKg2V--
--sCNd3Ivk/oijKKf1
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)
iQEVAwUBQuEddtgoQloHrPnoAQKiYQgAraTSkvVRvdeG7qLRn22YwqCs2qD5RCvG
GCN65EqVStpeggDFHbFh0+sIvJJaxkIh6uhA6Swi0XIsdbpHv7ZiJs2cWy0yShbi
sURtS1qp6glCDFQrsrjIQWqGoAXd0k+thZgbVJxGmdk7YZZnOCQUuSZxwm7fOcnZ
U4843HMQLCKB5wR4uddQcTC6sWfyBCmSuNF29vfXs6FMP7aLf6bzjZMGGI35ZUiM
VJERczSAyd/GcGM0vlPwVphVej+crNam7Bx/2+YFuIMR6Tkg9DZKCg0Ul0JNmRHp
GF7HkgCUpIKEAWGWKxcAyWSwdbjHUIod0nT1/ALnzdsDOI71zE9XjA==
=k1hs
-----END PGP SIGNATURE-----
--sCNd3Ivk/oijKKf1--