VirtualBox

Changeset 43404 in vbox for trunk/src


Ignore:
Timestamp:
Sep 22, 2012 12:09:45 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80890
Message:

Additions/haiku: cleanup.

Location:
trunk/src/VBox/Additions/haiku/SharedFolders
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.c

    r43364 r43404  
    4646#include "vboxsf.h"
    4747
    48 #define MODULE_NAME "file_systems/vboxsf"
    49 #define FS_NAME "vboxsf"
     48#define MODULE_NAME     "file_systems/vboxsf"
     49#define FS_NAME         "vboxsf"
     50#define FS_PRETTY_NAME  "VirtualBox Shared Folders"
    5051
    5152VBSFCLIENT g_clientHandle;
     
    5556status_t init_module(void)
    5657{
     58#if 0
     59    /* @todo enable this soon */
     60    int rc = get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest);
     61    if (RT_LIKELY(rc == B_OK)
     62    {
     63        rc = vboxInit();
     64        if (RT_SUCCESS(rc))
     65        {
     66            rc = vboxConnect(&g_clientHandle);
     67            if (RT_SUCCESS(rc))
     68            {
     69                rc = vboxCallSetUtf8(&g_clientHandle);
     70                if (RT_SUCCESS(rc))
     71                {
     72                    rc = vboxCallSetSymlinks(&g_clientHandle);
     73                    if (RT_FAILURE(rc))
     74                        LogRel((FS_NAME ":Warning! vboxCallSetSymlinks failed (rc=%d) - symlink will appear as copies.\n", rc));
     75
     76                    mutex_init(&g_vnodeCacheLock, "vboxsf vnode cache lock");
     77                    Log((FS_NAME ":init_module succeeded.\n");
     78                    return B_OK;
     79                }
     80                else
     81                    LogRel((FS_NAME ":vboxCallSetUtf8 failed. rc=%d\n", rc));
     82            }
     83            else
     84                LogRel((FS_NAME ":vboxConnect failed. rc=%d\n", rc));
     85        }
     86        else
     87            LogRel((FS_NAME ":vboxInit failed. rc=%d\n", rc));
     88    }
     89    else
     90        LogRel((FS_NAME ":get_module failed for '%s'. rc=%d\n", VBOXGUEST_MODULE_NAME, rc));
     91
     92    return B_ERROR;
     93#endif
     94
    5795    if (get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest) != B_OK)
    5896    {
     
    157195PSHFLSTRING build_path(vboxsf_vnode* dir, const char* const name)
    158196{
    159 
    160197    dprintf("*** build_path(%p, %p)\n", dir, name);
    161198    if (!dir || !name)
     
    265302    }
    266303
    267     st->st_dev = 0;
    268     st->st_ino = vnode->vnode;
    269     st->st_mode = mode_from_fmode(params.Info.Attr.fMode);
    270     st->st_nlink = 1;
    271     st->st_uid = 0;
    272     st->st_gid = 0;
    273     st->st_rdev = 0;
    274     st->st_size = params.Info.cbObject;
     304    st->st_dev     = 0;
     305    st->st_ino     = vnode->vnode;
     306    st->st_mode    = mode_from_fmode(params.Info.Attr.fMode);
     307    st->st_nlink   = 1;
     308    st->st_uid     = 0;
     309    st->st_gid     = 0;
     310    st->st_rdev    = 0;
     311    st->st_size    = params.Info.cbObject;
    275312    st->st_blksize = 1;
    276     st->st_blocks = params.Info.cbAllocated;
    277     st->st_atime = RTTimeSpecGetSeconds(&params.Info.AccessTime);
    278     st->st_mtime = RTTimeSpecGetSeconds(&params.Info.ModificationTime);
    279     st->st_ctime = RTTimeSpecGetSeconds(&params.Info.BirthTime);
     313    st->st_blocks  = params.Info.cbAllocated;
     314    st->st_atime   = RTTimeSpecGetSeconds(&params.Info.AccessTime);
     315    st->st_mtime   = RTTimeSpecGetSeconds(&params.Info.ModificationTime);
     316    st->st_ctime   = RTTimeSpecGetSeconds(&params.Info.BirthTime);
    280317    return B_OK;
    281318}
     
    290327    RT_ZERO(params);
    291328    params.Handle = SHFL_HANDLE_NIL;
    292     params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS
    293         | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ;
     329    params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ;
    294330
    295331    int rc = vboxCallCreate(&g_clientHandle, &volume->map, vnode->path, &params);
     
    332368        cookie->buffer_start = cookie->buffer = malloc(cookie->buffer_length);
    333369
    334         int rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path,
    335             0, cookie->index, &cookie->buffer_length, cookie->buffer, &cookie->num_files);
     370        int rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path, 0, cookie->index,
     371                                &cookie->buffer_length, cookie->buffer, &cookie->num_files);
    336372
    337373        if (rc != 0 && rc != VERR_NO_MORE_FILES)
     
    372408        return rv;
    373409    }
     410
    374411    buffer->d_dev = 0;
    375412    buffer->d_pdev = 0;
     
    453490        info->flags |= B_FS_IS_READONLY;
    454491
    455     info->dev = 0;
    456     info->root = 1;
    457     info->block_size = volume_info.ulBytesPerAllocationUnit;
    458     info->io_size = volume_info.ulBytesPerAllocationUnit;
     492    info->dev          = 0;
     493    info->root         = 1;
     494    info->block_size   = volume_info.ulBytesPerAllocationUnit;
     495    info->io_size      = volume_info.ulBytesPerAllocationUnit;
    459496    info->total_blocks = volume_info.ullTotalAllocationBytes / info->block_size;
    460     info->free_blocks = volume_info.ullAvailableAllocationBytes / info->block_size;
    461     info->total_nodes = LONGLONG_MAX;
    462     info->free_nodes = LONGLONG_MAX;
     497    info->free_blocks  = volume_info.ullAvailableAllocationBytes / info->block_size;
     498    info->total_nodes  = LONGLONG_MAX;
     499    info->free_nodes   = LONGLONG_MAX;
    463500    strcpy(info->volume_name, "VBox share");
    464501    return B_OK;
     
    730767
    731768    uint32_t l = *length;
    732     void* other_buffer = malloc(l); // TODO map the user memory into kernel space here for efficiency
     769    void* other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
    733770    int rc = vboxCallRead(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
    734771    memcpy(buffer, other_buffer, l);
     
    751788
    752789    uint32_t l = *length;
    753     void* other_buffer = malloc(l); // TODO map the user memory into kernel space here for efficiency
     790    void* other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
    754791    memcpy(other_buffer, buffer, l);
    755792    int rc = vboxCallWrite(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
     
    763800status_t vboxsf_write_stat(fs_volume *volume, fs_vnode *vnode, const struct stat *stat, uint32 statMask)
    764801{
    765     // the host handles updating the stat info - in the guest, this is a no-op
     802    /* The host handles updating the stat info - in the guest, this is a no-op */
    766803    return B_OK;
    767804}
     
    781818    int rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
    782819    free(path);
     820    /** @todo r=ramshankar: we should perhaps also check rc here and change
     821     *        Handle initialization from 0 to SHFL_HANDLE_NIL. */
    783822    if (params.Handle == SHFL_HANDLE_NIL)
    784823        return vbox_err_to_haiku_err(rc);
     
    864903
    865904
    866 // TODO move this into the runtime
     905/* @todo move this into the runtime */
    867906status_t vbox_err_to_haiku_err(int rc)
    868907{
    869     switch (rc) {
    870         case VINF_SUCCESS: return B_OK;
    871         case VERR_INVALID_POINTER: return B_BAD_ADDRESS;
    872         case VERR_INVALID_PARAMETER: return B_BAD_VALUE;
    873         case VERR_PERMISSION_DENIED: return B_PERMISSION_DENIED;
    874         case VERR_NOT_IMPLEMENTED: return B_UNSUPPORTED;
    875         case VERR_FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND;
    876 
    877         case SHFL_FILE_EXISTS: return B_FILE_EXISTS;
     908    switch (rc)
     909    {
     910        case VINF_SUCCESS:              return B_OK;
     911        case VERR_INVALID_POINTER:      return B_BAD_ADDRESS;
     912        case VERR_INVALID_PARAMETER:    return B_BAD_VALUE;
     913        case VERR_PERMISSION_DENIED:    return B_PERMISSION_DENIED;
     914        case VERR_NOT_IMPLEMENTED:      return B_UNSUPPORTED;
     915        case VERR_FILE_NOT_FOUND:       return B_ENTRY_NOT_FOUND;
     916
    878917        case SHFL_PATH_NOT_FOUND:
    879         case SHFL_FILE_NOT_FOUND: return B_ENTRY_NOT_FOUND;
    880 
    881         default: return B_ERROR;
     918        case SHFL_FILE_NOT_FOUND:       return B_ENTRY_NOT_FOUND;
     919        case SHFL_FILE_EXISTS:          return B_FILE_EXISTS;
     920
     921        default:
     922            return B_ERROR;
    882923    }
    883924}
     
    904945{
    905946    unmount,
    906     vboxsf_read_fs_info, // read_fs_info
    907     NULL, // write_fs_info
    908     NULL, // sync
    909     vboxsf_get_vnode, // get_vnode
    910     NULL, // open_index_dir
    911     NULL, // close_index_dir
    912     NULL, // free_index_dir_cookie
    913     NULL, // read_index_dir
    914     NULL, // rewind_index_dir
    915     NULL, // create_index
    916     NULL, // remove_index
    917     NULL, // read_index_stat
    918     NULL, // open_query
    919     NULL, // close_query
    920     NULL, // free_query_cookie
    921     NULL, // read_query
    922     NULL, // rewind_query
    923     NULL, // all_layers_mounted
    924     NULL, // create_sub_vnode
    925     NULL, // delete_sub_vnode
     947    vboxsf_read_fs_info,
     948    NULL,                   /* write_fs_info */
     949    NULL,                   /* sync */
     950    vboxsf_get_vnode,
     951    NULL,                   /* open_index_dir */
     952    NULL,                   /* close_index_dir */
     953    NULL,                   /* free_index_dir_cookie */
     954    NULL,                   /* read_index_dir */
     955    NULL,                   /* rewind_index_dir */
     956    NULL,                   /* create_index */
     957    NULL,                   /* remove_index */
     958    NULL,                   /* read_index_stat */
     959    NULL,                   /* open_query */
     960    NULL,                   /* close_query */
     961    NULL,                   /* free_query_cookie */
     962    NULL,                   /* read_query */
     963    NULL,                   /* rewind_query */
     964    NULL,                   /* all_layers_mounted */
     965    NULL,                   /* create_sub_vnode */
     966    NULL,                   /* delete_sub_vnode */
    926967};
    927968
    928969static fs_vnode_ops vboxsf_vnode_ops =
    929970{
    930     vboxsf_lookup, // lookup
    931     NULL, // get_vnode_name
    932     vboxsf_put_vnode, // put_vnode
    933     NULL, // remove_vnode
    934     NULL, // can_page
    935     NULL, // read_pages
    936     NULL, // write_pages
    937     NULL, // io
    938     NULL, // cancel_io
    939     NULL, // get_file_map
    940     NULL, // ioctl
    941     NULL, // set_flags
    942     NULL, // select
    943     NULL, // deselect
    944     NULL, // fsync
    945     vboxsf_read_symlink, // read_symlink
    946     vboxsf_create_symlink, // create_symlink
    947     vboxsf_link, // link
    948     vboxsf_unlink, // unlink
    949     vboxsf_rename, // rename
    950     NULL, // access
    951     vboxsf_read_stat, // read_stat
    952     vboxsf_write_stat, // write_stat
    953     NULL, // preallocate
    954     vboxsf_create, // create
    955     vboxsf_open, // open
    956     vboxsf_close, // close
    957     vboxsf_free_cookie, // free_cookie
    958     vboxsf_read, // read
    959     vboxsf_write, // write
    960     vboxsf_create_dir, // create_dir
    961     vboxsf_remove_dir, // remove_dir
    962     vboxsf_open_dir, // open_dir
    963     vboxsf_close_dir, // close_dir
    964     vboxsf_free_dir_cookie, // free_dir_cookie
    965     vboxsf_read_dir, // read_dir
    966     vboxsf_rewind_dir, // rewind_dir
    967     NULL, // open_attr_dir
    968     NULL, // close_attr_dir
    969     NULL, // free_attr_dir_cookie
    970     NULL, // read_attr_dir
    971     NULL, // rewind_attr_dir
    972     NULL, // create_attr
    973     NULL, // open_attr
    974     NULL, // close_attr
    975     NULL, // free_attr_cookie
    976     NULL, // read_attr
    977     NULL, // write_attr
    978     NULL, // read_attr_stat
    979     NULL, // write_attr_stat
    980     NULL, // rename_attr
    981     NULL, // remove_attr
    982     NULL, // create_special_node
    983     NULL, // get_super_vnode
     971    vboxsf_lookup,
     972    NULL,                   /* get_vnode_name */
     973    vboxsf_put_vnode,
     974    NULL,                   /* remove_vnode */
     975    NULL,                   /* can_page */
     976    NULL,                   /* read_pages */
     977    NULL,                   /* write_pages */
     978    NULL,                   /* io */
     979    NULL,                   /* cancel_io */
     980    NULL,                   /* get_file_map */
     981    NULL,                   /* ioctl */
     982    NULL,                   /* set_flags */
     983    NULL,                   /* select */
     984    NULL,                   /* deselect */
     985    NULL,                   /* fsync */
     986    vboxsf_read_symlink,
     987    vboxsf_create_symlink,
     988    vboxsf_link,
     989    vboxsf_unlink,
     990    vboxsf_rename,
     991    NULL,                   /* access */
     992    vboxsf_read_stat,
     993    vboxsf_write_stat
     994    NULL,                   /* preallocate */
     995    vboxsf_create,
     996    vboxsf_open,
     997    vboxsf_close,
     998    vboxsf_free_cookie,
     999    vboxsf_read,
     1000    vboxsf_write,
     1001    vboxsf_create_dir,
     1002    vboxsf_remove_dir,
     1003    vboxsf_open_dir,
     1004    vboxsf_close_dir,
     1005    vboxsf_free_dir_cookie,
     1006    vboxsf_read_dir,
     1007    vboxsf_rewind_dir,
     1008    NULL,                   /* open_attr_dir */
     1009    NULL,                   /* close_attr_dir */
     1010    NULL,                   /* free_attr_dir_cookie */
     1011    NULL,                   /* read_attr_dir */
     1012    NULL,                   /* rewind_attr_dir */
     1013    NULL,                   /* create_attr */
     1014    NULL,                   /* open_attr */
     1015    NULL,                   /* close_attr */
     1016    NULL,                   /* free_attr_cookie */
     1017    NULL,                   /* read_attr */
     1018    NULL,                   /* write_attr */
     1019    NULL,                   /* read_attr_stat */
     1020    NULL,                   /* write_attr_stat */
     1021    NULL,                   /* rename_attr */
     1022    NULL,                   /* remove_attr */
     1023    NULL,                   /* create_special_node */
     1024    NULL,                   /* get_super_vnode */
    9841025};
    9851026
     
    9911032        std_ops,
    9921033    },
    993     FS_NAME,                        // short_name
    994     "VirtualBox shared folders",    // pretty_name
    995     0, //B_DISK_SYSTEM_SUPPORTS_WRITING,    // DDM flags
    996     // scanning
    997     NULL, // identify_partition
    998     NULL, // scan_partition
    999     NULL, // free_identify_partition_cookie
    1000     NULL,    // free_partition_content_cookie()
     1034    FS_NAME,
     1035    FS_PRETTY_NAME,
     1036    0,                      /* DDM flags */
     1037    NULL,                   /* identify_partition */
     1038    NULL,                   /* scan_partition */
     1039    NULL,                   /* free_identify_partition_cookie */
     1040    NULL,                   /* free_partition_content_cookie */
    10011041    mount,
    10021042};
  • trunk/src/VBox/Additions/haiku/SharedFolders/vboxsf.h

    r43364 r43404  
    9191extern "C" {
    9292#endif
     93
    9394status_t vboxsf_new_vnode(PVBSFMAP map, PSHFLSTRING path, PSHFLSTRING name, vboxsf_vnode** p);
    9495status_t vboxsf_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode, int* _type, uint32* _flags, bool reenter);
     
    9899status_t vbox_err_to_haiku_err(int rc);
    99100extern mutex g_vnodeCacheLock;
     101
    100102#ifdef __cplusplus
    101103}
    102104#endif
    103105
    104 #endif
     106#endif /* ___vboxsf_h */
    105107
  • trunk/src/VBox/Additions/haiku/SharedFolders/vnode_cache.cpp

    r43364 r43404  
    4949struct HashTableDefinition
    5050{
    51     typedef uint32 KeyType;
    52     typedef    vboxsf_vnode ValueType;
     51    typedef uint32       KeyType;
     52    typedef vboxsf_vnode ValueType;
    5353
    5454    size_t HashKey(uint32 key) const
     
    116116
    117117extern "C" status_t vboxsf_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode,
    118     int* _type, uint32* _flags, bool reenter)
     118                                     int* _type, uint32* _flags, bool reenter)
    119119{
    120120    vboxsf_vnode* vn = g_cache.Lookup(id);
Note: See TracChangeset for help on using the changeset viewer.

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