Git Product home page Git Product logo

libnfs-go's Introduction

Go Reference

NFS Server Library

Experimental NFSv4 server library in pure go.

The motive I started this project is mainly I need to immigrate a few projects to k8s and there are no other storage services except an OSS(like aws s3). So I need something to join OSS and k8s PV together. To me NFS is a interesting choice.

Currently this repo doesn't include any COS wrapper in it.

Getting start

To give it a try:

package main

import (
	"fmt"
	"os"

	"github.com/smallfz/libnfs-go/backend"
	"github.com/smallfz/libnfs-go/memfs"
	"github.com/smallfz/libnfs-go/server"
)

func main() {
	mfs := memfs.NewMemFS()
	backend := backend.New(mfs)

	mfs.MkdirAll("/test", os.FileMode(0755))
	mfs.MkdirAll("/test2", os.FileMode(0755))
	mfs.MkdirAll("/many", os.FileMode(0755))

	perm := os.FileMode(0755)
	for i := 0; i < 256; i++ {
		mfs.MkdirAll(fmt.Sprintf("/many/sub-%d", i+1), perm)
	}

	// TODO: replace the in-memory backend with your own implementation.
	// ....

	svr, err := server.NewServerTCP(":2049", backend)
	if err != nil {
		fmt.Printf("server.NewServerTCP: %v"\n, err)
		return
	}

	if err := svr.Serve(); err != nil {
		fmt.Printf("svr.Serve: %v\n", err)
	}
}

After the server started you can mount the in-memory filesystem to local:

on Mac:

mount -o nfsvers=4,noacl,tcp -t nfs localhost:/ /Users/smallfz/mnt

on Linux:

mount -o nfsvers=4,minorversion=0,noacl,tcp -t nfs localhost:/ /mnt

Status

Recent testing results of nfstest_posix with --nfsversion=4:

  • access: 58/58 pass
  • open: 19/22 pass
  • chdir: 3/3 pass
  • readdir: 3/3 pass
  • opendir: 2/2 pass
  • seekdir,rewinddir: 9/9 pass
  • telldir: 5/5 pass
  • read: 3/3 pass
  • write: 7/7 pass
  • close: 3/3 pass
  • stat: 22/23 pass
  • fstat: 22/23 pass
  • chmod: 2/16 pass
  • creat: 6/6 pass
  • unlink: 2/4 pass
  • mkdir: 5/7 pass
  • rmdir: 3/5 pass
  • link: x
  • fcntl: x
  • ...

Contributing

Firing an issue if anything. Any advice is appreciated.

libnfs-go's People

Contributors

smallfz avatar peterverraedt avatar mdouchement avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.