socsvn commit: r255117 - soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files
oleksandr at FreeBSD.org
oleksandr at FreeBSD.org
Wed Jul 24 16:27:06 UTC 2013
Author: oleksandr
Date: Wed Jul 24 16:27:05 2013
New Revision: 255117
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255117
Log:
Implemented getattr, setattr and pathconf functions for vboxvfs_vnops
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 Wed Jul 24 15:46:49 2013 (r255116)
+++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-freebsd.kmk Wed Jul 24 16:27:05 2013 (r255117)
@@ -1,868 +1,453 @@
-Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c
+Index: src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c
===================================================================
---- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (revision 4)
-+++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vnops.c (working copy)
-@@ -14,8 +14,7 @@
+--- src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c (revision 4)
++++ src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c (working copy)
+@@ -14,13 +14,13 @@
* 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"
-+#if 0
++#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
- #include <sys/namei.h>
-@@ -33,7 +32,29 @@
+ #include <sys/proc.h>
+ #include <sys/bio.h>
+ #include <sys/buf.h>
++#include <sys/dirent.h>
+ #include <sys/kernel.h>
+ #include <sys/sysctl.h>
+ #include <sys/vnode.h>
+@@ -29,10 +29,40 @@
+ #include <sys/malloc.h>
+ #include <sys/module.h>
- #include <vm/vm.h>
- #include <vm/vm_extern.h>
-+#endif
+-#include <iprt/mem.h>
++#include "vboxvfs.h"
++#if 0
++#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
-+#include <sys/namei.h>
-+#include <sys/kernel.h>
-+#include <sys/types.h>
-+#include <sys/malloc.h>
-+#include <sys/stat.h>
++#include <sys/uio.h>
+#include <sys/bio.h>
-+#include <sys/conf.h>
+#include <sys/buf.h>
++#include <sys/conf.h>
++#include <sys/dirent.h>
++#include <sys/fcntl.h>
+#include <sys/iconv.h>
++#include <sys/kernel.h>
++#include <sys/malloc.h>
+#include <sys/mount.h>
-+#include <sys/vnode.h>
-+#include <sys/dirent.h>
++#include <sys/namei.h>
++#include <sys/priv.h>
++#include <sys/proc.h>
+#include <sys/queue.h>
-+#include <sys/unistd.h>
++#include <sys/vnode.h>
+#include <sys/endian.h>
++#include <geom/geom.h>
++#include <geom/geom_vfs.h>
++
+#include <vm/uma.h>
++#endif
+
-+#include "vboxvfs.h"
+ #define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data)
+
++#ifdef MALLOC_DECLARE
++MALLOC_DEFINE(M_VBOXVFS, "vboxvfs", "VBOX VFS");
++#endif
+
- /*
- * Prototypes for VBOXVFS vnode operations
- */
-@@ -56,6 +77,7 @@
- static vop_symlink_t vboxvfs_symlink;
- static vop_readdir_t vboxvfs_readdir;
- static vop_strategy_t vboxvfs_strategy;
-+static vop_bmap_t vboxvfs_bmap;
- static vop_print_t vboxvfs_print;
- static vop_pathconf_t vboxvfs_pathconf;
- static vop_advlock_t vboxvfs_advlock;
-@@ -65,177 +87,755 @@
- static vop_inactive_t vboxvfs_inactive;
- static vop_putpages_t vboxvfs_putpages;
- static vop_reclaim_t vboxvfs_reclaim;
-+static vop_vptofh_t vboxvfs_vptofh;
+ static int vboxvfs_version = VBOXVFS_VERSION;
- struct vop_vector vboxvfs_vnodeops = {
-- .vop_default = &default_vnodeops,
-+ .vop_default = &default_vnodeops,
+ SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem");
+@@ -51,15 +81,15 @@
+ static vfs_unmount_t vboxvfs_unmount;
-- .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,
-+ .vop_access = vboxvfs_access,
-+ .vop_bmap = vboxvfs_bmap,
-+ .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_vptofh = vboxvfs_vptofh,
-+ .vop_symlink = vboxvfs_symlink,
-+ .vop_write = vboxvfs_write,
+ 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,
};
-+/*
-+ * uid and gid in sffs determine owner and group for all files.
-+ */
-+#if 0
-+static int
-+sfnode_access(sfnode_t *node, mode_t mode, cred_t *cr)
-+{
-+ sffs_data_t *sffs = node->sf_sffs;
-+ mode_t m;
-+ int shift = 0;
-+ int error;
-+ vnode_t *vp;
-+ ASSERT(MUTEX_HELD(&sffs_lock));
-+
-+ /*
-+ * get the mode from the cache or provider
-+ */
-+ if (sfnode_stat_cached(node))
-+ error = 0;
-+ else
-+ error = sfnode_update_stat_cache(node);
-+ m = (error == 0) ? node->sf_stat.sf_mode : 0;
-+
-+ /*
-+ * mask off the permissions based on uid/gid
-+ */
-+ if (crgetuid(cr) != sffs->sf_uid) {
-+ shift += 3;
-+ if (groupmember(sffs->sf_gid, cr) == 0)
-+ shift += 3;
-+ }
-+ mode &= ~(m << shift);
-+
-+ if (mode == 0) {
-+ error = 0;
-+ } else {
-+ vp = sfnode_get_vnode(node);
-+ error = secpolicy_vnode_access(cr, vp, sffs->sf_uid, mode);
-+ VN_RELE(vp);
-+ }
-+ return (error);
-+}
-+#endif
- static int vboxvfs_access(struct vop_access_args *ap)
+
+@@ -66,193 +96,238 @@
+ 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)
{
-- return 0;
-+#if 0
-+ sfnode_t *node = VN2SFN(vp->a_vp);
-+ int error;
-+
-+ mutex_enter(&sffs_lock);
-+ error = sfnode_access(node, mode, cr);
-+ mutex_exit(&sffs_lock);
-+
-+ return (error);
-+#endif
-+ struct vnode *vp = ap->a_vp;
-+ accmode_t accmode = ap->a_accmode;
-+
-+ if ((accmode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
-+ switch (vp->v_type) {
-+ case VDIR:
-+ case VLNK:
-+ case VREG:
-+ return (EROFS);
-+ /* NOT REACHED */
-+ default:
-+ break;
-+ }
-+ }
-+ return (vaccess(vp->v_type, 0444, 0, 0,
-+ accmode, ap->a_cred, NULL));
- }
+- struct vboxvfs_mount_info args;
+- int rc = 0;
++ struct vboxvfs_mount_info args;
++ int rc = 0;
-+/*
-+ * Clears the (cached) directory listing for the node.
-+ */
-+static void
-+vfsnode_clear_dir_list(struct vboxvfs_node *np)
-+{
-+ while (np->sf_dir_list != NULL) {
-+ sffs_dirents_t *next = np->sf_dir_list->sf_next;
-+ free(np->sf_dir_list, M_VBOXVFS);
-+ np->sf_dir_list = next;
-+ }
-+}
-+
-+/*
-+ * Open the provider file associated with a vnode. Holding the file open is
-+ * the only way we have of trying to have a vnode continue to refer to the
-+ * same host file in the host in light of the possibility of host side renames.
-+ */
-+static void
-+vfsnode_open(struct vboxvfs_node *np)
-+{
-+ int error;
-+ sfp_file_t *fp;
-+
-+ if (np->sf_file != NULL)
-+ return;
-+ error = sfprov_open(np->vboxvfsmp->sf_handle, np->sf_path, &fp);
-+ if (error == 0)
-+ np->sf_file = fp;
-+}
-+
- static int vboxvfs_open(struct vop_open_args *ap)
- {
-- return 0;
-+ struct vnode *vp = ap->a_vp;
-+ struct vboxvfs_node *np;
-+ int error = 0;
-+ off_t fsize;
-+
-+ np = VTOVBOXFS(vp);
-+ vfsnode_open(np);
-+ if (np->sf_file == NULL)
-+ error = EINVAL;
-+
-+ fsize = np->vboxvfsmp->size;
-+ vnode_create_vobject(ap->a_vp, fsize, ap->a_td);
-+
-+ return (error);
- }
-+#if 0
-+static uint64_t
-+sfnode_cur_time_usec(void)
-+{
-+ clock_t now = drv_hztousec(ddi_get_lbolt());
-+ return now;
-+}
+- printf("%s: Enter\n", __FUNCTION__);
++ printf("%s: Enter\n", __FUNCTION__);
-+static int
-+sfnode_stat_cached(sfnode_t *node)
-+{
-+ return (sfnode_cur_time_usec() - node->sf_stat_time) <
-+ node->sf_sffs->sf_stat_ttl * 1000L;
-+}
-+#endif
-+static void
-+vfsnode_invalidate_stat_cache(struct vboxvfs_node *np)
-+{
-+ np->sf_stat_time = 0;
-+}
-+
- static int vboxvfs_close(struct vop_close_args *ap)
- {
-- return 0;
-+
-+ struct vnode *vp = ap->a_vp;
-+ struct vboxvfs_node *np;
-+
-+ np = VTOVBOXFS(vp);
-+
-+ /*
-+ * Free the directory entries for the node. We do this on this call
-+ * here because the directory node may not become inactive for a long
-+ * time after the readdir is over. Case in point, if somebody cd's into
-+ * the directory then it won't become inactive until they cd away again.
-+ * In such a case we would end up with the directory listing not getting
-+ * updated (i.e. the result of 'ls' always being the same) until they
-+ * change the working directory.
-+ */
-+ vfsnode_clear_dir_list(np);
-+
-+ vfsnode_invalidate_stat_cache(np);
-+
-+ if (np->sf_file != NULL)
-+ {
-+ (void)sfprov_close(np->sf_file);
-+ np->sf_file = NULL;
-+ }
-+
-+ return (0);
- }
+- 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);
- static int vboxvfs_getattr(struct vop_getattr_args *ap)
- {
-- return 0;
-+#if 0
-+ struct vnode *vp;
-+ struct vboxvfs_node *node;
-+ struct vattr *vap;
-+ struct timespec ts;
-+
-+ ts.tv_sec = 0;
-+
-+ vp = ap->a_vp;
-+ vap = ap->a_vap;
-+ node = VTON(vp);
-+
-+ vap->va_fsid = dev2udev(nodevgmp->im_dev);
-+ vap->va_fileid = node->hash_id;
-+ vap->va_uid = 0;
-+ vap->va_gid = 0;
-+ vap->va_atime.tv_sec = VNOVAL;
-+ vap->va_atime.tv_nsec = VNOVAL;
-+ vap->va_mtime.tv_sec = VNOVAL;
-+ vap->va_mtime.tv_nsec = VNOVAL;
-+ vap->va_ctime.tv_sec = VNOVAL;
-+ vap->va_ctime.tv_nsec = VNOVAL;
-+ vap->va_rdev = NODEV;
-+ if (vp->v_type & VDIR) {
-+ vap->va_size = 40; /*XXX*/
-+ vap->va_nlink = 2;
-+ vap->va_mode = 0555;
-+ } else {
-+ vap->va_size = node->vboxvfsmp->size;
-+ vap->va_nlink = 1;
-+ vap->va_mode = 0444;
-+ }
-+ vap->va_flags = 0;
-+ vap->va_gen = 1;
-+ vap->va_blocksize = node->vboxvfsmp->bsize;
-+ vap->va_bytes = vap->va_size;
-+ vap->va_type = vp->v_type;
-+ vap->va_filerev = 0;
-+#endif
-+ return (0);
- }
+- 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);
- static int vboxvfs_setattr(struct vop_setattr_args *ap)
- {
-- return 0;
-+#if 0
-+ struct vnode *vp;
-+ struct vattr *vap;
-+
-+ vp = ap->a_vp;
-+ vap = ap->a_vap;
-+ if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
-+ vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
-+ vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)
-+ return (EROFS);
-+ if (vap->va_size != (u_quad_t)VNOVAL) {
-+ switch (vp->v_type) {
-+ case VDIR:
-+ return (EISDIR);
-+ case VLNK:
-+ case VREG:
-+ return (EROFS);
-+ case VCHR:
-+ case VBLK:
-+ case VSOCK:
-+ case VFIFO:
-+ case VNON:
-+ case VBAD:
-+ case VMARKER:
-+ return (0);
-+ }
-+ }
-+#endif
-+ return (0);
- }
+- rc = kernel_mount(ma, flags);
++ rc = kernel_mount(ma, flags);
- static int vboxvfs_read(struct vop_read_args *ap)
- {
-- return 0;
-+#if 0
-+ static const int clustersize = MAXBSIZE;
-+
-+ struct vnode *vp = ap->a_vp;
-+ struct uio *uio = ap->a_uio;
-+ struct vboxvfs_node *node = VTON(vp);
-+ struct vboxvfs_mnt *vboxvfsmp;
-+ struct buf *bp;
-+ daddr_t lbn;
-+ off_t diff, fsize;
-+ int error = 0;
-+ long size, n, on;
-+
-+ if (uio->uio_resid == 0)
-+ return (0);
-+ if (uio->uio_offset < 0)
-+ return (EINVAL);
-+
-+ if (vp->v_type == VCHR || vp->v_type == VBLK)
-+ return (EOPNOTSUPP);
-+ if (vp->v_type != VREG)
-+ return (EINVAL);
-+
-+ vboxvfsmp = node->vboxvfsmp;
-+ fsize = vboxvfsmp->size;
-+
-+ do {
-+ lbn = lblkno(vboxvfsmp, uio->uio_offset);
-+ on = blkoff(vboxvfsmp, uio->uio_offset);
-+ n = min((u_int)(clustersize - on), uio->uio_resid);
-+ diff = fsize - uio->uio_offset;
-+ if (diff <= 0)
-+ return (0);
-+ if (diff < n)
-+ n = diff;
-+
-+ size = (n + vboxvfsmp->bmask) & ~vboxvfsmp->bmask;
-+ if (vboxvfsmp->use_devvp)
-+ error = bread(vboxvfsmp->im_devvp,
-+ lbn << (vboxvfsmp->bshift - DEV_BSHIFT),
-+ size, NOCRED, &bp);
-+ else
-+ error = bread(vp, lbn, size, NOCRED, &bp);
-+
-+ n = min(n, size - bp->b_resid);
-+ if (error) {
-+ brelse(bp);
-+ return (error);
-+ }
-+ error = uiomove(bp->b_data + on, (int)n, uio);
-+ brelse(bp);
-+ } while (error == 0 && uio->uio_resid > 0 && n != 0);
-+ return (error);
-+#endif
-+ return (0);
- }
+- printf("%s: Leave rc=%d\n", __FUNCTION__, rc);
++ printf("%s: Leave rc=%d\n", __FUNCTION__, rc);
- static int vboxvfs_write(struct vop_write_args *ap)
- {
-- return 0;
-+ return (0);
- }
+- return rc;
+-}
++ return (rc);
++};
- static int vboxvfs_create(struct vop_create_args *ap)
- {
-- return 0;
-+ return (0);
- }
+ static const char *vboxvfs_opts[] = {
+- "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL
++ "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL
+ };
- static int vboxvfs_remove(struct vop_remove_args *ap)
+-static int vboxvfs_mount(struct mount *mp, struct thread *td)
++static int vboxvfs_mount(struct mount *mp)
{
-- return 0;
-+ return (0);
- }
+- 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;
- static int vboxvfs_rename(struct vop_rename_args *ap)
- {
-- return 0;
-+ return (0);
- }
+- printf("%s: Enter\n", __FUNCTION__);
++ printf("%s: Enter\n", __FUNCTION__);
- static int vboxvfs_link(struct vop_link_args *ap)
- {
-- return EOPNOTSUPP;
-+ return (EOPNOTSUPP);
- }
+- if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
+- return EOPNOTSUPP;
++ if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
++ return (EOPNOTSUPP);
- static int vboxvfs_symlink(struct vop_symlink_args *ap)
- {
-- return EOPNOTSUPP;
-+ 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);
++ }
- static int vboxvfs_mknod(struct vop_mknod_args *ap)
- {
-- return EOPNOTSUPP;
-+ return (EOPNOTSUPP);
- }
+- 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);
- static int vboxvfs_mkdir(struct vop_mkdir_args *ap)
- {
-- return 0;
-+ return (0);
- }
+- 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;
- static int vboxvfs_rmdir(struct vop_rmdir_args *ap)
- {
-- return 0;
-+ return (0);
- }
-+#if 0
-+struct vboxvfs_uiodir {
-+ struct dirent *dirent;
-+ u_long *cookies;
-+ int ncookies;
-+ int acookies;
-+ int eofflag;
-+};
+- 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;
-+static int
-+vboxvfs_uiodir(struct vboxvfs_uiodir *uiodir, int de_size, struct uio *uio, long cookie)
-+{
-+ if (uiodir->cookies != NULL) {
-+ if (++uiodir->acookies > uiodir->ncookies) {
-+ uiodir->eofflag = 0;
-+ return (-1);
-+ }
-+ *uiodir->cookies++ = cookie;
-+ }
-+
-+ if (uio->uio_resid < de_size) {
-+ uiodir->eofflag = 0;
-+ return (-1);
-+ }
-+
-+ return (uiomove(uiodir->dirent, de_size, uio));
-+}
-+#endif
- static int vboxvfs_readdir(struct vop_readdir_args *ap)
- {
-- return 0;
-+#if 0
-+ struct vnode *vp;
-+ struct uio *uio;
-+ struct dirent dir;
-+ struct vboxvfs_node *node;
-+ struct vboxvfs_mnt *vboxvfsmp;
-+ struct vboxvfs_uiodir uiodir;
-+ u_long *cookies = NULL;
-+ int ncookies;
-+ int error = 0;
-+
-+ vp = ap->a_vp;
-+ uio = ap->a_uio;
-+ node = VTON(vp);
-+ vboxvfsmp = node->vboxvfsmp;
-+ uiodir.eofflag = 1;
-+
-+ if (a->a_ncookies != NULL) {
-+ /*
-+ * Guess how many entries are needed. If we run out, this
-+ * function will be called again and thing will pick up were
-+ * it left off.
-+ */
-+ ncookies = uio->uio_resid / 8;
-+ cookies = malloc(sizeof(u_long) * ncookies,
-+ M_TEMP, M_WAITOK);
-+ if (cookies == NULL)
-+ return (ENOMEM);
-+ uiodir.ncookies = ncookies;
-+ uiodir.cookies = cookies;
-+ uiodir.acookies = 0;
-+ } else {
-+ uiodir.cookies = NULL;
-+ }
-+
-+ /* Do up the '.' and '..' entries. Dummy values are
-+ * used for the cookies since the offset here is
-+ * usually zero, and NFS doesn't like that value
-+ */
-+ if (uio->uio_offset == 0) {
-+ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */
-+ dir.d_type = DT_DIR;
-+ dir.d_name[0] = '.';
-+ dir.d_name[1] = '\0';
-+ dir.d_namlen = 1;
-+ dir.d_reclen = GENERIC_DIRSIZ(&dir);
-+ uiodir.dirent = &dir;
-+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 1);
-+ if (error)
-+ goto finished;
-+
-+ dir.d_fileno = node->hash_id; /* AVG_ROOTDIR_INO */
-+ dir.d_type = DT_DIR;
-+ dir.d_name[0] = '.';
-+ dir.d_name[1] = '.';
-+ dir.d_name[2] = '\0';
-+ dir.d_namlen = 2;
-+ dir.d_reclen = GENERIC_DIRSIZ(&dir);
-+ uiodir.dirent = &dir;
-+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 2);
-+ if (error)
-+ goto finished;
-+
-+ strcpy(&dir.d_name[0], AVG_THEFILE_NAME);
-+ dir.d_namlen = strlen(AVG_THEFILE_NAME);
-+ dir.d_fileno = AVG_THEFILE_INO;
-+ dir.d_type = DT_REG;
-+ dir.d_reclen = GENERIC_DIRSIZ(&dir);
-+ uiodir.dirent = &dir;
-+ error = vboxvfs_uiodir(&uiodir, dir.d_reclen, uio, 3);
-+ if (error)
-+ goto finished;
-+ }
-+
-+finished:
-+
-+ /* tell the calling layer whether we need to be called again */
-+ *ap->a_eofflag = uiodir.eofflag;
-+
-+ if (error < 0)
-+ error = 0;
-+
-+ if (ap-g>a_ncookies != NULL) {
-+ if (error)
-+ free(cookies, M_TEMP);
-+ else {
-+ *ap->a_ncookies = uiodir.acookies;
-+ *ap->a_cookies = cookies;
-+ }
-+ }
-+
-+ return (error);
-+#endif
-+ return (0);
- }
+- pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info));
+- if (!pShFlGlobalInfo)
+- return ENOMEM;
++ pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info));
++ if (!pShFlGlobalInfo)
++ return ENOMEM;
- static int vboxvfs_fsync(struct vop_fsync_args *ap)
- {
-- return 0;
-+ return (0);
- }
+- 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;
- static int vboxvfs_print (struct vop_print_args *ap)
- {
-- return 0;
-+#if 0
-+ struct vnode *vp = ap->a_vp;
-+ struct vboxvfs_node *node;
-+
-+ node = VTON(vp);
-+ printf(" ino %lu, on dev %s", (u_long)node->hash_id,
-+ devtoname(node->vboxvfsmp->im_dev));
-+ printf("\n");
-+#endif
-+ return (0);
- }
+- 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);
- static int vboxvfs_pathconf (struct vop_pathconf_args *ap)
- {
-- return 0;
-+#if 0
-+ switch (ap->a_name) {
-+ case _PC_LINK_MAX:
-+ *ap->a_retval = 65535;
-+ return (0);
-+ case _PC_NAME_MAX:
-+ i *ap->a_retval = NAME_MAX;
-+ return (0);
-+ case _PC_PATH_MAX:
-+ *ap->a_retval = PATH_MAX;
-+ return (0);
-+ case _PC_NO_TRUNC:
-+ *ap->a_retval = 1;
-+ return (0);
-+ default:
-+ return (EINVAL);
-+ }
-+#endif
-+ return (0);
- }
+- rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map);
+- RTMemFree(pShFlShareName);
++ rc = vboxCallMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map);
++ RTMemFree(pShFlShareName);
- static int vboxvfs_strategy (struct vop_strategy_args *ap)
- {
-- return 0;
-+#if 0
-+ struct buf *bp;
-+ struct vnode *vp;
-+ struct vboxvfs_node *node;
-+ struct bufobj *bo;
-+
-+ bp = ap->a_bp;
-+ vp = ap->a_vp;
-+ node = VTON(vp);
-+
-+ if (bp->b_blkno == bp->b_lblkno) {
-+ bp->b_blkno = bp->b_lblkno << (node->vboxvfsmp->bshift - DEV_BSHIFT);
-+ }
-+ bo = node->vboxfsmp->im_bo;
-+ bp->b_iooffset = dbtob(bp->b_blkno);
-+ BO_STRATEGY(bo, bp);
-+#endif
-+ return (0);
- }
+- 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);
++ }
-+static int
-+vboxvfs_bmap(struct vop_bmap_args *ap)
-+{
-+#if 0
-+ struct vboxvfs_node *node;
-+
-+ node = VTON(ap->a_vp);
-+
-+ if (ap->a_bop != NULL)
-+ *ap->a_bop = &node->vboxvfsmp->im_devvp->v_bufobj;
-+ if (ap->a_bnp == NULL)
-+ return (0);
-+ if (ap->a_runb)
-+ *ap->a_runb = 0;
-+
-+ /* Translate logical to physical sector number */
-+ *ap->a_bnp = ap->a_bn << (node->vboxvfsmp->bshift - DEV_BSHIFT);
-+
-+ if (ap->a_runp)
-+ *ap->a_runp = 0;
-+ if (ap->a_runb)
-+ *ap->a_runb = 0;
-+#endif
-+ return (0);
-+}
-+
-+/*
-+ * File specific ioctls.
-+ */
- static int vboxvfs_ioctl(struct vop_ioctl_args *ap)
- {
-- return ENOTTY;
-+ printf("%s called\n", __func__);
-+ return (ENOTTY);
- }
+- 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__);
- static int vboxvfs_getextattr(struct vop_getextattr_args *ap)
- {
- return 0;
+-}
+ return (0);
- }
++};
- static int vboxvfs_advlock(struct vop_advlock_args *ap)
+-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, &pShFlGlobalInfo->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(pShFlGlobalInfo);
++ mp->mnt_data = NULL;
+
- return 0;
+ return (0);
}
- static int vboxvfs_lookup(struct vop_lookup_args *ap)
+-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)
{
-- return 0;
-+#if 0
-+ struct vnode *dvp;
-+ struct vnode *tdp = NULL;
-+ struct vnode **vpp = ap->a_vpp;
-+ struct vboxvfs_node *node;
-+ struct vboxvfs_mnt *vboxvfsmp;
-+ u_long nameiop;
-+ u_long flags;
-+ char *nameptr;
-+ long namelen;
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-soc-all
mailing list