vboxvfs_vfsops.c revision fc3a35e9acf780b1098f7d03bc0df1ef09bca298
/* $Id$ */
/** @file
* VirtualBox File System Driver for Solaris Guests.
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* Sun Microsystems, Inc. confidential
* All rights reserved
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "vboxvfs.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** The module name. */
#define DEVICE_NAME "vboxvfs"
/** The module description as seen in 'modinfo'. */
#define DEVICE_DESC "VirtualBox Shared Filesystem"
/** Mount Options */
#define MNTOPT_VBOXVFS_UID "uid"
#define MNTOPT_VBOXVFS_GID "gid"
/** Helpers */
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static int vboxvfs_CheckMountPerm(vfs_t *pVFS, struct mounta *pMount, vnode_t *pVNodeSpec, cred_t *pCred);
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* mntopts_t: mount options table array
*/
static mntopt_t g_VBoxVFSMountOptions[] =
{
/* Option Name Cancel Opt. Default Arg Flags Data */
};
/**
* mntopts_t: mount options table prototype
*/
static mntopts_t g_VBoxVFSMountTableProt =
{
sizeof(g_VBoxVFSMountOptions) / sizeof(mntopt_t),
};
/**
* vfsdef_t: driver specific mount options
*/
static vfsdef_t g_VBoxVFSDef =
{
};
/**
* modlfs: loadable file system
*/
static struct modlfs g_VBoxVFSLoadMod =
{
&mod_fsops, /* extern from kernel */
};
/**
*/
static struct modlinkage g_VBoxVFSModLinkage =
{
MODREV_1, /* loadable module system revision */
NULL /* terminate array of linkage structures */
};
/**
* state info. for vboxvfs
*/
typedef struct
{
/** Device Info handle. */
/** Driver Mutex. */
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Opaque pointer to list of states. */
static void *g_pVBoxVFSState;
/** GCC C++ hack. */
unsigned __gxx_personality_v0 = 0xdecea5ed;
/** Global connection to the client. */
static VBSFCLIENT g_VBoxVFSClient;
/** Global VFS Operations pointer. */
/** The file system type identifier. */
static int g_VBoxVFSType;
/**
* Kernel entry points
*/
int _init(void)
{
if (!rc)
{
if (rc)
}
return rc;
}
int _fini(void)
{
if (!rc)
return rc;
}
{
}
{
int rc;
/* Initialize the R0 guest library. */
if (VBOX_SUCCESS(rc))
{
/* Connect to the host service. */
if (VBOX_SUCCESS(rc))
{
/* Use UTF-8 encoding. */
if (VBOX_SUCCESS(rc))
{
/* Fill up VFS user entry points. */
static const fs_operation_def_t s_VBoxVFS_vfsops_template[] =
{
};
if (!rc)
{
/* Set VNode operations. */
if (!rc)
{
return 0;
}
}
else
}
else
{
}
}
else
{
}
vboxUninit();
}
else
{
}
return rc;
}
{
int rc;
int Uid = 0;
int Gid = 0;
char *pszShare;
#if 0
#endif
/* Check user credentials for mounting in the specified target. */
if (rc)
{
return EPERM;
}
/* We can mount to only directories. */
return ENOTDIR;
/* We don't support remounting. */
return ENOTSUP;
{
return EBUSY;
}
/* I don't think we really need to support kernel mount arguments anymore. */
#if 0
/* Retreive arguments. */
&& cbData > 0)
{
{
LogRel((DEVICE_NAME: "VBoxVFS_Mount: argument length too long. expected=%d. received=%d\n", sizeof(Args), cbData));
return EINVAL;
}
/* Copy arguments; they can be in kernel or user space. */
if (rc)
{
return EFAULT;
}
}
else
{
cbData = 0;
}
#endif
/* Get UID argument (optional). */
if (rc < 0)
{
return EINVAL;
}
/* Get GID argument (optional). */
if (rc < 0)
{
return EINVAL;
}
/* Get special (sharename). */
if (!rc)
{
/* Get the vnode for the special file for storing the device identifier and path. */
if (!rc)
{
/* Check if user has permission to use the special file for mounting. */
if (!rc)
{
}
else
}
else
}
else
{
}
if (!rc)
return rc;
/* Get VNode of the special file being mounted. */
{
/* Open the vnode for mounting. */
if (rc)
{
}
}
else
{
}
if (!rc)
{
return rc;
}
/* Allocate the global info. structure. */
if (!pVBoxVFSGlobalInfo)
{
LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for global struct.\n", sizeof(*pVBoxVFSGlobalInfo)));
return ENOMEM;
}
if (!pShflShareName)
{
LogRel((DEVICE_NAME ":VBoxVFS_Mount: RTMemAlloc failed to alloc %d bytes for ShFlShareName.\n", cbShflShareName));
return ENOMEM;
}
if (VBOX_FAILURE (rc))
{
return EPROTO;
}
/* @todo mutex for protecting the structure. */
/* @todo root vnode */
return 0;
}
{
int rc;
/* Check if user can unmount. */
if (rc)
{
return EPERM;
}
/* @todo implement ref-counting of active vnodes & check for busy state here. */
/* @todo mutex protection needed here */
if (VBOX_FAILURE(rc))
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
vboxUninit();
}
static int vboxvfs_CheckMountPerm(vfs_t *pVFS, struct mounta *pMount, vnode_t *pVNodeSpec, cred_t *pCred)
{
/* Check if user has the rights to mount the special file. */
int rc;
return ENOTBLK;
{
}
if (!rc)
return rc;
}
{
int rc;
long Val;
if (rc)
{
if ( !rc
{
return 0;
}
return -1;
}
return 1;
}