Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jul 2013 06:15:33 GMT
From:      oleksandr@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r254822 - soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files
Message-ID:  <201307160615.r6G6FXfM018616@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oleksandr
Date: Tue Jul 16 06:15:33 2013
New Revision: 254822
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254822

Log:
  Add vboxvfs_mnt struct, correct vfsops.c function and code style fix

Modified:
  soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk

Modified: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk
==============================================================================
--- soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk	Tue Jul 16 04:39:44 2013	(r254821)
+++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk	Tue Jul 16 06:15:33 2013	(r254822)
@@ -9,3 +9,434 @@
  include $(PATH_SUB_CURRENT)/drm/Makefile.kmk
  
  #
+--- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk
++++ src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk
+@@ -38,7 +38,7 @@ vboxvfs_LIBS          = \
+ 	$(VBOX_LIB_VBGL_R0) \
+ 	$(VBOX_LIB_IPRT_GUEST_R0)
+ vboxvfs_DEPS          = \
+-       $$(vboxvfs_0_OUTDIR)/vnode_if.h \
++#       $$(vboxvfs_0_OUTDIR)/vnode_if.h \
+        $$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h \
+        $$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h
+ vboxvfs_CLEAN        += $(vboxvfs_DEPS)
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h
++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h
+@@ -23,6 +23,7 @@
+ 
+ #define MAX_HOST_NAME 256
+ #define MAX_NLS_NAME 32
++#define VFSTOVBOXFS(mp)		((struct vboxvfs_mnt *)((mp)->mnt_data))
+ 
+ struct vboxvfs_mount_info {
+     char name[MAX_HOST_NAME];
+@@ -35,10 +36,26 @@ struct vboxvfs_mount_info {
+ #ifdef _KERNEL
+ 
+ #include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h"
+-#include <sys/mount.h>
+-#include <sys/vnode.h>
++/*#include <sys/mount.h>
++#include <sys/vnode.h> */
++
++struct vboxvfs_mnt
++{
++	VBSFMAP			map;
++	int			im_flags;			
++	struct mount		*im_mountp;
++	struct g_consumer	*im_cp; 
++	struct bufobj		*im_bo;
++	struct cdev		*im_dev;
++	struct vnode		*im_devvp;
++	off_t			size;
++	int			bsize;
++	int			bshift;
++	int			bmask;
++	int			use_devvp;
++};
+ 
+-struct vboxvfsmount {
++struct vboxvfs_mount {
+     uid_t           uid;
+     gid_t           gid;
+     mode_t          file_mode;
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c
++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c
+@@ -51,208 +51,239 @@ static vfs_statfs_t     vboxvfs_statfs;
+ static vfs_unmount_t    vboxvfs_unmount;
+ 
+ static struct vfsops vboxvfs_vfsops = {
+-    .vfs_init     =    vboxvfs_init,
+-    .vfs_cmount   =    vboxvfs_cmount,
+-    .vfs_mount    =    vboxvfs_mount,
+-    .vfs_quotactl =    vboxvfs_quotactl,
+-    .vfs_root     =    vboxvfs_root,
+-    .vfs_statfs   =    vboxvfs_statfs,
+-    .vfs_sync     =    vfs_stdsync,
+-    .vfs_uninit   =    vboxvfs_uninit,
+-    .vfs_unmount  =    vboxvfs_unmount,
++    	.vfs_init     =		vboxvfs_init,
++    	.vfs_cmount   =    	vboxvfs_cmount,
++    	.vfs_mount    =    	vboxvfs_mount,
++    	.vfs_quotactl =    	vboxvfs_quotactl,
++    	.vfs_root     =    	vboxvfs_root,
++    	.vfs_statfs   =    	vboxvfs_statfs,
++    	.vfs_sync     =    	vfs_stdsync,
++    	.vfs_uninit   =		vboxvfs_uninit,
++    	.vfs_unmount  =   	vboxvfs_unmount,
+ };
+ 
+ 
+ VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK);
+ MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1);
+ 
+-static int vboxvfs_cmount(struct mntarg *ma, void * data, int flags, struct thread *td)
++static int vboxvfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
+ {
+-    struct vboxvfs_mount_info args;
+-    int rc = 0;
++    	struct vboxvfs_mount_info args;
++    	int rc = 0;
+ 
+-    printf("%s: Enter\n", __FUNCTION__);
++    	printf("%s: Enter\n", __FUNCTION__);
+ 
+-    rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info));
+-    if (rc)
+-        return rc;
++    	rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info));
++    	if (rc)
++        	return (rc);
+ 
+-    ma = mount_argf(ma, "uid", "%d", args.uid);
+-    ma = mount_argf(ma, "gid", "%d", args.gid);
+-    ma = mount_arg(ma, "from", args.name, -1);
++  	ma = mount_argf(ma, "uid", "%d", args.uid);
++    	ma = mount_argf(ma, "gid", "%d", args.gid);
++    	ma = mount_arg(ma, "from", args.name, -1);
+ 
+-    rc = kernel_mount(ma, flags);
++    	rc = kernel_mount(ma, flags);
+ 
+-    printf("%s: Leave rc=%d\n", __FUNCTION__, rc);
++    	printf("%s: Leave rc=%d\n", __FUNCTION__, rc);
+ 
+-    return rc;
+-}
++    	return (rc);
++};
+ 
+ static const char *vboxvfs_opts[] = {
+-    "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL
++    	"uid", "gid", "from", "fstype", "fspath", "errmsg", NULL
+ };
+ 
+-static int vboxvfs_mount(struct mount *mp, struct thread *td)
++static int vboxvfs_mount(struct mount *mp)
+ {
+-    int rc;
+-    char *pszShare;
+-    int  cbShare, cbOption;
+-    int uid = 0, gid = 0;
+-    struct sf_glob_info *pShFlGlobalInfo;
+-    SHFLSTRING *pShFlShareName = NULL;
+-    int cbShFlShareName;
++    	int rc;
++    	char *pszShare;
++   	int  cbShare, cbOption;
++    	int uid = 0, gid = 0;
++   	struct sf_glob_info *pShFlGlobalInfo;
++    	SHFLSTRING *pShFlShareName = NULL;
++    	int cbShFlShareName;
+ 
+-    printf("%s: Enter\n", __FUNCTION__);
++    	printf("%s: Enter\n", __FUNCTION__);
+ 
+-    if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
+-        return EOPNOTSUPP;
++    	if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
++        	return (EOPNOTSUPP);
+ 
+-    if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts))
+-    {
+-        vfs_mount_error(mp, "%s", "Invalid option");
+-        return EINVAL;
+-    }
++    	if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts))
++    	{
++        	vfs_mount_error(mp, "%s", "Invalid option");
++        	return (EINVAL);
++    	}
+ 
+-    rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare);
+-    if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe)
+-        return EINVAL;
++    	rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare);
++    	if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe)
++        	return (EINVAL);
+ 
+-    rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption);
+-    if ((rc != ENOENT) && (rc || cbOption != sizeof(gid)))
+-        return EINVAL;
++    	rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption);
++    	if ((rc != ENOENT) && (rc || cbOption != sizeof(gid)))
++        	return EINVAL;
+ 
+-    rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption);
+-    if ((rc != ENOENT) && (rc || cbOption != sizeof(uid)))
+-        return EINVAL;
++    	rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption);
++    	if ((rc != ENOENT) && (rc || cbOption != sizeof(uid)))
++        	return EINVAL;
+ 
+-    pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info));
+-    if (!pShFlGlobalInfo)
+-        return ENOMEM;
++    	pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info));
++    	if (!pShFlGlobalInfo)
++        	return ENOMEM;
+ 
+-    cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1;
+-    pShFlShareName  = RTMemAllocZ(cbShFlShareName);
+-    if (!pShFlShareName)
+-        return VERR_NO_MEMORY;
++    	cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1;
++    	pShFlShareName  = RTMemAllocZ(cbShFlShareName);
++    	if (!pShFlShareName)
++        	return VERR_NO_MEMORY;
+ 
+-    pShFlShareName->u16Length = cbShFlShareName;
+-    pShFlShareName->u16Size   = cbShFlShareName + 1;
+-    memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1);
++    	pShFlShareName->u16Length = cbShFlShareName;
++    	pShFlShareName->u16Size   = cbShFlShareName + 1;
++    	memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1);
+ 
+-    rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map);
+-    RTMemFree(pShFlShareName);
++    	rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map);
++    	RTMemFree(pShFlShareName);
+ 
+-    if (RT_FAILURE (rc))
+-    {
+-        RTMemFree(pShFlGlobalInfo);
+-        printf("vboxCallMapFolder failed rc=%d\n", rc);
+-        return EPROTO;
+-    }
++    	if (RT_FAILURE (rc))
++    	{
++        	RTMemFree(pShFlGlobalInfo);
++        	printf("vboxCallMapFolder failed rc=%d\n", rc);
++        	return (EPROTO);
++    	}
+ 
+-    pShFlGlobalInfo->uid = uid;
+-    pShFlGlobalInfo->gid = gid;
++    	pShFlGlobalInfo->uid = uid;
++   	 pShFlGlobalInfo->gid = gid;
+ 
+-    mp->mnt_data = pShFlGlobalInfo;
++    	mp->mnt_data = pShFlGlobalInfo;
+ 
+-    /* @todo root vnode. */
++    	/* @todo root vnode. */
+ 
+-    vfs_getnewfsid(mp);
+-    vfs_mountedfrom(mp, pszShare);
++    	vfs_getnewfsid(mp);
++    	vfs_mountedfrom(mp, pszShare);
+ 
+-    printf("%s: Leave rc=0\n", __FUNCTION__);
++    	printf("%s: Leave rc=0\n", __FUNCTION__);
+ 
+-    return 0;
+-}
++    	return (0);
++};
+ 
+-static int vboxvfs_unmount(struct mount *mp, int mntflags, struct thread *td)
++/*
++ * Unmount a shared folder.
++ *
++ * vboxvfs_unmount umounts the mounted file system. It return 0 
++ * on sucess and any relevant errno on failure.
++ */
++static int vboxvfs_unmount(struct mount *mp, int mntflags)
+ {
+-    struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp);
+-    int rc;
+-    int flags = 0;
++    	struct thread *td = curthread;
++/*    	struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); */
++	struct vboxvfs_mnt *vboxvfsmp;
++    	int error;
++    	int flags = 0;
++	
++	vboxvfsmp = VFSTOVBOXFS(mp);
+ 
+-    rc = vboxCallUnmapFolder(&g_vboxSFClient, &pShFlGlobalInfo->map);
+-    if (RT_FAILURE(rc))
+-        printf("Failed to unmap shared folder\n");
++    	error = vboxCallUnmapFolder(&g_vboxSFClient, &vboxvfsmp->map);
++    	if (RT_FAILURE(error))
++        	printf("Failed to unmap shared folder\n");
+ 
+-    if (mntflags & MNT_FORCE)
+-        flags |= FORCECLOSE;
++    	if (mntflags & MNT_FORCE)
++        	flags |= FORCECLOSE;
+ 
+-    /* There is 1 extra root vnode reference (vnode_root). */
+-    rc = vflush(mp, 1, flags, td);
+-    if (rc)
+-        return rc;
++    	/* There is 1 extra root vnode reference (vnode_root). */
++    	error = vflush(mp, 1, flags, td);
++    	if (error)
++        	return (error);
+ 
+ 
+-    RTMemFree(pShFlGlobalInfo);
+-    mp->mnt_data = NULL;
++    	RTMemFree(vboxvfsmp);
++    	mp->mnt_data = NULL;
+ 
+-    return 0;
++    	return (0);
+ }
+ 
+-static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
++static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp)
+ {
+-    int rc = 0;
+-    struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp);
+-    struct vnode *vp;
++    	int rc = 0;
++    	struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp);
++    	struct vnode *vp;
+ 
+-    printf("%s: Enter\n", __FUNCTION__);
++    	printf("%s: Enter\n", __FUNCTION__);
+ 
+-    vp = pShFlGlobalInfo->vnode_root;
+-    VREF(vp);
++    	vp = pShFlGlobalInfo->vnode_root;
++    	VREF(vp);
+ 
+-    vn_lock(vp, flags | LK_RETRY, td);
+-    *vpp = vp;
++//    	vn_lock(vp, flags | LK_RETRY, td);
++    	*vpp = vp;
+ 
+-    printf("%s: Leave\n", __FUNCTION__);
++    	printf("%s: Leave\n", __FUNCTION__);
+ 
+-    return rc;
++    	return (rc);
+ }
+ 
+-static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, struct thread *td)
++/*
++ * Do operation associated with quotas, not supported
++ */
++static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg)
+ {
+-    return EOPNOTSUPP;
++    	return (EOPNOTSUPP);
+ }
+ 
+ int vboxvfs_init(struct vfsconf *vfsp)
+ {
+-    int rc;
+-
+-    /* Initialize the R0 guest library. */
+-    rc = vboxInit();
+-    if (RT_FAILURE(rc))
+-        return ENXIO;
+-
+-    /* Connect to the host service. */
+-    rc = vboxConnect(&g_vboxSFClient);
+-    if (RT_FAILURE(rc))
+-    {
+-        printf("Failed to get connection to host! rc=%d\n", rc);
+-        vboxUninit();
+-        return ENXIO;
+-    }
+-
+-    rc = vboxCallSetUtf8 (&g_vboxSFClient);
+-    if (RT_FAILURE (rc))
+-    {
+-        printf("vboxCallSetUtf8 failed, rc=%d\n", rc);
+-        vboxDisconnect(&g_vboxSFClient);
+-        vboxUninit();
+-        return EPROTO;
+-    }
+-
+-    printf("Successfully loaded shared folder module\n");
+-
+-    return 0;
++	int rc = -1;
++
++	/* Initialize the R0 guest library. */
++    	rc = vboxInit();
++    	if (RT_FAILURE(rc))
++	{
++		printf("sfprov_connect: vboxConnect() failed rc=%d\n", rc);
++        	return ENXIO;
++	}
++
++    	/* Connect to the host service. */
++    	rc = vboxConnect(&g_vboxSFClient);
++    	if (RT_FAILURE(rc))
++    	{
++        	printf("Failed to get connection to host! rc=%d\n", rc);
++        	vboxUninit();
++        	return ENXIO;
++    	}
++
++    	rc = vboxCallSetUtf8 (&g_vboxSFClient);
++    	if (RT_FAILURE (rc))
++    	{
++        	printf("vboxCallSetUtf8 failed, rc=%d\n", rc);
++        	vboxDisconnect(&g_vboxSFClient);
++        	vboxUninit();
++       		 return EPROTO;
++    	}
++
++    	printf("Successfully loaded shared folder module\n");
++
++    	return (0);
+ }
+ 
+ int vboxvfs_uninit(struct vfsconf *vfsp)
+ {
+-    vboxDisconnect(&g_vboxSFClient);
+-    vboxUninit();
++    	vboxDisconnect(&g_vboxSFClient);
++    	vboxUninit();
+ 
+-    return 0;
++    	return (0);
+ }
+ 
+-int vboxvfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
++/*
++ * vboxvfs_statfs call
++ */
++int vboxvfs_statfs(struct mount *mp, struct statfs *sbp)
+ {
+-    return 0;
++	struct vboxvfs_mnt *vboxvfsmp;
++
++	vboxvfsmp = VFSTOVBOXFS(mp);
++	
++	sbp->f_bsize = vboxvfsmp->bsize;
++	sbp->f_iosize = vboxvfsmp->bsize;
++	sbp->f_blocks = vboxvfsmp->size >> vboxvfsmp->bshift;
++	sbp->f_bfree = 0;
++	sbp->f_bavail = 0;
++	sbp->f_files = 0;
++	sbp->f_ffree = 0;
++
++        return (0);
+ }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307160615.r6G6FXfM018616>