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

Storage OpenBSD/adJ #2809

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Storage OpenBSD/adJ #2809

wants to merge 7 commits into from

Conversation

vtamara
Copy link

@vtamara vtamara commented Mar 5, 2024

Why this should be merged

Adds support for OpenBSD/adJ as required by #2782

How this works

Using build constraints and the right field names for syscall.Statfs_t in OpenBSD as described at golang/go#47958

How this was tested

With the following storage_openbsd_test.go:

package storage

import (
    //"fmt"
    "os/exec"
    "strconv"
    "strings"
    "testing"
)


func TestAvalableBytes(t *testing.T) {
	avail1, err := AvailableBytes("/home");
	if avail1 <= 0 || err != nil {
		t.Fatalf(`avail1 = %d, err = %v`, avail1, err.Error())
	}

	stdout, err := exec.Command("/bin/df", "/home").Output()
	// In OpenBSD the df program returns something like:
	// df /home
	// Filesystem  512-blocks      Used     Avail Capacity  Mounted on
	// /dev/sd0g     75663352  64674648   7205540    90%    /home  
	if err != nil {
		t.Fatalf(`err = %v`, err.Error())
	}
	//fmt.Printf("output %s\n", stdout)
	f := strings.Fields(string(stdout));
	bavail2, err := strconv.ParseUint(f[10], 10, 64)
	if err != nil {
		t.Fatalf(`err = %v`, err.Error())
	}
	avail2 := bavail2 * 512;

	if avail1 != avail2 {
		t.Fatalf(`avail1 = %d, avail2 = %d`, avail1, avail2)
	}

}

Sorry, I had to replicate #2803 (my initial fork didn't copy all the branches and tags and later I discovered I needed all of them).

@vtamara
Copy link
Author

vtamara commented Apr 21, 2024

Blessings, since the effort of porting to OpenBSD has brought improvements in security I wanted you to notice that I applied for funding in the "Avalanche Community Grants Quadratic Funding Round One" to do a deeper audit of the sources of the fundamental tools of Avalanche, complete the porting and test more fully. Could you please vote for the project at: https://explorer.gitcoin.co/#/round/43114/4/28 ?

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

Successfully merging this pull request may close these issues.

None yet

1 participant