diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-05-15 00:22:23 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-05-15 00:22:23 +0000 |
commit | b2bffca2e3b59dd882039e3b0ab835d127bdaf7a (patch) | |
tree | b32fa56b374f7d485b94afe794b82f83e152e26b /locale | |
parent | 848438d4e85c57fe47424113fb3d654f444b5327 (diff) | |
download | glibc-b2bffca2e3b59dd882039e3b0ab835d127bdaf7a.zip glibc-b2bffca2e3b59dd882039e3b0ab835d127bdaf7a.tar.gz glibc-b2bffca2e3b59dd882039e3b0ab835d127bdaf7a.tar.bz2 |
Update.
2002-05-11 Jakub Jelinek <jakub@redhat.com>
* include/netinet/in.h (bindresvport_internal): Add prototype.
* include/rpc/auth.h (authunix_create_internal,
authunix_create_default_internal, authnone_create_internal,
authdes_pk_create_internal): Add prototypes.
* include/rpc/clnt.h (clnt_create_internal, clnttcp_create_internal,
clntudp_create_internal, clntudp_bufcreate_internal,
clntunix_create_internal): Add prototypes.
* include/rpc/svc.h (svc_sendreply_internal, svcerr_decode_internal,
svc_getreq_internal, svc_getreq_common_internal,
svc_getreqset_internal, svc_getreq_poll_internal,
svc_register_internal, svc_unregister_internal,
svcudp_create_internal, svcudp_bufcreate_internal): Add prototypes.
* include/rpc/svc_auth.h (_authenticate_internal): Add prototype.
* include/sys/socket.h (__sendto, __recvfrom, __sendmsg, __recvmsg,
__setsockopt, __getsockname, __bind, __listen): Add prototypes.
* inet/rexec.c (rexec_af): Use __listen and __getsockname.
* inet/rcmd.c (rcmd_af): Use __listen.
(rresvport_af): Use __bind.
* sunrpc/clnt_udp.c: Use INTUSE calls to bindresvport,
authunix_create, authunix_create_default, authnone_create,
authdes_pk_create, clnt_create, clnttcp_create, clntudp_create,
clntudp_bufcreate, clntunix_create svc_sendreply, svcerr_decode,
svc_getreq, svc_getreq_common, svc_getreqset, svc_getreq_poll,
svc_register, svc_unregister, svcudp_create, svcudp_bufcreate,
_authenticate, add INTDEF after such function definitions.
Use __listen, __bind, __sendto, __recvfrom, __sendmsg, __recvmsg,
__setsockopt, __getsockname instead of non-__ variants.
* sunrpc/pmap_rmt.c: Likewise.
* sunrpc/rtime.c: Likewise.
* sunrpc/svc_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/svc_unix.c: Likewise.
* sunrpc/bindrsvprt.c: Likewise.
* sunrpc/svc_tcp.c: Likewise.
* sunrpc/auth_none.c: Likewise.
* sunrpc/clnt_raw.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/auth_unix.c: Likewise.
* sunrpc/key_call.c: Likewise.
* sunrpc/clnt_gen.c: Likewise.
* sunrpc/pm_getmaps.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/pmap_clnt.c: Likewise.
* sunrpc/svc_run.c: Likewise.
* sunrpc/svc.c: Likewise.
* sunrpc/svc_simple.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
* sunrpc/auth_des.c: Likewise.
* sunrpc/svc_auth.c: Likewise.
* sysdeps/generic/unwind-dw2-fde.c (__register_frame_info_bases,
__register_frame_info_table_bases, __deregister_frame_info_bases):
Add INTDEF.
(__register_frame_info_bases_internal,
__register_frame_info_table_bases_internal,
__deregister_frame_info_bases_internal): Add prototypes.
(__register_frame_info, __register_frame): Use INTUSE in call to
__register_frame_info_bases.
(__register_frame_info_table): Similarly.
(__deregister_frame_info, __deregister_frame): Similarly.
* sysdeps/generic/sendto.c (__sendto): Renamed from sendto, add
sendto as weak alias.
* sysdeps/mach/hurd/sendto.c: Likewise.
* sysdeps/generic/recvfrom.c (__recvfrom): Renamed from recvfrom, add
recvfrom as weak alias.
* sysdeps/mach/hurd/recvfrom.c: Likewise.
* sysdeps/unix/sysv/aix/recvfrom.c: Likewise.
* sysdeps/generic/recvmsg.c (__recvmsg): Renamed from recvmsg, add
recvmsg as weak alias.
* sysdeps/unix/sysv/aix/recvmsg.c: Likewise.
* sysdeps/generic/sendmsg.c (__sendmsg): Renamed from sendmsg, add
sendmsg as weak alias.
* sysdeps/unix/sysv/aix/sendmsg.c: Likewise.
* sysdeps/generic/setsockopt.c (__setsockopt): Renamed from
setsockopt, add setsockopt as weak alias.
* sysdeps/mach/hurd/setsockopt.c: Likewise.
* sysdeps/generic/bind.c (__bind): Renamed from bind, add bind as
weak alias.
* sysdeps/mach/hurd/bind.c: Likewise.
* sysdeps/generic/listen.c (__listen): Renamed from listen, add listen
as weak alias.
* sysdeps/mach/hurd/listen.c: Likewise.
* sysdeps/generic/getsockname.c (__getsockname): Renamed from
getsockname, add getsockname as weak alias.
* sysdeps/mach/hurd/getsockname.c: Likewise.
* sysdeps/unix/sysv/aix/getsockname.c: Likewise.
* sysdeps/mach/hurd/recvmsg.c (__recvmsg): Add weak alias.
* sysdeps/mach/hurd/sendmsg.c (__sendmsg): Add weak alias.
* sysdeps/unix/inet/syscalls.list (__bind, __listen, __recvmsg,
__recvfrom, __sendmsg, __sendto, __setsockopt): Add aliases.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (__recvmsg, __sendmsg):
Add aliases.
* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/recvfrom.S (__recvfrom): Add weak alias.
* sysdeps/unix/sysv/linux/recvmsg.S (__recvmsg): Likewise.
* sysdeps/unix/sysv/linux/sendmsg.S (__sendmsg): Likewise.
* sysdeps/unix/sysv/linux/sendto.S (__sendto): Likewise.
* sysdeps/unix/sysv/linux/setsockopt.S (__setsockopt): Likewise.
* sysdeps/unix/sysv/linux/bind.S (__bind): Likewise.
* sysdeps/unix/sysv/linux/listen.S (__listen): Likewise.
* sysdeps/unix/sysv/linux/getsockname.S (__getsockname): Likewise.
2002-05-10 Jakub Jelinek <jakub@redhat.com>
* locale/programs/localedef.h (show_archive_content): Add verbose
argument.
* locale/programs/localedef.c (main): Adjust caller.
* locale/programs/locarchive.c (struct nameent, struct dataent): New.
(nameentcmp, dataentcmp): New functions.
(xstrcmp): Remove.
(show_archive_content): Print verbose listing with --list-archive -v.
* locale/programs/locarchive.c (open_archive): Take extra argument
readonly. If true open file with O_RDONLY and don't create the
archive if it doesn't exist.
Adapt all callers.
(close_archive): Don't do anything if fd element is -1.
* locale/programs/localedef.h (open_archive): Adjust prototype.
* locale/programs/locfile.c (write_all_categories): Adjust open_archive
call.
* malloc/malloc.c (__posix_memalign): Correct check for size of
alignment value [PR libc/3444].
Diffstat (limited to 'locale')
-rw-r--r-- | locale/programs/localedef.c | 2 | ||||
-rw-r--r-- | locale/programs/localedef.h | 4 | ||||
-rw-r--r-- | locale/programs/locarchive.c | 178 | ||||
-rw-r--r-- | locale/programs/locfile.c | 2 |
4 files changed, 160 insertions, 26 deletions
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index 37b52b0..c1d347b 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -202,7 +202,7 @@ main (int argc, char *argv[]) /* Handle a few special cases. */ if (list_archive) - show_archive_content (); + show_archive_content (verbose); if (add_to_archive) return add_locales_to_archive (argc - remaining, &argv[remaining], replace_archive); diff --git a/locale/programs/localedef.h b/locale/programs/localedef.h index 9567845..3217338 100644 --- a/locale/programs/localedef.h +++ b/locale/programs/localedef.h @@ -159,7 +159,7 @@ extern struct localedef_t *load_locale (int locale, const char *name, /* Open the locale archive. */ -extern void open_archive (struct locarhandle *ah); +extern void open_archive (struct locarhandle *ah, bool readonly); /* Close the locale archive. */ extern void close_archive (struct locarhandle *ah); @@ -175,6 +175,6 @@ extern int add_locales_to_archive (size_t nlist, char *list[], bool replace); extern int delete_locales_from_archive (size_t nlist, char *list[]); /* List content of locale archive. */ -extern void show_archive_content (void); +extern void show_archive_content (int verbose); #endif /* localedef.h */ diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index be55147..9ef373a 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -142,7 +142,7 @@ create_archive (const char *archivefname, struct locarhandle *ah) { /* There is already an archive. Must have been a localedef run which happened in parallel. Simply open this file then. */ - open_archive (ah); + open_archive (ah, false); return; } @@ -334,7 +334,7 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) void -open_archive (struct locarhandle *ah) +open_archive (struct locarhandle *ah, bool readonly) { struct stat64 st; struct stat64 st2; @@ -350,13 +350,27 @@ open_archive (struct locarhandle *ah) again: /* Open the archive. We must have exclusive write access. */ - fd = open64 (archivefname, O_RDWR); + fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR); if (fd == -1) { /* Maybe the file does not yet exist. */ if (errno == ENOENT) { - create_archive (archivefname, ah); + if (readonly) + { + static const struct locarhead nullhead = + { + .namehash_used = 0, + .namehash_offset = 0, + .namehash_size = 0 + }; + + ah->addr = (void *) &nullhead; + ah->fd = -1; + } + else + create_archive (archivefname, ah); + return; } else @@ -368,7 +382,7 @@ open_archive (struct locarhandle *ah) error (EXIT_FAILURE, errno, _("cannot stat locale archive \"%s\""), archivefname); - if (lockf64 (fd, F_LOCK, st.st_size) == -1) + if (!readonly && lockf64 (fd, F_LOCK, sizeof (struct locarhead)) == -1) { close (fd); @@ -394,13 +408,17 @@ open_archive (struct locarhandle *ah) || st.st_dev != st2.st_dev || st.st_ino != st2.st_ino) { + (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead)); close (fd); goto again; } /* Read the header. */ if (TEMP_FAILURE_RETRY (read (fd, &head, sizeof (head))) != sizeof (head)) - error (EXIT_FAILURE, errno, _("cannot read archive header")); + { + (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead)); + error (EXIT_FAILURE, errno, _("cannot read archive header")); + } ah->fd = fd; ah->len = (head.sumhash_offset @@ -408,17 +426,24 @@ open_archive (struct locarhandle *ah) /* Now we know how large the administrative information part is. Map all of it. */ - ah->addr = mmap64 (NULL, ah->len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + ah->addr = mmap64 (NULL, ah->len, PROT_READ | (readonly ? 0 : PROT_WRITE), + MAP_SHARED, fd, 0); if (ah->addr == MAP_FAILED) - error (EXIT_FAILURE, errno, _("cannot map archive header")); + { + (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead)); + error (EXIT_FAILURE, errno, _("cannot map archive header")); + } } void close_archive (struct locarhandle *ah) { - munmap (ah->addr, ah->len); - close (ah->fd); + if (ah->fd != -1) + { + munmap (ah->addr, ah->len); + close (ah->fd); + } } @@ -648,7 +673,7 @@ add_locales_to_archive (nlist, list, replace) /* Open the archive. This call never returns if we cannot successfully open the archive. */ - open_archive (&ah); + open_archive (&ah, false); while (nlist-- > 0) { @@ -847,7 +872,7 @@ delete_locales_from_archive (nlist, list) /* Open the archive. This call never returns if we cannot successfully open the archive. */ - open_archive (&ah); + open_archive (&ah, false); head = ah.addr; namehashtab = (struct namehashent *) ((char *) ah.addr @@ -897,30 +922,62 @@ delete_locales_from_archive (nlist, list) } +struct nameent +{ + char *name; + uint32_t locrec_offset; +}; + + +struct dataent +{ + const unsigned char *sum; + uint32_t file_offset; + uint32_t nlink; +}; + + +static int +nameentcmp (const void *a, const void *b) +{ + return strcmp (((const struct nameent *) a)->name, + ((const struct nameent *) b)->name); +} + + static int -xstrcmp (const void *a, const void *b) +dataentcmp (const void *a, const void *b) { - return strcmp (*(const char **) a, *(const char **) b); + if (((const struct dataent *) a)->file_offset + < ((const struct dataent *) b)->file_offset) + return -1; + + if (((const struct dataent *) a)->file_offset + > ((const struct dataent *) b)->file_offset) + return 1; + + return 0; } void -show_archive_content (void) +show_archive_content (int verbose) { struct locarhandle ah; struct locarhead *head; struct namehashent *namehashtab; + struct nameent *names; int cnt; - char **names; int used; /* Open the archive. This call never returns if we cannot successfully open the archive. */ - open_archive (&ah); + open_archive (&ah, true); head = ah.addr; - names = (char **) xmalloc (head->namehash_used * sizeof (char *)); + names = (struct nameent *) xmalloc (head->namehash_used + * sizeof (struct nameent)); namehashtab = (struct namehashent *) ((char *) ah.addr + head->namehash_offset); @@ -928,14 +985,91 @@ show_archive_content (void) if (namehashtab[cnt].locrec_offset != 0) { assert (used < head->namehash_used); - names[used++] = ah.addr + namehashtab[cnt].name_offset; + names[used].name = ah.addr + namehashtab[cnt].name_offset; + names[used++].locrec_offset = namehashtab[cnt].locrec_offset; } /* Sort the names. */ - qsort (names, used, sizeof (char *), xstrcmp); + qsort (names, used, sizeof (struct nameent), nameentcmp); + + if (verbose) + { + struct dataent *files; + struct sumhashent *sumhashtab; + int sumused; + + files = (struct dataent *) xmalloc (head->sumhash_used + * sizeof (struct sumhashent)); + + sumhashtab = (struct sumhashent *) ((char *) ah.addr + + head->sumhash_offset); + for (cnt = sumused = 0; cnt < head->sumhash_size; ++cnt) + if (sumhashtab[cnt].file_offset != 0) + { + assert (sumused < head->sumhash_used); + files[sumused].sum = (const unsigned char *) sumhashtab[cnt].sum; + files[sumused].file_offset = sumhashtab[cnt].file_offset; + files[sumused++].nlink = 0; + } + + /* Sort by file locations. */ + qsort (files, sumused, sizeof (struct dataent), dataentcmp); + + /* Compute nlink fields. */ + for (cnt = 0; cnt < used; ++cnt) + { + struct locrecent *locrec; + int idx; + + locrec = (struct locrecent *) ((char *) ah.addr + + names[cnt].locrec_offset); + for (idx = 0; idx < __LC_LAST; ++idx) + if (idx != LC_ALL) + { + struct dataent *data, dataent; + + dataent.file_offset = locrec->record[idx].offset; + data = (struct dataent *) bsearch (&dataent, files, sumused, + sizeof (struct dataent), + dataentcmp); + assert (data != NULL); + ++data->nlink; + } + } - for (cnt = 0; cnt < used; ++cnt) - puts (names[cnt]); + /* Print it. */ + for (cnt = 0; cnt < used; ++cnt) + { + struct locrecent *locrec; + int idx, i; + + locrec = (struct locrecent *) ((char *) ah.addr + + names[cnt].locrec_offset); + for (idx = 0; idx < __LC_LAST; ++idx) + if (idx != LC_ALL) + { + struct dataent *data, dataent; + + dataent.file_offset = locrec->record[idx].offset; + data = (struct dataent *) bsearch (&dataent, files, sumused, + sizeof (struct dataent), + dataentcmp); + printf ("%6d %7x %3d ", + locrec->record[idx].len, locrec->record[idx].offset, + data->nlink); + for (i = 0; i < 16; i += 4) + printf ("%02x%02x%02x%02x", + data->sum[i], data->sum[i + 1], + data->sum[i + 2], data->sum[i + 3]); + printf (" %s/%s\n", names[cnt].name, + idx == LC_MESSAGES ? "LC_MESSAGES/SYS_LC_MESSAGES" + : locnames[idx]); + } + } + } + else + for (cnt = 0; cnt < used; ++cnt) + puts (names[cnt].name); close_archive (&ah); diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c index 4d978d1..389adf1 100644 --- a/locale/programs/locfile.c +++ b/locale/programs/locfile.c @@ -337,7 +337,7 @@ write_all_categories (struct localedef_t *definitions, /* Open the archive. This call never returns if we cannot successfully open the archive. */ - open_archive (&ah); + open_archive (&ah, false); if (add_locale_to_archive (&ah, locname, to_archive, true) != 0) error (EXIT_FAILURE, errno, _("cannot add to locale archive")); |