diff options
author | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-09-17 22:35:00 (EDT) |
---|---|---|
committer | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-09-17 22:35:00 (EDT) |
commit | 3635a6e7099906551fe89102b4026b387e12a1d1 (patch) | |
tree | 6ed296ec1007a289a2efa294f0b9a5bc10de599f | |
parent | 37c40a63c9990377512c6345a32b3b645d1f29a4 (diff) |
Adding error message for the lock file.
pkg just says "Could not obtain administrative lock" and provides no
further info when it encounters problems with the lock file. The
attached
patch makes these errors a bit easier to diagnose.
Thanks to cconroy
http://code.google.com/p/opkg/issues/detail?id=22
git-svn-id: http://opkg.googlecode.com/svn/trunk@216 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r-- | libopkg/opkg_conf.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c index fbbd2b2..4d1306e 100644 --- a/libopkg/opkg_conf.c +++ b/libopkg/opkg_conf.c @@ -32,6 +32,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <errno.h> extern char *conf_file_dir; @@ -108,6 +109,7 @@ static void opkg_conf_free_string(char **conf_str) int opkg_conf_init(opkg_conf_t *conf, const args_t *args) { int err; + int errno_copy; char *tmp_dir_base; nv_pair_list_t tmp_dest_nv_pair_list; char *lists_dir = NULL, *lock_file = NULL; @@ -135,12 +137,19 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args) conf->lock_fd = creat (lock_file, S_IRUSR | S_IWUSR | S_IRGRP); err = lockf (conf->lock_fd, F_TLOCK, 0); + errno_copy = errno; free (lock_file); if (err) { - opkg_message (conf, OPKG_ERROR, "Could not obtain administrative lock\n"); + if(args->offline_root) { + opkg_message (conf, OPKG_ERROR, "Could not obtain administrative lock for offline root (ERR: %s) at %s/%s/lock\n", + strerror(errno_copy), args->offline_root, OPKG_STATE_DIR_PREFIX); + } else { + opkg_message (conf, OPKG_ERROR, "Could not obtain administrative lock (ERR: %s) at %s/lock\n", + strerror(errno_copy), OPKG_STATE_DIR_PREFIX); + } return OPKG_CONF_ERR_LOCK; } |