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

Statfs.BlockSize() is returning an incorrect value #72

Open
ncw opened this issue Feb 2, 2023 · 0 comments
Open

Statfs.BlockSize() is returning an incorrect value #72

ncw opened this issue Feb 2, 2023 · 0 comments

Comments

@ncw
Copy link

ncw commented Feb 2, 2023

An rclone user reported that the free/used/total sizes were half what they should be in the smb backend: rclone/rclone#6733

I have verified this against this docker image https://hub.docker.com/r/dperson/samba and also that if you mount that disk from Windows it gets the free/used/total sizes correct.

Putting in a bit of debugging I see the Statfs block is returned as

stat{
    TotalAllocationUnits: 959122528,
    CallerAvailableAllocationUnits: 407504932,
    ActualAvailableAllocationUnits: 407504932,
    SectorsPerAllocationUnit: 2,
    BytesPerSector: 512,
}

Wheras the BlockSize is calculated like this

go-smb2/client.go

Lines 1438 to 1440 in c8e61c7

func (fi *fileFsFullSizeInformation) BlockSize() uint64 {
return uint64(fi.BytesPerSector)
}

I suspect it should be calculated like this instead - this would make the sizes come out correctly.

func (fi *fileFsFullSizeInformation) BlockSize() uint64 {
	return uint64(fi.BytesPerSector) * uint64(fi.SectorsPerAllocationUnit)
}

However I have no knowledge of the SMB protocol so that might be completely wrong.

If you think that is good then I can make a PR with that in.

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

No branches or pull requests

1 participant