logo       


Re: [HACKERS] initdb mkdir_p() doesn't work: msg#00294

Subject: Re: [HACKERS] initdb mkdir_p() doesn't work


Andrew Dunstan wrote:



Peter Eisentraut wrote:

Here is what I get:

peter ~$ pg-install/bin/initdb pg-install/var/data
...
creating directory pg-install/var/data ... initdb: failed

No points for details in the error message here either.

If I create pg-install/var first, then it work.


I will check it out. I know I spent quite some time making sure this worked, but I might have missed something obvious. I wonder if it is platform specific?



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
Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe