The following changes since commit e254d00ba9dfcdf26e6a8fedd2339c16f5a616f7: Get rid of fallocate on Windows (2013-02-06 13:52:12 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Bruce Cran (2): Windows: fix sysconf(_SC_PHYS_PAGES). Windows: fix mlock, remove ftruncate and fix error handling. Jens Axboe (6): Fix crash and precision of ETA with zones stat: fix wrong type used for 32-bit compiles Fix zones for numjobs=x, where x > 1 Makfile: use LINK for the link phase t/log: include minmax.h for min() Fix bug with rate and read/write mixed workloads at 100% bias Makefile | 11 ++- engines/windowsaio.c | 76 ---------------- eta.c | 12 ++- init.c | 2 +- io_u.c | 3 +- os/os-windows.h | 12 ++- os/windows/posix.c | 246 ++++++++++++++++++++++++++++++++++++++------------ os/windows/posix.h | 1 + stat.c | 4 +- t/log.c | 1 + 10 files changed, 217 insertions(+), 151 deletions(-) --- Diff of recent changes: diff --git a/Makefile b/Makefile index d097c05..8a7410a 100644 --- a/Makefile +++ b/Makefile @@ -155,6 +155,7 @@ T_PROGS += $(T_AXMAP_PROGS) ifneq ($(findstring $(MAKEFLAGS),s),s) ifndef V QUIET_CC = @echo ' ' CC $@; + QUIET_LINK = @echo ' ' LINK $@; QUIET_DEP = @echo ' ' DEP $@; endif endif @@ -193,19 +194,19 @@ init.o: FIO-VERSION-FILE init.c $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c t/stest: $(T_SMALLOC_OBJS) - $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS) t/ieee754: $(T_IEEE_OBJS) - $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS) t/genzipf: $(T_ZIPF_OBJS) - $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS) t/axmap: $(T_AXMAP_OBJS) - $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS) fio: $(OBJS) - $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS) clean: FORCE -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak cscope.out *.d diff --git a/engines/windowsaio.c b/engines/windowsaio.c index 4a00794..3a24fa7 100644 --- a/engines/windowsaio.c +++ b/engines/windowsaio.c @@ -50,82 +50,6 @@ static DWORD WINAPI IoCompletionRoutine(LPVOID lpParameter); static int fio_windowsaio_init(struct thread_data *td); static int fio_windowsaio_open_file(struct thread_data *td, struct fio_file *f); static int fio_windowsaio_close_file(struct thread_data fio_unused *td, struct fio_file *f); -static int win_to_posix_error(DWORD winerr); - -static int win_to_posix_error(DWORD winerr) -{ - switch (winerr) - { - case ERROR_FILE_NOT_FOUND: return ENOENT; - case ERROR_PATH_NOT_FOUND: return ENOENT; - case ERROR_ACCESS_DENIED: return EACCES; - case ERROR_INVALID_HANDLE: return EBADF; - case ERROR_NOT_ENOUGH_MEMORY: return ENOMEM; - case ERROR_INVALID_DATA: return EINVAL; - case ERROR_OUTOFMEMORY: return ENOMEM; - case ERROR_INVALID_DRIVE: return ENODEV; - case ERROR_NOT_SAME_DEVICE: return EXDEV; - case ERROR_WRITE_PROTECT: return EROFS; - case ERROR_BAD_UNIT: return ENODEV; - case ERROR_SHARING_VIOLATION: return EACCES; - case ERROR_LOCK_VIOLATION: return EACCES; - case ERROR_SHARING_BUFFER_EXCEEDED: return ENOLCK; - case ERROR_HANDLE_DISK_FULL: return ENOSPC; - case ERROR_NOT_SUPPORTED: return ENOSYS; - case ERROR_FILE_EXISTS: return EEXIST; - case ERROR_CANNOT_MAKE: return EPERM; - case ERROR_INVALID_PARAMETER: return EINVAL; - case ERROR_NO_PROC_SLOTS: return EAGAIN; - case ERROR_BROKEN_PIPE: return EPIPE; - case ERROR_OPEN_FAILED: return EIO; - case ERROR_NO_MORE_SEARCH_HANDLES: return ENFILE; - case ERROR_CALL_NOT_IMPLEMENTED: return ENOSYS; - case ERROR_INVALID_NAME: return ENOENT; - case ERROR_WAIT_NO_CHILDREN: return ECHILD; - case ERROR_CHILD_NOT_COMPLETE: return EBUSY; - case ERROR_DIR_NOT_EMPTY: return ENOTEMPTY; - case ERROR_SIGNAL_REFUSED: return EIO; - case ERROR_BAD_PATHNAME: return ENOENT; - case ERROR_SIGNAL_PENDING: return EBUSY; - case ERROR_MAX_THRDS_REACHED: return EAGAIN; - case ERROR_BUSY: return EBUSY; - case ERROR_ALREADY_EXISTS: return EEXIST; - case ERROR_NO_SIGNAL_SENT: return EIO; - case ERROR_FILENAME_EXCED_RANGE: return EINVAL; - case ERROR_META_EXPANSION_TOO_LONG: return EINVAL; - case ERROR_INVALID_SIGNAL_NUMBER: return EINVAL; - case ERROR_THREAD_1_INACTIVE: return EINVAL; - case ERROR_BAD_PIPE: return EINVAL; - case ERROR_PIPE_BUSY: return EBUSY; - case ERROR_NO_DATA: return EPIPE; - case ERROR_MORE_DATA: return EAGAIN; - case ERROR_DIRECTORY: return ENOTDIR; - case ERROR_PIPE_CONNECTED: return EBUSY; - case ERROR_NO_TOKEN: return EINVAL; - case ERROR_PROCESS_ABORTED: return EFAULT; - case ERROR_BAD_DEVICE: return ENODEV; - case ERROR_BAD_USERNAME: return EINVAL; - case ERROR_OPEN_FILES: return EAGAIN; - case ERROR_ACTIVE_CONNECTIONS: return EAGAIN; - case ERROR_DEVICE_IN_USE: return EAGAIN; - case ERROR_INVALID_AT_INTERRUPT_TIME: return EINTR; - case ERROR_IO_DEVICE: return EIO; - case ERROR_NOT_OWNER: return EPERM; - case ERROR_END_OF_MEDIA: return ENOSPC; - case ERROR_EOM_OVERFLOW: return ENOSPC; - case ERROR_BEGINNING_OF_MEDIA: return ESPIPE; - case ERROR_SETMARK_DETECTED: return ESPIPE; - case ERROR_NO_DATA_DETECTED: return ENOSPC; - case ERROR_POSSIBLE_DEADLOCK: return EDEADLOCK; - case ERROR_CRC: return EIO; - case ERROR_NEGATIVE_SEEK: return EINVAL; - case ERROR_DISK_FULL: return ENOSPC; - case ERROR_NOACCESS: return EFAULT; - case ERROR_FILE_INVALID: return ENXIO; - } - - return winerr; -} static int fio_windowsaio_init(struct thread_data *td) { diff --git a/eta.c b/eta.c index cfb8679..5ef31c6 100644 --- a/eta.c +++ b/eta.c @@ -139,6 +139,15 @@ static int thread_eta(struct thread_data *td) bytes_total = td->fill_device_size; } + if (td->o.zone_size && td->o.zone_skip && bytes_total) { + unsigned int nr_zones; + uint64_t zone_bytes; + + zone_bytes = bytes_total + td->o.zone_size + td->o.zone_skip; + nr_zones = (zone_bytes - 1) / (td->o.zone_size + td->o.zone_skip); + bytes_total -= nr_zones * td->o.zone_skip; + } + /* * if writing and verifying afterwards, bytes_total will be twice the * size. In a mixed workload, verify phase will be the size of the @@ -156,9 +165,6 @@ static int thread_eta(struct thread_data *td) bytes_total <<= 1; } - if (td->o.zone_size && td->o.zone_skip) - bytes_total /= (td->o.zone_skip / td->o.zone_size); - if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) { double perc, perc_t; diff --git a/init.c b/init.c index 60ba299..e8f3a9b 100644 --- a/init.c +++ b/init.c @@ -408,7 +408,7 @@ static int fixup_options(struct thread_data *td) /* * only really works with 1 file */ - if (o->zone_size && o->open_files == 1) + if (o->zone_size && o->open_files > 1) o->zone_size = 0; /* diff --git a/io_u.c b/io_u.c index 6ae3eae..6598881 100644 --- a/io_u.c +++ b/io_u.c @@ -490,7 +490,7 @@ static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir) assert(ddir_rw(ddir)); - if (td->rate_pending_usleep[ddir] <= 0) + if (td->rate_pending_usleep[ddir] <= 0 || !td->o.rwmix[odir]) return ddir; /* @@ -545,6 +545,7 @@ static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir) if (ddir_trim(ddir)) return ddir; + return ddir; } diff --git a/os/os-windows.h b/os/os-windows.h index 98f9030..09f9c54 100644 --- a/os/os-windows.h +++ b/os/os-windows.h @@ -151,12 +151,14 @@ static inline int blockdev_invalidate_cache(struct fio_file *f) static inline unsigned long long os_phys_mem(void) { - SYSTEM_INFO sysInfo; - uintptr_t addr; + long pagesize, pages; - GetSystemInfo(&sysInfo); - addr = (uintptr_t)sysInfo.lpMaximumApplicationAddress; - return (unsigned long long)addr; + pagesize = sysconf(_SC_PAGESIZE); + pages = sysconf(_SC_PHYS_PAGES); + if (pages == -1 || pagesize == -1) + return 0; + + return (unsigned long long) pages * (unsigned long long) pagesize; } static inline void os_get_tmpdir(char *path, int len) diff --git a/os/windows/posix.c b/os/windows/posix.c index de67911..6a7841d 100755 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -43,6 +43,81 @@ int vsprintf_s( const char *format, va_list argptr); +int win_to_posix_error(DWORD winerr) +{ + switch (winerr) + { + case ERROR_FILE_NOT_FOUND: return ENOENT; + case ERROR_PATH_NOT_FOUND: return ENOENT; + case ERROR_ACCESS_DENIED: return EACCES; + case ERROR_INVALID_HANDLE: return EBADF; + case ERROR_NOT_ENOUGH_MEMORY: return ENOMEM; + case ERROR_INVALID_DATA: return EINVAL; + case ERROR_OUTOFMEMORY: return ENOMEM; + case ERROR_INVALID_DRIVE: return ENODEV; + case ERROR_NOT_SAME_DEVICE: return EXDEV; + case ERROR_WRITE_PROTECT: return EROFS; + case ERROR_BAD_UNIT: return ENODEV; + case ERROR_SHARING_VIOLATION: return EACCES; + case ERROR_LOCK_VIOLATION: return EACCES; + case ERROR_SHARING_BUFFER_EXCEEDED: return ENOLCK; + case ERROR_HANDLE_DISK_FULL: return ENOSPC; + case ERROR_NOT_SUPPORTED: return ENOSYS; + case ERROR_FILE_EXISTS: return EEXIST; + case ERROR_CANNOT_MAKE: return EPERM; + case ERROR_INVALID_PARAMETER: return EINVAL; + case ERROR_NO_PROC_SLOTS: return EAGAIN; + case ERROR_BROKEN_PIPE: return EPIPE; + case ERROR_OPEN_FAILED: return EIO; + case ERROR_NO_MORE_SEARCH_HANDLES: return ENFILE; + case ERROR_CALL_NOT_IMPLEMENTED: return ENOSYS; + case ERROR_INVALID_NAME: return ENOENT; + case ERROR_WAIT_NO_CHILDREN: return ECHILD; + case ERROR_CHILD_NOT_COMPLETE: return EBUSY; + case ERROR_DIR_NOT_EMPTY: return ENOTEMPTY; + case ERROR_SIGNAL_REFUSED: return EIO; + case ERROR_BAD_PATHNAME: return ENOENT; + case ERROR_SIGNAL_PENDING: return EBUSY; + case ERROR_MAX_THRDS_REACHED: return EAGAIN; + case ERROR_BUSY: return EBUSY; + case ERROR_ALREADY_EXISTS: return EEXIST; + case ERROR_NO_SIGNAL_SENT: return EIO; + case ERROR_FILENAME_EXCED_RANGE: return EINVAL; + case ERROR_META_EXPANSION_TOO_LONG: return EINVAL; + case ERROR_INVALID_SIGNAL_NUMBER: return EINVAL; + case ERROR_THREAD_1_INACTIVE: return EINVAL; + case ERROR_BAD_PIPE: return EINVAL; + case ERROR_PIPE_BUSY: return EBUSY; + case ERROR_NO_DATA: return EPIPE; + case ERROR_MORE_DATA: return EAGAIN; + case ERROR_DIRECTORY: return ENOTDIR; + case ERROR_PIPE_CONNECTED: return EBUSY; + case ERROR_NO_TOKEN: return EINVAL; + case ERROR_PROCESS_ABORTED: return EFAULT; + case ERROR_BAD_DEVICE: return ENODEV; + case ERROR_BAD_USERNAME: return EINVAL; + case ERROR_OPEN_FILES: return EAGAIN; + case ERROR_ACTIVE_CONNECTIONS: return EAGAIN; + case ERROR_DEVICE_IN_USE: return EAGAIN; + case ERROR_INVALID_AT_INTERRUPT_TIME: return EINTR; + case ERROR_IO_DEVICE: return EIO; + case ERROR_NOT_OWNER: return EPERM; + case ERROR_END_OF_MEDIA: return ENOSPC; + case ERROR_EOM_OVERFLOW: return ENOSPC; + case ERROR_BEGINNING_OF_MEDIA: return ESPIPE; + case ERROR_SETMARK_DETECTED: return ESPIPE; + case ERROR_NO_DATA_DETECTED: return ENOSPC; + case ERROR_POSSIBLE_DEADLOCK: return EDEADLOCK; + case ERROR_CRC: return EIO; + case ERROR_NEGATIVE_SEEK: return EINVAL; + case ERROR_DISK_FULL: return ENOSPC; + case ERROR_NOACCESS: return EFAULT; + case ERROR_FILE_INVALID: return ENXIO; + } + + return winerr; +} + int GetNumLogicalProcessors(void) { SYSTEM_LOGICAL_PROCESSOR_INFORMATION *processor_info = NULL; @@ -79,6 +154,7 @@ int GetNumLogicalProcessors(void) long sysconf(int name) { long val = -1; + long val2 = -1; SYSTEM_INFO sysInfo; MEMORYSTATUSEX status; @@ -87,7 +163,7 @@ long sysconf(int name) case _SC_NPROCESSORS_ONLN: val = GetNumLogicalProcessors(); if (val == -1) - log_err("_SC_NPROCESSORS_ONLN failed\n"); + log_err("sysconf(_SC_NPROCESSORS_ONLN) failed\n"); break; @@ -98,8 +174,11 @@ long sysconf(int name) case _SC_PHYS_PAGES: status.dwLength = sizeof(status); - GlobalMemoryStatusEx(&status); - val = status.ullTotalPhys; + val2 = sysconf(_SC_PAGESIZE); + if (GlobalMemoryStatusEx(&status) && val2 != -1) + val = status.ullTotalPhys / val2; + else + log_err("sysconf(_SC_PHYS_PAGES) failed\n"); break; default: log_err("sysconf(%d) is not implemented\n", name); @@ -210,6 +289,8 @@ void *mmap(void *addr, size_t len, int prot, int flags, if ((flags & MAP_ANON) | (flags & MAP_ANONYMOUS)) { allocAddr = VirtualAlloc(addr, len, MEM_COMMIT, vaProt); + if (allocAddr == NULL) + errno = win_to_posix_error(GetLastError()); } return allocAddr; @@ -217,21 +298,26 @@ void *mmap(void *addr, size_t len, int prot, int flags, int munmap(void *addr, size_t len) { - return !VirtualFree(addr, 0, MEM_RELEASE); + if (!VirtualFree(addr, 0, MEM_RELEASE)) { + errno = win_to_posix_error(GetLastError()); + return -1; + } + + return 0; } int fork(void) { log_err("%s is not implemented\n", __func__); errno = ENOSYS; - return (-1); + return -1; } pid_t setsid(void) { log_err("%s is not implemented\n", __func__); errno = ENOSYS; - return (-1); + return -1; } static HANDLE log_file = INVALID_HANDLE_VALUE; @@ -276,7 +362,7 @@ void syslog(int priority, const char *message, ... /* argument */) int kill(pid_t pid, int sig) { errno = ESRCH; - return (-1); + return -1; } /* @@ -297,7 +383,7 @@ int fcntl(int fildes, int cmd, ...) return 0; else if (cmd != F_SETFL) { errno = EINVAL; - return (-1); + return -1; } va_start(ap, 1); @@ -369,12 +455,42 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) int mlock(const void * addr, size_t len) { - return !VirtualLock((LPVOID)addr, len); + SIZE_T min, max; + BOOL success; + HANDLE process = GetCurrentProcess(); + + success = GetProcessWorkingSetSize(process, &min, &max); + if (!success) { + errno = win_to_posix_error(GetLastError()); + return -1; + } + + min += len; + max += len; + success = SetProcessWorkingSetSize(process, min, max); + if (!success) { + errno = win_to_posix_error(GetLastError()); + return -1; + } + + success = VirtualLock((LPVOID)addr, len); + if (!success) { + errno = win_to_posix_error(GetLastError()); + return -1; + } + + return 0; } int munlock(const void * addr, size_t len) { - return !VirtualUnlock((LPVOID)addr, len); + BOOL success = VirtualUnlock((LPVOID)addr, len); + if (!success) { + errno = win_to_posix_error(GetLastError()); + return -1; + } + + return 0; } pid_t waitpid(pid_t pid, int *stat_loc, int options) @@ -408,21 +524,15 @@ char *basename(char *path) return name; } -int ftruncate(int fildes, off_t length) -{ - BOOL bSuccess; - int64_t prev_pos = _telli64(fildes); - _lseeki64(fildes, length, SEEK_SET); - HANDLE hFile = (HANDLE)_get_osfhandle(fildes); - bSuccess = SetEndOfFile(hFile); - _lseeki64(fildes, prev_pos, SEEK_SET); - return !bSuccess; -} - int fsync(int fildes) { HANDLE hFile = (HANDLE)_get_osfhandle(fildes); - return !FlushFileBuffers(hFile); + if (!FlushFileBuffers(hFile)) { + errno = win_to_posix_error(GetLastError()); + return -1; + } + + return 0; } int nFileMappings = 0; @@ -450,14 +560,33 @@ void *shmat(int shmid, const void *shmaddr, int shmflg) void* mapAddr; MEMORY_BASIC_INFORMATION memInfo; mapAddr = MapViewOfFile(fileMappings[shmid], FILE_MAP_ALL_ACCESS, 0, 0, 0); - VirtualQuery(mapAddr, &memInfo, sizeof(memInfo)); + if (mapAddr == NULL) { + errno = win_to_posix_error(GetLastError()); + return (void*)-1; + } + + if (VirtualQuery(mapAddr, &memInfo, sizeof(memInfo)) == 0) { + errno = win_to_posix_error(GetLastError()); + return (void*)-1; + } + mapAddr = VirtualAlloc(mapAddr, memInfo.RegionSize, MEM_COMMIT, PAGE_READWRITE); + if (mapAddr == NULL) { + errno = win_to_posix_error(GetLastError()); + return (void*)-1; + } + return mapAddr; } int shmdt(const void *shmaddr) { - return !UnmapViewOfFile(shmaddr); + if (!UnmapViewOfFile(shmaddr)) { + errno = win_to_posix_error(GetLastError()); + return -1; + } + + return 0; } int shmctl(int shmid, int cmd, struct shmid_ds *buf) @@ -468,21 +597,22 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf) } else { log_err("%s is not implemented\n", __func__); } - return (-1); + errno = ENOSYS; + return -1; } int setuid(uid_t uid) { log_err("%s is not implemented\n", __func__); errno = ENOSYS; - return (-1); + return -1; } int setgid(gid_t gid) { log_err("%s is not implemented\n", __func__); errno = ENOSYS; - return (-1); + return -1; } int nice(int incr) @@ -575,14 +705,14 @@ ssize_t readv(int fildes, const struct iovec *iov, int iovcnt) { log_err("%s is not implemented\n", __func__); errno = ENOSYS; - return (-1); + return -1; } ssize_t writev(int fildes, const struct iovec *iov, int iovcnt) { log_err("%s is not implemented\n", __func__); errno = ENOSYS; - return (-1); + return -1; } long long strtoll(const char *restrict str, char **restrict endptr, @@ -678,40 +808,40 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) DIR *opendir(const char *dirname) { - struct dirent_ctx *dc = NULL; - - /* See if we can open it. If not, we'll return an error here */ - HANDLE file = CreateFileA(dirname, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); - if (file != INVALID_HANDLE_VALUE) { - CloseHandle(file); - dc = (struct dirent_ctx*)malloc(sizeof(struct dirent_ctx)); - StringCchCopyA(dc->dirname, MAX_PATH, dirname); - dc->find_handle = INVALID_HANDLE_VALUE; - } else { - DWORD error = GetLastError(); - if (error == ERROR_FILE_NOT_FOUND) - errno = ENOENT; - - else if (error == ERROR_PATH_NOT_FOUND) - errno = ENOTDIR; - else if (error == ERROR_TOO_MANY_OPEN_FILES) - errno = ENFILE; - else if (error == ERROR_ACCESS_DENIED) - errno = EACCES; - else - errno = error; - } - - return dc; + struct dirent_ctx *dc = NULL; + + /* See if we can open it. If not, we'll return an error here */ + HANDLE file = CreateFileA(dirname, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (file != INVALID_HANDLE_VALUE) { + CloseHandle(file); + dc = (struct dirent_ctx*)malloc(sizeof(struct dirent_ctx)); + StringCchCopyA(dc->dirname, MAX_PATH, dirname); + dc->find_handle = INVALID_HANDLE_VALUE; + } else { + DWORD error = GetLastError(); + if (error == ERROR_FILE_NOT_FOUND) + errno = ENOENT; + + else if (error == ERROR_PATH_NOT_FOUND) + errno = ENOTDIR; + else if (error == ERROR_TOO_MANY_OPEN_FILES) + errno = ENFILE; + else if (error == ERROR_ACCESS_DENIED) + errno = EACCES; + else + errno = error; + } + + return dc; } int closedir(DIR *dirp) { - if (dirp != NULL && dirp->find_handle != INVALID_HANDLE_VALUE) - FindClose(dirp->find_handle); + if (dirp != NULL && dirp->find_handle != INVALID_HANDLE_VALUE) + FindClose(dirp->find_handle); - free(dirp); - return 0; + free(dirp); + return 0; } struct dirent *readdir(DIR *dirp) diff --git a/os/windows/posix.h b/os/windows/posix.h index cb89cf6..85640a2 100644 --- a/os/windows/posix.h +++ b/os/windows/posix.h @@ -6,5 +6,6 @@ typedef int clockid_t; extern int clock_gettime(clockid_t clock_id, struct timespec *tp); extern int inet_aton(const char *, struct in_addr *); +extern int win_to_posix_error(DWORD winerr); #endif diff --git a/stat.c b/stat.c index 28acc23..759bcef 100644 --- a/stat.c +++ b/stat.c @@ -182,7 +182,7 @@ static unsigned int calc_clat_percentiles(unsigned int *io_u_plat, * Find and display the p-th percentile of clat */ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, - fio_fp64_t *plist, uint64_t precision) + fio_fp64_t *plist, unsigned int precision) { unsigned int len, j = 0, minv, maxv; unsigned int *ovals; @@ -205,7 +205,7 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, log_info(" clat percentiles (usec):\n |"); } - snprintf(fmt, sizeof(fmt), "%%1.%luf", precision); + snprintf(fmt, sizeof(fmt), "%%1.%uf", precision); per_line = (80 - 7) / (precision + 14); for (j = 0; j < len; j++) { diff --git a/t/log.c b/t/log.c index 76ae68e..1ed3851 100644 --- a/t/log.c +++ b/t/log.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdarg.h> +#include "../minmax.h" int log_err(const char *format, ...) { -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html