Date: Sun, 22 Sep 2013 10:41:09 GMT From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257602 - soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files Message-ID: <201309221041.r8MAf91M070320@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: oleksandr Date: Sun Sep 22 10:41:09 2013 New Revision: 257602 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257602 Log: update mount root vfs section 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 Sun Sep 22 09:17:40 2013 (r257601) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Sun Sep 22 10:41:09 2013 (r257602) @@ -2,15 +2,13 @@ =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk (revision 4) +++ src/VBox/Additions/freebsd/vboxvfs/Makefile.kmk (working copy) -@@ -32,13 +32,14 @@ - . \ +@@ -33,12 +33,13 @@ $(vboxvfs_0_OUTDIR) vboxvfs_SOURCES = \ -- vboxvfs_vfsops.c \ + vboxvfs_vfsops.c \ - vboxvfs_vnops.c -+ vboxfs_vfsops.c \ -+ vboxfs_vnops.c \ -+ vboxfs_prov.c ++ vboxvfs_vnops.c \ ++ vboxvfs_prov.c vboxvfs_LIBS = \ $(VBOX_LIB_VBGL_R0) \ $(VBOX_LIB_IPRT_GUEST_R0) @@ -20,397 +18,65 @@ $$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h \ $$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h vboxvfs_CLEAN += $(vboxvfs_DEPS) -Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c -=================================================================== ---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (revision 4) -+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (working copy) -@@ -1,241 +0,0 @@ --/* $Id: vboxvfs_vnops.c $ */ --/** @file -- * Description. -- */ -- --/* -- * Copyright (C) 2008-2010 Oracle Corporation -- * -- * This file is part of VirtualBox Open Source Edition (OSE), as -- * available from http://www.virtualbox.org. This file is free software; -- * you can redistribute it and/or modify it under the terms of the GNU -- * General Public License (GPL) as published by the Free Software -- * Foundation, in version 2 as it comes in the "COPYING" file of the -- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the -- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. -- */ -- --#include "vboxvfs.h" --#include <sys/param.h> --#include <sys/systm.h> --#include <sys/namei.h> --#include <sys/kernel.h> --#include <sys/proc.h> --#include <sys/bio.h> --#include <sys/buf.h> --#include <sys/fcntl.h> --#include <sys/mount.h> --#include <sys/unistd.h> --#include <sys/vnode.h> --#include <sys/limits.h> --#include <sys/lockf.h> --#include <sys/stat.h> -- --#include <vm/vm.h> --#include <vm/vm_extern.h> -- --/* -- * Prototypes for VBOXVFS vnode operations -- */ --static vop_create_t vboxvfs_create; --static vop_mknod_t vboxvfs_mknod; --static vop_open_t vboxvfs_open; --static vop_close_t vboxvfs_close; --static vop_access_t vboxvfs_access; --static vop_getattr_t vboxvfs_getattr; --static vop_setattr_t vboxvfs_setattr; --static vop_read_t vboxvfs_read; --static vop_write_t vboxvfs_write; --static vop_fsync_t vboxvfs_fsync; --static vop_remove_t vboxvfs_remove; --static vop_link_t vboxvfs_link; --static vop_lookup_t vboxvfs_lookup; --static vop_rename_t vboxvfs_rename; --static vop_mkdir_t vboxvfs_mkdir; --static vop_rmdir_t vboxvfs_rmdir; --static vop_symlink_t vboxvfs_symlink; --static vop_readdir_t vboxvfs_readdir; --static vop_strategy_t vboxvfs_strategy; --static vop_print_t vboxvfs_print; --static vop_pathconf_t vboxvfs_pathconf; --static vop_advlock_t vboxvfs_advlock; --static vop_getextattr_t vboxvfs_getextattr; --static vop_ioctl_t vboxvfs_ioctl; --static vop_getpages_t vboxvfs_getpages; --static vop_inactive_t vboxvfs_inactive; --static vop_putpages_t vboxvfs_putpages; --static vop_reclaim_t vboxvfs_reclaim; -- --struct vop_vector vboxvfs_vnodeops = { -- .vop_default = &default_vnodeops, -- -- .vop_access = vboxvfs_access, -- .vop_advlock = vboxvfs_advlock, -- .vop_close = vboxvfs_close, -- .vop_create = vboxvfs_create, -- .vop_fsync = vboxvfs_fsync, -- .vop_getattr = vboxvfs_getattr, -- .vop_getextattr = vboxvfs_getextattr, -- .vop_getpages = vboxvfs_getpages, -- .vop_inactive = vboxvfs_inactive, -- .vop_ioctl = vboxvfs_ioctl, -- .vop_link = vboxvfs_link, -- .vop_lookup = vboxvfs_lookup, -- .vop_mkdir = vboxvfs_mkdir, -- .vop_mknod = vboxvfs_mknod, -- .vop_open = vboxvfs_open, -- .vop_pathconf = vboxvfs_pathconf, -- .vop_print = vboxvfs_print, -- .vop_putpages = vboxvfs_putpages, -- .vop_read = vboxvfs_read, -- .vop_readdir = vboxvfs_readdir, -- .vop_reclaim = vboxvfs_reclaim, -- .vop_remove = vboxvfs_remove, -- .vop_rename = vboxvfs_rename, -- .vop_rmdir = vboxvfs_rmdir, -- .vop_setattr = vboxvfs_setattr, -- .vop_strategy = vboxvfs_strategy, -- .vop_symlink = vboxvfs_symlink, -- .vop_write = vboxvfs_write, --}; -- --static int vboxvfs_access(struct vop_access_args *ap) --{ -- return 0; --} -- --static int vboxvfs_open(struct vop_open_args *ap) --{ -- return 0; --} -- --static int vboxvfs_close(struct vop_close_args *ap) --{ -- return 0; --} -- --static int vboxvfs_getattr(struct vop_getattr_args *ap) --{ -- return 0; --} -- --static int vboxvfs_setattr(struct vop_setattr_args *ap) --{ -- return 0; --} -- --static int vboxvfs_read(struct vop_read_args *ap) --{ -- return 0; --} -- --static int vboxvfs_write(struct vop_write_args *ap) --{ -- return 0; --} -- --static int vboxvfs_create(struct vop_create_args *ap) --{ -- return 0; --} -- --static int vboxvfs_remove(struct vop_remove_args *ap) --{ -- return 0; --} -- --static int vboxvfs_rename(struct vop_rename_args *ap) --{ -- return 0; --} -- --static int vboxvfs_link(struct vop_link_args *ap) --{ -- return EOPNOTSUPP; --} -- --static int vboxvfs_symlink(struct vop_symlink_args *ap) --{ -- return EOPNOTSUPP; --} -- --static int vboxvfs_mknod(struct vop_mknod_args *ap) --{ -- return EOPNOTSUPP; --} -- --static int vboxvfs_mkdir(struct vop_mkdir_args *ap) --{ -- return 0; --} -- --static int vboxvfs_rmdir(struct vop_rmdir_args *ap) --{ -- return 0; --} -- --static int vboxvfs_readdir(struct vop_readdir_args *ap) --{ -- return 0; --} -- --static int vboxvfs_fsync(struct vop_fsync_args *ap) --{ -- return 0; --} -- --static int vboxvfs_print (struct vop_print_args *ap) --{ -- return 0; --} -- --static int vboxvfs_pathconf (struct vop_pathconf_args *ap) --{ -- return 0; --} -- --static int vboxvfs_strategy (struct vop_strategy_args *ap) --{ -- return 0; --} -- --static int vboxvfs_ioctl(struct vop_ioctl_args *ap) --{ -- return ENOTTY; --} -- --static int vboxvfs_getextattr(struct vop_getextattr_args *ap) --{ -- return 0; --} -- --static int vboxvfs_advlock(struct vop_advlock_args *ap) --{ -- return 0; --} -- --static int vboxvfs_lookup(struct vop_lookup_args *ap) --{ -- return 0; --} -- --static int vboxvfs_inactive(struct vop_inactive_args *ap) --{ -- return 0; --} -- --static int vboxvfs_reclaim(struct vop_reclaim_args *ap) --{ -- return 0; --} -- --static int vboxvfs_getpages(struct vop_getpages_args *ap) --{ -- return 0; --} -- --static int vboxvfs_putpages(struct vop_putpages_args *ap) --{ -- return 0; --} -- -Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h -=================================================================== ---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (revision 4) -+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs.h (working copy) -@@ -1,92 +0,0 @@ --/* $Id: vboxvfs.h $ */ --/** @file -- * Description. -- */ -- --/* -- * Copyright (C) 2010 Oracle Corporation -- * -- * This file is part of VirtualBox Open Source Edition (OSE), as -- * available from http://www.virtualbox.org. This file is free software; -- * you can redistribute it and/or modify it under the terms of the GNU -- * General Public License (GPL) as published by the Free Software -- * Foundation, in version 2 as it comes in the "COPYING" file of the -- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the -- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. -- */ -- --#ifndef ___VBOXVFS_H___ --#define ___VBOXVFS_H___ -- --#define VBOXVFS_VFSNAME "vboxvfs" --#define VBOXVFS_VERSION 1 -- --#define MAX_HOST_NAME 256 --#define MAX_NLS_NAME 32 -- --struct vboxvfs_mount_info { -- char name[MAX_HOST_NAME]; -- char nls_name[MAX_NLS_NAME]; -- int uid; -- int gid; -- int ttl; --}; -- --#ifdef _KERNEL -- --#include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h" --#include <sys/mount.h> --#include <sys/vnode.h> -- --struct vboxvfsmount { -- uid_t uid; -- gid_t gid; -- mode_t file_mode; -- mode_t dir_mode; -- struct mount *mp; -- struct ucred *owner; -- u_int flags; -- long nextino; -- int caseopt; -- int didrele; --}; -- --/* structs - stolen from the linux shared module code */ --struct sf_glob_info { -- VBSFMAP map; --/* struct nls_table *nls;*/ -- int ttl; -- int uid; -- int gid; -- struct vnode *vnode_root; --}; -- --struct sf_inode_info { -- SHFLSTRING *path; -- int force_restat; --}; -- --#if 0 --struct sf_dir_info { -- struct list_head info_list; --}; --#endif -- --struct sf_dir_buf { -- size_t nb_entries; -- size_t free_bytes; -- size_t used_bytes; -- void *buf; --#if 0 -- struct list_head head; --#endif --}; -- --struct sf_reg_info { -- SHFLHANDLE handle; --}; -- --#endif /* KERNEL */ -- --#endif /* !___VBOXVFS_H___ */ -- Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c =================================================================== --- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c (revision 4) +++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c (working copy) -@@ -1,258 +0,0 @@ +@@ -1,4 +1,4 @@ -/* $Id: vboxvfs_vfsops.c $ */ --/** @file -- * Description. -- */ -- --/* -- * Copyright (C) 2008-2010 Oracle Corporation -- * -- * This file is part of VirtualBox Open Source Edition (OSE), as -- * available from http://www.virtualbox.org. This file is free software; -- * you can redistribute it and/or modify it under the terms of the GNU -- * General Public License (GPL) as published by the Free Software -- * Foundation, in version 2 as it comes in the "COPYING" file of the -- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the -- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. -- */ ++/* $Id: vboxfs_vfsops.c $ */ + /** @file + * Description. + */ +@@ -14,245 +14,525 @@ + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ - -#include "vboxvfs.h" --#include <sys/param.h> --#include <sys/systm.h> --#include <sys/proc.h> --#include <sys/bio.h> --#include <sys/buf.h> --#include <sys/kernel.h> --#include <sys/sysctl.h> --#include <sys/vnode.h> --#include <sys/mount.h> --#include <sys/stat.h> --#include <sys/malloc.h> --#include <sys/module.h> -- --#include <iprt/mem.h> -- --#define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data) -- ++#include <sys/types.h> + #include <sys/param.h> + #include <sys/systm.h> + #include <sys/proc.h> + #include <sys/bio.h> + #include <sys/buf.h> ++#include <sys/conf.h> ++#include <sys/dirent.h> + #include <sys/kernel.h> + #include <sys/sysctl.h> + #include <sys/vnode.h> + #include <sys/mount.h> ++#include <sys/namei.h> ++#include <sys/fcntl.h> ++#include <sys/priv.h> + #include <sys/stat.h> + #include <sys/malloc.h> + #include <sys/module.h> + +-#include <iprt/mem.h> ++#include <geom/geom.h> ++#include <geom/geom_vfs.h> + ++#include "vboxvfs.h" ++ + #define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data) + -static int vboxvfs_version = VBOXVFS_VERSION; -- ++#ifdef MALLOC_DECLARE ++MALLOC_DEFINE(M_VBOXVFS, "vboxvfs", "VBOX VFS"); ++#endif + -SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem"); -SYSCTL_INT(_vfs_vboxvfs, OID_AUTO, version, CTLFLAG_RD, &vboxvfs_version, 0, ""); -- --/* global connection to the host service. */ --static VBSFCLIENT g_vboxSFClient; -- ++static int vboxfs_version = VBOXVFS_VERSION; + ++SYSCTL_NODE(_vfs, OID_AUTO, vboxfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem"); ++SYSCTL_INT(_vfs_vboxfs, OID_AUTO, version, CTLFLAG_RD, &vboxfs_version, 0, ""); ++ + /* global connection to the host service. */ + static VBSFCLIENT g_vboxSFClient; ++static sfp_connection_t *sfprov = NULL; + -static vfs_init_t vboxvfs_init; -static vfs_uninit_t vboxvfs_uninit; -static vfs_cmount_t vboxvfs_cmount; @@ -419,7 +85,15 @@ -static vfs_quotactl_t vboxvfs_quotactl; -static vfs_statfs_t vboxvfs_statfs; -static vfs_unmount_t vboxvfs_unmount; -- ++static vfs_init_t vboxfs_init; ++static vfs_uninit_t vboxfs_uninit; ++static vfs_cmount_t vboxfs_cmount; ++static vfs_mount_t vboxfs_mount; ++static vfs_root_t vboxfs_root; ++static vfs_quotactl_t vboxfs_quotactl; ++static vfs_statfs_t vboxfs_statfs; ++static vfs_unmount_t vboxfs_unmount; + -static struct vfsops vboxvfs_vfsops = { - .vfs_init = vboxvfs_init, - .vfs_cmount = vboxvfs_cmount, @@ -430,40 +104,74 @@ - .vfs_sync = vfs_stdsync, - .vfs_uninit = vboxvfs_uninit, - .vfs_unmount = vboxvfs_unmount, --}; -- -- ++static struct vfsops vboxfs_vfsops = { ++ .vfs_init = vboxfs_init, ++ .vfs_cmount = vboxfs_cmount, ++ .vfs_mount = vboxfs_mount, ++ .vfs_quotactl = vboxfs_quotactl, ++ .vfs_root = vboxfs_root, ++ .vfs_statfs = vboxfs_statfs, ++ .vfs_sync = vfs_stdsync, ++ .vfs_uninit = vboxfs_uninit, ++ .vfs_unmount = vboxfs_unmount, ++ .vfs_vget = vboxfs_vget, + }; + + -VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK); --MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1); -- ++VFS_SET(vboxfs_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 vboxfs_cmount(struct mntarg *ma, void *data, uint64_t flags) + { - struct vboxvfs_mount_info args; - int rc = 0; -- ++ struct vboxfs_mount_info args; ++ int error = 0; + - printf("%s: Enter\n", __FUNCTION__); -- ++ printf("%s: Enter\n", __FUNCTION__); ++ ++ if (data == NULL) ++ return (EINVAL); ++ error = copyin(data, &args, sizeof(struct vboxfs_mount_info)); ++ if (error) ++ return (error); + - 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_argf(ma, "file_mode", "%d", args.fmode); ++ ma = mount_argf(ma, "dir_mode", "%d", args.dmode); ++ 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); -- ++ error = kernel_mount(ma, flags); + - rc = kernel_mount(ma, flags); -- ++ printf("%s: Leave error=%d\n", __FUNCTION__, error); + - printf("%s: Leave rc=%d\n", __FUNCTION__, rc); -- ++ return (error); ++}; + - return rc; -} - -static const char *vboxvfs_opts[] = { - "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL --}; -- ++static const char *vboxfs_opts[] = { ++ "fstype", "fspath", "from", "uid", "gid", "file_mode", "dir_mode", "errmsg", NULL + }; + -static int vboxvfs_mount(struct mount *mp, struct thread *td) --{ ++static int vboxfs_mount(struct mount *mp) + { - int rc; - char *pszShare; - int cbShare, cbOption; @@ -471,2976 +179,3172 @@ - struct sf_glob_info *pShFlGlobalInfo; - SHFLSTRING *pShFlShareName = NULL; - int cbShFlShareName; -- ++ struct vboxfs_mnt *vboxfsmp = NULL; ++ struct vboxfs_node *unode; ++ struct buf *bp = NULL; ++ struct cdev *dev; ++ struct g_consumer *cp; ++ struct bufobj *bo; ++ struct vnode *devvp; /* vnode of the mount device */ ++ struct thread *td = curthread; ++ struct vfsoptlist *opts = mp->mnt_optnew; ++ struct nameidata nd, *ndp = &nd; ++ sfp_mount_t *handle; ++ int error, share_len; ++ char *share_name; ++ mode_t file_mode, dir_mode; ++ char *tmp, *ep; ++ uid_t uid = 0; ++ gid_t gid = 0; + - 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(opts, vboxfs_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; -- ++ if (vfs_getopt(opts, "uid", (void **)&tmp, NULL) == 0) { ++ if (tmp != NULL) ++ uid = (uid_t)strtol(tmp, &ep, 10); ++ if (tmp == NULL || *ep) { ++ vfs_mount_error(mp, "Invalid uid"); ++ return (EINVAL); ++ } ++ } ++ ++ if (vfs_getopt(opts, "gid", (void **)&tmp, NULL) == 0) { ++ if (tmp != NULL) ++ gid = (gid_t)strtol(tmp, &ep, 10); ++ if (tmp == NULL || *ep) { ++ vfs_mount_error(mp, "Invalid gid"); ++ return (EINVAL); ++ } ++ } + - rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption); - if ((rc != ENOENT) && (rc || cbOption != sizeof(gid))) - return EINVAL; -- ++ if (vfs_getopt(opts, "file_mode", (void **)&tmp, NULL) == 0) { ++ if (tmp != NULL) ++ file_mode = (mode_t)strtol(tmp, &ep, 8); ++#if 0 ++ if (tmp == NULL || *ep) { ++ vfs_mount_error(mp, "Invalid file_mode"); ++ return (EINVAL); ++ } ++#endif ++ file_mode &= S_IRWXU | S_IRWXG | S_IRWXO; ++ } + - rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption); - if ((rc != ENOENT) && (rc || cbOption != sizeof(uid))) - return EINVAL; -- ++ if (vfs_getopt(opts, "dir_mode", (void **)&tmp, NULL) == 0) { ++ if (tmp != NULL) ++ dir_mode = (mode_t)strtol(tmp, &ep, 8); ++#if 0 ++ if (tmp == NULL || *ep) { ++ vfs_mount_error(mp, "Invalid dir_mode"); ++ return (EINVAL); ++ } ++#endif ++ dir_mode &= S_IRWXU | S_IRWXG | S_IRWXO; ++ } + - pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info)); - if (!pShFlGlobalInfo) - return ENOMEM; -- ++ vboxfsmp = malloc(sizeof(struct vboxfs_mnt), M_VBOXVFS, M_WAITOK | M_ZERO); ++ vboxfsmp->sf_uid = uid; ++ vboxfsmp->sf_gid = gid; ++ vboxfsmp->sf_fmode = file_mode; ++ vboxfsmp->sf_dmode = dir_mode; + - cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1; - pShFlShareName = RTMemAllocZ(cbShFlShareName); - if (!pShFlShareName) - return VERR_NO_MEMORY; -- ++ /* ++ * Invoke Hypervisor mount interface before proceeding ++ */ ++ //error = sfprov_mount(share_name, &handle); ++ // if (error) { ++ // return (error); ++ //} + - pShFlShareName->u16Length = cbShFlShareName; - pShFlShareName->u16Size = cbShFlShareName + 1; - memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1); -- ++ mp->mnt_data = handle; + - rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map); - RTMemFree(pShFlShareName); -- ++ error = vfs_getopt(opts, "from", (void **)&share_name, &share_len); + - if (RT_FAILURE (rc)) - { - RTMemFree(pShFlGlobalInfo); - printf("vboxCallMapFolder failed rc=%d\n", rc); - return EPROTO; - } -- ++ if (error || share_name[share_len - 1] != '\0' || share_len > 0xfffe) ++ { ++ vfs_mount_error(mp, "Invalid from"); ++ return (EINVAL); ++ } + - pShFlGlobalInfo->uid = uid; - pShFlGlobalInfo->gid = gid; -- ++ /* Check that the mount device exists */ ++ if (share_name == NULL) ++ return (EINVAL); + - mp->mnt_data = pShFlGlobalInfo; -- ++ NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, share_name, td); ++ printf("Device exist_0 %d", namei(ndp)); ++ if ((error = namei(ndp))) ++ return (error); ++ printf("Device exist"); ++ NDFREE(ndp, NDF_ONLY_PNBUF); ++ devvp = ndp->ni_vp; + - /* @todo root vnode. */ -- ++ printf("Device exist_2"); ++ if (vn_isdisk(devvp, &error) == 0) { ++ vput(devvp); ++ return (error); ++ } + - vfs_getnewfsid(mp); - vfs_mountedfrom(mp, pszShare); -- ++ printf("Device exist_3"); ++ /* Check the access rights on the mount device */ ++ error = VOP_ACCESS(devvp, VREAD, td->td_ucred, td); ++ if (error) ++ error = priv_check(td, PRIV_VFS_MOUNT_PERM); ++ if (error) { ++ vput(devvp); ++ return (error); ++ } + - printf("%s: Leave rc=0\n", __FUNCTION__); -- -- return 0; --} -- --static int vboxvfs_unmount(struct mount *mp, int mntflags, struct thread *td) --{ -- struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); -- int rc; -- int flags = 0; -- -- rc = vboxCallUnmapFolder(&g_vboxSFClient, &pShFlGlobalInfo->map); -- if (RT_FAILURE(rc)) -- printf("Failed to unmap shared folder\n"); -- -- 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; -- -- -- RTMemFree(pShFlGlobalInfo); -- mp->mnt_data = NULL; -- -- return 0; --} -- --static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) --{ -- int rc = 0; -- struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp); -- struct vnode *vp; -- -- printf("%s: Enter\n", __FUNCTION__); -- -- vp = pShFlGlobalInfo->vnode_root; -- VREF(vp); -- -- vn_lock(vp, flags | LK_RETRY, td); -- *vpp = vp; -- -- printf("%s: Leave\n", __FUNCTION__); -- -- return rc; --} -- --static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, struct thread *td) --{ -- 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 vboxvfs_uninit(struct vfsconf *vfsp) --{ -- vboxDisconnect(&g_vboxSFClient); -- vboxUninit(); -- -- return 0; --} -- --int vboxvfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td) --{ ++ printf("Device exist_4"); ++ dev = devvp->v_rdev; ++ dev_ref(dev); ++ DROP_GIANT(); ++ g_topology_lock(); ++ error = g_vfs_open(devvp, &cp, "vboxvfs", 0); ++ g_topology_unlock(); ++ PICKUP_GIANT(); ++ VOP_UNLOCK(devvp, 0); ++ if (error) ++ goto bail; + - return 0; --} -Index: src/VBox/Additions/freebsd/vboxvfs/vboxfs.h -=================================================================== ---- src/VBox/Additions/freebsd/vboxvfs/vboxfs.h (revision 0) -+++ src/VBox/Additions/freebsd/vboxvfs/vboxfs.h (working copy) -@@ -0,0 +1,326 @@ -+/* $Id: vboxfs.h $ */ -+/** @file -+ * Description. -+ */ -+ -+/* -+ * Copyright (C) 2010 Oracle Corporation -+ * -+ * This file is part of VirtualBox Open Source Edition (OSE), as -+ * available from http://www.virtualbox.org. This file is free software; -+ * you can redistribute it and/or modify it under the terms of the GNU -+ * General Public License (GPL) as published by the Free Software -+ * Foundation, in version 2 as it comes in the "COPYING" file of the -+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the -+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. -+ */ -+ -+#ifndef ___VBOXVFS_H___ -+#define ___VBOXVFS_H___ -+ -+#define VBOXVFS_VFSNAME "vboxfs" -+#define VBOXVFS_VERSION 1 -+ -+#define MAX_HOST_NAME 256 -+#define MAX_NLS_NAME 32 -+//#define MODEMASK 07777 /* mode bits plus permission bits */ -+/** Helper macros */ -+#define VFSTOVBOXFS(mp) ((struct vboxfs_mnt *)((mp)->mnt_data)) -+#define VTOVBOXFS(vp) ((struct vboxfs_node *)(vp)->v_data) -+ -+MALLOC_DECLARE(M_VBOXVFS); -+ -+#ifdef _KERNEL -+#include "../../../../../include/iprt/nocrt/limits.h" -+#include "../../../../../include/iprt/alloc.h" -+#include "../../../../../include/iprt/asm.h" -+#include "../../../../../include/iprt/asm-amd64-x86.h" -+#include "../../../../../include/iprt/asm-math.h" -+#include "../../../../../include/iprt/assert.h" -+#include "../../../../../include/iprt/cdefs.h" -+#include "../../../../../include/iprt/err.h" -+#include "../../../../../include/iprt/fs.h" -+#include "../../../../../include/iprt/log.h" -+#include "../../../../../include/iprt/mangling.h" -+#include "../../../../../include/iprt/mem.h" -+#include "../../../../../include/iprt/param.h" -+#include "../../../../../include/iprt/path.h" -+#include "../../../../../include/iprt/semaphore.h" -+#include "../../../../../include/iprt/stdarg.h" -+#include "../../../../../include/iprt/stdint.h" -+#include "../../../../../include/iprt/string.h" -+#include "../../../../../include/iprt/time.h" -+#include "../../../../../include/iprt/types.h" -+#include "../../../../../include/iprt/uni.h" -+#include "../../../../../include/iprt/nocrt/limits.h" -+#include "../../../../../include/iprt/alloc.h" -+#include "../../../../../include/iprt/asm.h" -+#include "../../../../../include/iprt/asm-amd64-x86.h" -+#include "../../../../../include/iprt/asm-math.h" -+#include "../../../../../include/iprt/assert.h" -+#include "../../../../../include/iprt/cdefs.h" -+#include "../../../../../include/iprt/err.h" -+#include "../../../../../include/iprt/fs.h" -+#include "../../../../../include/iprt/log.h" -+#include "../../../../../include/iprt/mangling.h" -+#include "../../../../../include/iprt/mem.h" -+#include "../../../../../include/iprt/param.h" -+#include "../../../../../include/iprt/path.h" -+#include "../../../../../include/iprt/semaphore.h" -+#include "../../../../../include/iprt/stdarg.h" -+#include "../../../../../include/iprt/stdint.h" -+#include "../../../../../include/iprt/string.h" -+#include "../../../../../include/iprt/time.h" -+#include "../../../../../include/iprt/types.h" -+#include "../../../../../include/iprt/uni.h" -+ -+#include "../../common/VBoxGuestLib/SysHlp.h" -+#include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h" -+#include <sys/mount.h> -+#include <sys/vnode.h> -+#include <sys/_timespec.h> -+ -+/* -+ * representation of an active mount point -+ */ -+struct sfp_mount { -+ VBSFMAP map; -+}; -+ -+/* -+ * Mount / Unmount a shared folder. -+ * -+ * sfprov_mount() takes as input the connection pointer and the name of -+ * the shared folder. On success, it returns zero and supplies an -+ * sfp_mount_t handle. On failure it returns any relevant errno value. -+ * -+ * sfprov_unmount() unmounts the mounted file system. It returns 0 on -+ * success and any relevant errno on failure. -+ */ -+typedef struct sfp_mount sfp_mount_t; -+ -+struct sfp_file { -+ SHFLHANDLE handle; -+ VBSFMAP map; /* need this again for the close operation */ -+}; -+ -+typedef struct sfp_file sfp_file_t; -+ -+/* -+ * File operations: open/close/read/write/etc. -+ * -+ * open/create can return any relevant errno, however ENOENT -+ * generally means that the host file didn't exist. -+ */ -+typedef struct sffs_stat { -+ mode_t sf_mode; -+ off_t sf_size; -+ off_t sf_alloc; -+ struct timespec sf_atime; -+ struct timespec sf_mtime; -+ struct timespec sf_ctime; -+} sffs_stat_t; -+ -+/* -+ * Read directory entries. *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309221041.r8MAf91M070320>