diff options
author | Dan McGee <dan@archlinux.org> | 2011-02-28 17:43:36 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-02-28 17:43:36 +0100 |
commit | 5ea4706f57e15de23a5fd36eff3bc4619aeac224 (patch) | |
tree | e2183dab0dc35c7acfbb0a519655fa1a308b24d3 /lib/libalpm/util.c | |
parent | 1eccae3d9349a4366f511910f64870027a7fd2d7 (diff) | |
download | pacman-5ea4706f57e15de23a5fd36eff3bc4619aeac224.tar.gz pacman-5ea4706f57e15de23a5fd36eff3bc4619aeac224.tar.xz |
Move locking functions to where they are needed
We only call these from the transaction init and teardown, so move them
to that file, mark them static, and push more of the logic of handle
manipulation into these functions.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r-- | lib/libalpm/util.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 149a7f80..9281f0e6 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -28,7 +28,6 @@ #include <stdlib.h> #include <stdarg.h> #include <string.h> -#include <fcntl.h> #include <unistd.h> #include <ctype.h> #include <dirent.h> @@ -210,45 +209,6 @@ char *_alpm_strtrim(char *str) return(str); } -/* Create a lock file */ -FILE *_alpm_lckmk(void) -{ - int fd; - char *dir, *ptr; - const char *file = alpm_option_get_lockfile(); - - /* create the dir of the lockfile first */ - dir = strdup(file); - ptr = strrchr(dir, '/'); - if(ptr) { - *ptr = '\0'; - } - _alpm_makepath(dir); - FREE(dir); - - do { - fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000); - } while (fd == -1 && errno == EINTR); - if(fd > 0) { - FILE *f = fdopen(fd, "w"); - fprintf(f, "%ld\n", (long)getpid()); - fflush(f); - fsync(fd); - return(f); - } - return(NULL); -} - -/* Remove a lock file */ -int _alpm_lckrm(void) -{ - const char *file = alpm_option_get_lockfile(); - if(unlink(file) == -1 && errno != ENOENT) { - return(-1); - } - return(0); -} - /* Compression functions */ /** |