Exemplo n.º 1
0
            static Result Mount(FileSystemClient fs, U8Span mountName, ContentStorageId storageId)
            {
                // It can take some time for the system partition to be ready (if it's on the SD card).
                // Thus, we will retry up to 10 times, waiting one second each time.
                const int maxRetries    = 10;
                const int retryInterval = 1000;

                Result rc = fs.Impl.CheckMountNameAcceptingReservedMountName(mountName);

                if (rc.IsFailure())
                {
                    return(rc);
                }

                using ReferenceCountedDisposable <IFileSystemProxy> fsProxy = fs.Impl.GetFileSystemProxyServiceObject();

                ReferenceCountedDisposable <IFileSystemSf> fileSystem = null;

                try
                {
                    for (int i = 0; i < maxRetries; i++)
                    {
                        rc = fsProxy.Target.OpenContentStorageFileSystem(out fileSystem, storageId);

                        if (rc.IsSuccess())
                        {
                            break;
                        }

                        if (!ResultFs.SystemPartitionNotReady.Includes(rc))
                        {
                            return(rc);
                        }

                        if (i == maxRetries - 1)
                        {
                            return(rc);
                        }

                        fs.Hos.Os.SleepThread(TimeSpan.FromMilliSeconds(retryInterval));
                    }

                    var fileSystemAdapter  = new FileSystemServiceObjectAdapter(fileSystem);
                    var mountNameGenerator = new ContentStorageCommonMountNameGenerator(storageId);
                    return(fs.Register(mountName, fileSystemAdapter, mountNameGenerator));
                }
                finally
                {
                    fileSystem?.Dispose();
                }
            }
Exemplo n.º 2
0
        public static Result MountContentStorage(this FileSystemClient fs, U8Span mountName, ContentStorageId storageId)
        {
            Result rc = MountHelpers.CheckMountNameAcceptingReservedMountName(mountName);

            if (rc.IsFailure())
            {
                return(rc);
            }

            IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();

            rc = fsProxy.OpenContentStorageFileSystem(out IFileSystem contentFs, storageId);
            if (rc.IsFailure())
            {
                return(rc);
            }

            var mountNameGenerator = new ContentStorageCommonMountNameGenerator(storageId);

            return(fs.Register(mountName, contentFs, mountNameGenerator));
        }