VirtualBox

Changeset 2857 in kBuild


Ignore:
Timestamp:
Sep 1, 2016 3:39:51 AM (9 years ago)
Author:
bird
Message:

updates

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/dir-nt-bird.c

    r2856 r2857  
    212212        if (pDirObj->bObjType == KFSOBJ_TYPE_DIR)
    213213        {
    214             KMKNTOPENDIR *pDir = xmalloc(sizeof(*pDir));
    215             pDir->pDir    = (PKFSDIR)pDirObj;
    216             pDir->idxNext = 0;
    217             return pDir;
    218         }
     214            if (kFsCacheDirEnsurePopuplated(g_pFsCache, (PKFSDIR)pDirObj, NULL))
     215            {
     216                KMKNTOPENDIR *pDir = xmalloc(sizeof(*pDir));
     217                pDir->pDir    = (PKFSDIR)pDirObj;
     218                pDir->idxNext = 0;
     219                return pDir;
     220            }
     221        }
     222        kFsCacheObjRelease(g_pFsCache, pDirObj);
    219223    }
    220224    return NULL;
     
    330334        }
    331335        kFsCacheObjRelease(g_pFsCache, pPathObj);
    332     }
    333     errno = ENOENT;
     336        errno = ENOENT;
     337    }
     338    else
     339        errno =    enmError == KFSLOOKUPERROR_NOT_DIR
     340                || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR
     341              ? ENOTDIR : ENOENT;
     342
    334343    return -1;
    335344}
     
    438447}
    439448
     449
     450/**
     451 * Special stat call used by remake.c
     452 *
     453 * @returns 0 on success, -1 + errno on failure.
     454 * @param   pszPath             The path to stat.
     455 * @param   pStat               Where to return the mtime field only.
     456 */
     457int stat_only_mtime(const char *pszPath, struct stat *pStat)
     458{
     459    if (commands_started == 0)
     460    {
     461        KFSLOOKUPERROR  enmError;
     462        PKFSOBJ         pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);
     463        if (pPathObj)
     464        {
     465            if (pPathObj->bObjType != KFSOBJ_TYPE_MISSING)
     466            {
     467                kHlpAssert(pPathObj->fHaveStats); /* currently always true. */
     468                pStat->st_mtime = pPathObj->Stats.st_mtime;
     469                kFsCacheObjRelease(g_pFsCache, pPathObj);
     470                return 0;
     471            }
     472
     473            kFsCacheObjRelease(g_pFsCache, pPathObj);
     474            errno = ENOENT;
     475        }
     476        else
     477            errno =    enmError == KFSLOOKUPERROR_NOT_DIR
     478                    || enmError == KFSLOOKUPERROR_PATH_COMP_NOT_DIR
     479                  ? ENOTDIR : ENOENT;
     480        return -1;
     481    }
     482    /** @todo implement cache refreshing.   */
     483    return birdStatFollowLink(pszPath, pStat);
     484}
     485
  • trunk/src/kmk/read.c

    r2799 r2857  
    532532    void *stream_buf = NULL;
    533533    struct stat st;
     534# ifdef KBUILD_OS_WINDOWS
     535    if (!birdStatOnFdJustSize(fileno(ebuf.fp), &st.st_size))
     536# else
    534537    if (!fstat (fileno (ebuf.fp), &st))
     538# endif
    535539      {
    536540        int stream_buf_size = 256*1024;
  • trunk/src/kmk/remake.c

    r2754 r2857  
    17941794  int e;
    17951795
     1796#if defined(KMK) && defined(KBUILD_OS_WINDOWS)
     1797  extern int stat_only_mtime(const char *pszPath, struct stat *pStat);
     1798  e = stat_only_mtime (name, &st);
     1799#else
    17961800  EINTRLOOP (e, stat (name, &st));
     1801#endif
    17971802  if (e == 0)
    17981803    mtime = FILE_TIMESTAMP_STAT_MODTIME (name, st);
  • trunk/src/lib/nt/kFsCache.c

    r2856 r2857  
    494494    {
    495495        if (pchDot[1] != '.')
    496             pchDot = (const char *)kHlpMemChr(pchDot + 1, '.', &pszPath[cchPath] - pchDot - 1);
     496        {
     497            pchDot++;
     498            pchDot = (const char *)kHlpMemChr(pchDot, '.', &pszPath[cchPath] - pchDot);
     499        }
    497500        else
    498501        {
    499502            char ch;
    500             if (   (ch = pchDot[2]) == '\0'
     503            if (   (ch = pchDot[2]) != '\0'
    501504                && IS_SLASH(ch))
    502505            {
     
    529532    {
    530533        if (pwcDot[1] != '.')
    531             pwcDot = wmemchr(pwcDot + 1, '.', &pwszPath[cwcPath] - pwcDot - 1);
     534        {
     535            pwcDot++;
     536            pwcDot = wmemchr(pwcDot, '.', &pwszPath[cwcPath] - pwcDot);
     537        }
    532538        else
    533539        {
    534540            wchar_t wch;
    535             if (   (wch = pwcDot[2]) == '\0'
     541            if (   (wch = pwcDot[2]) != '\0'
    536542                && IS_SLASH(wch))
    537543            {
     
    11551161    *penmError = KFSLOOKUPERROR_DIR_READ_ERROR;
    11561162    return K_TRUE;
     1163}
     1164
     1165
     1166/**
     1167 * Does the initial directory populating or refreshes it if it has been
     1168 * invalidated.
     1169 *
     1170 * This assumes the parent directory is opened.
     1171 *
     1172 * @returns K_TRUE on success, K_FALSE on error.
     1173 * @param   pCache              The cache.
     1174 * @param   pDir                The directory.
     1175 * @param   penmError           Where to store K_FALSE explanation.  Optional.
     1176 */
     1177KBOOL kFsCacheDirEnsurePopuplated(PKFSCACHE pCache, PKFSDIR pDir, KFSLOOKUPERROR *penmError)
     1178{
     1179    KFSLOOKUPERROR enmIgnored;
     1180    if (   pDir->fPopulated
     1181        && (   pDir->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
     1182            || pDir->Obj.uCacheGen == pCache->uGeneration) )
     1183        return K_TRUE;
     1184    return kFsCachePopuplateOrRefreshDir(pCache, pDir, penmError ? penmError : &enmIgnored);
    11571185}
    11581186
  • trunk/src/lib/nt/kFsCache.h

    r2856 r2857  
    408408
    409409
     410KBOOL       kFsCacheDirEnsurePopuplated(PKFSCACHE pCache, PKFSDIR pDir, KFSLOOKUPERROR *penmError);
    410411KBOOL       kFsCacheDirAddChild(PKFSCACHE pCache, PKFSDIR pParent, PKFSOBJ pChild, KFSLOOKUPERROR *penmError);
    411412PKFSOBJ     kFsCacheCreateObject(PKFSCACHE pCache, PKFSDIR pParent,
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