regops.c revision c97989161fbe75bc14cea477a5443bbf474dd3ad
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * vboxvfs -- VirtualBox Guest Additions for Linux:
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * Regular file inode and file operations
c97989161fbe75bc14cea477a5443bbf474dd3advboxsync * Copyright (C) 2006-2007 innotek GmbH
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * available from http://www.virtualbox.org. This file is free software;
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * you can redistribute it and/or modify it under the terms of the GNU
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * General Public License as published by the Free Software Foundation,
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * If you received this file as part of a commercial VirtualBox
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * distribution, then only the terms of your commercial VirtualBox
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * license agreement apply instead of the previous paragraph.
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * Limitations: only COW memory mapping is supported
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_read_aux (const char *caller, struct sf_glob_info *sf_g,
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync struct sf_reg_info *sf_r, void *buf, uint32_t *nread,
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync int rc = vboxCallRead (&client_handle, &sf_g->map, sf_r->handle,
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_read (struct file *file, char *buf, size_t size, loff_t *off)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync struct sf_glob_info *sf_g = GET_GLOB_INFO (inode->i_sb);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync elog ("read from non regular file %d\n", inode->i_mode);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync elog ("could not allocate bounce buffer memory %u bytes\n",
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync err = sf_reg_read_aux (__func__, sf_g, sf_r, tmp, &nread, pos);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_write (struct file *file, const char *buf, size_t size, loff_t *off)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync struct sf_inode_info *sf_i = GET_INODE_INFO (inode);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync struct sf_glob_info *sf_g = GET_GLOB_INFO (inode->i_sb);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync elog ("write to non regular file %d\n", inode->i_mode);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync elog ("could not allocate bounce buffer memory %u bytes\n",
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync rc = vboxCallWrite (&client_handle, &sf_g->map, sf_r->handle,
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_open (struct inode *inode, struct file *file)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync struct sf_glob_info *sf_g = GET_GLOB_INFO (inode->i_sb);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync struct sf_inode_info *sf_i = GET_INODE_INFO (inode);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync params.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS;
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync params.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS;
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync if (!(params.CreateFlags & SHFL_CF_ACCESS_READWRITE)) {
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync rc = vboxCallCreate (&client_handle, &sf_g->map, sf_i->path, ¶ms);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync /* XXX: here i probably should check rc and convert some values to
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync EEXISTS ENOENT etc */
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync elog ("vboxCallCreate failed flags=%d,%#x rc=%d\n",
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_release (struct inode *inode, struct file *file)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync rc = vboxCallClose (&client_handle, &sf_g->map, sf_r->handle);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncstatic struct page *
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_nopage (struct vm_area_struct *vma, unsigned long vaddr, int unused)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_nopage (struct vm_area_struct *vma, unsigned long vaddr, int *type)
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync struct sf_glob_info *sf_g = GET_GLOB_INFO (inode->i_sb);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync off = (vaddr - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync err = sf_reg_read_aux (__func__, sf_g, sf_r, buf, &nread, off);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync clear_user_page (page_address (page), vaddr, page);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsyncsf_reg_mmap (struct file *file, struct vm_area_struct *vma)