Update NetworkChangeName to be more similar to my original (moving IFNAMSIZ constant outside the function like it should've been)
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
parent
4f9817a3ca
commit
e44920cbe6
1 changed files with 4 additions and 2 deletions
|
@ -662,15 +662,17 @@ func getIfSocket() (int, error) {
|
||||||
return -1, sErr
|
return -1, sErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from <net/if.h>
|
||||||
|
const IFNAMSIZ = 16
|
||||||
|
|
||||||
func NetworkChangeName(oldName, newName string) error {
|
func NetworkChangeName(oldName, newName string) error {
|
||||||
fd, err := getIfSocket()
|
fd, err := getIfSocket()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer syscall.Close(fd)
|
defer syscall.Close(fd)
|
||||||
IFNAMSIZ := 16
|
|
||||||
|
|
||||||
data := [32]byte{}
|
data := [IFNAMSIZ * 2]byte{}
|
||||||
copy(data[:IFNAMSIZ-1], oldName)
|
copy(data[:IFNAMSIZ-1], oldName)
|
||||||
copy(data[IFNAMSIZ:IFNAMSIZ*2-1], newName)
|
copy(data[IFNAMSIZ:IFNAMSIZ*2-1], newName)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue