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

Document how to read squashfs files #32

Closed
probonopd opened this issue Nov 2, 2019 · 3 comments · Fixed by #34
Closed

Document how to read squashfs files #32

probonopd opened this issue Nov 2, 2019 · 3 comments · Fixed by #34

Comments

@probonopd
Copy link

probonopd commented Nov 2, 2019

Hi, thanks for this very useful library. Could you please document how to read squashfs files and print the files, directories, and symlinks contained therein; e.g., is the following halfway right?

package main

import (
	"log"
	"os"

	"github.com/diskfs/go-diskfs/filesystem/squashfs" // Have to use: GO111MODULE=on /usr/local/go/bin/go get github.com/diskfs/go-diskfs@squashfs
)

func main() {
	f, err := os.Open("/home/me/go/src/github.com/diskfs/go-diskfs/filesystem/squashfs/testdata/file.sqs")
	if err != nil {
		log.Println(err)
	}
	defer f.Close()
	fs, err := squashfs.Read(f, 0, 0, 4096)
	if err != nil {
		log.Println(err)
	}
	files, err := fs.ReadDir("/") // How to list all contents including subdirectories?
	for f := range files {
		print(f)
	}
}
@deitch
Copy link
Collaborator

deitch commented Nov 6, 2019

Reading any filesystem is identical. One of the key points of the lib is to abstract it all. So it almost is it, but not quite.

package main

import (
	"log"
	"os"

	diskfs "github.com/diskfs/go-diskfs" 
)

func main() {
	disk, err := diskfs.Open("/home/me/go/src/github.com/diskfs/go-diskfs/filesystem/squashfs/testdata/file.sqs")
	if err != nil {
		log.Panic(err)
	}
	fs, err := disk.GetFilesystem(0) // assuming it is the whole disk, so partition = 0
	if err != nil {
		log.Panic(err)
	}
	files, err := fs.ReadDir("/") // this should list everything
}

We probably should document this, so keep it open.

@deitch deitch mentioned this issue Nov 6, 2019
@deitch deitch closed this as completed in #34 Nov 6, 2019
@probonopd
Copy link
Author

probonopd commented Nov 6, 2019

Thanks for the example @deitch however it does not compile for me:

me@host:~$ /usr/local/go/bin/go build test.go 
# github.com/diskfs/go-diskfs/partition/gpt
go/src/github.com/diskfs/go-diskfs/partition/gpt/partiton.go:218:8: assignment mismatch: 1 variable but uuid.NewV4 returns 2 values
go/src/github.com/diskfs/go-diskfs/partition/gpt/table.go:82:22: multiple-value uuid.NewV4() in single-value context
go/src/github.com/diskfs/go-diskfs/partition/gpt/table.go:283:8: assignment mismatch: 1 variable but uuid.NewV4 returns 2 values

@deitch
Copy link
Collaborator

deitch commented Nov 6, 2019

Yeah it’s just sample code. Not really runnable.

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

Successfully merging a pull request may close this issue.

2 participants