VirtualBox

Changeset 6054 in vbox for trunk/src/VBox/Additions/linux


Ignore:
Timestamp:
Dec 12, 2007 12:42:44 PM (17 years ago)
Author:
vboxsync
Message:

vboxvfs: implemented readfile()

Location:
trunk/src/VBox/Additions/linux/sharedfolders
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r5999 r6054  
    345345        buf = kmap (page);
    346346        off = (vaddr - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
    347 
    348347        err = sf_reg_read_aux (__func__, sf_g, sf_r, buf, &nread, off);
    349348        if (err) {
     
    390389
    391390struct file_operations sf_reg_fops = {
    392         .read     = sf_reg_read,
    393         .open     = sf_reg_open,
    394         .write    = sf_reg_write,
    395         .release  = sf_reg_release,
    396         .mmap     = sf_reg_mmap,
     391        .read        = sf_reg_read,
     392        .aio_read    = generic_file_aio_read,
     393        .open        = sf_reg_open,
     394        .write       = sf_reg_write,
     395        .aio_write   = generic_file_aio_write,
     396        .release     = sf_reg_release,
     397        .mmap        = sf_reg_mmap,
    397398#if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0)
    398399# if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 23)
    399400        .splice_read = generic_file_splice_read,
    400401# else
    401         .sendfile = generic_file_sendfile,
     402        .sendfile    = generic_file_sendfile,
    402403# endif
    403         .fsync    = simple_sync_file,
     404        .fsync       = simple_sync_file,
     405        .llseek      = generic_file_llseek,
    404406#endif
    405407};
    406408
    407 
    408 /* iops */
    409409
    410410struct inode_operations sf_reg_iops = {
     
    415415#endif
    416416};
     417
     418
     419#if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0)
     420static int
     421sf_readpage(struct file *file, struct page *page)
     422{
     423        char *buf = kmap(page);
     424        struct inode *inode = file->f_dentry->d_inode;
     425        struct sf_glob_info *sf_g = GET_GLOB_INFO (inode->i_sb);
     426        struct sf_reg_info *sf_r = file->private_data;
     427        uint32_t nread = PAGE_SIZE;
     428        loff_t off = page->index << PAGE_SHIFT;
     429        int ret;
     430
     431        TRACE ();
     432
     433        ret = sf_reg_read_aux (__func__, sf_g, sf_r, buf, &nread, off);
     434        if (ret) {
     435            kunmap (page);
     436            return ret;
     437        }
     438        flush_dcache_page (page);
     439        kunmap (page);
     440        SetPageUptodate(page);
     441        if (PageLocked(page))
     442            unlock_page(page);
     443        return 0;
     444}
     445
     446struct address_space_operations sf_reg_aops = {
     447        .readpage      = sf_readpage,
     448# if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 24)
     449        .write_begin   = simple_write_begin,
     450        .write_end     = simple_write_end,
     451# else
     452        .prepare_write = simple_prepare_write,
     453        .commit_write  = simple_commit_write,
     454# endif
     455};
     456#endif
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r6038 r6054  
    2626#if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0)
    2727/*
    28  * sf_aops and sf_backing_dev_info are just quick implementations to make
     28 * sf_reg_aops and sf_backing_dev_info are just quick implementations to make
    2929 * sendfile work. For more information have a look at
    3030 *
     
    3535 *   http://pserver.samba.org/samba/ftp/cifs-cvs/samplefs.tar.gz
    3636 */
    37 static struct address_space_operations sf_aops = {
    38         .readpage      = simple_readpage,
    39 #if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 24)
    40         .write_begin   = simple_write_begin,
    41         .write_end     = simple_write_end,
    42 #else
    43         .prepare_write = simple_prepare_write,
    44         .commit_write  = simple_commit_write,
    45 #endif
    46 };
    4737
    4838static struct backing_dev_info sf_backing_dev_info = {
     
    112102
    113103#if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0)
    114         inode->i_mapping->a_ops = &sf_aops;
     104        inode->i_mapping->a_ops = &sf_reg_aops;
    115105        inode->i_mapping->backing_dev_info = &sf_backing_dev_info;
    116106#endif
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r6042 r6054  
    393393init (void)
    394394{
    395         int rc;
     395        int rcVBox;
     396        int rcRet = 0;
    396397        int err;
    397398
     
    404405                        sizeof (struct vbsf_mount_info),
    405406                        PAGE_SIZE);
     407                return -EINVAL;
    406408        }
    407409
     
    413415
    414416        if (vboxadd_cmc_ctl_guest_filter_mask (VMMDEV_EVENT_HGCM, 0)) {
     417                rcRet = -EINVAL;
    415418                goto fail0;
    416419        }
    417420
    418         rc = vboxInit ();
    419         if (VBOX_FAILURE (rc)) {
    420                 LogRelFunc (("vboxInit failed, rc=%d\n", rc));
     421        rcVBox = vboxInit ();
     422        if (VBOX_FAILURE (rcVBox)) {
     423                LogRelFunc (("vboxInit failed, rc=%d\n", rcVBox));
     424                rcRet = -EPROTO;
    421425                goto fail0;
    422426        }
    423427
    424         rc = vboxConnect (&client_handle);
    425         if (VBOX_FAILURE (rc)) {
    426                 LogRelFunc (("vboxConnect failed, rc=%d\n", rc));
     428        rcVBox = vboxConnect (&client_handle);
     429        if (VBOX_FAILURE (rcVBox)) {
     430                LogRelFunc (("vboxConnect failed, rc=%d\n", rcVBox));
     431                rcRet = -EPROTO;
    427432                goto fail1;
    428433        }
    429434
    430         rc = vboxCallSetUtf8 (&client_handle);
    431         if (VBOX_FAILURE (rc)) {
    432                 LogRelFunc (("vboxCallSetUtf8 failed, rc=%d\n", rc));
     435        rcVBox = vboxCallSetUtf8 (&client_handle);
     436        if (VBOX_FAILURE (rcVBox)) {
     437                LogRelFunc (("vboxCallSetUtf8 failed, rc=%d\n", rcVBox));
     438                rcRet = -EPROTO;
    433439                goto fail2;
    434440        }
     
    447453        vboxadd_cmc_ctl_guest_filter_mask (0, VMMDEV_EVENT_HGCM);
    448454        unregister_filesystem (&vboxsf_fs_type);
    449         return -1;
     455        return rcRet;
    450456}
    451457
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r5999 r6054  
    5959
    6060/* forward declarations */
    61 extern struct inode_operations  sf_dir_iops;
    62 extern struct inode_operations  sf_reg_iops;
    63 extern struct file_operations   sf_dir_fops;
    64 extern struct file_operations   sf_reg_fops;
    65 extern struct dentry_operations sf_dentry_ops;
     61extern struct inode_operations         sf_dir_iops;
     62extern struct inode_operations         sf_reg_iops;
     63extern struct file_operations          sf_dir_fops;
     64extern struct file_operations          sf_reg_fops;
     65extern struct dentry_operations        sf_dentry_ops;
     66extern struct address_space_operations sf_reg_aops;
    6667
    6768extern void
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette