亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cache.c

?? FAT文件系統源代碼
?? C
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
/*++


Module Name:

    cache.c

Abstract:

    This file contains FAT file system path/name cache functions.

Revision History:

--*/

#include "fatfs.h"


#ifdef PATH_CACHING

/*  PathCacheCreate - Create a new entry in a volume's path cache
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pwsPath - pointer to path
 *      len - length of path (ie, portion to cache)
 *      pstm - pointer to DSTREAM corresponding to path (other than root)
 *
 *  EXIT
 *      None.  If the entry can be added to the path cache, great;
 *      if not, oh well.
 *
 *  NOTES
 *      Pre-processed paths should include NEITHER a leading [back]slash
 *      NOR a trailing one (ie, only the characters inbetween).  Furthermore,
 *      callers should never try to cache the root;  it's pointless because
 *      the root stream is already persistent.
 *
 *      If the caller has NOT pre-processed the path according to the above
 *      rules, then he should pass len == 0 and we will take care of the
 *      rest.  In that case though, the path must be null-terminated.
 *
 *      Also, when streams are cached, their critical section is usually
 *      being held by the caller at the time.  So, after we take the *cache*
 *      critical section, it is important that we not attempt to take any
 *      *other* stream's critical section, since that could cause a deadlock.
 *
 *      This is why PathCacheDestroy has the option of returning the stream
 *      belonging to a destroyed cache entry;  if PathCacheDestroy was allowed
 *      to close its reference to the stream on the spot, it would have to
 *      briefly relinquish the *cache* critical section first, and we'd rather
 *      not do that in this particular function.
 */

void PathCacheCreate(PVOLUME pvol, PCWSTR pwsPath, int len, PDSTREAM pstm)
{
    PCACHE pcch;
    PDSTREAM pstmFree = NULL;

    ASSERT(OWNCRITICALSECTION(&pstm->s_cs));

    if (pvol->v_flags & VOLF_UNMOUNTED)
        return;

    EnterCriticalSection(&pvol->v_csStms);
    EnterCriticalSection(&pvol->v_csCaches);

    ASSERT(pvol->v_cCaches <= pvol->v_cMaxCaches && pstm != pvol->v_pstmRoot);

#ifdef TFAT
        if (pvol->v_flags & VOLF_TFAT_REDIR_ROOT)
        {
            // If we are redirecting the root dir, then remove the hidden dir from the path, only if the path is
            // not the hidden dir itself.  
            if (IS_REDIR_PATH(pwsPath) && (len > (HIDDEN_TFAT_ROOT_DIR_LEN+1))) 
            {                
                pwsPath += (HIDDEN_TFAT_ROOT_DIR_LEN+1);
                len -= (HIDDEN_TFAT_ROOT_DIR_LEN+1);
            }       
        }
#endif


    // Cache this stream, if it isn't already cached

    if (!PathCacheFindStream(pvol, pstm)) {

        // If len <= 0, then the caller has an unprocessed null-terminated
        // path which we must calculate the length of;  in particular,
        // if len < 0, then -len is the number of elements to remove from the
        // end of the path being cached.

        if (len <= 0) {
            len = PathCacheLength(&pwsPath, -len);
            if (len <= 0)
                goto exit;

            if (pstm->s_cwPath == 0) {
#ifdef TFAT
                // The hidden root dir stream has cwPath set to 0, so ignore this case
                if (!IS_REDIR_PATH(pwsPath))
#endif
                    pstm->s_cwPath = len + 1;
            }
        }

#ifdef DEMAND_PAGING_DEADLOCKS
        // If the stream we've opened can currently be demand-paged,
        // then we MUST temporarily release the stream's CS around these
        // memory manager calls.

        if (pstm->s_flags & STF_DEMANDPAGED)
            LeaveCriticalSection(&pstm->s_cs);
#endif
        // If we've already got the (hard-coded) maximum number of cache
        // entries, then destroy the oldest one.  We don't free the stream
        // right away -- we wait until we've released the cache critical
        // section first, to avoid deadlocks.

        if (pvol->v_cCaches == pvol->v_cMaxCaches)
            pstmFree = PathCacheDestroy(pvol, pvol->v_dlCaches.pcchPrev, FALSE);

        // Now allocate a new entry.

        pcch = (PCACHE)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CACHE)+(len+1-ARRAYSIZE(pcch->c_awcPath))*sizeof(WCHAR));

#ifdef DEMAND_PAGING_DEADLOCKS
        if (pstm->s_flags & STF_DEMANDPAGED)
            EnterCriticalSection(&pstm->s_cs);
#endif
        if (pcch) {

            DEBUGALLOC(pcch->c_cbAlloc = sizeof(CACHE)+(len+1-ARRAYSIZE(pcch->c_awcPath))*sizeof(WCHAR));

            pstm->s_refs++;
            pcch->c_pstm = pstm;
            pcch->c_flags = CACHE_PATH;

            pvol->v_cCaches++;
            AddItem((PDLINK)&pvol->v_dlCaches, (PDLINK)&pcch->c_dlink);

            __try {
                memcpy(pcch->c_awcPath, pwsPath, len*sizeof(WCHAR));
                pcch->c_cwPath = len;
            }
            __except (EXCEPTION_EXECUTE_HANDLER) {
                ;
            }
        }
    }
  exit:
    LeaveCriticalSection(&pvol->v_csCaches);
    LeaveCriticalSection(&pvol->v_csStms);

    if (pstmFree) {

// WINSE 25001, fix deadlock
// #ifdef DEMAND_PAGING_DEADLOCKS
        // if (pstm->s_flags & STF_DEMANDPAGED)
            LeaveCriticalSection(&pstm->s_cs);
// #endif

        EnterCriticalSection(&pstmFree->s_cs);
        CloseStream(pstmFree);

// #ifdef DEMAND_PAGING_DEADLOCKS
//         if (pstm->s_flags & STF_DEMANDPAGED)
            EnterCriticalSection(&pstm->s_cs);
// #endif
    }
}


/*  PathCacheSearch - Search for a path in a volume's path cache
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      ppwsPath - address of pointer to path
 *
 *  EXIT
 *      Pointer to DSTREAM if found, NULL if not
 *
 *  NOTES
 *      This will advance the caller's pwsPath up to the final
 *      [back]slash in the specified path.  Also, we don't bother with
 *      exception handling around the first bit of code because the only
 *      caller (OpenPath) already has a handler.
 */

PDSTREAM PathCacheSearch(PVOLUME pvol, PCWSTR *ppwsPath)
{
    int len;
    PCACHE pcch, pcchEnd;
    PCWSTR pwsPath = *ppwsPath;
    PDSTREAM pstmreturn = NULL;

    // Determine the path length we need to compare.  To do so,
    // we must find the final [back]slash.

    len = wcslen (pwsPath);
    if (len <= 1)
        return NULL;

    len--;

    // Ignore a trailing slash
    if (pwsPath[len] == L'\\' || pwsPath[len] == L'/') {
        len--;
    }

    // Find the nearest slash from the current pointer
    while (len && pwsPath[len] != L'\\' && pwsPath[len] != L'/') {
        len--;
    }

    // We don't cache the root (not much point), so get out if that's
    // the case...

    if (len == 0)
        return NULL;

#ifdef TFAT
        if (pvol->v_flags & VOLF_TFAT_REDIR_ROOT)
        {
            // If we are redirecting the root dir, then remove the hidden dir from the path, only if the path is
            // not the hidden dir itself.  
            if (IS_REDIR_PATH(pwsPath) && (len > (HIDDEN_TFAT_ROOT_DIR_LEN+1))) 
            {                
                pwsPath += (HIDDEN_TFAT_ROOT_DIR_LEN+1);
                len -= (HIDDEN_TFAT_ROOT_DIR_LEN+1);
            }       
        }
#endif

    EnterCriticalSection(&pvol->v_csStms);
    EnterCriticalSection(&pvol->v_csCaches);

    __try {
        pcch = pvol->v_dlCaches.pcchNext;
        pcchEnd = (PCACHE)&pvol->v_dlCaches;

        while (pcch != pcchEnd) {

            if (len == pcch->c_cwPath && _wcsnicmp(pcch->c_awcPath, pwsPath, len) == 0) {

                PDSTREAM pstm = pcch->c_pstm;

                // Since this entry is a match, bump it up in the list

                RemoveItem((PDLINK)&pcch->c_dlink);
                AddItem((PDLINK)&pvol->v_dlCaches, (PDLINK)&pcch->c_dlink);

                *ppwsPath = pwsPath + len + 1;

                pstm->s_refs++;
                pstmreturn = pstm;
                break;
            }
            pcch = pcch->c_dlink.pcchNext;
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        ;
    }

    LeaveCriticalSection(&pvol->v_csCaches);
    LeaveCriticalSection(&pvol->v_csStms);

    if (pstmreturn) {
        EnterCriticalSection(&pstmreturn->s_cs);
    }
    return pstmreturn;
}


/*  PathCacheInvalidate - Invalidate all cached paths containing this path
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pwsPath - pointer to path to invalidate
 *
 *  EXIT
 *      TRUE if any cache entries were invalidated, FALSE if not
 */

BOOL PathCacheInvalidate(PVOLUME pvol, PCWSTR pwsPath)
{
    int len;
    BOOL fInvalidate;

    len = PathCacheLength(&pwsPath, 0);
    if (len == 0)
        return FALSE;

    fInvalidate = FALSE;

    EnterCriticalSection(&pvol->v_csCaches);

    __try {
        PCACHE pcch, pcchEnd;

        pcch = pvol->v_dlCaches.pcchNext;
        pcchEnd = (PCACHE)&pvol->v_dlCaches;

        while (pcch != pcchEnd) {

            if (len <= pcch->c_cwPath && _wcsnicmp(pcch->c_awcPath, pwsPath, len) == 0 &&
                (pcch->c_awcPath[len] == 0 || pcch->c_awcPath[len] == TEXTW('\\') || pcch->c_awcPath[len] == TEXTW('/'))) {
                PathCacheDestroy(pvol, pcch, TRUE);
                pcch = pvol->v_dlCaches.pcchNext;
                fInvalidate = TRUE;
                continue;
            }
            pcch = pcch->c_dlink.pcchNext;
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        ;
    }

    LeaveCriticalSection(&pvol->v_csCaches);

    return fInvalidate;
}

/*  PathCacheStreamInvalidate - Invalidate all cached paths containing this stream
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pwsPath - pointer to path to invalidate
 *
 *  EXIT
 *      TRUE if any cache entries were invalidated, FALSE if not
 */

BOOL PathCacheStreamInvalidate(PVOLUME pvol, PDSTREAM pstm)
{
    BOOL fInvalidate = FALSE;

    EnterCriticalSection(&pvol->v_csCaches);

    __try {
        PCACHE pcch, pcchEnd;

        pcch = pvol->v_dlCaches.pcchNext;
        pcchEnd = (PCACHE)&pvol->v_dlCaches;

        while (pcch != pcchEnd) {

            if (pcch->c_pstm == pstm) {
                PathCacheDestroy(pvol, pcch, TRUE);
                pcch = pvol->v_dlCaches.pcchNext;
                fInvalidate = TRUE;
                continue;
            }
            pcch = pcch->c_dlink.pcchNext;
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        ;
    }

    LeaveCriticalSection(&pvol->v_csCaches);

    return fInvalidate;
}


/*  PathCacheLength - Calculate the length of a path
 *
 *  ENTRY
 *      ppwsPath - pointer to pointer to path
 *      celRemove - count of elements to remove from end
 *
 *  EXIT
 *      length of path (leading and terminating slashes ignored);
 *      *ppwsPath is updated as well
 */

int PathCacheLength(PCWSTR *ppwsPath, int celRemove)
{
    int len = 0;
    PCWSTR pwsEnd, pwsPath = *ppwsPath;

    // Ignore leading slash

    __try {
        if (*pwsPath == TEXTW('\\') || *pwsPath == TEXTW('/'))
            ++pwsPath;

        len = wcslen(pwsPath);
        if (len > 0) {

            pwsEnd = pwsPath + len - 1;

            // Ignore trailing slash

            if (*pwsEnd == TEXTW('\\') || *pwsEnd == TEXTW('/')) {
                pwsEnd--;
                len--;
            }

            while (celRemove > 0 && pwsEnd > pwsPath) {
                if (*pwsEnd == TEXTW('\\') || *pwsEnd == TEXTW('/'))
                    celRemove--;
                pwsEnd--;
                len--;
            }
        }
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        len = 0;
    }
    *ppwsPath = pwsPath;
    return len;
}


/*  PathCacheFindStream - Search for specific stream in path cache
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pstm - pointer to DSTREAM
 *
 *  EXIT
 *      Pointer to CACHE entry, NULL if none.  This function is really for
 *      internal use only.
 */

PCACHE PathCacheFindStream(PVOLUME pvol, PDSTREAM pstm)
{
    PCACHE pcch, pcchEnd;

    ASSERT(OWNCRITICALSECTION(&pstm->s_cs));
    ASSERT(OWNCRITICALSECTION(&pvol->v_csCaches));

    pcch = pvol->v_dlCaches.pcchNext;
    pcchEnd = (PCACHE)&pvol->v_dlCaches;

    while (pcch != pcchEnd) {
        if (pcch->c_pstm == pstm)
            return pcch;
        pcch = pcch->c_dlink.pcchNext;
    }
    return NULL;
}


/*  PathCacheDestroy - Free a specific path cache entry
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pcch - pointer to CACHE entry
 *      fClose - TRUE to close associated stream, FALSE to return
 *
 *  EXIT
 *      None.  This function is really for internal use only.
 */

PDSTREAM PathCacheDestroy(PVOLUME pvol, PCACHE pcch, BOOL fClose)
{
    PDSTREAM pstm = pcch->c_pstm;

    ASSERT(OWNCRITICALSECTION(&pvol->v_csCaches));

    pvol->v_cCaches--;
    RemoveItem((PDLINK)&pcch->c_dlink);

    DEBUGFREE(pcch->c_cbAlloc);
    VERIFYTRUE(HeapFree(hHeap, 0, (HLOCAL)pcch));

    if (fClose) {
        LeaveCriticalSection(&pvol->v_csCaches);
        EnterCriticalSection(&pstm->s_cs);
        CloseStream(pstm);
        EnterCriticalSection(&pvol->v_csCaches);
        return NULL;
    }
    return pstm;
}


/*  PathCacheDestroyAll - Free all path cache entries for a volume
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *
 *  EXIT
 *      None.  Calls PathCacheDestroy for each cache entry until the
 *      cache is empty.
 */

void PathCacheDestroyAll(PVOLUME pvol)
{
    PCACHE pcch, pcchEnd;

    EnterCriticalSection(&pvol->v_csCaches);

    pcchEnd = (PCACHE)&pvol->v_dlCaches;

    do {
        pcch = pvol->v_dlCaches.pcchNext;

        if (pcch == pcchEnd)
            break;

        PathCacheDestroy(pvol, pcch, TRUE);

    } while (TRUE);

    ASSERT(pvol->v_cCaches == 0);

    LeaveCriticalSection(&pvol->v_csCaches);
}

#endif  // PATH_CACHING

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日日欢夜夜爽一区| 91精品福利视频| 欧美精品一区二区不卡| 亚洲一卡二卡三卡四卡五卡| 91美女蜜桃在线| 亚洲综合激情网| 91精品国产91久久综合桃花| 91蝌蚪porny九色| 最新国产の精品合集bt伙计| 色综合视频一区二区三区高清| 一级日本不卡的影视| 91麻豆精品91久久久久久清纯 | 欧美一区二区三区在线看| 麻豆精品久久久| 国产精品久久久久久久久免费桃花| 91免费视频大全| 午夜久久久久久久久久一区二区| 亚洲精品一区二区在线观看| aa级大片欧美| 狠狠色丁香久久婷婷综合丁香| 中文字幕一区二区在线观看| 欧美日韩国产精品成人| 成人app网站| 理论片日本一区| 亚洲综合999| 国产欧美日韩在线视频| 欧美一区午夜视频在线观看 | 亚洲在线成人精品| 欧美精品一区二区不卡| 欧美日韩一区高清| 色综合av在线| 粉嫩av一区二区三区粉嫩| 日韩精品每日更新| 国产毛片精品国产一区二区三区| 日韩一区日韩二区| 中文字幕av不卡| 久久久99免费| 欧美精品一区二区三区蜜桃视频| 欧美日韩另类一区| 欧美三级乱人伦电影| 91国产丝袜在线播放| 99久久国产综合精品色伊| 国产精品亚洲а∨天堂免在线| 久久国产精品99久久久久久老狼| 亚洲成人免费在线| 亚洲va欧美va人人爽| 亚洲一区二区三区激情| 亚洲制服丝袜在线| 日韩综合在线视频| 蜜臀久久99精品久久久久宅男| 日韩电影在线一区二区| 久久精品国产精品青草| 国产乱人伦偷精品视频免下载| 久久99精品久久久久婷婷| 九九九精品视频| 高清日韩电视剧大全免费| av一区二区三区四区| 色久优优欧美色久优优| 欧美吻胸吃奶大尺度电影| 欧美日韩免费一区二区三区视频| 这里只有精品电影| 久久影视一区二区| 亚洲欧美日韩小说| 日韩黄色免费网站| av中文字幕不卡| 91精品国产综合久久香蕉麻豆| 91精品婷婷国产综合久久竹菊| 久久日韩精品一区二区五区| 国产精品欧美久久久久一区二区| 伊人性伊人情综合网| 精品在线你懂的| 欧美视频第二页| 久久精品免视看| 奇米精品一区二区三区在线观看| 国产成人夜色高潮福利影视| 欧美福利视频导航| 国产欧美日韩激情| 麻豆91精品91久久久的内涵| 色婷婷激情久久| 中文天堂在线一区| 男女激情视频一区| 欧美亚洲国产一区二区三区va | 91精品国产91久久久久久最新毛片| 中文字幕久久午夜不卡| 狠狠色狠狠色合久久伊人| 欧美另类z0zxhd电影| 亚洲在线一区二区三区| 亚洲国产视频在线| 日本精品一区二区三区高清| 久久精品视频一区| 黑人精品欧美一区二区蜜桃 | 日本一区二区三区国色天香| 亚洲成人你懂的| 在线视频一区二区三| 亚洲三级在线看| 欧美三级视频在线播放| 亚洲精品国产成人久久av盗摄| 成人综合婷婷国产精品久久蜜臀 | 精品精品欲导航| 美女视频网站黄色亚洲| 亚洲精品在线三区| 久久99国内精品| 久久尤物电影视频在线观看| 韩国中文字幕2020精品| 26uuu欧美日本| av男人天堂一区| 亚洲va欧美va国产va天堂影院| 91精品在线免费| 国产伦精品一区二区三区在线观看 | 奇米在线7777在线精品| 久久久国产精品午夜一区ai换脸| 成人av在线网| 亚洲福利视频一区二区| 精品国产区一区| 99精品桃花视频在线观看| 成人毛片在线观看| 日韩精品1区2区3区| 精品电影一区二区| 在线一区二区观看| 国产一区二区在线免费观看| 亚洲最大色网站| 欧美国产激情一区二区三区蜜月| 欧美视频在线观看一区| 国产成人三级在线观看| 麻豆国产精品视频| 亚洲夂夂婷婷色拍ww47| 亚洲国产成人va在线观看天堂| 日韩免费观看高清完整版| 色八戒一区二区三区| 丁香啪啪综合成人亚洲小说| 日韩精品久久理论片| 亚洲综合色丁香婷婷六月图片| 国产日产欧美一区二区视频| 91精品国产91久久久久久一区二区 | 欧美激情在线看| 久久精品免视看| 国产日本亚洲高清| xnxx国产精品| 日韩欧美成人午夜| 精品国产电影一区二区| 日韩三级视频在线看| 欧美一级日韩不卡播放免费| 欧美福利电影网| 日韩精品一区二| 精品国产人成亚洲区| 国产欧美精品区一区二区三区| 蜜桃av一区二区三区| 夜夜嗨av一区二区三区网页| 亚洲精品国产品国语在线app| 亚洲高清视频的网址| 婷婷成人激情在线网| 免费成人结看片| 精品在线一区二区| 成人理论电影网| 在线精品视频一区二区三四| 欧美男女性生活在线直播观看| 欧美日韩亚洲综合一区二区三区| 欧美日韩视频不卡| 精品国产乱码久久久久久影片| 日本久久一区二区| 日韩午夜精品视频| 国产精品色在线| 亚洲国产视频网站| 国产精品91一区二区| 在线观看日韩av先锋影音电影院| 日韩欧美一级二级三级久久久| 国产精品热久久久久夜色精品三区 | 中文在线一区二区| 亚洲五码中文字幕| 国产盗摄一区二区| 欧美猛男gaygay网站| 国产三级一区二区| 成人免费视频caoporn| 5566中文字幕一区二区电影 | 日韩一区二区三区电影| 亚洲三级在线免费观看| 乱中年女人伦av一区二区| 色综合久久久久综合体| 精品国产乱子伦一区| 天天综合天天综合色| 高清成人免费视频| 在线亚洲精品福利网址导航| 欧美日韩在线亚洲一区蜜芽| 久久美女艺术照精彩视频福利播放| 美国毛片一区二区三区| 国产亚洲综合性久久久影院| 成人18视频在线播放| 亚洲综合在线电影| 日韩欧美成人激情| 成人网男人的天堂| 亚洲永久免费视频| 777xxx欧美| 国产一区在线精品| 国产视频一区不卡| 99久久久久久| 婷婷中文字幕综合| 久久午夜免费电影| 91网址在线看| 欧美aⅴ一区二区三区视频| 久久综合色婷婷|