diff --git a/src/mk/SunOS b/src/mk/SunOS index 784c0960..e47c760e 100644 --- a/src/mk/SunOS +++ b/src/mk/SunOS @@ -1,7 +1,8 @@ include $(depth)/mk/commondefs include $(depth)/mk/localdefs -ALL_CXXFLAGS = $(CXXFLAGS) $(COMMONCXXFLAGS) $(LOCALCXXFLAGS) +ALL_CXXFLAGS = $(CXXFLAGS) $(COMMONCXXFLAGS) $(LOCALCXXFLAGS) \ + -DSTATFS_INCLUDE="" CC = gcc CXX = g++ diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 357dd44f..91ef1f25 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: pathut.cpp,v 1.16 2007-06-08 15:30:01 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: pathut.cpp,v 1.17 2007-09-08 08:07:05 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -36,6 +36,7 @@ using std::stack; #include "pathut.h" +#include #ifndef STATFS_INCLUDE #define STATFS_INCLUDE #endif @@ -44,10 +45,18 @@ using std::stack; bool fsocc(const string &path, int *pc, long *blocks) { +#ifdef sun + struct statvfs buf; + if (statvfs(path.c_str(), &buf) != 0) { + return false; + } +#else struct statfs buf; if (statfs(path.c_str(), &buf) != 0) { return false; } +#endif + // used blocks double fpc = 0.0; #define FSOCC_USED (double(buf.f_blocks - buf.f_bfree)) diff --git a/src/utils/readfile.cpp b/src/utils/readfile.cpp index 1da657c2..2e37a9d7 100644 --- a/src/utils/readfile.cpp +++ b/src/utils/readfile.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: readfile.cpp,v 1.4 2007-06-02 08:30:42 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: readfile.cpp,v 1.5 2007-09-08 08:07:05 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -32,6 +32,19 @@ using std::string; #include "readfile.h" +static void caterrno(string *reason) +{ + if (reason) { +#ifdef sun + // Note: sun strerror is noted mt-safe ?? + *reason += string("file_to_string: open failed: ") + strerror(errno); +#else + strerror_r(errno, errbuf, ERRBUFSZ); + *reason += string("file_to_string: open failed: ") + errbuf; +#endif + } +} + bool file_to_string(const string &fn, string &data, string *reason) { #define ERRBUFSZ 200 @@ -40,20 +53,14 @@ bool file_to_string(const string &fn, string &data, string *reason) int fd = open(fn.c_str(), O_RDONLY|O_STREAMING); if (fd < 0) { - if (reason) { - strerror_r(errno, errbuf, ERRBUFSZ); - *reason += string("file_to_string: open failed: ") + errbuf; - } + caterrno(reason); return false; } char buf[4096]; for (;;) { int n = read(fd, buf, 4096); if (n < 0) { - if (reason) { - strerror_r(errno, errbuf, ERRBUFSZ); - *reason += string("file_to_string: read failed: ") + errbuf; - } + caterrno(reason); goto out; } if (n == 0) @@ -62,10 +69,7 @@ bool file_to_string(const string &fn, string &data, string *reason) try { data.append(buf, n); } catch (...) { - if (reason) { - strerror_r(errno, errbuf, ERRBUFSZ); - *reason += string("file_to_string: out of memory? : ") +errbuf; - } + caterrno(reason); goto out; } }