Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum sample FS in C# #536

Open
SuperJMN opened this issue Jan 17, 2024 · 1 comment
Open

Minimum sample FS in C# #536

SuperJMN opened this issue Jan 17, 2024 · 1 comment

Comments

@SuperJMN
Copy link

SuperJMN commented Jan 17, 2024

Hello!

I'm a .NET user wanting to create a new filesystem implementation. I've installed the latest vertsion of WinFsp in my Windows 11 and and I've created a sample C# project. Everything seems ready to go. It's a console project where I installed the nuget package (winfsp.net" version 2.0.23075) .

As I said, I'd like to create an implementation for SeaweedFS, but I'm a bit lost with the data required by WinFsp.
It would really be of help if .NET developers like me had a minimum filesystem that only return a fixed list of hardcode files.

My current implementation is this:

public class SeaweedFS : FileSystemBase
{
    public override int GetSecurityByName(string FileName, [UnscopedRef] out uint FileAttributes, ref byte[] SecurityDescriptor)
    {
        FileAttributes = (UInt32)System.IO.FileAttributes.Normal;
        return STATUS_SUCCESS;
    }

    public override int Open(string FileName, uint CreateOptions, uint GrantedAccess, [UnscopedRef] out object FileNode, [UnscopedRef] out object FileDesc, [UnscopedRef] out FileInfo FileInfo, [UnscopedRef] out string NormalizedName)
    {
        FileInfo = new FileInfo()
        {
            FileSize = 12,
            CreationTime = 4,
            FileAttributes = 2,
        };

        NormalizedName = FileName;
        FileNode = new MyNode();
        FileDesc = default(object);

        return STATUS_SUCCESS;
    }

    public override void Close(object FileNode, object FileDesc)
    {
        base.Close(FileNode, FileDesc);
    }

    public override int ReadDirectory(object FileNode, object FileDesc, string Pattern, string Marker, IntPtr Buffer, uint Length, [UnscopedRef] out uint BytesTransferred)
    {
        BytesTransferred = 0;
        return STATUS_SUCCESS;
    }
}

Of course, it doesn't work.
So, what do I need to make it work? I'd be happy in the Windows Explorer showed a bunch of fake files / dirs.

Thanks a lot and congratulations for your WONDERFUL work.

@SuperJMN SuperJMN changed the title Request for the a minimum sample in C# Request for minimum sample in C# Jan 19, 2024
@SuperJMN SuperJMN changed the title Request for minimum sample in C# Minimum sample FS in C# Jan 19, 2024
@billziss-gh
Copy link
Collaborator

There are multiple sample .NET file systems here. Easiest to start with may be passthrough-dotnet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants