From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id DDBF8382E82F; Thu, 4 Mar 2021 11:33:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDBF8382E82F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/y2038] locale: Use LFS and 64 bit time_t for installed programs X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/y2038 X-Git-Oldrev: e813b6f8e9b9ba4aa13a6ec10d1ece4f24def67a X-Git-Newrev: de0df0e8ff67c75426bb3c71bac22bdf4a89e9a8 Message-Id: <20210304113320.DDBF8382E82F@sourceware.org> Date: Thu, 4 Mar 2021 11:33:20 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Mar 2021 11:33:21 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=de0df0e8ff67c75426bb3c71bac22bdf4a89e9a8 commit de0df0e8ff67c75426bb3c71bac22bdf4a89e9a8 Author: Adhemerval Zanella Date: Tue Mar 2 17:17:59 2021 -0300 locale: Use LFS and 64 bit time_t for installed programs It is enabled for locale and localedef. Diff: --- locale/Makefile | 9 +++++ locale/programs/charmap-dir.c | 12 +++---- locale/programs/locale.c | 26 +++++++------- locale/programs/locarchive.c | 80 +++++++++++++++++++++---------------------- locale/programs/locfile.c | 24 ++++++------- 5 files changed, 80 insertions(+), 71 deletions(-) diff --git a/locale/Makefile b/locale/Makefile index b7c60681fa..6d082ac13c 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -81,6 +81,15 @@ $(objpfx)localedef: $(localedef-aux:%=$(objpfx)%.o) $(objpfx)locale: $(locale-modules:%=$(objpfx)%.o) $(objpfx)localedef $(objpfx)locale: $(lib-modules:%=$(objpfx)%.o) +include $(o-iterator) +define o-iterator-doit +$(foreach f,$(localedef-modules) $(localedef-aux) $(locale-modules) \ + $(lib-modules),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 +endef +object-suffixes-left := $(all-object-suffixes) +include $(o-iterator) + + $(objpfx)C-translit.h: C-translit.h.in gen-translit.py $(make-target-directory) $(PYTHON) gen-translit.py < $< > $@.tmp diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c index 4841bfd05d..2b7131dcdd 100644 --- a/locale/programs/charmap-dir.c +++ b/locale/programs/charmap-dir.c @@ -86,13 +86,13 @@ charmap_readdir (CHARMAP_DIR *cdir) { for (;;) { - struct dirent64 *dirent; + struct dirent *dirent; size_t len; size_t size; char *filename; mode_t mode; - dirent = readdir64 (cdir->dir); + dirent = readdir (cdir->dir); if (dirent == NULL) return NULL; if (strcmp (dirent->d_name, ".") == 0) @@ -119,9 +119,9 @@ charmap_readdir (CHARMAP_DIR *cdir) mode = DTTOIF (dirent->d_type); else { - struct stat64 statbuf; + struct stat statbuf; - if (stat64 (cdir->pathname, &statbuf) < 0) + if (stat (cdir->pathname, &statbuf) < 0) continue; mode = statbuf.st_mode; @@ -165,10 +165,10 @@ fopen_uncompressed (const char *pathname, const char *compressor) pfd = open (pathname, O_RDONLY); if (pfd >= 0) { - struct stat64 statbuf; + struct stat statbuf; int fd[2]; - if (fstat64 (pfd, &statbuf) >= 0 + if (fstat (pfd, &statbuf) >= 0 && S_ISREG (statbuf.st_mode) && pipe (fd) >= 0) { diff --git a/locale/programs/locale.c b/locale/programs/locale.c index 575b208e82..a47790f167 100644 --- a/locale/programs/locale.c +++ b/locale/programs/locale.c @@ -321,14 +321,14 @@ select_dirs (const struct dirent *dirent) mode = DTTOIF (dirent->d_type); else { - struct stat64 st; + struct stat st; char buf[sizeof (COMPLOCALEDIR) + strlen (dirent->d_name) + 1]; stpcpy (stpcpy (stpcpy (buf, COMPLOCALEDIR), "/"), dirent->d_name); - if (stat64 (buf, &st) == 0) + if (stat (buf, &st) == 0) mode = st.st_mode; } @@ -453,7 +453,7 @@ write_locales (void) + strlen (dirents[cnt]->d_name) + sizeof "/LC_IDENTIFICATION"]; char *enddir; - struct stat64 st; + struct stat st; stpcpy (enddir = stpcpy (stpcpy (stpcpy (buf, COMPLOCALEDIR), @@ -461,7 +461,7 @@ write_locales (void) dirents[cnt]->d_name), "/LC_IDENTIFICATION"); - if (stat64 (buf, &st) == 0 && S_ISREG (st.st_mode)) + if (stat (buf, &st) == 0 && S_ISREG (st.st_mode)) { if (verbose && GET (dirents[cnt]->d_name) == NULL) { @@ -477,10 +477,10 @@ write_locales (void) dirents[cnt]->d_name, (int) (enddir - buf), buf, linebuf); - fd = open64 (buf, O_RDONLY); + fd = open (buf, O_RDONLY); if (fd != -1) { - void *mapped = mmap64 (NULL, st.st_size, PROT_READ, + void *mapped = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if (mapped != MAP_FAILED) { @@ -493,9 +493,9 @@ write_locales (void) /* Now try to get the charset information. */ strcpy (enddir, "/LC_CTYPE"); - fd = open64 (buf, O_RDONLY); - if (fd != -1 && fstat64 (fd, &st) >= 0 - && ((mapped = mmap64 (NULL, st.st_size, PROT_READ, + fd = open (buf, O_RDONLY); + if (fd != -1 && fstat (fd, &st) >= 0 + && ((mapped = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) != MAP_FAILED)) { @@ -636,7 +636,7 @@ nameentcmp (const void *a, const void *b) static int write_archive_locales (void **all_datap, char *linebuf) { - struct stat64 st; + struct stat st; void *all_data = *all_datap; size_t len = 0; struct locarhead *head; @@ -645,15 +645,15 @@ write_archive_locales (void **all_datap, char *linebuf) int fd, ret = 0; uint32_t cnt; - fd = open64 (ARCHIVE_NAME, O_RDONLY); + fd = open (ARCHIVE_NAME, O_RDONLY); if (fd < 0) return 0; - if (fstat64 (fd, &st) < 0 || st.st_size < sizeof (*head)) + if (fstat (fd, &st) < 0 || st.st_size < sizeof (*head)) goto error_out; len = st.st_size; - addr = mmap64 (NULL, len, PROT_READ, MAP_SHARED, fd, 0); + addr = mmap (NULL, len, PROT_READ, MAP_SHARED, fd, 0); if (addr == MAP_FAILED) goto error_out; diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index 6bb189ae37..13bfc6fe1f 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -95,7 +95,7 @@ prepare_address_space (int fd, size_t total, size_t *reserved, int *xflags, { if (total < RESERVE_MMAP_SIZE) { - void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_SHARED, fd, 0); + void *p = mmap (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_SHARED, fd, 0); if (p != MAP_FAILED) { void *aligned_p = PTR_ALIGN_UP (p, MAP_FIXED_ALIGNMENT); @@ -167,7 +167,7 @@ create_archive (const char *archivefname, struct locarhandle *ah) error (EXIT_FAILURE, errval, _("cannot initialize archive file")); } - if (ftruncate64 (fd, total) != 0) + if (ftruncate (fd, total) != 0) { int errval = errno; unlink (fname); @@ -181,7 +181,7 @@ create_archive (const char *archivefname, struct locarhandle *ah) &mmap_len); /* Map the header and all the administration data structures. */ - p = mmap64 (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); + p = mmap (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); if (p == MAP_FAILED) { int errval = errno; @@ -292,17 +292,17 @@ file_data_available_p (struct locarhandle *ah, uint32_t offset, uint32_t size) if (offset < ah->mmaped && offset + size <= ah->mmaped) return true; - struct stat64 st; - if (fstat64 (ah->fd, &st) != 0) + struct stat st; + if (fstat (ah->fd, &st) != 0) return false; if (st.st_size > ah->reserved) return false; size_t start = ALIGN_DOWN (ah->mmaped, MAP_FIXED_ALIGNMENT); - void *p = mmap64 (ah->addr + start, st.st_size - start, - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - ah->fd, start); + void *p = mmap (ah->addr + start, st.st_size - start, + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, + ah->fd, start); if (p == MAP_FAILED) { ah->mmaped = start; @@ -332,7 +332,7 @@ compare_from_file (struct locarhandle *ah, void *p1, uint32_t offset2, static void enlarge_archive (struct locarhandle *ah, const struct locarhead *head) { - struct stat64 st; + struct stat st; int fd; struct locarhead newhead; size_t total; @@ -350,12 +350,12 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) /* Not all of the old file has to be mapped. Change this now this we will have to access the whole content. */ - if (fstat64 (ah->fd, &st) != 0) + if (fstat (ah->fd, &st) != 0) enomap: error (EXIT_FAILURE, errno, _("cannot map locale archive file")); if (st.st_size < ah->reserved) - ah->addr = mmap64 (ah->addr, st.st_size, PROT_READ | PROT_WRITE, + ah->addr = mmap (ah->addr, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, ah->fd, 0); else { @@ -363,7 +363,7 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) munmap (ah->mmap_base, ah->mmap_len); else munmap (ah->addr, ah->reserved); - ah->addr = mmap64 (NULL, st.st_size, PROT_READ | PROT_WRITE, + ah->addr = mmap (NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, ah->fd, 0); ah->reserved = st.st_size; ah->mmap_base = NULL; @@ -430,7 +430,7 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) error (EXIT_FAILURE, errval, _("cannot initialize archive file")); } - if (ftruncate64 (fd, total) != 0) + if (ftruncate (fd, total) != 0) { int errval = errno; unlink (fname); @@ -444,7 +444,7 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) &mmap_len); /* Map the header and all the administration data structures. */ - p = mmap64 (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); + p = mmap (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); if (p == MAP_FAILED) { int errval = errno; @@ -453,7 +453,7 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) } /* Lock the new file. */ - if (lockf64 (fd, F_LOCK, total) != 0) + if (lockf (fd, F_LOCK, total) != 0) { int errval = errno; unlink (fname); @@ -557,8 +557,8 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) void open_archive (struct locarhandle *ah, bool readonly) { - struct stat64 st; - struct stat64 st2; + struct stat st; + struct stat st2; int fd; struct locarhead head; int retry = 0; @@ -578,7 +578,7 @@ open_archive (struct locarhandle *ah, bool readonly) while (1) { /* Open the archive. We must have exclusive write access. */ - fd = open64 (archivefname, readonly ? O_RDONLY : O_RDWR); + fd = open (archivefname, readonly ? O_RDONLY : O_RDWR); if (fd == -1) { /* Maybe the file does not yet exist? If we are opening @@ -609,11 +609,11 @@ open_archive (struct locarhandle *ah, bool readonly) archivefname); } - if (fstat64 (fd, &st) < 0) + if (fstat (fd, &st) < 0) error (EXIT_FAILURE, errno, _("cannot stat locale archive \"%s\""), archivefname); - if (!readonly && lockf64 (fd, F_LOCK, sizeof (struct locarhead)) == -1) + if (!readonly && lockf (fd, F_LOCK, sizeof (struct locarhead)) == -1) { close (fd); @@ -635,11 +635,11 @@ open_archive (struct locarhandle *ah, bool readonly) /* One more check. Maybe another process replaced the archive file with a new, larger one since we opened the file. */ - if (stat64 (archivefname, &st2) == -1 + if (stat (archivefname, &st2) == -1 || st.st_dev != st2.st_dev || st.st_ino != st2.st_ino) { - (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead)); + (void) lockf (fd, F_ULOCK, sizeof (struct locarhead)); close (fd); continue; } @@ -651,7 +651,7 @@ open_archive (struct locarhandle *ah, bool readonly) /* Read the header. */ if (TEMP_FAILURE_RETRY (read (fd, &head, sizeof (head))) != sizeof (head)) { - (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead)); + (void) lockf (fd, F_ULOCK, sizeof (struct locarhead)); error (EXIT_FAILURE, errno, _("cannot read archive header")); } @@ -666,11 +666,11 @@ open_archive (struct locarhandle *ah, bool readonly) /* Map the entire file. We might need to compare the category data in the file with the newly added data. */ - ah->addr = mmap64 (p, st.st_size, PROT_READ | (readonly ? 0 : PROT_WRITE), + ah->addr = mmap (p, st.st_size, PROT_READ | (readonly ? 0 : PROT_WRITE), MAP_SHARED | xflags, fd, 0); if (ah->addr == MAP_FAILED) { - (void) lockf64 (fd, F_ULOCK, sizeof (struct locarhead)); + (void) lockf (fd, F_ULOCK, sizeof (struct locarhead)); error (EXIT_FAILURE, errno, _("cannot map archive header")); } ah->reserved = reserved; @@ -845,7 +845,7 @@ add_locale (struct locarhandle *ah, struct namehashent *namehashent; unsigned int incr; struct locrecent *locrecent; - off64_t lastoffset; + off_t lastoffset; char *ptr; struct locale_category_data *size_order[__LC_LAST]; /* Page size alignment is a minor optimization for locality; use a @@ -995,11 +995,11 @@ add_locale (struct locarhandle *ah, { /* The data for this section is not yet available in the archive. Append it. */ - off64_t lastpos; + off_t lastpos; uint32_t md5hval; - lastpos = lseek64 (ah->fd, 0, SEEK_END); - if (lastpos == (off64_t) -1) + lastpos = lseek (ah->fd, 0, SEEK_END); + if (lastpos == (off_t) -1) error (EXIT_FAILURE, errno, _("cannot add to locale archive")); /* If block of small categories would cross page boundary, @@ -1340,9 +1340,9 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) { const char *fname = *list++; size_t fnamelen = strlen (fname); - struct stat64 st; + struct stat st; DIR *dirp; - struct dirent64 *d; + struct dirent *d; int seen; locale_data_t data; int cnt; @@ -1352,7 +1352,7 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) /* First see whether this really is a directory and whether it contains all the require locale category files. */ - if (stat64 (fname, &st) < 0) + if (stat (fname, &st) < 0) { error (0, 0, _("stat of \"%s\" failed: %s: ignored"), fname, strerror (errno)); @@ -1373,7 +1373,7 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) } seen = 0; - while ((d = readdir64 (dirp)) != NULL) + while ((d = readdir (dirp)) != NULL) { for (cnt = 0; cnt < __LC_LAST; ++cnt) if (cnt != LC_ALL) @@ -1396,7 +1396,7 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) strcpy (stpcpy (stpcpy (fullname, fname), "/"), d->d_name); - if (stat64 (fullname, &st) == -1) + if (stat (fullname, &st) == -1) /* We cannot stat the file, ignore it. */ break; @@ -1413,7 +1413,7 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) strcpy (stpcpy (stpcpy (t, d->d_name), "/SYS_"), d->d_name); - if (stat64 (fullname, &st) == -1) + if (stat (fullname, &st) == -1) /* There is no SYS_* file or we cannot access it. */ break; @@ -1449,8 +1449,8 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) int fd; strcpy (stpcpy (stpcpy (fullname, fname), "/"), locnames[cnt]); - fd = open64 (fullname, O_RDONLY); - if (fd == -1 || fstat64 (fd, &st) == -1) + fd = open (fullname, O_RDONLY); + if (fd == -1 || fstat (fd, &st) == -1) { /* Cannot read the file. */ if (fd != -1) @@ -1466,8 +1466,8 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) strcpy (stpcpy (stpcpy (t, locnames[cnt]), "/SYS_"), locnames[cnt]); - fd = open64 (fullname, O_RDONLY); - if (fd == -1 || fstat64 (fd, &st) == -1 + fd = open (fullname, O_RDONLY); + if (fd == -1 || fstat (fd, &st) == -1 || !S_ISREG (st.st_mode)) { if (fd != -1) @@ -1477,7 +1477,7 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace) } /* Map the file. */ - data[cnt].addr = mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED, + data[cnt].addr = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if (data[cnt].addr == MAP_FAILED) { diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c index 0f1affa1d4..d8b493dcff 100644 --- a/locale/programs/locfile.c +++ b/locale/programs/locfile.c @@ -362,7 +362,7 @@ siblings_uncached (const char *output_path) { size_t len; char *base, *p; - struct stat64 output_stat; + struct stat output_stat; DIR *dirp; int nelems; const char **elems; @@ -385,7 +385,7 @@ siblings_uncached (const char *output_path) len = p - base; /* Get the properties of output_path. */ - if (lstat64 (output_path, &output_stat) < 0 || !S_ISDIR (output_stat.st_mode)) + if (lstat (output_path, &output_stat) < 0 || !S_ISDIR (output_stat.st_mode)) return NULL; /* Iterate through the directories in base directory. */ @@ -396,12 +396,12 @@ siblings_uncached (const char *output_path) elems = NULL; for (;;) { - struct dirent64 *other_dentry; + struct dirent *other_dentry; const char *other_name; char *other_path; - struct stat64 other_stat; + struct stat other_stat; - other_dentry = readdir64 (dirp); + other_dentry = readdir (dirp); if (other_dentry == NULL) break; @@ -414,7 +414,7 @@ siblings_uncached (const char *output_path) other_path[len] = '/'; strcpy (other_path + len + 1, other_name); - if (lstat64 (other_path, &other_stat) >= 0 + if (lstat (other_path, &other_stat) >= 0 && S_ISDIR (other_stat.st_mode) && other_stat.st_uid == output_stat.st_uid && other_stat.st_gid == output_stat.st_gid @@ -755,9 +755,9 @@ write_locale_data (const char *output_path, int catidx, const char *category, fd = -2; if (strcmp (category, "LC_MESSAGES") == 0) { - struct stat64 st; + struct stat st; - if (stat64 (fname, &st) < 0) + if (stat (fname, &st) < 0) { if (mkdir (fname, 0777) >= 0) { @@ -845,9 +845,9 @@ failure while writing data for category `%s'"), category); space usage. */ if (other_paths != NULL) { - struct stat64 fname_stat; + struct stat fname_stat; - if (lstat64 (fname, &fname_stat) >= 0 + if (lstat (fname, &fname_stat) >= 0 && S_ISREG (fname_stat.st_mode)) { const char *fname_tail = fname + strlen (output_path); @@ -866,14 +866,14 @@ failure while writing data for category `%s'"), category); const char *other_path = *other_p; size_t other_path_len = strlen (other_path); char *other_fname; - struct stat64 other_fname_stat; + struct stat other_fname_stat; other_fname = (char *) xmalloc (other_path_len + strlen (fname_tail) + 1); memcpy (other_fname, other_path, other_path_len); strcpy (other_fname + other_path_len, fname_tail); - if (lstat64 (other_fname, &other_fname_stat) >= 0 + if (lstat (other_fname, &other_fname_stat) >= 0 && S_ISREG (other_fname_stat.st_mode) /* Consider only files on the same device. Otherwise hard linking won't work anyway. */