Пример #1
0
        public bool IsLogClean()
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            bool isLogFileClosed = (m_restartPage.LogRestartArea.ClientInUseList == LogRestartArea.NoClients);

            if (isLogFileClosed)
            {
                // Windows 2000 and earlier will close the log file by setting the ClientInUseList to NoClients when the volume is shutdown cleanly.
                // If the log file is closed than it must be clean.
                return(true);
            }
            else if ((m_restartPage.LogRestartArea.Flags & LogRestartFlags.LogFileIsClean) != 0)
            {
                // Windows XP and later will set the clean bit when the volume is shutdown cleanly.
                // If the clean bit is set than the log file must be clean.
                return(true);
            }
            else
            {
                // The volume has not been shutdown cleanly.
                // It's possible that the log is clean if the volume was completely idle for at least five seconds preceding the unclean shutdown.
                // Currently, we skip the analysis and assume that's not the case.
                return(false);
            }
        }
Пример #2
0
 public LogRecord ReadCurrentRestartRecord()
 {
     if (m_restartPage == null)
     {
         m_restartPage = ReadRestartPage();
     }
     return(ReadRecord(m_restartPage.LogRestartArea.CurrentLsn));
 }
Пример #3
0
        private int LsnToRecordOffsetInPage(ulong lsn)
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            return((int)((lsn << 3) & (m_restartPage.LogPageSize - 1)));
        }
Пример #4
0
        private void WritePage(ulong pageOffset, LogRecordPage page)
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            byte[] pageBytes = page.GetBytes((int)m_restartPage.LogPageSize, m_restartPage.LogRestartArea.LogPageDataOffset);
            WriteData(pageOffset, pageBytes);
        }
Пример #5
0
        private LogRecordPage ReadPageFromFile(ulong pageOffset)
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            byte[] pageBytes = ReadData(pageOffset, (int)m_restartPage.LogPageSize);
            return(new LogRecordPage(pageBytes, 0, m_restartPage.LogRestartArea.LogPageDataOffset));
        }
Пример #6
0
        public LogRecord ReadRecord(ulong lsn)
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            ulong         pageOffsetInFile   = LsnToPageOffsetInFile(lsn);
            int           recordOffsetInPage = LsnToRecordOffsetInPage(lsn);
            LogRecordPage page = ReadPage(pageOffsetInFile);

            return(page.ReadRecord(recordOffsetInPage, m_restartPage.LogRestartArea.LogPageDataOffset));
        }
Пример #7
0
        public LogRestartPage ReadRestartPage()
        {
            byte[] pageBytes      = ReadData(0, Volume.BytesPerSector);
            uint   systemPageSize = LogRestartPage.GetSystemPageSize(pageBytes, 0);
            int    bytesToRead    = (int)systemPageSize - pageBytes.Length;

            if (bytesToRead > 0)
            {
                byte[] temp = ReadData((ulong)pageBytes.Length, bytesToRead);
                pageBytes = ByteUtils.Concatenate(pageBytes, temp);
            }
            m_restartPage = new LogRestartPage(pageBytes, 0);
            return(m_restartPage);
        }
Пример #8
0
        private int FindClientIndex(string clientName)
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            for (int index = 0; index < m_restartPage.LogRestartArea.LogClientArray.Count; index++)
            {
                if (String.Equals(m_restartPage.LogRestartArea.LogClientArray[index].ClientName, clientName, StringComparison.OrdinalIgnoreCase))
                {
                    return(index);
                }
            }
            return(-1);
        }