예제 #1
0
        public FileSystem(uint sectors, uint minIndexNodes)
        {
            //Ensure index nodes use whole sectors
            minIndexNodes += 8 - minIndexNodes % 8;

            Header = new Header()
            {
                Sectors      = sectors,
                IndexNodes   = minIndexNodes,
                VersionMajor = 1,
                VersionMinor = 0
            };
            IndexNodes = new IndexNode[minIndexNodes];

            var dataSectors   = Header.Sectors - Header.IndexSectors - 1;
            var bitmapSectors = 0U;

            while (bitmapSectors * (512 * 8) < dataSectors)
            {
                bitmapSectors++;
                dataSectors--;
            }

            Bitmap = new SectorBitmap(dataSectors);
            Header.BitmapLength  = (uint)Bitmap.Bitmap.LongLength;
            Header.BitmapSectors = Bitmap.BitmapSectors;

            DataSectors = new DataSector[dataSectors];
        }
예제 #2
0
        public uint InsertDataSector(DataSector data)
        {
            var index = Array.FindIndex(DataSectors, x => x == null);

            if (index == -1)
            {
                throw new InvalidOperationException("Exausted data capacity");
            }
            DataSectors[index] = data;
            return((uint)index);
        }