* [PATCH] opensm - address windows env issues
@ 2010-05-25 16:03 Stan C. Smith
[not found] ` <4A4BD5F425D5495387BA92964E2873C8-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Stan C. Smith @ 2010-05-25 16:03 UTC (permalink / raw)
To: 'Sasha Khapyorsky'; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
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.smith-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
--- 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-25 18:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 16:03 [PATCH] opensm - address windows env issues Stan C. Smith
[not found] ` <4A4BD5F425D5495387BA92964E2873C8-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-05-25 18:58 ` Sasha Khapyorsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox