pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones



Thanks for the hint. Below is updated diff.

BR,

Zdenek


--- perform.c?rev=1.99  2010-12-12 14:18:38.000000000 +0100
+++ perform.c   2011-08-26 10:23:51.000000000 +0200
@@ -59,7 +59,9 @@
 #include "lib.h"
 #include "add.h"
 #include "version.h"
+#include <dirent.h>

+DIR *dir_pointer;
 struct pkg_meta {
        char *meta_contents;
        char *meta_comment;
@@ -175,11 +177,16 @@
         * Handle the easy case of direct success or
         * pre-existing directory first.
         */
-       if (mkdir(path, 0777) == 0 || errno == EEXIST)
-               return 0;
-       if (errno != ENOENT)
-               return -1;
-
+       dir_pointer = opendir (path);
+       if (dir_pointer == NULL) {
+           if (mkdir(path, 0777) == 0 || errno == EEXIST)
+                   return 0;
+           if (errno != ENOENT)
+                   return -1;
+       }
+       else {
+           (void) closedir (dir_pointer);
+       }
        cur_end = p = xstrdup(path);

        for (;;) {
@@ -202,9 +209,15 @@
                 * ENOENT can only happen if something else races us,
                 * in which case we should better give up.
                 */
-               if (mkdir(p, 0777) == -1 && errno != EEXIST) {
-                       free(p);
-                       return -1;
+               dir_pointer = opendir (p);
+               if (dir_pointer == NULL) {
+                   if (mkdir(p, 0777) == -1 && errno != EEXIST) {
+                           free(p);
+                           return -1;
+                   }
+               }
+               else {
+                   (void) closedir (dir_pointer);
                }
                if (done)
                        break;


Thomas Klausner <wiz%NetBSD.org@localhost> napsal dne 26.08.2011 10:20:06:

>  I think you should only call closedir if dir_pointer is != NULL, i.e.
>  move it in the if statement.
>   Thomas



Home | Main Index | Thread Index | Old Index