forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core, cmd, vendor: fixes and database inspection tool (#15)
* core, eth: some fixes for freezer * vendor, core/rawdb, cmd/geth: add db inspector * core, cmd/utils: check ancient store path forceily * cmd/geth, common, core/rawdb: a few fixes * cmd/geth: support windows file rename and fix rename error * core: support ancient plugin * core, cmd: streaming file copy * cmd, consensus, core, tests: keep genesis in leveldb * core: write txlookup during ancient init * core: bump database version
- Loading branch information
1 parent
42c746d
commit 37d280d
Showing
29 changed files
with
1,287 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com> | ||
// All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license. | ||
// | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func rename(oldpath, newpath string) error { | ||
return os.Rename(oldpath, newpath) | ||
} | ||
|
||
func isErrInvalid(err error) bool { | ||
if err == os.ErrInvalid { | ||
return true | ||
} | ||
// Go < 1.8 | ||
if syserr, ok := err.(*os.SyscallError); ok && syserr.Err == syscall.EINVAL { | ||
return true | ||
} | ||
// Go >= 1.8 returns *os.PathError instead | ||
if patherr, ok := err.(*os.PathError); ok && patherr.Err == syscall.EINVAL { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func syncDir(name string) error { | ||
// As per fsync manpage, Linux seems to expect fsync on directory, however | ||
// some system don't support this, so we will ignore syscall.EINVAL. | ||
// | ||
// From fsync(2): | ||
// Calling fsync() does not necessarily ensure that the entry in the | ||
// directory containing the file has also reached disk. For that an | ||
// explicit fsync() on a file descriptor for the directory is also needed. | ||
f, err := os.Open(name) | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
if err := f.Sync(); err != nil && !isErrInvalid(err) { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com> | ||
// All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style license. | ||
|
||
package main | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
var ( | ||
modkernel32 = syscall.NewLazyDLL("kernel32.dll") | ||
procMoveFileExW = modkernel32.NewProc("MoveFileExW") | ||
) | ||
|
||
const _MOVEFILE_REPLACE_EXISTING = 1 | ||
|
||
func moveFileEx(from *uint16, to *uint16, flags uint32) error { | ||
r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) | ||
if r1 == 0 { | ||
if e1 != 0 { | ||
return error(e1) | ||
} | ||
return syscall.EINVAL | ||
} | ||
return nil | ||
} | ||
|
||
func rename(oldpath, newpath string) error { | ||
from, err := syscall.UTF16PtrFromString(oldpath) | ||
if err != nil { | ||
return err | ||
} | ||
to, err := syscall.UTF16PtrFromString(newpath) | ||
if err != nil { | ||
return err | ||
} | ||
return moveFileEx(from, to, _MOVEFILE_REPLACE_EXISTING) | ||
} | ||
|
||
func syncDir(name string) error { return nil } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.