singrdk/base/Services/Fat/Control/Utilities.sg

113 lines
4.0 KiB
Plaintext
Raw Normal View History

2008-03-05 09:52:00 -05:00
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: Fat\Control\Utilities.sg
//
// Note:
//
using System;
using Microsoft.SingSharp;
using Microsoft.SingSharp.Reflection;
using Microsoft.Singularity.Applications;
using Microsoft.Singularity.Channels;
using Microsoft.Singularity.Configuration;
using Microsoft.Singularity.Directory;
using Microsoft.Singularity.Io;
using Microsoft.Singularity.Services.Fat.Contracts;
namespace Microsoft.Singularity.Services.Fat.FatControl
{
internal class Utilities
{
internal static FatControlContract.Imp ConnectToManager()
{
2008-11-17 18:29:00 -05:00
DirectoryServiceContract.Imp! rootds = DirectoryService.NewClientEndpoint();
2008-03-05 09:52:00 -05:00
try {
2008-11-17 18:29:00 -05:00
FatControlContract.Imp! service_imp;
FatControlContract.Exp! service_exp;
FatControlContract.NewChannel(out service_imp, out service_exp);
ErrorCode error;
if (!SdsUtils.Bind(FatControlContract.ManagerControlPath, rootds, service_exp, out error)) {
Console.WriteLine("Failed to connect to service path '{0}'. Error: {1}",
FatControlContract.ManagerControlPath,
SdsUtils.ErrorCodeToString(error));
delete service_imp;
return null;
2008-03-05 09:52:00 -05:00
}
2008-11-17 18:29:00 -05:00
service_imp.RecvSuccess();
return service_imp;
2008-03-05 09:52:00 -05:00
}
2008-11-17 18:29:00 -05:00
finally {
delete rootds;
2008-03-05 09:52:00 -05:00
}
}
internal static void DisplayError(FatContractErrorCode e)
{
string message = "unknown";
switch (e) {
case FatContractErrorCode.NoError:
message = "no error";
break;
case FatContractErrorCode.DiskUnavailable:
message = "disk unavailable";
break;
case FatContractErrorCode.PathUnavailable:
message = "path unavailable";
break;
case FatContractErrorCode.Busy:
message = "filesystem busy";
break;
case FatContractErrorCode.NotMounted:
message = "path not mounted";
break;
case FatContractErrorCode.InternalError:
message = "internal error";
break;
case FatContractErrorCode.NotFatPartition:
message = "not a FAT partition";
break;
case FatContractErrorCode.ReadFailed:
message = "read error";
break;
case FatContractErrorCode.BadBPB:
message = "bad boot parameter block";
break;
case FatContractErrorCode.ReadOnlyDisk:
message = "read only disk";
break;
case FatContractErrorCode.InvalidStartSector:
message = "invalid start sector";
break;
2008-11-17 18:29:00 -05:00
case FatContractErrorCode.InvalidSectorCount:
message = "invalid sector count";
break;
2008-03-05 09:52:00 -05:00
case FatContractErrorCode.InvalidFormatSettings:
message = "invalid format settings";
break;
case FatContractErrorCode.InvalidVolumeLabel:
message = "invalid volume label";
break;
}
Console.WriteLine("Failed: {0}.", message);
}
internal static void DisplayChannelClosedError()
{
Console.WriteLine(
"Failed: Channel to FAT client manager closed unexpectedly."
);
}
}
}