regops.c revision 7ca4727ba2f9e3703771a308b11cd551f3fca4fd
/** @file
*
* vboxvfs -- VirtualBox Guest Additions for Linux:
* Regular file inode and file operations
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*
* Limitations: only COW memory mapping is supported
*/
#include "vfsmod.h"
static void *alloc_bounch_buffer (size_t *tmp_sizep, PRTCCPHYS physp, size_t xfer_size, const char *caller)
{
void *tmp;
/* try for big first. */
if (!tmp) {
/* fall back on a page sized buffer. */
if (!tmp) {
return NULL;
}
}
return tmp;
}
static void free_bounch_buffer (void *tmp)
{
}
/* fops */
static int
{
/** @todo bird: yes, kmap() and kmalloc() input only. Since the buffer is
* contiguous in physical memory (kmalloc or single page), we should
* use a physical address here to speed things up. */
if (RT_FAILURE (rc)) {
LogFunc(("vboxCallRead failed. caller=%s, rc=%Rrc\n",
return -EPROTO;
}
return 0;
}
static int
{
/** @todo bird: yes, kmap() and kmalloc() input only. Since the buffer is
* contiguous in physical memory (kmalloc or single page), we should
* use a physical address here to speed things up. */
if (RT_FAILURE (rc)) {
LogFunc(("vboxCallWrite failed. caller=%s, rc=%Rrc\n",
return -EPROTO;
}
return 0;
}
static ssize_t
{
int err;
void *tmp;
ssize_t total_bytes_read = 0;
TRACE ();
return -EINVAL;
}
/** XXX Check read permission accoring to inode->i_mode! */
if (!size) {
return 0;
}
if (!tmp)
return -ENOMEM;
while (left) {
}
if (err)
goto fail;
goto fail;
}
break;
}
}
*off += total_bytes_read;
return total_bytes_read;
fail:
return err;
}
static ssize_t
{
int err;
void *tmp;
TRACE ();
return -EINVAL;
}
/** XXX Check write permission accoring to inode->i_mode! */
if (!size)
return 0;
if (!tmp)
return -ENOMEM;
while (left) {
}
goto fail;
}
#if 1
if (VbglR0CanUsePhysPageList()) {
} else
#endif
if (err)
goto fail;
break;
}
#if 1 /* XXX: which way is correct? */
*off += total_bytes_written;
#else
#endif
return total_bytes_written;
fail:
return err;
}
static int
{
struct sf_reg_info *sf_r;
TRACE ();
if (!sf_r) {
LogRelFunc(("could not allocate reg info\n"));
return -ENOMEM;
}
/* We check the value of params.Handle afterwards to find out if
* the call succeeded or failed, as the API does not seem to cleanly
* distinguish error and informational messages.
*
* Furthermore, we must set params.Handle to SHFL_HANDLE_NIL to
* make the shared folders host service use our fMode parameter */
LogFunc(("O_CREAT set\n"));
/* We ignore O_EXCL, as the Linux kernel seems to call create
beforehand itself, so O_EXCL should always fail. */
LogFunc(("O_TRUNC set\n"));
}
else {
}
}
else {
LogFunc(("O_TRUNC set\n"));
}
}
case O_RDONLY:
break;
case O_WRONLY:
break;
case O_RDWR:
break;
default:
BUG ();
}
}
LogFunc(("sf_reg_open: calling vboxCallCreate, file %s, flags=%d, %#x\n",
if (RT_FAILURE (rc)) {
LogFunc(("vboxCallCreate failed flags=%d,%#x rc=%Rrc\n",
return -RTErrConvertToErrno(rc);
}
case SHFL_PATH_NOT_FOUND:
case SHFL_FILE_NOT_FOUND:
break;
case SHFL_FILE_EXISTS:
break;
default:
break;
}
}
return rc_linux;
}
static int
{
int rc;
struct sf_reg_info *sf_r;
struct sf_glob_info *sf_g;
TRACE ();
if (RT_FAILURE (rc)) {
}
return 0;
}
static int
static struct page *
#else /* LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0) */
static struct page *
# define SET_TYPE(t)
#endif
{
char *buf;
int err;
TRACE ();
return VM_FAULT_SIGBUS;
#else
return NOPAGE_SIGBUS;
}
#endif
if (!page) {
LogRelFunc(("failed to allocate page\n"));
return VM_FAULT_OOM;
#else
return NOPAGE_OOM;
#endif
}
#else
#endif
if (err) {
return VM_FAULT_SIGBUS;
#else
return NOPAGE_SIGBUS;
#endif
}
if (!nread) {
#else
#endif
}
else {
}
return 0;
#else
return page;
#endif
}
static struct vm_operations_struct sf_vma_ops = {
#else
#endif
};
static int
{
TRACE ();
LogFunc(("shared mmapping not available\n"));
return -EINVAL;
}
return 0;
}
struct file_operations sf_reg_fops = {
.read = sf_reg_read,
.open = sf_reg_open,
.write = sf_reg_write,
.mmap = sf_reg_mmap,
# else
# endif
#endif
};
struct inode_operations sf_reg_iops = {
#else
.getattr = sf_getattr,
#endif
};
static int
{
char *buf;
int ret;
TRACE ();
if (ret) {
if (PageLocked(page))
return ret;
}
return 0;
}
static int
{
char *buf;
int err;
TRACE ();
if (err < 0) {
goto out;
}
err = 0;
out:
return err;
}
int
{
TRACE ();
}
int
{
void *buf;
int err;
TRACE ();
if (err >= 0) {
}
return nwritten;
}
# endif /* KERNEL_VERSION >= 2.6.24 */
struct address_space_operations sf_reg_aops = {
.readpage = sf_readpage,
# else
# endif
};
#endif