Skip to content

Commit

Permalink
Fix creation of non-empty volumes (nanovms#662)
Browse files Browse the repository at this point in the history
 * remove -e argument if creating a non-empty volume
  • Loading branch information
fabioDMFerreira committed Oct 5, 2020
1 parent fb1d68b commit 8dcad23
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lepton/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func buildImage(c *Config, m *Manifest) error {
}

mkfsCommand.SetBoot(c.Boot)
mkfsCommand.SetImageName(c.RunConfig.Imagename)
mkfsCommand.SetFileSystemPath(c.RunConfig.Imagename)

mkfsCommand.SetupCommand()
stdin, err := mkfsCommand.GetStdinPipe()
Expand Down
12 changes: 6 additions & 6 deletions lepton/mkfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func (m *MkfsCommand) SetupCommand() {
}
}

// SetFileSystemPath add argument that sets file system path
func (m *MkfsCommand) SetFileSystemPath(path string) {
m.args = append(m.args, "-e", path)
// SetEmptyFileSystem add argument that sets file system as empty
func (m *MkfsCommand) SetEmptyFileSystem() {
m.args = append(m.args, "-e")
}

// SetFileSystemSize add argument that sets file system size
Expand All @@ -61,9 +61,9 @@ func (m *MkfsCommand) SetBoot(boot string) {
m.args = append(m.args, "-b", boot)
}

// SetImageName add argument that sets
func (m *MkfsCommand) SetImageName(imageName string) {
m.args = append(m.args, imageName)
// SetFileSystemPath add argument that sets file system path
func (m *MkfsCommand) SetFileSystemPath(fsPath string) {
m.args = append(m.args, fsPath)
}

// SetStdin sets process's standard input
Expand Down
5 changes: 2 additions & 3 deletions lepton/mkfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ func TestMKFSCommand(t *testing.T) {
mkfs.SetFileSystemSize("size")
mkfs.SetTargetRoot("targetRoot")
mkfs.SetBoot("boot")
mkfs.SetImageName("imageName")
mkfs.SetEmptyFileSystem()

got := mkfs.GetArgs()
want := []string{
"-e",
"rawPath",
"-s",
"size",
"-r",
"targetRoot",
"-b",
"boot",
"imageName",
"-e",
}

if !reflect.DeepEqual(got, want) {
Expand Down
3 changes: 2 additions & 1 deletion lepton/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func (v *Volume) Create(name, data, size, provider string) error {
mnf := name + ".manifest"

rawPath := path.Join(localVolumeDir, raw)
mkfsCommand.SetFileSystemPath(rawPath)

if data != "" {
v.config.Dirs = append(v.config.Dirs, data)
Expand All @@ -95,9 +94,11 @@ func (v *Volume) Create(name, data, size, provider string) error {

mkfsCommand.SetStdin(src)
} else if size != "" {
mkfsCommand.SetEmptyFileSystem()
mkfsCommand.SetFileSystemSize(size)
}

mkfsCommand.SetFileSystemPath(rawPath)
mkfsCommand.SetupCommand()
err := mkfsCommand.Execute()
if err != nil {
Expand Down

0 comments on commit 8dcad23

Please sign in to comment.