Skip to content

Commit

Permalink
fix daemon 's host flag
Browse files Browse the repository at this point in the history
  • Loading branch information
carmark committed Dec 10, 2022
1 parent d92d540 commit 8a3e19f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 8 additions & 2 deletions cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import (
"strings"
"syscall"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/gostor/gotgt/pkg/apiserver"
"github.com/gostor/gotgt/pkg/config"
_ "github.com/gostor/gotgt/pkg/port/iscsit"
"github.com/gostor/gotgt/pkg/scsi"
_ "github.com/gostor/gotgt/pkg/scsi/backingstore"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

func newDaemonCommand() *cobra.Command {
Expand All @@ -41,7 +43,11 @@ func newDaemonCommand() *cobra.Command {
Use: "daemon",
Short: "Setup a daemon",
Long: `Setup the Gotgt's daemon`,
PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlags(cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
host = viper.GetString("host")
return createDaemon(host, driver, logLevel, blockMultipleHosts)
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/port/iscsit/iscsid.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (s *ISCSITargetDriver) rxHandler(conn *iscsiConnection) {
log.Debug("rx handler: IOSTATE_RX_BHS")
length, err = conn.readData(buf)
if err != nil {
log.Error("read BHS failed:", err)
log.Error("read BHS failed: ", err)
conn.state = CONN_STATE_CLOSE
return
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/scsi/backingstore/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
"io"
"os"

log "github.com/sirupsen/logrus"

"github.com/gostor/gotgt/pkg/api"
"github.com/gostor/gotgt/pkg/scsi"
"github.com/gostor/gotgt/pkg/util"
log "github.com/sirupsen/logrus"
)

const (
Expand All @@ -51,13 +52,10 @@ func new() (api.BackingStore, error) {
}

func (bs *FileBackingStore) Open(dev *api.SCSILu, path string) error {
var mode os.FileMode

var (
mode os.FileMode
finfo os.FileInfo
)

if finfo, err := os.Stat(path); err != nil {
finfo, err := os.Stat(path)
if err != nil {
return err
} else {
// determine file type
Expand All @@ -75,6 +73,9 @@ func (bs *FileBackingStore) Open(dev *api.SCSILu, path string) error {
}
bs.DataSize = uint64(pos)
} else {
if finfo == nil {
log.Infof("finfo is nil")
}
bs.DataSize = uint64(finfo.Size())
}
}
Expand Down

0 comments on commit 8a3e19f

Please sign in to comment.