Re: [pgsql-hackers-win32] Data directory with trailing [back]slash - Mailing list pgsql-patches

From Andrew Dunstan
Subject Re: [pgsql-hackers-win32] Data directory with trailing [back]slash
Date
Msg-id 40D629FD.1020100@dunslane.net
Whole thread Raw
Responses Re: [pgsql-hackers-win32] Data directory with trailing [back]slash  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: [pgsql-hackers-win32] Data directory with trailing [back]slash  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches

Tom Lane wrote:

>"Magnus Hagander" <mha@sollentuna.net> writes:
>
>
>>It's not possible to start the postmaster on win32 with:
>>postmaster -D d:\pgdata\
>>or
>>postmaster -D d:/pgdata/
>>
>>
>
>Sounds like canonicalize_path() needs to be applied a bit sooner than
>it is.
>
>BTW I think canonicalize_path() is a few bricks shy of a load yet:
>I'm not sure it works well with Windows drive-letters, and it definitely
>will strip significant slashes when given input like '/' or 'C:\'.
>Feel free to fix those problems while at it...
>
>

Or use the attached patch, which I think does it right.

cheers

andrew
Index: src/port/path.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.20
diff -c -r1.20 path.c
*** src/port/path.c    11 Jun 2004 17:09:13 -0000    1.20
--- src/port/path.c    21 Jun 2004 00:19:27 -0000
***************
*** 115,121 ****
--- 115,144 ----
          if (*p == '\\')
              *p = '/';
      }
+
+     /* skip network and drive specifiers for win32 */
+     if (strlen(path) >= 2)
+     {
+         if (path[0] == '/' && path[1] == '/')
+         {
+             /* network drive */
+             path = strstr(path + 2, "/");
+             if (path == NULL)
+                 return;
+         }
+         else if (path[1] == ':' &&
+                  ((path[0] >= 'a' && path[0] <= 'z') ||
+                   (path[0] >= 'A' && path[0] <= 'Z')))
+         {
+             /* local drive */
+             path += 2;
+         }
+     }
+
  #endif
+
+     if (path[0] == '/')            /* don't trim leading '/'. */
+         ++path;

      trim_trailing_separator(path);
  }

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: nested xacts and phantom Xids
Next
From: Tom Lane
Date:
Subject: Re: nested xacts and phantom Xids