VirtualBox

Changeset 4909 in vbox


Ignore:
Timestamp:
Sep 20, 2007 7:27:19 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
24647
Message:

Implement statfs call for Linux guests. Makes volume info (e.g. df) work.

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

Legend:

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

    r4860 r4909  
    1919
    2020#include "vfsmod.h"
     21#include <linux/nfs_fs.h>
     22#include <linux/vfs.h>
    2123
    2224/* #define USE_VMALLOC */
     
    590592}
    591593
     594int sf_get_volume_info(struct super_block *sb, STRUCT_STATFS *stat)
     595{
     596        struct sf_glob_info *sf_g;
     597        SHFLVOLINFO SHFLVolumeInfo;
     598        uint32_t cbBuffer;
     599        int rc;
     600
     601        sf_g = GET_GLOB_INFO (sb);
     602        cbBuffer = sizeof(SHFLVolumeInfo);
     603        rc = vboxCallFSInfo(&client_handle, &sf_g->map, 0, SHFL_INFO_GET | SHFL_INFO_VOLUME,
     604                            &cbBuffer, (PSHFLDIRINFO)&SHFLVolumeInfo);
     605        if (VBOX_FAILURE(rc))
     606            return -RTErrConvertToErrno(rc);
     607
     608        stat->f_type        = NFS_SUPER_MAGIC; /* XXX vboxsf type? */
     609        stat->f_bsize       = SHFLVolumeInfo.ulBytesPerAllocationUnit;
     610        stat->f_blocks      = SHFLVolumeInfo.ullTotalAllocationBytes
     611                            / SHFLVolumeInfo.ulBytesPerAllocationUnit;
     612        stat->f_bfree       = SHFLVolumeInfo.ullAvailableAllocationBytes
     613                            / SHFLVolumeInfo.ulBytesPerAllocationUnit;
     614        stat->f_bavail      = SHFLVolumeInfo.ullAvailableAllocationBytes
     615                            / SHFLVolumeInfo.ulBytesPerAllocationUnit;
     616        stat->f_files       = 1000;
     617        stat->f_ffree       = 1000; /* don't return 0 here since the guest may think
     618                                     * that it is not possible to create any more files */
     619        stat->f_fsid.val[0] = 0;
     620        stat->f_fsid.val[1] = 0;
     621        stat->f_namelen     = 255;
     622        return 0;
     623}
     624
    592625struct dentry_operations sf_dentry_ops = {
    593626        .d_revalidate = sf_dentry_revalidate
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r4860 r4909  
    311311}
    312312
    313 static int
    314 sf_statfs (
    315313#if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 18)
    316            struct super_block *sb,
     314static int
     315sf_statfs (struct super_block *sb, STRUCT_STATFS *stat)
     316{
     317        return sf_get_volume_info(sb, stat);
     318}
    317319#else
    318            struct dentry *dentry,
    319 #endif
    320 #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0)
    321            struct statfs *stat
    322 #else
    323            struct kstatfs *stat
    324 #endif
    325         )
    326 {
    327         TRACE ();
    328         return -ENOSYS;
    329 }
     320static int
     321sf_statfs (struct dentry *dentry, STRUCT_STATFS *stat)
     322{
     323        struct super_block *sb = dentry->d_inode->i_sb;
     324        return sf_get_volume_info(sb, stat);
     325}
     326#endif
    330327
    331328static int
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r4735 r4909  
    9393                 struct sf_dir_info *sf_d, SHFLHANDLE handle);
    9494
     95#if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0)
     96#define STRUCT_STATFS  struct statfs
     97#else
     98#define STRUCT_STATFS  struct kstatfs
     99#endif
     100int sf_get_volume_info(struct super_block *sb,STRUCT_STATFS *stat);
     101
    95102#ifdef ALIGN
    96103#undef ALIGN
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