public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: get_nt_native_path: allow to append suffix
Date: Tue, 25 May 2021 14:56:15 +0000 (GMT)	[thread overview]
Message-ID: <20210525145615.65896393BC2F@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=15c96f2b2660d7a7776c61c9dc78d64262918955

commit 15c96f2b2660d7a7776c61c9dc78d64262918955
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue May 25 16:24:58 2021 +0200

    Cygwin: get_nt_native_path: allow to append suffix
    
    POSIX message queues will be moved into NTFS streams.
    Extend get_nt_native_path to provide a filename suffix which is not
    subject to special character transposition, to allow specifying
    a colon.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/path.cc | 8 +++++++-
 winsup/cygwin/path.h  | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index b8850a11a..2b480131a 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -502,8 +502,10 @@ path_conv::set_nt_native_path (PUNICODE_STRING new_path)
   uni_path.Buffer = wide_path;
 }
 
+/* If suffix is not NULL, append the suffix string verbatim.
+   This is used by fhandler_mqueue::mq_open to append an NTFS stream suffix. */
 PUNICODE_STRING
-path_conv::get_nt_native_path ()
+path_conv::get_nt_native_path (PUNICODE_STRING suffix)
 {
   PUNICODE_STRING res;
   if (wide_path)
@@ -514,9 +516,13 @@ path_conv::get_nt_native_path ()
     {
       uni_path.Length = 0;
       uni_path.MaximumLength = (strlen (path) + 10) * sizeof (WCHAR);
+      if (suffix)
+	uni_path.MaximumLength += suffix->Length;
       wide_path = (PWCHAR) cmalloc_abort (HEAP_STR, uni_path.MaximumLength);
       uni_path.Buffer = wide_path;
       ::get_nt_native_path (path, uni_path, has_dos_filenames_only ());
+      if (suffix)
+	RtlAppendUnicodeStringToString (&uni_path, suffix);
       res = &uni_path;
     }
   return res;
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index fe4dd5478..adb0ca11f 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -282,7 +282,7 @@ class path_conv
   ~path_conv ();
   inline const char *get_win32 () const { return path; }
   void set_nt_native_path (PUNICODE_STRING);
-  PUNICODE_STRING get_nt_native_path ();
+  PUNICODE_STRING get_nt_native_path (PUNICODE_STRING = NULL);
   inline POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
 					     SECURITY_ATTRIBUTES &sa)
   {


                 reply	other threads:[~2021-05-25 14:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210525145615.65896393BC2F@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).