X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;fp=src%2Fcommon%2Futils.c;h=eb1bbbb28aa1d07945c90cd82ddca63d17841216;hb=f9431861198d04bfa0e14cbe65360412de67f40a;hp=bc4f6112f9db4907e18dd9758f2a39105ca0a138;hpb=f03ea3f43450abb1a1ea704044e1e8c78cfc0b4c;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index bc4f6112f..eb1bbbb28 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -264,52 +264,6 @@ error: return ret; } -/* - * Create lock file to the given path and filename. - * Returns the associated file descriptor, -1 on error. - */ -LTTNG_HIDDEN -int utils_create_lock_file(const char *filepath) -{ - int ret; - int fd; - struct flock lock; - - assert(filepath); - - memset(&lock, 0, sizeof(lock)); - fd = open(filepath, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | - S_IRGRP | S_IWGRP); - if (fd < 0) { - PERROR("open lock file %s", filepath); - fd = -1; - goto error; - } - - /* - * Attempt to lock the file. If this fails, there is - * already a process using the same lock file running - * and we should exit. - */ - lock.l_whence = SEEK_SET; - lock.l_type = F_WRLCK; - - ret = fcntl(fd, F_SETLK, &lock); - if (ret == -1) { - PERROR("fcntl lock file"); - ERR("Could not get lock file %s, another instance is running.", - filepath); - if (close(fd)) { - PERROR("close lock file"); - } - fd = ret; - goto error; - } - -error: - return fd; -} - /* * Create directory using the given path and mode. *