Skip to content

Commit 772c0a9

Browse files
authored
packer: move call to unix.Sync behind Linux conditional compile (#84)
In RereadPartitions, move call to unix.Sync() in Linux specific code as unix.Sync() is not portable (not available on Windows).
1 parent 803c1f2 commit 772c0a9

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packer/packer.go

-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212
"log"
1313
"os"
1414
"unicode/utf16"
15-
16-
"golang.org/x/sys/unix"
1715
)
1816

1917
// Pack represents one pack process.
@@ -463,13 +461,9 @@ func (p *Pack) Partition(o *os.File, devsize uint64) error {
463461
}
464462

465463
func (p *Pack) RereadPartitions(o *os.File) error {
466-
// Make Linux re-read the partition table. Sequence of system calls like in fdisk(8).
467-
unix.Sync()
468-
469464
if err := rereadPartitions(o); err != nil {
470465
log.Printf("Re-reading partition table failed: %v. Remember to unplug and re-plug the SD card before creating a file system for persistent data, if desired.", err)
471466
}
472467

473-
unix.Sync()
474468
return nil
475469
}

packer/packer_linux.go

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
)
88

99
func rereadPartitions(o *os.File) error {
10+
// Make Linux re-read the partition table. Sequence of system calls like in fdisk(8).
11+
unix.Sync()
12+
1013
if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(o.Fd()), unix.BLKRRPART, 0); errno != 0 {
1114
return errno
1215
}
@@ -15,5 +18,7 @@ func rereadPartitions(o *os.File) error {
1518
return err
1619
}
1720

21+
unix.Sync()
22+
1823
return nil
1924
}

0 commit comments

Comments
 (0)