Skip to content

Commit

Permalink
Mark nbd devices as read-only when -buse-readonly flag is set. Closes #3
Browse files Browse the repository at this point in the history
.
  • Loading branch information
dop251 committed Jan 18, 2023
1 parent 1f021bb commit 078346f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Run tests
env:
GOARCH: ${{ matrix.arch }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- goarch: arm
goos: darwin
steps:
- uses: actions/checkout@v2
- uses: wangyoucao577/go-release-action@v1.20
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1.34
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/dop251/spgz
go 1.16

require (
github.com/dop251/buse v1.1.0
github.com/sirupsen/logrus v1.8.1
github.com/dop251/buse v1.2.0
github.com/sirupsen/logrus v1.9.0
)
25 changes: 15 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dop251/buse v1.1.0 h1:aExv0ds8rsUaqBGMHqGfLHZhJROIbFHcNK8UgfyLAKc=
github.com/dop251/buse v1.1.0/go.mod h1:MGzyYwutwcAUZa2KlHLEhUaYBr6JpZf4sqyh1v1lEZs=
github.com/dop251/nbd v0.0.0-20170916130042-b8933b281cb7 h1:mNIccc19FsLtxQl5bnGUJiu0xoyhE2yxaIypx1cIdj8=
github.com/dop251/nbd v0.0.0-20170916130042-b8933b281cb7/go.mod h1:/YqO/I24sucjxhCgQHgDrnffSwg5HzoYHQASayZnYl8=
github.com/dop251/buse v1.2.0 h1:nSbAlhxRF3+HDbEHFuvhnsBe60bJOrPnWgREuZvk+1M=
github.com/dop251/buse v1.2.0/go.mod h1:7e/aSLUZG3TDBshKkAhcHKvZy7x4NvE+yIGD/DJhGAY=
github.com/dop251/nbd v1.0.1 h1:OCIXTI0HWZMLu93NSDsgQGTJSgwF1a0pdg7vFNABLMY=
github.com/dop251/nbd v1.0.1/go.mod h1:RsJYtrsjdGUcIVgYJ2euKMYnQmNbm0WkcdJClDfRX+Q=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 2 additions & 0 deletions spgz/buse_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ func doBuse(file, dev string, blockSize int, readOnly bool) {
if err != nil {
log.Fatalf("Could not create a device: %v", err)
}
device.SetLogger(log.StandardLogger())
if blockSize > 0 {
device.SetBlockSize(blockSize)
}
device.SetReadOnly(readOnly)
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt)
disc := make(chan error, 1)
Expand Down

0 comments on commit 078346f

Please sign in to comment.