Ignore:
Timestamp:
Mar 16, 2011, 2:11:32 AM (14 years ago)
Author:
bird
Message:

libc: Added new env.var. LIBC_UNIX_EAS for controlling where EAs are used. Fixes #43.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/sys/fs.c

    r3695 r3697  
    226226static _fmutex        g_mtxFSInfoVolumes = _FMUTEX_INITIALIZER_EX(_FMC_MUST_COMPLETE, "mtxFSInfoVolumes");
    227227
     228/** Array of Unix EA settings overrides for all possible OS/2 volumes.
     229 * Tristate: -1 force off, 0 default, 1 force on.
     230 */
     231static char           g_achUnixEAsOverrides['Z' - 'A' + 1];
     232
    228233
    229234/*******************************************************************************
     
    436441    }
    437442    DosFreeModule(hmod);
     443   
     444    /*
     445     * Look for the UNIX EAs control environment variable.
     446     * The value form: !a, c, !d-e
     447     */
     448    const char *pszUnixEAs = getenv("LIBC_UNIX_EAS");
     449    if (pszUnixEAs)
     450    {
     451        while (*pszUnixEAs)
     452        {
     453            char chDrv;
     454            while ((chDrv = *pszUnixEAs) == ',' || chDrv == ';' || chDrv == ' ' || chDrv == '\t')
     455                pszUnixEAs++;
     456            if (!chDrv)
     457                break;
     458
     459            /* check for the operator. */
     460            int fOverride = 1;
     461            if (chDrv == '!')
     462            {
     463                fOverride = -1;
     464                chDrv = *++pszUnixEAs;
     465            }
     466
     467            /* check for the first drive letter, upper case it. */
     468            if (chDrv >= 'a' && chDrv <= 'z')
     469                chDrv -= 'a' - 'A';
     470            if (chDrv < 'A' || chDrv > 'Z')
     471                LIBCLOG_ERROR_RETURN_MSG(-1, "Bad LIBC_UNIX_EAS value; ch=%c\n", chDrv);
     472            pszUnixEAs++;
     473            if (*pszUnixEAs == ':')
     474                pszUnixEAs++;
     475
     476            /* check if it is a range spec. */
     477            char chDrv2;
     478            while ((chDrv2 = *pszUnixEAs) == ' ' || chDrv2 == '\t')
     479                pszUnixEAs++;
     480            if (chDrv2 == '-')
     481            {
     482                pszUnixEAs++;
     483                while ((chDrv2 = *pszUnixEAs) == ' ' || chDrv2 == '\t')
     484                    pszUnixEAs++;
     485
     486                if (chDrv >= 'a' && chDrv <= 'z')
     487                    chDrv -= 'a' - 'A';
     488                if (chDrv < 'A' || chDrv > 'Z')
     489                    LIBCLOG_ERROR_RETURN_MSG(-1, "Bad LIBC_UNIX_EAS value; ch=%c\n", chDrv2);
     490                pszUnixEAs++;
     491                if (*pszUnixEAs == ':')
     492                    pszUnixEAs++;
     493            }
     494            else
     495                chDrv2 = chDrv;
     496
     497            /* Be nice and swap the values if they are not in ascending order. */
     498            if (chDrv2 < chDrv)
     499            {
     500                char chDrvTmp = chDrv2;
     501                chDrv2 = chDrv;
     502                chDrv = chDrvTmp;
     503            }
     504
     505            /* apply them. */
     506            do
     507                g_achUnixEAsOverrides[chDrv - 'A'] = fOverride;
     508            while (chDrv++ < chDrv2);
     509        }
     510    }
     511
    438512    LIBCLOG_RETURN_INT(0);
    439513}
     
    18591933    /*else if (!strcmp(pFsInfo->szName, "FAT32"))
    18601934    { } */
     1935
     1936    /* check the Unix EAs overrides. */
     1937    if (g_achUnixEAsOverrides[minor(Dev) - 'A'] != 0)
     1938        pFsInfo->fUnixEAs = g_achUnixEAsOverrides[minor(Dev) - 'A'] > 0;
    18611939
    18621940    LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d fUnixEAs=%d\n",
Note: See TracChangeset for help on using the changeset viewer.