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 #2803

Closed
wants to merge 3 commits into from
Closed

Storage OpenBSD/adJ #2803

wants to merge 3 commits into from

Conversation

vtamara
Copy link
Contributor

@vtamara vtamara commented Mar 3, 2024

Why this should be merged

Starts to add 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)
	}

}

@vtamara vtamara closed this by deleting the head repository Mar 5, 2024
@vtamara vtamara mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant