diff options
author | Basavanagowda Kanur <gowda@gluster.com> | 2009-07-28 00:52:56 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-07-28 13:25:02 -0700 |
commit | a4c6e7c816fa9dfbed07a30af56a4ada824ce40b (patch) | |
tree | 01f90dbe6d6e8f2d1c54b8e5638e668a8f232ca5 /glusterfsd | |
parent | 8225fd2307d8a5a9bba4f21b5534b8469f679605 (diff) |
glusterfsd: handle logfile path specification appropriately.
when logfile path is not specified as absolute path, the symbolic
link created to the logfile (only in invocation of glusterfs with
--run-id) might end up as a broken symbolic link.
for example, command-line invocation like below will result in
broken symbolic link:
glusterfsd -f /home/glusterfs/volfiles/nufa/nufa.vol
-l ../home/glusterfs/logs/nufa.f1.log --run-id nufatest /mnt/nufa/
symbolic link will be created at $PWD/../home/glusterfs/logs/nufa.f1.log
will have a value of ../home/glusterfs/logs/nufa.f1.log.<date>.<time>.<pid>.
this symlink might be broken.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 156 (Broken symbolic link when relative path is given for a log file)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=156
Diffstat (limited to 'glusterfsd')
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 6f976bacb40..d658c0e090e 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1021,6 +1021,8 @@ main (int argc, char *argv[]) call_pool_t *pool = NULL; struct stat stbuf; char tmp_logfile[1024] = { 0 }; + char *tmp_logfile_dyn = NULL; + char *tmp_logfilebase = NULL; char timestr[256] = { 0 }; time_t utime; struct tm *tm = NULL; @@ -1130,13 +1132,18 @@ main (int argc, char *argv[]) /* Create symlink to actual log file */ unlink (cmd_args->log_file); - ret = symlink (tmp_logfile, cmd_args->log_file); + + tmp_logfile_dyn = strdup (tmp_logfile); + tmp_logfilebase = basename (tmp_logfile_dyn); + ret = symlink (tmp_logfilebase, cmd_args->log_file); if (-1 == ret) { fprintf (stderr, "symlink of logfile failed"); } else { FREE (cmd_args->log_file); cmd_args->log_file = strdup (tmp_logfile); } + + FREE (tmp_logfile_dyn); } } |