vfsmod.c revision b831031535c56ffc5431702eb0b6bffe65491d47
/** @file
*
* vboxvfs -- VirtualBox Guest Additions for Linux:
* Virtual File System for VirtualBox Shared Folders
*
* Module initialization/finalization
* File system registration/deregistration
* Superblock reading
* Few utility functions
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* 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.
*/
/**
* @note Anyone wishing to make changes here might wish to take a look at
* which seems to be the closest there is to official documentation on
* writing filesystem drivers for Linux.
*/
/*
* Suppress the definition of wchar_t from stddef.h that occurs below.
* This makes (at least) RHEL3U5 happy.
*/
#if 0
# define _WCHAR_T
#endif
#endif
#include "vfsmod.h"
// #define wchar_t linux_wchar_t
#define str(s) #s
MODULE_DESCRIPTION ("Host file system access VFS for VirtualBox");
MODULE_AUTHOR ("innotek GmbH");
MODULE_LICENSE ("GPL");
#ifdef MODULE_VERSION
#endif
/* globals */
/* forward declarations */
static struct super_operations sf_super_ops;
// #include "utils.c"
// #include "dirops.c"
// #include "regops.c"
/* allocate global info, try to map host share */
static int
{
struct sf_glob_info *sf_g;
TRACE ();
if (!sf_g) {
LogRelFunc(("could not allocate memory for global info\n"));
goto fail0;
}
if (name_len > 0xfffe) {
err = -ENAMETOOLONG;
LogFunc(("map name too big\n"));
goto fail1;
}
if (!str_name) {
LogRelFunc(("could not allocate memory for host name\n"));
goto fail1;
}
goto fail1;
}
}
else {
}
if (VBOX_FAILURE (rc)) {
goto fail2;
}
return 0;
}
return err;
}
/* unmap the share and free global info [sf_g] */
static void
{
int rc;
TRACE ();
if (VBOX_FAILURE (rc)) {
}
}
}
/* this is called (by sf_read_super_[24|26] when vfs mounts the fs and
wants to read super_block.
calls [sf_glob_alloc] to map the folder and allocate global
information structure.
initializes [sb], initializes root inode and dentry.
should respect [flags] */
static int
{
int err;
struct sf_inode_info *sf_i;
struct sf_glob_info *sf_g;
struct vbsf_mount_info *info;
TRACE ();
if (!data) {
LogFunc(("no mount info specified\n"));
return -EINVAL;
}
if (flags & MS_REMOUNT) {
LogFunc(("remounting is not supported\n"));
return -ENOSYS;
}
if (err) {
goto fail0;
}
if (!sf_i) {
LogRelFunc (("could not allocate memory for root inode info\n"));
goto fail1;
}
LogRelFunc (("could not allocate memory for root inode path\n"));
goto fail2;
}
if (err) {
LogFunc(("could not stat root of share\n"));
goto fail3;
}
#else
#endif
if (!iroot) {
LogFunc(("could not get root inode\n"));
goto fail3;
}
#endif
if (!droot) {
LogFunc(("d_alloc_root failed\n"));
goto fail4;
}
return 0;
sf_glob_free (sf_g);
return err;
}
static struct super_block *
{
int err;
TRACE ();
if (err) {
return NULL;
}
return sb;
}
#endif
/* this is called when vfs is about to destroy the [inode]. all
resources associated with this [inode] must be cleared here */
static void
{
struct sf_inode_info *sf_i;
TRACE ();
if (!sf_i) {
return;
}
}
/* this is called by vfs when it wants to populate [inode] with data.
the only thing that is known about inode at this point is its index
job to properly fill then [inode] */
static void
{
}
#endif
/* vfs is done with [sb] (umount called) call [sf_glob_free] to unmap
the folder and free [sf_g] */
static void
{
struct sf_glob_info *sf_g;
sf_glob_free (sf_g);
}
static int
{
}
#else
static int
{
}
#endif
static int
{
TRACE ();
return -ENOSYS;
}
static struct super_operations sf_super_ops = {
#endif
};
#else
static int
{
int err;
TRACE ();
if (err) {
}
return err;
}
static struct super_block *
{
TRACE ();
}
#else
static int
{
TRACE ();
}
#endif
static struct file_system_type vboxsf_fs_type = {
.owner = THIS_MODULE,
.name = "vboxsf",
};
#endif
extern int CMC_API
/* Module initialization/finalization handlers */
static int __init
init (void)
{
int rcVBox;
int rcRet = 0;
int err;
TRACE ();
if (sizeof (struct vbsf_mount_info) > PAGE_SIZE) {
"Mount information structure is too large %lu\n"
"Must be less than or equal to %lu\n",
sizeof (struct vbsf_mount_info),
return -EINVAL;
}
if (err) {
return err;
}
if (vboxadd_cmc_ctl_guest_filter_mask (VMMDEV_EVENT_HGCM, 0)) {
goto fail0;
}
if (VBOX_FAILURE (rcVBox)) {
goto fail0;
}
if (VBOX_FAILURE (rcVBox)) {
goto fail1;
}
if (VBOX_FAILURE (rcVBox)) {
goto fail2;
}
"vboxvfs: Successfully loaded version " VBOX_VERSION_STRING
return 0;
vboxUninit ();
return rcRet;
}
static void __exit
fini (void)
{
TRACE ();
vboxUninit ();
}
module_init (init);
module_exit (fini);
/* C++ hack */
int __gxx_personality_v0 = 0xdeadbeef;
#if 0
/* long long hacks (as far as i can see, gcc emits the refs to those
symbols, notwithstanding the fact that those aren't referenced
anywhere in the module) */
void __divdi3 (void)
{
BUG ();
}
void __moddi3 (void)
{
BUG ();
}
#endif /* 0 */
/*
* Local Variables:
* c-mode: linux
* indent-tabs-mode: nil
* c-basic-offset: 8
* End:
*/