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

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

?? volume.c

?? 從大量的wince源代碼中剝離出的fat文件系統源代碼.移植性非常高. 里面帶有source i.rar
?? C
?? 第 1 頁 / 共 5 頁
字號:
void UnlockVolume(PVOLUME pvol)
{
//    pvol->v_flags &= ~VOLF_LOCKED;
//    return;
    // We need to clear the volume's lock flag first, because if
    // MountDisk decides to try to format it, it will need to be able
    // to (re)lock the volume.

    ASSERT(pvol->v_flags & VOLF_LOCKED);
    pvol->v_flags &= ~VOLF_LOCKED;

    if (pvol->v_flags & VOLF_MODIFIED) {

        DWORD dwOldFlags;
        HANDLE hdsk = pvol->v_pdsk->d_hdsk;

        // Reinvigorate our data structures since it appears that the disk
        // could have been significantly modified.

        EnterCriticalSection(&csFATFS);

        // Since the unmount/remount can cause the REMOUNTED or RECYCLED bits
        // to be set, and since this could be called *within* an earlier mount,
        // we don't want to lose the original bits for that earlier mount.

        dwOldFlags = pvol->v_flags;

        // We set the RETAIN bit, so that we don't have to worry about
        // UnmountVolume freeing the current VOLUME structure.  It will be
        // reset by UnmountVolume as soon as CloseVolume has completed.
        // (I used to set the FROZEN bit instead, but that doesn't get reset
        // until much later -- when the volume is reopened by OpenVolume -- and
        // it prevents legitimate ReadVolume/WriteVolume calls from working -JTP)

        pvol->v_flags |= VOLF_RETAIN;
        UnmountVolume(pvol, FALSE);

        // When UnmountVolume called CloseVolume, CloseVolume froze the volume
        // and set v_bMediaDesc to MAX_VOLUMES.  We set it to zero now to insure
        // that we will re-use the volume without delay.
        pvol->v_bMediaDesc = 0;

        if (pvol->v_flags & VOLF_FROZEN) {
            pvol->v_pdsk->pVol = pvol;
            pvol->v_flags &= ~VOLF_FROZEN;
        }    
//#if 0
#ifndef DEBUG
        MountDisk(hdsk, NULL, pvol->v_flags);
#else
        VERIFYTRUE(MountDisk(hdsk, NULL, pvol->v_flags));
#endif        
//#endif

        // IMPORTANT NOTE: If the VOLF_FROZEN bit is *not* clear, then it's
        // possible that MountDisk (which calls MountVolume) may have recycled
        // the *wrong* volume (or allocated a completely new one), which means
        // that we may have just leaked a VOLUME;  at the very least, it probably
        // means our current pvol pointer is stale.

// TODO: Yadhug
//        ASSERT(!(pvol->v_flags & VOLF_FROZEN));

        // Restore the REMOUNTED and RECYCLED bits to their former glory

        pvol->v_flags &= ~(VOLF_REMOUNTED | VOLF_RECYCLED);
        pvol->v_flags |= dwOldFlags & (VOLF_REMOUNTED | VOLF_RECYCLED);

        LeaveCriticalSection(&csFATFS);

#if 0 
        if (pvol->v_volID > INVALID_AFS) {
            DEREGISTERAFS(pvol);
            pvol->v_volID = REGISTERAFS(pvol, pvol->v_volID);
        }
#endif        
    }
}


/*  OpenVolume - Allocate a VOLUME structure and validate volume
 *
 *  ENTRY
 *      pdsk -> DSK structure
 *      ppi -> partition info, if any
 *      ppbgbs - pointer to address of PBR (partition boot record) for volume
 *      pstmParent - pointer to parent stream (only if MiniFAT volume)
 *
 *  EXIT
 *      pointer to new VOLUME structure, or NULL if we couldn't make one
 */

PVOLUME OpenVolume(PDSK pdsk, PPARTINFO ppi, PBIGFATBOOTSEC *ppbgbs, PDSTREAM pstmParent)
{
    PVOLUME pvol;

    ASSERT(pdsk->d_hdsk != INVALID_HANDLE_VALUE);

    EnterCriticalSection(&csFATFS);

    // Find a reusable VOLUME or allocate a new one.

    pvol = FindVolume(pdsk, *ppbgbs);
    if (!pvol)
        goto exit;

    EnterCriticalSection(&pvol->v_cs);

    pvol->v_ppi = ppi;  // record the associated partition info (NULL if non-partitioned)
    if (ppi)            // and associate the volume with the partition info, if any exists
        ppi->pi_pvol = pvol;

    pvol->v_flags &= ~(VOLF_FROZEN | VOLF_UNCERTAIN | VOLF_DIRTY_WARN);


    // Initialize the rest of the VOLUME structure now.  This doesn't perform
    // any I/O, and will return an error only if there is a problem allocating
    // memory for either the FAT or root directory streams.

    if (!InitVolume(pvol, *ppbgbs)) {
        DEBUGMSG(ZONE_INIT || ZONE_ERRORS,(DBGTEXT("FATFS!OpenVolume: InitVolume failed, volume not opened!\n")));
        CloseVolume(pvol, NULL);
        pvol = NULL;
        goto exit;
    }

    // Now make sure the volume is valid.  This will set the INVALID bit if
    // it isn't, but we will still register/mount the volume so that it can be
    // made valid (ie, formatted) later.

    TestVolume(pvol, ppbgbs);

  exit:
    LeaveCriticalSection(&csFATFS);
    return pvol;
}


/*  CloseVolume - Free a VOLUME structure (if no open handles)
 *
 *  ENTRY
 *      pvol - pointer to VOLUME
 *      pwsVolName - pointer to volume name buffer (assumed to be MAX_PATH)
 *
 *  EXIT
 *      TRUE if freed, FALSE if not.  If not freed, then at a minimum,
 *      the disk handle is invalidated and the volume is marked FROZEN.
 *
 *  NOTES
 *      The volume's critical section should be held by the caller,
 *      and is the caller's responsibility to unhold if this returns FALSE
 *      (ie, volume not freed).
 */

BOOL CloseVolume(PVOLUME pvol, PWSTR pwsVolName)
{
    BOOL fSuccess = TRUE;
    PDSTREAM pstm, pstmEnd;
    PFHANDLE pfh, pfhEnd;

    DEBUGMSG(ZONE_APIS,(DBGTEXT("FATFS!CloseVolume(0x%x)\n"), pvol));

    ASSERT(pvol);

    ASSERT(OWNCRITICALSECTION(&csFATFS));
    ASSERT(OWNCRITICALSECTION(&pvol->v_cs));

#ifdef PATH_CACHING
    // We destroy the path cache first, releasing any streams
    // that it may have been holding onto, so that our assertion
    // checks below don't give us false fits.

    PathCacheDestroyAll(pvol);
#endif

    // Walk the open stream list, and for each open stream, walk
    // the open handle list, and for each open handle, mark it as
    // unmounted.  Streams with no open handles are immediately
    // closed;  the only streams that should fall into that category
    // are the special streams for the FAT and root directory.

    EnterCriticalSection(&pvol->v_csStms);

    pstm = pvol->v_dlOpenStreams.pstmNext;
    pstmEnd = (PDSTREAM)&pvol->v_dlOpenStreams;

    while (pstm != pstmEnd) {
        pstm->s_flags &= ~STF_VISITED;
        pstm = pstm->s_dlOpenStreams.pstmNext;
    }

  restart:
    pstm = pvol->v_dlOpenStreams.pstmNext;
    while (pstm != pstmEnd) {

        if (pstm->s_flags & STF_VISITED) {
            pstm = pstm->s_dlOpenStreams.pstmNext;
            continue;
        }

        pstm->s_flags |= STF_VISITED;

        // Add a ref to insure that the stream can't go away once we
        // let go of the volume's critical section.

        pstm->s_refs++;

        LeaveCriticalSection(&pvol->v_csStms);
        EnterCriticalSection(&pstm->s_cs);

        // Try to commit the stream before we unmount it, because we may
        // never be able to remount this stream again, and CommitStream
        // will refuse to commit a stream that's unmounted (and rightly so).

        CommitStream(pstm, TRUE);

        pfh = pstm->s_dlOpenHandles.pfhNext;
        pfhEnd = (PFHANDLE)&pstm->s_dlOpenHandles;

        if (pfh == pfhEnd) {

            if (pstm->s_refs == 2) {
                if (pstm == pvol->v_pstmFAT) {
                    pstm->s_refs--;
                    pvol->v_pstmFAT = NULL;
                }
                else if (pstm == pvol->v_pstmRoot) {
                    pstm->s_refs--;
                    pvol->v_pstmRoot = NULL;
                }
            }
        }
        else {

            // An open handle exists, so we won't be able to free the volume.

            fSuccess = FALSE;

            // Note that we print # of refs less 1, because one of the
            // refs is temporary (ie, it has been added by this function).

            DEBUGMSG(ZONE_INIT,(DBGTEXT("FATFS!CloseVolume: stream %.11hs still open (%d refs)\n"), pstm->s_achOEM, pstm->s_refs-1));

            // Since a stream's current buffer should be neither manipulated
            // nor held after the release of its critical section, and since we
            // own that critical section now, assert that the current buffer
            // is no longer held;  this means that the current buffer pointer
            // serves only as a "cache hint" now, and since we are about to call
            // FreeBufferPool, we need to invalidate that hint now, too.

            ASSERT(!(pstm->s_flags & STF_BUFCURHELD));
            pstm->s_pbufCur = NULL;

            while (pfh != pfhEnd) {
                pfh->fh_flags |= FHF_UNMOUNTED;
                pfh = pfh->fh_dlOpenHandles.pfhNext;
            }
        }

        pstm->s_flags |= STF_UNMOUNTED;

        CloseStream(pstm);
        EnterCriticalSection(&pvol->v_csStms);
        goto restart;
    }

    LeaveCriticalSection(&pvol->v_csStms);

    // Free any other memory associated with the volume.  The only
    // memory remaining (if ANY) should be the VOLUME structure and one
    // or more open streams hanging off it.  Also, before the registered name
    // of the volume goes away, save a copy if the caller wants it (like for
    // error reporting or something....)  We start at "+1" to avoid copying
    // the leading backslash.

    if (pwsVolName) {
        *pwsVolName = '\0';
        if (pvol->v_pwsHostRoot)
            wcscpy(pwsVolName, pvol->v_pwsHostRoot+1);
    }

    if (!(pvol->v_flags & VOLF_FORMATTING))
        DeregisterVolume(pvol);

    if (!FreeBufferPool(pvol))
        fSuccess = FALSE;

    // If this volume is associated with partition information, kill that association now

    if (pvol->v_ppi) {
        pvol->v_ppi->pi_pvol = NULL;
        pvol->v_ppi = NULL;
    }

    if (fSuccess) {

        // If we already tried once to close this volume and failed,
        // leave it allocated but frozen until the volume is remounted
        // or recycled, lest we mess up volume bookkeeping in
        // external components.  

        fSuccess =  !(pvol->v_flags & (VOLF_FROZEN | VOLF_RETAIN));

        if (fSuccess) {
#ifdef PATH_CACHING
            DEBUGFREE(DEBUGALLOC_CS);
            DeleteCriticalSection(&pvol->v_csCaches);
#endif
            DEBUGFREE(DEBUGALLOC_CS);
            DeleteCriticalSection(&pvol->v_csStms);
            DEBUGFREE(DEBUGALLOC_CS);
            LeaveCriticalSection(&pvol->v_cs);  // DeleteCriticalSection is picky about this...
            DeleteCriticalSection(&pvol->v_cs);
            DEBUGFREE(sizeof(VOLUME));
            VERIFYNULL(LocalFree((HLOCAL)pvol));
        }
        else {
            DEBUGMSGW(ZONE_INIT,(DBGTEXTW("FATFS!CloseVolume: retaining volume 0x%08x (%s)\n"), pvol, pvol->v_flags & VOLF_FROZEN? TEXTW("previously frozen") : TEXTW("following power cycle")));
            if (!(pvol->v_flags & VOLF_FROZEN)) {
                pvol->v_bMediaDesc = MAX_VOLUMES;
                pvol->v_flags |= VOLF_FROZEN;
            }
        }
    }
    else {
        DEBUGMSG(ZONE_INIT,(DBGTEXT("FATFS!CloseVolume: retaining volume 0x%08x (open files add/or dirty buffers)\n"), pvol));
        if (!(pvol->v_flags & VOLF_FROZEN)) {
            pvol->v_bMediaDesc = MAX_VOLUMES;   // overload bMediaDesc as a recycle skip count
            pvol->v_flags |= VOLF_FROZEN;
        }
    }
#ifdef DISK_CACHING
    pvol->v_CacheSize = 0;
    if (pvol->v_pFATCacheBuffer) {
        VirtualFree( pvol->v_pFATCacheBuffer, 0, MEM_RELEASE);
        pvol->v_pFATCacheBuffer = NULL; 
    }
    if (pvol->v_pFATCacheLookup) {
        HeapFree( GetProcessHeap(), 0, pvol->v_pFATCacheLookup);
        pvol->v_pFATCacheLookup = NULL;
    }    
#endif

    DEBUGMSG(ZONE_APIS,(DBGTEXT("FATFS!CloseVolume returned 0x%x\n"), fSuccess));
    return fSuccess;
}


/*  QueryVolumeParameters - Query volume parameters
 *
 *  ENTRY
 *      pvol - pointer VOLUME structure
 *      pdevpb - pointer to DOS-style device parameter block
 *      fVolume - TRUE to return volume info, FALSE for device info
 *
 *  EXIT
 *      ERROR_SUCCESS if successful, error code if not
 */

void QueryVolumeParameters(PVOLUME pvol, PDEVPB pdevpb, BOOL fVolume)
{
    // Caller wants a DEVPB.  Give him a close approximation of one.

    memset(pdevpb, 0, sizeof(DEVPB));

#ifdef OLD_CODE
    // In order to allow invalid volumes inside valid partitions
    // to be reformatted, I'm going to leave fVolume alone now. -JTP

    if (pvol->v_flags & VOLF_INVALID)
        fVolume = FALSE;
#endif

    // We'll use this bMediaType field to tell the caller what

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久久电影| 国产真实精品久久二三区| www.亚洲激情.com| 亚洲国产成人在线| 成人午夜激情片| 1000精品久久久久久久久| 99久久精品99国产精品| 亚洲蜜臀av乱码久久精品| 在线观看国产日韩| 亚洲成人自拍偷拍| 精品国产乱码久久久久久图片 | 在线一区二区三区四区五区 | 精品av综合导航| 成人午夜av电影| 亚洲一区二区三区影院| 6080午夜不卡| 国产寡妇亲子伦一区二区| 中文字幕一区日韩精品欧美| 欧美日韩在线综合| 久久国产婷婷国产香蕉| 午夜视频久久久久久| 欧美一二三区在线| 国产91丝袜在线18| 亚洲一区二区三区国产| 欧美精品一区二区三区四区| 99re免费视频精品全部| 奇米一区二区三区| 国产精品美女www爽爽爽| 欧美性xxxxx极品少妇| 久久99精品国产麻豆婷婷| 中文成人综合网| 欧美精品1区2区| 成人自拍视频在线| 日韩av一区二区三区四区| 国产精品欧美一区喷水| 欧美男女性生活在线直播观看| 久久国产综合精品| 樱花影视一区二区| 久久免费偷拍视频| 欧美日韩精品欧美日韩精品 | 水野朝阳av一区二区三区| 久久青草欧美一区二区三区| 色av成人天堂桃色av| 国产老妇另类xxxxx| 亚洲成人精品一区二区| 国产精品大尺度| 91精品国产综合久久精品图片 | 91浏览器入口在线观看| 精品一区免费av| 国产精品久久一卡二卡| 日韩欧美一区二区三区在线| 色婷婷亚洲婷婷| 国产91露脸合集magnet| 精品一区二区三区av| 日日欢夜夜爽一区| 亚洲综合成人在线| 国产精品对白交换视频 | 午夜视频一区在线观看| 国产精品传媒在线| 欧美激情综合五月色丁香| 日韩一区二区三区av| 欧美日韩激情在线| 欧美四级电影网| 一本一道综合狠狠老| 不卡的电影网站| 丁香婷婷综合激情五月色| 久久69国产一区二区蜜臀| 日韩在线一二三区| 伊人色综合久久天天| 国产精品成人免费| 国产精品久线在线观看| 欧美国产欧美亚州国产日韩mv天天看完整| 在线播放欧美女士性生活| 在线精品视频小说1| 在线精品视频小说1| 欧美羞羞免费网站| 欧美日韩你懂的| 欧美人体做爰大胆视频| 欧美色视频在线| 欧美日本一道本| 欧美一区二区精品在线| 日韩欧美国产综合| 精品少妇一区二区三区视频免付费| 8v天堂国产在线一区二区| 7777精品伊人久久久大香线蕉超级流畅| 欧美性videosxxxxx| 欧美福利电影网| 日韩免费看的电影| 2021中文字幕一区亚洲| 久久久三级国产网站| 国产精品日产欧美久久久久| 国产精品久久久久aaaa樱花| 亚洲精品伦理在线| 亚洲成人精品影院| 激情六月婷婷综合| 成人97人人超碰人人99| 色天使色偷偷av一区二区| 欧美性xxxxxxxx| 欧美成人福利视频| 日本一区二区不卡视频| 亚洲制服丝袜在线| 天天亚洲美女在线视频| 国产一区二区三区四| 北岛玲一区二区三区四区 | 欧美日韩电影在线播放| 777亚洲妇女| 国产日韩欧美综合在线| 亚洲女厕所小便bbb| 日韩精品五月天| 国产iv一区二区三区| 在线免费观看日本一区| 日韩一区二区在线看| 久久久99久久| 亚洲韩国精品一区| 精品一区二区三区久久久| 91在线观看一区二区| 欧美精品v国产精品v日韩精品| 久久精品一区二区三区四区| 亚洲激情校园春色| 国模一区二区三区白浆| 一本一道久久a久久精品综合蜜臀| 日韩一级黄色大片| 亚洲视频一二区| 久久99日本精品| 色婷婷综合五月| 久久久国产一区二区三区四区小说 | 亚洲精品菠萝久久久久久久| 麻豆91在线观看| 欧美中文字幕亚洲一区二区va在线| 亚洲大尺度视频在线观看| 国产一区中文字幕| 欧美日韩国产高清一区二区| 日本一区二区三区四区| 日韩主播视频在线| 91免费在线视频观看| 久久久久久免费| 日韩电影一区二区三区| 91美女在线看| 国产精品私人影院| 精品综合免费视频观看| 制服丝袜一区二区三区| 一区二区三区在线观看视频| 成人黄动漫网站免费app| 精品国产a毛片| 蜜臀av国产精品久久久久| 欧美午夜电影一区| 亚洲欧美国产高清| 成人91在线观看| 国产欧美一区二区精品性色超碰| 日本视频在线一区| 欧美日韩免费高清一区色橹橹| 国产精品天干天干在线综合| 韩国三级电影一区二区| 日韩一区二区三区在线视频| 午夜激情一区二区| 欧美中文字幕不卡| 亚洲一区二区三区中文字幕在线| 97久久超碰国产精品| 中文字幕一区在线观看| 成人的网站免费观看| 国产色91在线| 丰满放荡岳乱妇91ww| 久久久精品综合| 国产精品一二二区| 久久久国际精品| 国产成人av福利| 久久亚洲精精品中文字幕早川悠里| 免费人成精品欧美精品| 日韩欧美在线不卡| 久久超碰97中文字幕| 精品国产免费久久| 国产精品自拍一区| 国产精品欧美一级免费| 不卡av在线免费观看| 亚洲免费伊人电影| 欧美午夜影院一区| 日本免费在线视频不卡一不卡二| 欧美另类变人与禽xxxxx| 日本成人中文字幕在线视频| 亚洲精品免费在线观看| 欧美日韩国产免费| 欧美bbbbb| 国产日韩视频一区二区三区| 99视频精品免费视频| 一区二区不卡在线播放 | 不卡的av网站| 亚洲国产视频直播| 欧美一级免费观看| 国产精品一级片在线观看| 国产精品视频第一区| 一本大道av伊人久久综合| 亚洲v日本v欧美v久久精品| 日韩欧美专区在线| 成人开心网精品视频| 一区二区三区小说| 337p亚洲精品色噜噜| 国产精品一区免费在线观看| 亚洲人精品午夜| 欧美一区二区大片| 成人黄动漫网站免费app|