You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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:
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?The text was updated successfully, but these errors were encountered: