mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
image: Handle systems that don't support O_PATH when updating timestamp
Older kernel can't handle O_PATH in open() so this will fail on dirs and symlinks. For dirs wa can fallback to the normal Utimes, but for symlinks there is not much to do but ignore their timestamps.
This commit is contained in:
parent
cc28829429
commit
ed65815613
1 changed files with 14 additions and 4 deletions
18
image.go
18
image.go
|
@ -336,11 +336,21 @@ func (image *Image) applyLayer(layer, target string) error {
|
|||
|
||||
O_PATH := 010000000 // Not in syscall yet
|
||||
fd, err := syscall.Open(update.path, syscall.O_RDWR | O_PATH | syscall.O_NOFOLLOW, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
if err == syscall.EISDIR || err == syscall.ELOOP {
|
||||
// O_PATH not supported, use Utimes except on symlinks where Utimes doesn't work
|
||||
if err != syscall.ELOOP {
|
||||
err = syscall.Utimes(update.path, update.time)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
syscall.Futimes(fd, update.time)
|
||||
_ = syscall.Close(fd)
|
||||
}
|
||||
syscall.Futimes(fd, update.time)
|
||||
_ = syscall.Close(fd)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue