Re: Use of 'cp -r' in CREATE DATABASE

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Use of 'cp -r' in CREATE DATABASE
Date: 2003-12-12 01:41:36
Message-ID: 200312120141.hBC1faK02810@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan wrote:
> Nigel J. Andrews said:
> > On Thu, 11 Dec 2003, Alvaro Herrera wrote:
> >
> >> On Thu, Dec 11, 2003 at 06:36:05PM -0500, Bruce Momjian wrote:
> >> > Our dbcommands.c has for create database:
> >> >
> >> > snprintf(buf, sizeof(buf), "cp -r '%s' '%s'", src_loc,
> >> > target_dir);
> >> >
> >> [...]
> >> >
> >> > I think we should switch to -R in our code.
> >>
> >> But you will have to write special code for Win32, won't you?
> >> Maybe it would be better to avoid using system commands
> >> altogether and copy the whole thing using syscalls ...
> >
> > That was my immediate thought. Unfortunately that means reinventing the
> > wheel; or grabbing it from BSD or somewhere and distributing it with
> > postgresql.
> >
>
> We need a consistent policy about it, I think. I grabbed some code for a
> recursive mkdir from NetBSD, and it is in initdb.c. But I also wrote a
> recursive rm, and Bruce replaced it with calls to the native utilities
> using system(), for understandable reasons. Maybe we need a small,
> portable, utility library. Or maybe just relying on system utilities is
> acceptable.

From my prespective, the native utilities are better if we can invoke
them portabily because they can handle any OS-specific issues.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2003-12-12 02:08:54 Re: Use of 'cp -r' in CREATE DATABASE
Previous Message Bruce Momjian 2003-12-12 01:05:54 Re: Use of 'cp -r' in CREATE DATABASE