VirtualBox

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


Ignore:
Timestamp:
Jun 28, 2023 10:34:21 AM (19 months ago)
Author:
vboxsync
Message:

Additions: Get rid of MAX_MNTOPT_STR and replace with RTSystemGetPageSize() in the shared folders mounting tools, bugref:10476

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

Legend:

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

    r98103 r100317  
    6060
    6161#include <iprt/assertcompile.h>
    62 #include <iprt/param.h>  /* PAGE_SIZE (used by MAX_MNTOPT_STR) */
    6362#include <iprt/string.h>
    6463
     
    543542    static const char s_szSfNameOpt[] = "sf_name=";
    544543    char szSharedFolderIconved[sizeof(s_szSfNameOpt) - 1 + MAX_HOST_NAME];
    545     char szOpts[MAX_MNTOPT_STR];
     544    char *pszOpts = NULL;
    546545    struct vbsf_mount_opts opts =
    547546    {
     
    572571    if (!argv[0])
    573572        argv[0] = "mount.vboxsf";
     573
     574    long cbOpts = sysconf(_SC_PAGESIZE);
     575    if (cbOpts == -1)
     576        panic("Couldn't query system page size errno=%d.\n", errno);
     577
     578    pszOpts = alloca(cbOpts);
     579    if (!pszOpts)
     580        panic("Couldn't allocate memory for mount options buffers\n");
    574581
    575582    /*
     
    624631     */
    625632    offOpts   = 0;
    626     szOpts[0] = '\0';
    627     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szTTL);
    628     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szMsDirCacheTTL);
    629     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szMsInodeTTL);
    630     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szMaxIoPages);
    631     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szDirBuf);
    632     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szCacheMode);
    633     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szUid);
    634     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szGid);
    635     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szDMode);
    636     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szFMode);
    637     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szDMask);
    638     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szFMask);
    639     offOpts = append_option(szOpts, sizeof(szOpts), offOpts, opts.szIoCharset);
     633    pszOpts[0] = '\0';
     634    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szTTL);
     635    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szMsDirCacheTTL);
     636    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szMsInodeTTL);
     637    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szMaxIoPages);
     638    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szDirBuf);
     639    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szCacheMode);
     640    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szUid);
     641    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szGid);
     642    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szDMode);
     643    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szFMode);
     644    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szDMask);
     645    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szFMask);
     646    offOpts = append_option(pszOpts, cbOpts, offOpts, opts.szIoCharset);
    640647
    641648    /* For pre-2.6 kernels we have to supply the shared folder name as a
     
    655662            strcpy(&szSharedFolderIconved[sizeof(s_szSfNameOpt) - 1], pszSharedFolder);
    656663        }
    657         offOpts = append_option(szOpts, sizeof(szOpts), offOpts, szSharedFolderIconved);
     664        offOpts = append_option(pszOpts, cbOpts, offOpts, szSharedFolderIconved);
    658665    }
    659666
     
    661668     * Do the actual mounting.
    662669     */
    663     err = mount(pszSharedFolder, pszMountPoint, "vboxsf", opts.fFlags, szOpts);
     670    err = mount(pszSharedFolder, pszMountPoint, "vboxsf", opts.fFlags, pszOpts);
    664671    saved_errno = errno;
    665672
     
    674681    if (!nomtab)
    675682    {
    676         err = vbsfmount_complete(pszSharedFolder, pszMountPoint, opts.fFlags, szOpts);
     683        err = vbsfmount_complete(pszSharedFolder, pszMountPoint, opts.fFlags, pszOpts);
    677684        switch (err)
    678685        {
  • trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h

    r98103 r100317  
    3535#endif
    3636
    37 /* Linux constrains the size of data mount argument to PAGE_SIZE - 1. */
    38 #define MAX_MNTOPT_STR          PAGE_SIZE
    3937#define MAX_HOST_NAME           256
    4038#define MAX_NLS_NAME            32
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