From 0668e010113735594a2c570c6f1d890fed78337f Mon Sep 17 00:00:00 2001
From: Peter Baumann
Date: Thu, 22 Jul 2010 18:40:58 +0200
Subject: PB: file path cleanup, such as removing RMANHOME variable usage
---
server/rasserver_config.cc | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
(limited to 'server')
diff --git a/server/rasserver_config.cc b/server/rasserver_config.cc
index 04745a3..1b5730d 100644
--- a/server/rasserver_config.cc
+++ b/server/rasserver_config.cc
@@ -20,11 +20,6 @@ rasdaman GmbH.
* For more information please see
* or contact Peter Baumann via .
*/
-/*
- * 2003-nov-05 PB makeLogFileName: use constants, use /tmp if RMANHOME env var not defined
- * 2005-sep-05 PB parseCommandLine(): exit -2 on help
- * 2006-apr-21 PB added debug output
- */
using namespace std;
@@ -36,7 +31,7 @@ using namespace std;
#include
#include "debug.hh" // ENTER, LEAVE, TALK
-#include "globals.hh" // DEFAULT_PORT, LOGDIR, ALT_LOGDIR, LOG_SUFFIX
+#include "globals.hh" // DEFAULT_PORT, LOGDIR, LOG_SUFFIX
#include "rasserver_config.hh"
#include "storagemgr/sstoragelayout.hh"
@@ -106,7 +101,7 @@ void Configuration::initParameters()
cmlOptLevel = &cmlInter.addLongParameter(NSN, "opt", " optimization level(0-4)\n\t\t 0 = no / 4 = maximal optimization", 4L);
cmlConnectStr = &cmlInter.addStringParameter(NSN, "connect", " connect string for underlying database(e.g. test/test@julep)", "/");
- cmlLog = &cmlInter.addStringParameter('l', "log", " log is printed to \n\t\tif is stdout , log output is printed to standard out", "$RMANHOME/log/..log");
+ cmlLog = &cmlInter.addStringParameter('l', "log", " log is printed to \n\t\tif is stdout , log output is printed to standard out", string( CONFDIR ).append( "log/..log").c_str() );
cmlTileSize = &cmlInter.addLongParameter(NSN, "tilesize", " specifies maximal size of tiles in bytes\n\t\t-regular tiles with equal edge lengthes", 2097152);
cmlPctMin = &cmlInter.addLongParameter(NSN, "pctmin", " specifies minimal size of blobtiles in bytes", 2048);
@@ -233,22 +228,16 @@ Configuration::initLogFiles()
const char *
Configuration::makeLogFileName(const char *srvName,const char *desExt)
{
- static char buffer[ FILENAME_MAX ];
+ static char logfilePath[ FILENAME_MAX ];
int pid =getpid();
- char *dir = getenv( RMANHOME_VAR );
- if (dir == NULL)
- {
- cout << "Error: environment variable " << RMANHOME_VAR << " not set. Using " << ALT_LOGDIR << " for the moment being." << endl;
- strcpy( buffer, ALT_LOGDIR );
- }
- else
+ mkdir( LOGDIR, S_IRWXU + S_IRGRP+S_IXGRP + S_IROTH+S_IXOTH ); // create if not exist, rwxr-xr-x
+ int pathLen = snprintf( logfilePath, FILENAME_MAX, "%s/%s.%06d.%s", LOGDIR, srvName, pid, desExt );
+ if (pathLen >= FILENAME_MAX)
{
- strcpy( buffer, dir );
- strcat( buffer, LOGDIR );
+ logfilePath[FILENAME_MAX-1] = '\0'; // force-terminate string before printing
+ cerr << "Warning: path name longer than allowed by OS, likely log file cannot be written: " << logfilePath << endl;
}
- mkdir(buffer,S_IRWXU + S_IRGRP+S_IXGRP + S_IROTH+S_IXOTH); // create if not exist, rwxr-xr-x
- sprintf(buffer+strlen(buffer),"/%s.%06d.%s",srvName,pid,desExt);
- return buffer;
+ return logfilePath;
}
void
--
cgit