Don't clobber errno, so that we can provide a useful error message.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Thu, 12 Nov 2009 06:26:11 +0000 (06:26 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Thu, 12 Nov 2009 06:26:11 +0000 (06:26 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@288 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_conf.c

index 4b2ad03bbb10498af65cdb2e367528d384bddebc..f67711e298664fd7a5d8d2859004952b1e813517 100644 (file)
@@ -152,8 +152,9 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
      else
        sprintf_alloc (&lock_file, "%s/lock", OPKG_STATE_DIR_PREFIX);
 
-     conf->lock_fd = creat (lock_file, S_IRUSR | S_IWUSR | S_IRGRP);
-     err = lockf (conf->lock_fd, F_TLOCK, 0);
+     err = conf->lock_fd = creat (lock_file, S_IRUSR | S_IWUSR | S_IRGRP);
+     if (err != -1)
+       err = lockf (conf->lock_fd, F_TLOCK, 0);
      errno_copy = errno;
 
      free (lock_file);