Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 18:05:30 GMT
From:      Allen Landsidel <landsidel.allen@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/174020: initdb will not run on a mounted FS with a snapshot directory
Message-ID:  <201211301805.qAUI5Uu8009396@red.freebsd.org>
Resent-Message-ID: <201211301810.qAUIA0ZV005212@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211301805.qAUI5Uu8009396>