///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: Fat.sg
//
// TODO: Block allocation for sequential cluster groups. This
// would entail less buffer cache lock operations.
//
using Microsoft.SingSharp;
using Microsoft.Singularity.Io;
using Microsoft.Singularity.Channels;
using System;
namespace Microsoft.Singularity.Services.Fat.Fs
{
internal abstract class Fat
{
/// Largest number of clusters that can be allocated
/// at a time.
///
public const int MaxAllocationLength = Bitmap.MaxAllocationLength;
/// Allocate cluster chain. The allocation is
/// no guaranteed to be contiguous
/// true if some of the requested clusters
/// have been allocated, false if there were no free
/// clusters available.
internal abstract bool AllocateChain(int hintClusterArea,
int targetLength,
out int allocStart,
out int allocLength);
/// Frees the chain starting at specified offset
internal abstract void FreeChain(int startCluster);
/// Grow an existing cluster chain. The allocation is
/// not guaranteed to be contiguous.
/// true if some of the requested clusters
/// have been allocated, false if there were no free
/// clusters available.
internal abstract bool GrowChain(BlockIndex! index,
int requestedExtensionLength,
out int actualExtensionLength);
/// Truncates chain past specified new tail
/// cluster.
internal abstract void TruncateChain(BlockIndex! index,
int lengthInClusters);
/// Populates BlockIndex with clusters from chain.
///
internal abstract void PopulateIndex(BlockIndex! index,
int firstCluster);
/// Property for clean shutdown bit held in FAT.
/// This property has no physical meaning on FAT12.
///
internal abstract bool CleanShutdown { get; set; }
/// Property for hard error bit held in FAT.
/// This property has no physical meaning on FAT12.
///
internal abstract bool HardError { get; set; }
/// Value representing total number of clusters.
internal abstract int TotalClusters { get; }
/// Value representing end of cluster chain.
internal abstract int EndOfChain { get; }
/// Value representing of bad cluster.
internal abstract int BadCluster { get; }
}
}