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