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
The following reply was made to PR pkg/45289; it has been noted by GNATS.
From: Zdenek Tlusty <tlusty%vse.cz@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: gnats-admin%netbsd.org@localhost,
pkg-manager%netbsd.org@localhost,
pkgsrc-bugs%netbsd.org@localhost
Subject: Re: pkg/45289: Using pkg_add command from pkgsrc on Solaris 10 zones
Date: Fri, 26 Aug 2011 10:26:16 +0200
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