mirror of
https://github.com/hanzoai/s3.git
synced 2026-11-03 03:07:41 +00:00
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.
- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
"Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
(replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
keep their upstream import paths with zero churn. Internal identifiers and
import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
help/usage/flag strings, shell autocomplete program name, and the product name
in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
(e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
`cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
updated to ignore the `s3` build output.
89 lines
2.3 KiB
Go
89 lines
2.3 KiB
Go
package mount
|
|
|
|
import (
|
|
"context"
|
|
"syscall"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
|
|
"github.com/seaweedfs/go-fuse/v2/fuse"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/filer"
|
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
|
)
|
|
|
|
// These are non-POSIX extensions
|
|
const (
|
|
SEEK_DATA uint32 = 3 // seek to next data after the offset
|
|
SEEK_HOLE uint32 = 4 // seek to next hole after the offset
|
|
ENXIO = fuse.Status(syscall.ENXIO)
|
|
)
|
|
|
|
// Lseek finds next data or hole segments after the specified offset
|
|
// See https://man7.org/linux/man-pages/man2/lseek.2.html
|
|
func (wfs *WFS) Lseek(cancel <-chan struct{}, in *fuse.LseekIn, out *fuse.LseekOut) fuse.Status {
|
|
// not a documented feature
|
|
if in.Padding != 0 {
|
|
return fuse.EINVAL
|
|
}
|
|
|
|
if in.Whence != SEEK_DATA && in.Whence != SEEK_HOLE {
|
|
return fuse.EINVAL
|
|
}
|
|
|
|
// file must exist
|
|
fh := wfs.GetHandle(FileHandleId(in.Fh))
|
|
if fh == nil {
|
|
return fuse.EBADF
|
|
}
|
|
|
|
// lock the file until the proper offset was calculated
|
|
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("Lseek", fh.fh, util.SharedLock)
|
|
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock)
|
|
|
|
fileSize := int64(filer.FileSize(fh.GetEntry().GetEntry()))
|
|
offset := max(int64(in.Offset), 0)
|
|
|
|
glog.V(4).Infof(
|
|
"Lseek %s fh %d in [%d,%d], whence %d",
|
|
fh.FullPath(), fh.fh, offset, fileSize, in.Whence,
|
|
)
|
|
|
|
// can neither seek beyond file nor seek to a hole at the end of the file with SEEK_DATA
|
|
if offset > fileSize {
|
|
return ENXIO
|
|
} else if in.Whence == SEEK_DATA && offset == fileSize {
|
|
return ENXIO
|
|
}
|
|
|
|
// Create a context that will be cancelled when the cancel channel receives a signal
|
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
|
defer cancelFunc() // Ensure cleanup
|
|
|
|
go func() {
|
|
select {
|
|
case <-cancel:
|
|
cancelFunc()
|
|
case <-ctx.Done():
|
|
// Clean exit when lseek operation completes
|
|
}
|
|
}()
|
|
|
|
// search chunks for the offset
|
|
found, offset := fh.entryChunkGroup.SearchChunks(ctx, offset, fileSize, in.Whence)
|
|
if found {
|
|
out.Offset = uint64(offset)
|
|
return fuse.OK
|
|
}
|
|
|
|
// in case we found no exact matches, we return the recommended fallbacks, that is:
|
|
// original offset for SEEK_DATA or end of file for an implicit hole
|
|
if in.Whence == SEEK_DATA {
|
|
out.Offset = in.Offset
|
|
} else {
|
|
out.Offset = uint64(fileSize)
|
|
}
|
|
|
|
return fuse.OK
|
|
}
|