Add a Windows version of truncate_log_file(). Use the Windows flavor of vsprintf().
Would you prefer items of this nature as two separate patches? thanks, stan. Signed-off-by: stan smith <stan.sm...@intel.com> --- a/opensm/osm_log.c 2010-05-22 05:49:24.000000000 -0700 +++ b/opensm/osm_log.c 2010-05-24 11:40:07.823895800 -0700 @@ -96,8 +96,14 @@ static void truncate_log_file(osm_log_t * p_log) { - fprintf(stderr, - "truncate_log_file: cannot truncate on windows system (yet)\n"); + int fd = _fileno(p_log->out_port); + HANDLE hFile = (HANDLE) _get_osfhandle(fd); + + if (_lseek(fd, 0, SEEK_SET) < 0) + fprintf(stderr, "truncate_log_file: cannot rewind: %s\n", + strerror(errno)); + SetEndOfFile(hFile); + p_log->count = 0; } #endif /* ndef __WIN__ */ @@ -123,12 +129,21 @@ return; va_start(args, p_str); +#ifndef __WIN__ if (p_log->log_prefix == NULL) vsprintf(buffer, p_str, args); else { int n = snprintf(buffer, sizeof(buffer), "%s: ", p_log->log_prefix); vsprintf(buffer + n, p_str, args); } +#else + if (p_log->log_prefix == NULL) + _vsnprintf(buffer, 1024, (LPSTR)p_str, args); + else { + int n = snprintf(buffer, sizeof(buffer), "%s: ", p_log->log_prefix); + _vsnprintf(buffer + n, (1024 - n), (LPSTR)p_str, args); + } +#endif va_end(args); /* this is a call to the syslog */ -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html