olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1296297-1.patch

00db10
Add --list-archive FILE support to localedef.
00db10
00db10
This feature largely supports the integrated work
00db10
for InstLang support, and does not explicitly change
00db10
any help text or behaviour at the API level for these
00db10
routines. The basic purpose is to allow a file name to
00db10
propagate to through the internal APIs to be used instead
00db10
of the default locale archive. Given that build-locale-archive
00db10
links against copies of the internal API it can use these
00db10
non-public APIs without problem.
00db10
00db10
Author: Carlos O'Donell <carlos@redhat.com>
00db10
Date:   Mon Feb 24 22:33:35 2014 -0500
00db10
00db10
    Fix failure load locale template.
00db10
    
00db10
    The call to open_tmpl_archive was being passed a pointer to an
00db10
    object allocated on the stack. The object on the stack is not
00db10
    guaranteed to be initialized to zero so we need to minimally
00db10
    initialize `fname' in the struct locarhandle to ensure that
00db10
    open_tml_archive loads the default tempalte.
00db10
    
00db10
    This error was seen while debugging glibc installs in a qemu
00db10
    VM where it is more likely the stack pages were dirty. It has
00db10
    not been reported on non-VM systems.
00db10
00db10
Author: Carlos O'Donell <carlos@redhat.com>
00db10
Date:   Fri Oct 18 23:27:45 2013 -0400
00db10
00db10
    Allow fill_archive to be called with NULL fname.
00db10
    
00db10
    The fill_archive function should support being
00db10
    called with a NULL fname argument. A NULL fname
00db10
    argument indicates that the default archive should
00db10
    be opened. We enable this by setting ah.fname to
00db10
    NULL before initializing ah or calling open_archive.
00db10
    This way if fname is NULL then ah.fname remains NULL
00db10
    and open_archive opens the default archive.
00db10
00db10
Author: Carlos O'Donell <carlos@redhat.com>
00db10
Date:   Thu Oct 3 05:22:51 2013 -0400
00db10
00db10
[snip]
00db10
    - Support `--list-archive FILE' in localedef utility.
00db10
00db10
This landed upstream in:
00db10
00db10
commit 484c12fb1e3664fb434291234ea5787c5e3df4f5
00db10
Author: Carlos O'Donell <carlos@redhat.com>
00db10
Date:   Fri Oct 18 23:41:30 2013 -0400
00db10
00db10
    Enhance localedef --list-archive option.
00db10
    
00db10
    The localedef --list-archive option claims that it can
00db10
    accept a [file] argument and list the contents of that
00db10
    archive. The support was never implemented. This patch
00db10
    adds that support and allows --list-archive to work as
00db10
    expected. You can now use localedef to list the contents
00db10
    of arbitrary locale archives by using:
00db10
    ./localedef --list-archive file
00db10
00db10
The defaultfname flag was removed there, see
00db10
<https://sourceware.org/ml/libc-alpha/2013-10/msg00127.html>.
00db10
00db10
Index: glibc-2.17-c758a686/locale/locarchive.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/locale/locarchive.h
00db10
+++ glibc-2.17-c758a686/locale/locarchive.h
00db10
@@ -80,6 +80,8 @@ struct locrecent
00db10
 
00db10
 struct locarhandle
00db10
 {
00db10
+  /* Full path to the locale archive file.  */
00db10
+  const char *fname;
00db10
   int fd;
00db10
   void *addr;
00db10
   size_t mmaped;
00db10
Index: glibc-2.17-c758a686/locale/programs/localedef.c
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/locale/programs/localedef.c
00db10
+++ glibc-2.17-c758a686/locale/programs/localedef.c
00db10
@@ -202,7 +202,7 @@ main (int argc, char *argv[])
00db10
 
00db10
   /* Handle a few special cases.  */
00db10
   if (list_archive)
00db10
-    show_archive_content (verbose);
00db10
+    show_archive_content (remaining > 1 ? argv[remaining] : NULL, verbose);
00db10
   if (add_to_archive)
00db10
     return add_locales_to_archive (argc - remaining, &argv[remaining],
00db10
 				   replace_archive);
00db10
Index: glibc-2.17-c758a686/locale/programs/localedef.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/locale/programs/localedef.h
00db10
+++ glibc-2.17-c758a686/locale/programs/localedef.h
00db10
@@ -176,7 +176,8 @@ extern int add_locales_to_archive (size_
00db10
 /* Removed named locales from archive.  */
00db10
 extern int delete_locales_from_archive (size_t nlist, char *list[]);
00db10
 
00db10
-/* List content of locale archive.  */
00db10
-extern void show_archive_content (int verbose) __attribute__ ((noreturn));
00db10
+/* List content of locale archive. If FNAME is non-null use that as
00db10
+   the locale archive to list, otherwise the default.  */
00db10
+extern void show_archive_content (char *fname, int verbose) __attribute__ ((noreturn));
00db10
 
00db10
 #endif /* localedef.h */
00db10
Index: glibc-2.17-c758a686/locale/programs/locarchive.c
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/locale/programs/locarchive.c
00db10
+++ glibc-2.17-c758a686/locale/programs/locarchive.c
00db10
@@ -197,6 +197,7 @@ create_archive (const char *archivefname
00db10
 	     _("cannot change mode of new locale archive"));
00db10
     }
00db10
 
00db10
+  ah->fname = NULL;
00db10
   ah->fd = fd;
00db10
   ah->addr = p;
00db10
   ah->mmaped = total;
00db10
@@ -519,11 +520,19 @@ open_archive (struct locarhandle *ah, bo
00db10
   struct locarhead head;
00db10
   int retry = 0;
00db10
   size_t prefix_len = output_prefix ? strlen (output_prefix) : 0;
00db10
-  char archivefname[prefix_len + sizeof (ARCHIVE_NAME)];
00db10
-
00db10
-  if (output_prefix)
00db10
-    memcpy (archivefname, output_prefix, prefix_len);
00db10
-  strcpy (archivefname + prefix_len, ARCHIVE_NAME);
00db10
+  char fname[prefix_len + sizeof (ARCHIVE_NAME)];
00db10
+  char *archivefname = ah->fname;
00db10
+  bool defaultfname = false;
00db10
+
00db10
+  /* If ah has a non-NULL fname open that otherwise open the default.  */
00db10
+  if (archivefname == NULL)
00db10
+    {
00db10
+      defaultfname = true;
00db10
+      archivefname = fname;
00db10
+      if (output_prefix)
00db10
+        memcpy (archivefname, output_prefix, prefix_len);
00db10
+      strcpy (archivefname + prefix_len, ARCHIVE_NAME);
00db10
+    }
00db10
 
00db10
   while (1)
00db10
     {
00db10
@@ -531,8 +540,11 @@ open_archive (struct locarhandle *ah, bo
00db10
       fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR);
00db10
       if (fd == -1)
00db10
 	{
00db10
-	  /* Maybe the file does not yet exist.  */
00db10
-	  if (errno == ENOENT)
00db10
+	  /* Maybe the file does not yet exist? If we are opening
00db10
+	     the default locale archive we ignore the failure and
00db10
+	     list an empty archive, otherwise we print an error
00db10
+	     and exit.  */
00db10
+	  if (errno == ENOENT && defaultfname)
00db10
 	    {
00db10
 	      if (readonly)
00db10
 		{
00db10
@@ -1258,6 +1270,7 @@ add_locales_to_archive (nlist, list, rep
00db10
 
00db10
   /* Open the archive.  This call never returns if we cannot
00db10
      successfully open the archive.  */
00db10
+  ah.fname = NULL;
00db10
   open_archive (&ah, false);
00db10
 
00db10
   while (nlist-- > 0)
00db10
@@ -1457,6 +1470,7 @@ delete_locales_from_archive (nlist, list
00db10
 
00db10
   /* Open the archive.  This call never returns if we cannot
00db10
      successfully open the archive.  */
00db10
+  ah.fname = NULL;
00db10
   open_archive (&ah, false);
00db10
 
00db10
   head = ah.addr;
00db10
@@ -1545,7 +1559,7 @@ dataentcmp (const void *a, const void *b
00db10
 
00db10
 
00db10
 void
00db10
-show_archive_content (int verbose)
00db10
+show_archive_content (char *fname, int verbose)
00db10
 {
00db10
   struct locarhandle ah;
00db10
   struct locarhead *head;
00db10
@@ -1555,6 +1569,7 @@ show_archive_content (int verbose)
00db10
 
00db10
   /* Open the archive.  This call never returns if we cannot
00db10
      successfully open the archive.  */
00db10
+  ah.fname = fname;
00db10
   open_archive (&ah, true);
00db10
 
00db10
   head = ah.addr;
00db10
Index: glibc-2.17-c758a686/locale/programs/locfile.c
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/locale/programs/locfile.c
00db10
+++ glibc-2.17-c758a686/locale/programs/locfile.c
00db10
@@ -337,6 +337,7 @@ write_all_categories (struct localedef_t
00db10
 
00db10
       /* Open the archive.  This call never returns if we cannot
00db10
 	 successfully open the archive.  */
00db10
+      ah.fname = NULL;
00db10
       open_archive (&ah, false);
00db10
 
00db10
       if (add_locale_to_archive (&ah, locname, to_archive, true) != 0)