Ejemplo n.º 1
0
        public static DatabaseRecord ReadFrom(byte[] buffer, int offset)
        {
            DatabaseRecord result = null;

            if (Utilities.ToInt32BigEndian(buffer, offset + 0xC) != 0)
            {
                switch ((RecordType)(buffer[offset + 0x13] & 0xF))
                {
                    case RecordType.Volume:
                        result = new VolumeRecord();
                        break;

                    case RecordType.Component:
                        result = new ComponentRecord();
                        break;

                    case RecordType.Extent:
                        result = new ExtentRecord();
                        break;

                    case RecordType.Disk:
                        result = new DiskRecord();
                        break;

                    case RecordType.DiskGroup:
                        result = new DiskGroupRecord();
                        break;

                    default:
                        throw new NotImplementedException("Unrecognized record type: " + buffer[offset + 0x13]);
                }

                result.DoReadFrom(buffer, offset);
            }

            return result;
        }
Ejemplo n.º 2
0
        private SparseStream OpenVolume(VolumeRecord volume)
        {
            List<SparseStream> cmpntStreams = new List<SparseStream>();
            foreach (var component in _database.GetVolumeComponents(volume.Id))
            {
                cmpntStreams.Add(OpenComponent(component));
            }

            if (cmpntStreams.Count < 1)
            {
                throw new IOException("Volume with no associated components");
            }
            else if (cmpntStreams.Count == 1)
            {
                return cmpntStreams[0];
            }
            else
            {
                return new MirrorStream(Ownership.Dispose, cmpntStreams.ToArray());
            }
        }
Ejemplo n.º 3
0
        private LogicalVolumeStatus GetVolumeStatus(VolumeRecord volume)
        {
            int numFailed = 0;
            ulong numOK = 0;
            LogicalVolumeStatus worst = LogicalVolumeStatus.Healthy;
            foreach (var cmpnt in _database.GetVolumeComponents(volume.Id))
            {
                LogicalVolumeStatus cmpntStatus = GetComponentStatus(cmpnt);
                worst = WorstOf(worst, cmpntStatus);
                if (cmpntStatus == LogicalVolumeStatus.Failed)
                {
                    numFailed++;
                }
                else
                {
                    numOK++;
                }
            }

            if (numOK < 1)
            {
                return LogicalVolumeStatus.Failed;
            }
            else if (numOK == volume.ComponentCount)
            {
                return worst;
            }
            else
            {
                return LogicalVolumeStatus.FailedRedundancy;
            }
        }