ports/174020: initdb will not run on a mounted FS with a snapshot directory

Allen Landsidel landsidel.allen at gmail.com
Fri Nov 30 18:10:00 UTC 2012


>Number:         174020
>Category:       ports
>Synopsis:       initdb will not run on a mounted FS with a snapshot directory
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 30 18:10:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Allen Landsidel
>Release:        9.1-PRERELEASE
>Organization:
>Environment:
FreeBSD labdb01.concord.local 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0: Thu Nov  8 17:16:43 UTC 2012     root at prodx-master.concord.local:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
The PostGreSQL initdb utility checks that the target data directory specified with -D is empty, and fails if it is not, with no option to override.  This causes initdb to fail when used on a data directory that is a filesystem mount point if it contains a dump snapshot directory (".snap" directory).

Adding initdb options is well beyond the scope of a port patch.  I thought this simple workaround may be acceptable.
>How-To-Repeat:
Create a fresh filesystem, mount it at /usr/local/pgsql, and attempt to run initdb.
>Fix:
Tell initdb to ignore the ".snap" directory as it does for "." and ".." already.

OR

Add an option to initdb that allows it to run on a data directory that is not empty.

For the first option, this simple patch to pgcheckdir.c does the trick:

--------------- cut
--- pgcheckdir.c.orig   2012-11-30 17:22:16.000000000 +0000
+++ pgcheckdir.c        2012-11-30 17:22:58.000000000 +0000
@@ -42,7 +42,8 @@
        while ((file = readdir(chkdir)) != NULL)
        {
                if (strcmp(".", file->d_name) == 0 ||
-                       strcmp("..", file->d_name) == 0)
+                       strcmp("..", file->d_name) == 0 ||
+                       strcmp(".snap", file->d_name) == 0)
                {
                        /* skip this and parent directory */
                        continue;
--------------- cut


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-ports-bugs mailing list