VirtualBox

Changeset 31202 in vbox


Ignore:
Timestamp:
Jul 29, 2010 12:41:03 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64204
Message:

Shared Folders/VBoxService: Added Linux + Solaris support.

Location:
trunk/src/VBox/Additions
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk

    r29583 r31202  
    5050 VBoxService_DEFS        += VBOXSERVICE_CPUHOTPLUG
    5151endif
     52ifdef VBOX_WITH_SHARED_FOLDERS
     53 # darwin freebsd
     54 if1of ($(KBUILD_TARGET), linux solaris)
     55  VBoxService_DEFS        += VBOX_WITH_SHARED_FOLDERS
     56 endif
     57endif
    5258
    5359VBoxService_SOURCES       = \
     
    5662        VBoxServiceUtils.cpp \
    5763        VBoxServiceStats.cpp
     64
    5865ifdef VBOX_WITH_GUEST_CONTROL
    5966 VBoxService_SOURCES    += \
     
    6168        VBoxServiceControlExec.cpp
    6269endif
     70
    6371ifdef VBOX_WITH_MEMBALLOON
    6472 VBoxService_SOURCES    += \
     
    6977        VBoxServicePageSharing.cpp
    7078endif
     79
    7180ifdef VBOX_WITH_GUEST_PROPS
    7281 VBoxService_SOURCES.win  = \
     
    7685        VBoxServicePropCache.cpp
    7786endif
     87
    7888if1of ($(KBUILD_TARGET), linux)
    7989 VBoxService_SOURCES     += \
    8090        VBoxServiceCpuHotPlug.cpp
    8191endif
     92
     93ifdef VBOX_WITH_SHARED_FOLDERS
     94 if1of ($(KBUILD_TARGET), linux solaris)
     95  VBoxService_SOURCES          += \
     96        VBoxServiceAutoMount.cpp
     97  VBoxService_SOURCES.linux    += \
     98        ../../linux/sharedfolders/vbsfmount.c
     99 endif
     100endif
     101
    82102VBoxService_SOURCES.win  += \
    83103        VBoxService-win.rc \
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp

    r30957 r31202  
    104104#ifdef VBOX_WITH_PAGE_SHARING
    105105    { &g_PageSharing, NIL_RTTHREAD, false, false, false, true },
     106#endif
     107#ifdef VBOX_WITH_SHARED_FOLDERS
     108    { &g_AutoMount, NIL_RTTHREAD, false, false, false, true },
    106109#endif
    107110};
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r30601 r31202  
    250250extern VBOXSERVICE  g_PageSharing;
    251251#endif
     252#ifdef VBOX_WITH_SHARED_FOLDERS
     253extern VBOXSERVICE  g_AutoMount;
     254#endif
    252255
    253256extern RTEXITCODE   VBoxServiceSyntax(const char *pszFormat, ...);
  • trunk/src/VBox/Additions/linux/sharedfolders/Makefile.kmk

    r28998 r31202  
    8888mount.vboxsf_DEFS        = _GNU_SOURCE
    8989mount.vboxsf_SOURCES     = \
    90         mount.vboxsf.c
    91 
     90        mount.vboxsf.c \
     91        vbsfmount.c
    9292
    9393## Scripts needed for building kernel modules
  • trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c

    r30153 r31202  
    88
    99/*
    10  * Copyright (C) 2006-2007 Oracle Corporation
     10 * Copyright (C) 2006-2010 Oracle Corporation
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5353    } while (0)
    5454
    55 struct opts
    56 {
    57     int  uid;
    58     int  gid;
    59     int  ttl;
    60     int  dmode;
    61     int  fmode;
    62     int  dmask;
    63     int  fmask;
    64     int  ronly;
    65     int  noexec;
    66     int  nodev;
    67     int  nosuid;
    68     int  remount;
    69     char nls_name[MAX_NLS_NAME];
    70     char *convertcp;
    71 };
    72 
    7355#define PANIC_ATTR __attribute ((noreturn, __format__ (__printf__, 1, 2)))
    7456
     
    11395
    11496static void
    115 process_mount_opts(const char *s, struct opts *opts)
     97process_mount_opts(const char *s, struct vbsf_mount_opts *opts)
    11698{
    11799    const char *next = s;
     
    319301            exit(EXIT_FAILURE);
    320302        }
    321     }
    322 }
    323 
    324 static void
    325 complete(char *host_name, char *mount_point,
    326           unsigned long flags, struct opts *opts)
    327 {
    328     FILE *f, *m;
    329     char *buf;
    330     size_t size;
    331     struct mntent e;
    332 
    333     m = open_memstream(&buf, &size);
    334     if (!m)
    335         panic_err("could not update mount table (failed to create memstream)");
    336 
    337     if (opts->uid)
    338         fprintf(m, "uid=%d,", opts->uid);
    339     if (opts->gid)
    340         fprintf(m, "gid=%d,", opts->gid);
    341     if (opts->ttl)
    342         fprintf(m, "ttl=%d,", opts->ttl);
    343     if (*opts->nls_name)
    344         fprintf(m, "iocharset=%s,", opts->nls_name);
    345     if (flags & MS_NOSUID)
    346         fprintf(m, "%s,", MNTOPT_NOSUID);
    347     if (flags & MS_RDONLY)
    348         fprintf(m, "%s,", MNTOPT_RO);
    349     else
    350         fprintf(m, "%s,", MNTOPT_RW);
    351 
    352     fclose(m);
    353 
    354     if (size > 0)
    355         buf[size - 1] = 0;
    356     else
    357         buf = "defaults";
    358 
    359     f = setmntent(MOUNTED, "a+");
    360     if (!f)
    361         panic_err("could not open mount table for update");
    362 
    363     e.mnt_fsname = host_name;
    364     e.mnt_dir = mount_point;
    365     e.mnt_type = "vboxsf";
    366     e.mnt_opts = buf;
    367     e.mnt_freq = 0;
    368     e.mnt_passno = 0;
    369 
    370     if (addmntent(f, &e))
    371     {
    372         if (size > 0)
    373         {
    374             memset(buf, 0, size);
    375             free(buf);
    376         }
    377         panic_err("could not add an entry to the mount table");
    378     }
    379 
    380     endmntent(f);
    381 
    382     if (size > 0)
    383     {
    384         memset(buf, 0, size);
    385         free(buf);
    386303    }
    387304}
     
    461378    char *mount_point;
    462379    struct vbsf_mount_info_new mntinf;
    463     struct opts opts =
     380    struct vbsf_mount_opts opts =
    464381    {
    465382        0,     /* uid */
     
    558475    mntinf.fmask = opts.fmask;
    559476
     477    /*
     478     * Note: When adding and/or modifying parameters of the vboxsf mounting
     479     *       options you also would have to adjust VBoxServiceAutoMount.cpp
     480     *       to keep this code here slick without having VbglR3.
     481     */
    560482    err = mount(NULL, mount_point, "vboxsf", flags, &mntinf);
    561483    if (err == -1 && errno == EPROTO)
     
    593515
    594516    if (!nomtab)
    595         complete(host_name, mount_point, flags, &opts);
     517    {
     518        err = vbsfmount_complete(host_name, mount_point, flags, &opts);
     519        switch (err)
     520        {
     521            case 0: /* Success. */
     522                break;
     523
     524            case 1:
     525                panic_err("%s: Could not update mount table (failed to create memstream).", argv[0]);
     526                break;
     527
     528            case 2:
     529                panic_err("%s: Could not open mount table for update.", argv[0]);
     530                break;
     531
     532            case 3:
     533                panic_err("%s: Could not add an entry to the mount table.", argv[0]);
     534                break;
     535
     536            default:
     537                panic_err("%s: Unknown error while completing mount operation: %d", argv[0], err);
     538                break;
     539        }
     540    }
    596541
    597542    exit(EXIT_SUCCESS);
  • trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h

    r28998 r31202  
    44
    55/*
    6  * Copyright (C) 2006-2007 Oracle Corporation
     6 * Copyright (C) 2006-2010 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121#define MAX_NLS_NAME    32
    2222
    23 /* Linux constraints the size of data mount argument to PAGE_SIZE - 1 */
     23/* Linux constraints the size of data mount argument to PAGE_SIZE - 1. */
    2424struct vbsf_mount_info_old
    2525{
     
    5353};
    5454
     55struct vbsf_mount_opts
     56{
     57    int  uid;
     58    int  gid;
     59    int  ttl;
     60    int  dmode;
     61    int  fmode;
     62    int  dmask;
     63    int  fmask;
     64    int  ronly;
     65    int  noexec;
     66    int  nodev;
     67    int  nosuid;
     68    int  remount;
     69    char nls_name[MAX_NLS_NAME];
     70    char *convertcp;
     71};
     72
     73/** Completes the mount operation by adding the new mount point to mtab if required. */
     74int vbsfmount_complete(const char *host_name, const char *mount_point,
     75                       unsigned long flags, struct vbsf_mount_opts *opts);
     76
    5577#endif /* vbsfmount.h */
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