Пример #1
0
        public override int Flush(object fileNode, object fileDesc, out FileInfo fileInfo)
        {
            Logger.LogTrace($"{nameof ( Flush )} {( fileDesc as FileMetadata ) ? . Name}");

            if (fileNode is FileNode node)
            {
                OnetimeTask flushTask = new OnetimeTask(node.Flush, default);
                TaskDispatcher.Dispatch(flushTask);
            }

            FlushMetadata( );

            if (fileDesc is FileMetadata metadata)
            {
                fileInfo = metadata.FileInfo;
            }
            else
            {
                throw GetIoExceptionWithNtStatus(STATUS_INVALID_HANDLE);
            }

            return(STATUS_SUCCESS);
        }
Пример #2
0
        public override int Init(object host)
        {
            Logger.LogTrace($"{nameof ( Init )}");

            Current = this;

            UpdateQuota( );

            FileMetadata rootDirectoryMetadata;

            lock ( DataContext )
            {
                rootDirectoryMetadata =
                    DataContext.FileMetadata.SingleOrDefault(
                        metadata
                        => metadata.Name == "\\");
            }

            if (rootDirectoryMetadata == null)
            {
                rootDirectoryMetadata = CreateDirectory(
                    "\\",
                    securityDescriptor : DefaultSecurity.
                    RootSecurity);
            }

            if (host is FileSystemHost fileSystemHost)
            {
                fileSystemHost.SectorSize = 4096;
                fileSystemHost.SectorsPerAllocationUnit    = 1;
                fileSystemHost.MaxComponentLength          = 255;
                fileSystemHost.FileInfoTimeout             = 100000;
                fileSystemHost.CaseSensitiveSearch         = true;
                fileSystemHost.CasePreservedNames          = true;
                fileSystemHost.UnicodeOnDisk               = true;
                fileSystemHost.PersistentAcls              = true;
                fileSystemHost.PostCleanupWhenModifiedOnly = true;
                fileSystemHost.PassQueryDirectoryPattern   = true;
                fileSystemHost.FlushAndPurgeOnCleanup      = true;
                fileSystemHost.VolumeCreationTime          =
                    rootDirectoryMetadata.CreationTime;
                fileSystemHost.VolumeSerialNumber = 0;
                fileSystemHost.FileSystemName     = nameof(CloudFileSystem);
            }

            Logger.LogInformation($"Filesystem Initialized.");

            IntervalTask updateQuotaTask = new IntervalTask(
                UpdateQuota,
                TimeSpan.FromMinutes(2),
                priority: TaskPriority.
                Background);

            IntervalTask flushMetadataTask = new IntervalTask(
                FlushMetadata,
                TimeSpan.FromSeconds(20),
                priority: TaskPriority.Low);

            TaskDispatcher.Dispatch(updateQuotaTask);
            TaskDispatcher.Dispatch(flushMetadataTask);

            return(STATUS_SUCCESS);
        }