From: Bradford C Smith Date: Fri, 27 Jul 2007 19:10:56 GMT Subject: [PATCH 2/2] use make_absolute_path() in lock_file() Message-ID: <1185563460165-git-send-email-bradford.carl.smith@gmail.com> In-Reply-To: <11855634582686-git-send-email-bradford.carl.smith@gmail.com> From: Bradford C. Smith Use make_absolute_path() to get fully resolved path name for creating the lock file. Signed-off-by: Bradford C. Smith --- lockfile.c | 16 +++------------- 1 files changed, 3 insertions(+), 13 deletions(-) diff --git a/lockfile.c b/lockfile.c index 9202472..57f850f 100644 --- a/lockfile.c +++ b/lockfile.c @@ -28,20 +28,10 @@ static void remove_lock_file_on_signal(int signo) static int lock_file(struct lock_file *lk, const char *path) { int fd; - struct stat st; - if ((!lstat(path, &st)) && S_ISLNK(st.st_mode)) { - ssize_t sz; - static char target[PATH_MAX]; - sz = readlink(path, target, sizeof(target)); - if (sz < 0) - warning("Cannot readlink %s", path); - else if (target[0] != '/') - warning("Cannot lock target of relative symlink %s", path); - else - path = target; - } - sprintf(lk->filename, "%s.lock", path); + strcpy(lk->filename, path); + make_absolute_path(lk->filename); + strcat(lk->filename, ".lock"); fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666); if (0 <= fd) { if (!lock_file_list) { -- 1.5.3.rc3.9.g9ef91