From: ticktock35 Date: Fri, 18 Sep 2009 02:35:00 +0000 (+0000) Subject: Adding error message for the lock file. X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3635a6e7099906551fe89102b4026b387e12a1d1;p=oweals%2Fopkg-lede.git 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 --- 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 #include #include +#include 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; }