Git Product home page Git Product logo

vfs's People

Contributors

adammck avatar blang avatar dsharp-pivotal avatar eugene-dounar avatar gernest avatar gitter-badger avatar lalinsky avatar lotrfan avatar wuman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vfs's Issues

S3 implementation

Hello @blang

Maybe you know by any chance the s3 implementation of your Filesystem interface? If not would be interested in having one even if you claim "Only Stdlib" (this will bring aws sdk as a dependency)?

Thank you in advance.

memfs seems not work correctly?

Hi there,

I am interested to use this in my minimum docker image, basically the idea is that mount /tmp as tmpfs for the program to use. As it is minimum, there is no mount command, etc, just the app binary it self.

However from my test it seems not to use memory fs, that is after the docker container stop, I can see the file content is on the filesystem. So not sure if there is a problem with it, or the way I expect it to work is totally wrong.

Here is my snippet

package main

import (
	"fmt"
	"io/fs"
	"io/ioutil"

	"github.com/blang/vfs"
	"github.com/blang/vfs/memfs"
    u "github.com/sunshine69/golang-tools/utils"
)

func main() {
	fmt.Println("started")
	var osfs vfs.Filesystem = vfs.OS()
	err := osfs.Mkdir("/adir", 0777)
    u.CheckErr(err, "Error")
	mfs := memfs.Create()
	err = mfs.Mkdir("/tmp", 0777)
    u.CheckErr(err, "Error")
    ioutil.WriteFile("/tmp/test", []byte("hello my file"), fs.ModeAppend)
    //Seems not work, after run I can inspect the container and the file does exist. If it is in memory it should not exist
}

Dockerfile

FROM stevekieu/golang-script:20210804 AS BUILD_BASE
RUN mkdir /app && mkdir /imagetmp && chmod 1777 /imagetmp

ADD . /app/
WORKDIR /app
ENV CGO_ENABLED=0 PATH=/usr/local/go/bin:/opt/go/bin:/usr/bin:/usr/sbin:/bin:/sbin

ARG APP_VERSION
RUN go mod download golang.org/x/net
RUN go build -trimpath -ldflags="-X main.version=v1.0 -extldflags=-static -w -s" --tags "osusergo,netgo,sqlite_stat4,sqlite_foreign_keys,sqlite_json" -o minimum-docker
CMD ["/app/minimum-docker"]

FROM scratch
# the ca files is from my current ubuntu 20 /etc/ssl/certs/ca-certificates.crt - it should provide all current root certs
ADD ca-certificates.crt /etc/ssl/certs/
COPY --from=BUILD_BASE /app/minimum-docker /minimum-docker
COPY --from=BUILD_BASE /imagetmp /tmp
ENV TZ=Australia/Brisbane
ENTRYPOINT [ "/minimum-docker" ]

Build the image, and run. After run use docker inspect the container name to find the UpperDir location, and get in there, the /tmp exists a file with the content. If it is memfs, then it should not exists any file at all.

Thanks

Filesystem.OpenFile returns vfs.File, not *vfs.File

I was wondering why OpenFile doesn't return a pointer to a File, like its standard library counterpart. I would say that mirroring the standard library as closely as possible makes it a lot less painful to migrate to using vfs as a wrapper.

`Chtimes` support

Right now there is no way to change the mtime of a mem file. os.Chtimes(path, atime, mtime) i think would make a good addition as there is no other way of achieving this functionality.

Can this be used with embed ?

To embed a file system in a go app and then use this to write / read to said file system.

Embed creates a readonly file system so weren't sure if it would be possible

Exec?

This is probably very silly, but I'd like to be able to run one of the files in the virtual filesystem. Is this something that's supported, or is this a terrible idea that I should immediately forget about?

Portability?

Does this run on Windows? Or only on Linux and Mac?

`Readlink` support

To complement Lstat(path) it would be nice if Readlink(path) was added to the interface

Access to a FS from a shell

I'm not sure if it is possible but I would like to see an example where we can create any kind of FS but it should be visible on underlying OS under some mount point. For instance, here is a code I came up with:

package main

import (
	"log"
	"os"
	"time"

	"github.com/blang/vfs"
	"github.com/blang/vfs/memfs"
	"github.com/blang/vfs/mountfs"
)

func main() {
	// Create a vfs accessing the filesystem of the underlying OS
	osfs := vfs.OS()

	// Create a fully writable filesystem in memory
	mfs := memfs.Create()

	// Create a vfs supporting mounts
	fs := mountfs.Create(osfs)

	// Mount a memfs inside /memfs
	fs.Mount(mfs, "/memfs")

	f, err := mfs.OpenFile("file.efs", os.O_CREATE|os.O_WRONLY, 0)
	defer f.Close()

	if err == nil {
		log.Println("created /memfs/file.efs")
		_, err := f.Write([]byte("Some content"))
		if err != nil {
			log.Println("unable to write content to file.efs", err)
		}
	} else {
		log.Println("failed to create /memfs/file.efs", err)
	}
	for {
		time.Sleep(10 * time.Second)
	}

}

So, if I compile and run it it serves as a daemon, but I would like to see my /memfs from underlying OS shell. Is it possible?

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.