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

9P/CLI API refactoring #28

Merged
merged 194 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
a52ed73
files: export FSIDDir's `mountFunc` type
djdv Nov 16, 2022
be1d397
files: add old IPFS API and extract logic
djdv Nov 26, 2022
6a7a865
files: adapt to IPFS pkg move
djdv Dec 22, 2022
57edbe8
files: adapt to FUSE API changes
djdv Dec 22, 2022
7e9208b
files: move+rename pkg to `filesystem/9p`
djdv Dec 24, 2022
ca16fb4
9p: lint - methods were removed but type was not
djdv Dec 28, 2022
a475a0d
9p: minor - move some declarations
djdv Dec 28, 2022
86ce404
9p: unexport File type -> file; alias was unused
djdv Dec 28, 2022
4c16932
9p: metadata - simplify + inline timestamp logic
djdv Dec 28, 2022
af35985
9p: directory - revert link when Rename errors
djdv Dec 30, 2022
514fc8c
9p: directory - update links when renamed
djdv Dec 30, 2022
1766856
net: remove package
djdv Mar 29, 2023
c870038
net/9p: add package
djdv Mar 29, 2023
2b2990d
api: 9p - major refactor
djdv Mar 29, 2023
d3b422e
net/9p: lint - struct alignment
djdv Apr 11, 2023
e73782f
net/9p: various additions + fixes
djdv May 11, 2023
517064e
9p: remove suggested file name for "mounts" dir
djdv Apr 3, 2023
49055f7
9p: lint - pack `chanEmitter` struct (32 -> 24)
djdv Apr 4, 2023
91a32b1
9p: add `openFlags` type; extends `p9.OpenFlags`
djdv Apr 4, 2023
8e73a27
9p: mountpoint - use embedded `openFlags` type
djdv Apr 4, 2023
e33ba92
9p: chan - use embedded `openFlags` type
djdv Apr 12, 2023
46893b9
9p: rework constructor helper implementations
djdv Apr 9, 2023
ca8c5d9
9p: link - extract and use constructor
djdv Apr 9, 2023
fe3ee4d
9p: stat - move metadata options to relevant file
djdv Apr 9, 2023
f9f8cdd
9p: directory - update constructor (needs review)
djdv Apr 9, 2023
f7eec37
9p: directory - don't re-use global for empty mask
djdv Apr 9, 2023
6d500e3
9p: link - extract link options
djdv Apr 9, 2023
4066534
9p: mount - update constructor
djdv Apr 9, 2023
741754b
9p: guest - update constructor
djdv Apr 9, 2023
2f80ad4
9p: host - update constructor
djdv Apr 9, 2023
c762d1d
9p: listener - new ctor + revisions (needs review + splitting)
djdv Apr 9, 2023
66ad33e
9p: MkdirAll - fix unclosed intermediate file
djdv Apr 12, 2023
a386e83
9p: chan - update constructor
djdv Apr 12, 2023
b9f042c
9p: mountpoint - update constructor
djdv Apr 12, 2023
7c5a0f9
9p: listener - adapt to type changes
djdv Apr 12, 2023
0a10dd3
9p: options - update type unions
djdv Apr 12, 2023
ddeb850
9p: ReadDir - fix potential `nil` dereference
djdv Apr 12, 2023
b983eed
9p: tmp directory - call `Walk` before `UnlinkAt`
djdv Apr 12, 2023
637eb09
9p: directory - fix unclosed references in `Walk`
djdv Apr 12, 2023
0628e3b
9p: directory - fix handling of walks with `..`
djdv Apr 12, 2023
9441d41
9p: listener - fix invalid protocol for `UnlinkAt`
djdv Apr 12, 2023
61339eb
9p: listener - accept a channel buffer size option
djdv Apr 12, 2023
b04de52
9p: listener - update tests
djdv Apr 12, 2023
7333284
9p: lint - unused parameters
djdv May 6, 2023
f7ceb9f
9p: lint - unused system (will return later)
djdv May 11, 2023
c53f26c
9p: add some utility helper functions
djdv May 11, 2023
4eb54af
9p: refactor `ReadDir`
djdv May 11, 2023
25ff185
9p: directory - refactor
djdv May 11, 2023
1f37a7e
9p: listener - restructure API
djdv May 11, 2023
416a6f7
9p: mount - change unmount API + refactor
djdv May 15, 2023
aa86e0b
9p: mountpoint - change file format
djdv May 15, 2023
8713c1d
9p: lint - struct alignment
djdv May 15, 2023
e94becc
9p: directory - remove `Attach` method
djdv May 18, 2023
c37747e
9p: remove `AttacherFile` interface
djdv May 18, 2023
bc5fb4e
command: bulk changes / needs splitting
djdv Apr 1, 2023
44a014a
command: reduce stack frames used for subcommands
djdv Mar 9, 2023
d691a6c
command: linting
djdv Mar 9, 2023
dc8e685
command: go 1.19 fix
djdv Mar 17, 2023
1f867aa
command: less yelling, we're not CP/M.
djdv Mar 19, 2023
87f5a07
command: change help text format
djdv Mar 19, 2023
4bed6cd
command: refactor generic logic + change format
djdv Mar 19, 2023
e5616a0
command: update test for new help text format
djdv Mar 19, 2023
96b7685
command: add "Must" version of `MakeCommand`
djdv Mar 19, 2023
3a9deb2
commands: daemon - major refactor
djdv Jan 30, 2023
273fe71
commands: daemon - separate lazy-settings initializer
djdv Jan 29, 2023
ea22891
commands: daemon - reduce constructor boilerplate
djdv Feb 5, 2023
507cf3f
commands: mount - adapt to API changes / internalize hosts
djdv Feb 5, 2023
4a7e0f6
commands: bulk changes / needs splitting
djdv Mar 29, 2023
9d41c26
commands: fix/change daemon launcher condition
djdv Feb 8, 2023
5ba0125
commands: document some flag types
djdv Mar 8, 2023
7599d85
commands: deduplicate default-value text-setter
djdv Feb 8, 2023
0c49304
commands: mount - adapt to API changes / internalize sysIDs
djdv Feb 14, 2023
835839e
commands: bulk changes / needs splitting
djdv Mar 29, 2023
aea7448
commands: fix subprocess stderr handling
djdv Mar 6, 2023
f3907ff
commands: proc - linting
djdv Mar 6, 2023
a6439e9
commands: bulk changes / needs splitting
djdv Mar 31, 2023
74eda84
commands: daemon - needs commit message / review
djdv Mar 31, 2023
13e665b
commands: needs commit message / review
djdv Mar 31, 2023
752ef55
commands: fix *nix builds
djdv Mar 17, 2023
01c7f6e
commands: adapt to `command` API changes
djdv Mar 19, 2023
1db9b31
commands: mount - bulk changes / needs splitting
djdv Mar 29, 2023
f1c9339
commands: mount - unused leftover
djdv Mar 29, 2023
01d04ee
commands: daemon - prefix fields for `ParseField`
djdv Mar 29, 2023
3ba27c7
commands: daemon - unlink host dir when it's empty
djdv Mar 29, 2023
9c04e6c
commands: daemon - pass down `unlink*` setting
djdv Mar 29, 2023
5e855aa
commands: daemon+(un)mount - internalize+share file names
djdv Apr 3, 2023
c03ab65
commands: daemon - adapt to constructor changes
djdv Apr 12, 2023
6b3ec51
commands: minor variable name change
djdv May 9, 2023
77f1e80
commands: fix POSIX symbolic_mode parser
djdv May 11, 2023
fc9d5f9
commands: daemon - perm flag parser changed arity
djdv May 15, 2023
6db3b9b
commands: daemon - use global const for cmd name
djdv May 15, 2023
251f0c8
commands: proc - use external `GetListeners` impl
djdv May 15, 2023
3d9a15b
commands: client - lint/cleanup
djdv May 15, 2023
70b4af7
commands: unmount - adapt to p9 API changes
djdv May 15, 2023
cd2b406
commands: mount - split up IPFS type+flag ctors
djdv May 15, 2023
a145871
commands: daemon - allow strings to `shutdown` file
djdv May 15, 2023
487a6b1
commands: daemon - use external `AttacherFile` intf
djdv May 15, 2023
692cf04
commands: daemon - impl `MountPoint` requirements
djdv May 15, 2023
cbaa877
commands: daemon - refactor main pipeline
djdv May 15, 2023
a5d5d18
commands: clearer error message when `-ipfs` fails to get default value
djdv May 18, 2023
a4c490a
commands: implement root attacher with error accumulator
djdv May 18, 2023
afcdeb4
commands: shared - add `unwind` utility function
djdv May 18, 2023
526819a
commands: daemon - use new root `Attacher` with server
djdv May 18, 2023
ce7040a
commands: mount - utilize new client utilities
djdv May 18, 2023
1e26a5c
fs: lint - redundant constants
djdv May 15, 2023
9d04f02
fs: adapt to `command` API changes
djdv Mar 19, 2023
7c7067f
deps: update cgofuse
djdv Jan 30, 2023
75d13b6
go: update minimum version to 1.20
djdv Mar 23, 2023
3933073
9p: lint - move const out of doc.go
djdv May 20, 2023
892183f
commands: mount - prefix guest CLI flag names with guest's name
djdv May 20, 2023
adfb363
commands: flag - backport `BoolFunc` from Go 1.21
djdv May 21, 2023
9357e20
commands: unmount - separate cmd flags from API options
djdv May 20, 2023
2a0b28d
commands: flag - add symbolic permission generator
djdv May 21, 2023
5cec702
commands: flag - add 9P {u,g}id => string (for help text)
djdv May 21, 2023
dc7179a
commands: mount - separate cmd flags from API options
djdv May 21, 2023
6b6deff
commands: daemon - prefix CLI flags with "api-"
djdv May 21, 2023
3cee38c
commands: flag - prefix remaining shared flag names with "api-"
djdv May 21, 2023
d8b5e2d
commands: daemon - allow multiple `api-server` flags
djdv May 21, 2023
4ffb3cd
commands: daemon - allow csv values for `api-server` flag
djdv May 21, 2023
c7d5e09
commands: daemon - update helptext
djdv May 21, 2023
023c086
9p: mount - address type concern regarding file creation
djdv May 21, 2023
2faf737
commands: daemon - do type checking when making "mounts" files
djdv May 21, 2023
8a481bc
commands: unmount - utilize new client utilities
djdv May 21, 2023
95b7502
commands: shutdown - utilize new client utilities
djdv May 21, 2023
736cad1
commands: shared - global consts for consistent file names
djdv May 21, 2023
e1b93ae
commands: flag - move type definitions to more appropriate files
djdv May 21, 2023
a52ba6a
commands: daemon+client refactor IPC
djdv May 24, 2023
431a097
cgofuse: lint - use constant error values
djdv May 25, 2023
0d7e176
command: lint - use Go 1.20's `errors.Join`
djdv May 25, 2023
48f9535
9p: use Go 1.20's `errors.Join` + misc cleanup
djdv May 25, 2023
402d28c
net/9p: use Go 1.20's `errors.Join` + misc cleanup
djdv May 25, 2023
8bc9fff
filesystem: use Go 1.20's `errors.Join`
djdv May 25, 2023
be76ba7
cgofuse: use Go 1.20's `errors.Join`
djdv May 25, 2023
02d61ff
commands: use Go 1.20's `errors.Join`
djdv May 25, 2023
cce2143
fserrors: remove `errors.Join` shim
djdv May 25, 2023
70a0987
commands: all - remove `unwind` utility
djdv May 25, 2023
42c2b2b
commands: daemon - refactoring + missing check
djdv May 28, 2023
09ee74d
commands: daemon - gen perm symbols for flag text
djdv May 30, 2023
b9b249a
commands: daemon - retain permissions flag data
djdv May 30, 2023
b25c2c3
commands: mount - retain permissions flag data
djdv May 30, 2023
2a40b90
commands: client - addr flag's default on new line
djdv May 30, 2023
d95142e
commands: all - fill in + update help text
djdv May 30, 2023
6a11309
build: add godoc string
djdv May 30, 2023
8545477
commands: client - unexport `ErrServiceNotFound`
djdv May 30, 2023
7bc6ac6
commands: mount - unnecessary call to `FSync`
djdv May 30, 2023
61661cf
9p: move WinFSP workaround to `cgofuse` pkg
djdv May 30, 2023
c315594
cgofuse: fix inconsistent key name
djdv May 30, 2023
434938b
cgofuse: add mount point polling method
djdv May 31, 2023
8d174c8
deps: switch to hard fork of p9
djdv Jun 1, 2023
f096d23
9p: fix conflicting {File|Mutex} `Lock` method
djdv Jun 1, 2023
484f03e
commands: error attacher - add Lock wrapper
djdv Jun 1, 2023
52c3ce5
command: minor refine of `getSubcmmands`
djdv Jun 2, 2023
f694398
command: suppress help and error text from `flag`
djdv Jun 2, 2023
6b5a77b
build: construct subenv and add build mode flags
djdv Jun 4, 2023
5a831c0
9p: (TODO: review) fix - field parser was returning early
djdv Jun 6, 2023
2861de4
command: don't implement `flag.Value` for `-help`
djdv Jun 9, 2023
6f62eb1
command: doc - don't specify help flag's name
djdv Jun 9, 2023
6b2e158
command: lint - unused `FlagSettings` interface
djdv Jun 9, 2023
cf2d732
command: consolidate interfaces + change methods
djdv Jun 9, 2023
2e5dde9
command: rename `HelpArg` to `Help`
djdv Jun 9, 2023
7ccc3f4
command: add `SubcommandGroup` constructor
djdv Jun 11, 2023
addb323
command: breaking API changes
djdv Jun 12, 2023
a93274d
commands: adapt to `command` API changes
djdv Jun 12, 2023
ce81780
command: return a copy of subcommands, not direct access
djdv Jun 14, 2023
b97b5c0
command: don't require `io.StringWriter` outputs
djdv Jun 14, 2023
be67450
command: remove error return + consolidate options
djdv Jun 14, 2023
cd9019b
commands: flag - allow symbolic name "nobody"
djdv Jun 15, 2023
556dbbf
command: add text renderer + change usage errors
djdv Jun 16, 2023
88840be
generic: enum - include valid symbols in error msg
djdv Jun 20, 2023
569d161
cgofuse: don't use unexported alias in exports
djdv Jun 20, 2023
96d7d96
9p: MkdirAll - partially fix Mkdir race condition
djdv Jun 20, 2023
1865e29
9p: all - refactor constructors/remove reflection
djdv Jun 21, 2023
befe075
commands: adapt to `command` & `p9` API changes
djdv Jun 21, 2023
81aeb13
commands: lint - flag rune operations
djdv Jun 21, 2023
2468ce9
commands: lint - daemon large struct copies
djdv Jun 21, 2023
967584d
9p: make `FieldParser` optional for mount points
djdv Jun 22, 2023
b413c9e
commands: mountpoint - `FieldParser` is optional
djdv Jun 22, 2023
d3e9401
doc: nascent documentation
djdv Jun 6, 2023
d246df9
cgofuse: remove `nofuse` build constraint
djdv Jun 28, 2023
801a0e8
commands: (un)mount - add support for `nofuse` and `noipfs` build tags
djdv Jun 28, 2023
ab0870d
build: add support for passing build tags
djdv Jun 28, 2023
47a4ea6
command: add `ValueNamer` interface for flags
djdv Jun 29, 2023
cbf6798
commands: flag - implement `command.ValueNamer`
djdv Jun 29, 2023
bde2f37
commands: shutdown - change helptext format
djdv Jun 29, 2023
a4eafbb
commands: migrate to `generic.OptionFunc`
djdv Jul 3, 2023
4a06e69
9p: migrate to `generic.OptionFunc`
djdv Jul 3, 2023
340eebe
build: add output name flag `-o`.
djdv Jul 3, 2023
3316cb8
commands: permissions - limit tests to Linux
djdv Jul 3, 2023
d650929
ci: create a "latest" release synced with `master`
djdv Jul 3, 2023
b6c9ce3
ci: vet build tags during tests
djdv Jul 10, 2023
344d761
commands: slices - backport `slices.SortFunc`
djdv Jul 3, 2023
bbb3214
daemon: monitor `SIGTERM` and Windows events
djdv Jul 5, 2023
fa9ea09
commands: client/server - refactor maddr+log flags
djdv Jul 10, 2023
78a26a5
commands: lint - use consistent option apply style
djdv Jul 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ runs:
run: |
mkdir build
$buildDir = Join-Path . build
$commandDir = Join-Path . cmd fs
go build -o ${buildDir} ${commandDir}
$buildCommand = Join-Path . cmd build
go run $buildCommand -o $buildDir
18 changes: 18 additions & 0 deletions .github/actions/latest/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Latest"
description: 'Update the GitHub release tagged "latest"'
inputs:
github-token:
description: "Token used to publish releases"
required: true
runs:
using: "composite"
steps:
- shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
git tag --force latest master
git push --force origin latest
pushd artifact
gh release upload --clobber latest *
popd
20 changes: 0 additions & 20 deletions .github/actions/prerelease/action.yaml

This file was deleted.

22 changes: 21 additions & 1 deletion .github/actions/test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ runs:
env:
CPATH: ${{env.CPATH}}
run: |
$commandPath = $(Join-Path . ...)
$commandPath = Join-Path . ...
$tagValues = & {
$tags = 'nofuse', 'noipfs'
$combinations = @()
$allCombinations = [Math]::Pow(2, $tags.Length)
for ($i = 0; $i -lt $allCombinations; $i++) {
$components = @()
for ($j = 0; $j -lt $tags.Length; $j++) {
if (($i -band ([Math]::Pow(2, $j))) -ne 0) {
$components += $tags[$j]
}
}
if ($components.Count -gt 0) {
$combinations += $components -join ','
}
}
return $combinations
}
$tagValues | ForEach-Object {
"go vet -tags=$_ ${commandPath}"
}
go test -cover ${commandPath}
go test -race ${commandPath}
11 changes: 4 additions & 7 deletions .github/workflows/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
push:
branches:
- master
tags:
- 'prerelease'
- 'release'
pull_request:
jobs:
Test:
Expand All @@ -18,7 +15,7 @@ jobs:
- uses: ./.github/actions/setup
- uses: ./.github/actions/test
Build:
if: github.ref == 'refs/tags/prerelease' || github.ref == 'refs/tags/release'
if: github.ref == 'refs/heads/master'
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
Expand All @@ -28,13 +25,13 @@ jobs:
- uses: ./.github/actions/setup
- uses: ./.github/actions/build
- uses: ./.github/actions/archive
Prerelease:
if: github.ref == 'refs/tags/prerelease' # TODO: invert this? If prerelease; setup + test + build + release
Release:
if: github.ref == 'refs/heads/master'
needs: [Test, Build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: ./.github/actions/prerelease
- uses: ./.github/actions/latest
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions cmd/build/buildmode_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions cmd/build/env_nocgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !cgo

package main

func setupEnvironment(environment []string) ([]string, error) { return environment, nil }
5 changes: 5 additions & 0 deletions cmd/build/env_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build cgo && !windows

package main

func setupEnvironment(environment []string) ([]string, error) { return environment, nil }
98 changes: 98 additions & 0 deletions cmd/build/env_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//go:build cgo

package main

import (
"fmt"
"os"
"path/filepath"
"strings"
)

func setupEnvironment(environment []string) ([]string, error) {
const librarySearchPathKey = "CPATH"
searchPaths, searchPathsIndex, searchPathsSet := lookupEnv(environment, librarySearchPathKey)
if searchPathsSet {
if hasFuseHeader(searchPaths) {
return environment, nil
}
}
fuseLibPath, err := getDefaultFUSELibPath()
if err != nil {
return nil, err
}
if searchPathsSet {
newSearchPaths := appendSearchPaths(searchPaths, fuseLibPath)
setEnv(environment, searchPathsIndex, librarySearchPathKey, newSearchPaths)
} else {
environment = append(environment, newEnvPair(librarySearchPathKey, fuseLibPath))
}
return environment, nil
}

func lookupEnv(environment []string, key string) (string, int, bool) {
for i, pair := range environment {
if strings.HasPrefix(pair, key) {
const separator = "="
valueIndex := len(key) + len(separator)
return pair[valueIndex:], i, true
}
}
return "", -1, false
}

func hasFuseHeader(pathList string) bool {
paths := strings.Split(pathList, string(os.PathListSeparator))
const headerName = "fuse.h"
for _, path := range paths {
headerPath := filepath.Join(path, headerName)
if _, err := os.Stat(headerPath); err == nil {
return true
}
}
return false
}

func getDefaultFUSELibPath() (string, error) {
const findErrFmt = `could not find WinFSP's FUSE library "%s"`
fuseLibPath := getFUSELibPath()
if _, err := os.Stat(fuseLibPath); err != nil {
return "", fmt.Errorf(findErrFmt+": %w", fuseLibPath, err)
}
if !hasFuseHeader(fuseLibPath) {
return "", fmt.Errorf(findErrFmt, fuseLibPath)
}
return fuseLibPath, nil
}

func getFUSELibPath() string {
return filepath.Join(
getProgramsPath(),
"WinFsp", "inc", "fuse",
)
}

func getProgramsPath() string {
const (
x64SearchPath = "ProgramFiles(x86)"
x86SearchPath = "ProgramFiles"
)
progPath, ok := os.LookupEnv(x64SearchPath)
if ok {
return progPath
}
return os.Getenv(x86SearchPath)
}

func appendSearchPaths(searchPaths, path string) string {
return fmt.Sprintf("%s%c%s", searchPaths, os.PathListSeparator, path)
}

func setEnv(environment []string, index int, key, value string) {
environment[index] = newEnvPair(key, value)
}

func newEnvPair(key, value string) string {
const separator = "="
return key + separator + value
}
Loading