示例#1
0
func main() {
	flag.Usage = usage
	flag.Parse()
	if flag.NArg() < 1 {
		usage()
	}

	for _, name := range flag.Args() {
		f, err := os.OpenFile(name, syscall.O_RDONLY|syscall.O_NOATIME|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0644)
		if ek(err) {
			continue
		}

		if *dflag {
			err = syscall.Fdatasync(int(f.Fd()))
		} else {
			err = syscall.Fsync(int(f.Fd()))
		}
		ek(err)
		ek(f.Close())
	}
	os.Exit(status)
}
示例#2
0
func Fdatasync(fd uintptr) (err error) {
	return syscall.Fdatasync(int(fd))
}
示例#3
0
// fdatasync flushes written data to a file descriptor.
func fdatasync(db *DB) error {
	return syscall.Fdatasync(int(db.file.Fd()))
}
示例#4
0
// Fdatasync is similar to fsync(), but does not flush modified metadata
// unless that metadata is needed in order to allow a subsequent data retrieval
// to be correctly handled.
func Fdatasync(f *os.File) error {
	return syscall.Fdatasync(int(f.Fd()))
}