Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > initdb mkdir_p() doesn't work
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 31st May 12:50
andrew
External User
 
Posts: 1
Default initdb mkdir_p() doesn't work



I don't remember why the code is the way it is. The failure appears to
be before we ever get to mkdir_p(). I can't see any reason right now why
we can't call mkdir_p() in all cases. The attached patch does that (and
makes the code slightly simpler as a result). I tested it with one
element and 2 element existant and nonexistant paths, and it appeared to
work for all of them.

cheers

andrew


? .deps
? initdb
Index: initdb.c
================================================== =================
RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.11
diff -c -w -r1.11 initdb.c
*** initdb.c 17 Nov 2003 20:35:28 -0000 1.11
--- initdb.c 23 Nov 2003 19:46:56 -0000
***************
*** 797,803 ****
mkdatadir(char *subdir)
{
char *path;
- int res;

path = xmalloc(strlen(pg_data) + 2 +
(subdir == NULL ? 0 : strlen(subdir)));
--- 797,802 ----
***************
*** 807,819 ****
else
strcpy(path, pg_data);

! res = mkdir(path, 0700);
! if (res == 0)
! return true;
! else if (subdir == NULL || errno != ENOENT)
! return false;
! else
! return !mkdir_p(path, 0700);
}


--- 806,812 ----
else
strcpy(path, pg_data);

! return (mkdir_p(path, 0700) == 0);
}


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
  Reply With Quote


  sponsored links


2 31st May 12:50
andrew
External User
 
Posts: 1
Default initdb mkdir_p() doesn't work



I don't remember why the code is the way it is. The failure appears to
be before we ever get to mkdir_p(). I can't see any reason right now why
we can't call mkdir_p() in all cases. The attached patch does that (and
makes the code slightly simpler as a result). I tested it with one
element and 2 element existant and nonexistant paths, and it appeared to
work for all of them.

cheers

andrew


? .deps
? initdb
Index: initdb.c
================================================== =================
RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.11
diff -c -w -r1.11 initdb.c
*** initdb.c 17 Nov 2003 20:35:28 -0000 1.11
--- initdb.c 23 Nov 2003 19:46:56 -0000
***************
*** 797,803 ****
mkdatadir(char *subdir)
{
char *path;
- int res;

path = xmalloc(strlen(pg_data) + 2 +
(subdir == NULL ? 0 : strlen(subdir)));
--- 797,802 ----
***************
*** 807,819 ****
else
strcpy(path, pg_data);

! res = mkdir(path, 0700);
! if (res == 0)
! return true;
! else if (subdir == NULL || errno != ENOENT)
! return false;
! else
! return !mkdir_p(path, 0700);
}


--- 806,812 ----
else
strcpy(path, pg_data);

! return (mkdir_p(path, 0700) == 0);
}


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
  Reply With Quote
3 9th June 22:07
pgman
External User
 
Posts: 1
Default initdb mkdir_p() doesn't work


Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666