mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Update from Gnulib by running admin/merge-gnulib
This commit is contained in:
parent
5289c2b3eb
commit
f836452beb
9 changed files with 66 additions and 62 deletions
|
|
@ -29,7 +29,10 @@
|
||||||
|
|
||||||
#include "acl-internal.h"
|
#include "acl-internal.h"
|
||||||
|
|
||||||
|
#include "minmax.h"
|
||||||
|
|
||||||
#if USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR
|
#if USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR
|
||||||
|
# include <stdckdint.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
# include <sys/xattr.h>
|
# include <sys/xattr.h>
|
||||||
|
|
@ -181,32 +184,44 @@ file_has_acl (char const *name, struct stat const *sb)
|
||||||
&& errno == ERANGE)
|
&& errno == ERANGE)
|
||||||
{
|
{
|
||||||
free (heapbuf);
|
free (heapbuf);
|
||||||
listbufsize = listxattr (name, NULL, 0);
|
ssize_t newsize = listxattr (name, NULL, 0);
|
||||||
if (listbufsize < 0)
|
if (newsize <= 0)
|
||||||
return -1;
|
return newsize;
|
||||||
if (SIZE_MAX < listbufsize)
|
|
||||||
|
/* Grow LISTBUFSIZE to at least NEWSIZE. Grow it by a
|
||||||
|
nontrivial amount too, to defend against denial of
|
||||||
|
service by an adversary that fiddles with ACLs. */
|
||||||
|
bool overflow = ckd_add (&listbufsize, listbufsize, listbufsize >> 1);
|
||||||
|
listbufsize = MAX (listbufsize, newsize);
|
||||||
|
if (overflow || SIZE_MAX < listbufsize)
|
||||||
{
|
{
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
listbuf = heapbuf = malloc (listbufsize);
|
listbuf = heapbuf = malloc (listbufsize);
|
||||||
if (!listbuf)
|
if (!listbuf)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* In Fedora 39, a file can have both NFSv4 and POSIX ACLs,
|
||||||
|
but if it has an NFSv4 ACL that's the one that matters.
|
||||||
|
In earlier Fedora the two types of ACLs were mutually exclusive.
|
||||||
|
Attempt to work correctly on both kinds of systems. */
|
||||||
|
bool nfsv4_acl
|
||||||
|
= 0 < listsize && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize);
|
||||||
int ret
|
int ret
|
||||||
= (listsize < 0 ? -1
|
= (listsize <= 0 ? listsize
|
||||||
: (have_xattr (XATTR_NAME_POSIX_ACL_ACCESS, listbuf, listsize)
|
: (nfsv4_acl
|
||||||
|
|| have_xattr (XATTR_NAME_POSIX_ACL_ACCESS, listbuf, listsize)
|
||||||
|| (S_ISDIR (sb->st_mode)
|
|| (S_ISDIR (sb->st_mode)
|
||||||
&& have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT,
|
&& have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT,
|
||||||
listbuf, listsize))));
|
listbuf, listsize))));
|
||||||
bool nfsv4_acl_but_no_posix_acl
|
|
||||||
= ret == 0 && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize);
|
|
||||||
free (heapbuf);
|
free (heapbuf);
|
||||||
|
|
||||||
/* If there is an NFSv4 ACL but no POSIX ACL, follow up with a
|
/* If there is an NFSv4 ACL, follow up with a getxattr syscall
|
||||||
getxattr syscall to see whether the NFSv4 ACL is nontrivial. */
|
to see whether the NFSv4 ACL is nontrivial. */
|
||||||
if (nfsv4_acl_but_no_posix_acl)
|
if (nfsv4_acl)
|
||||||
{
|
{
|
||||||
ret = getxattr (name, XATTR_NAME_NFSV4_ACL,
|
ret = getxattr (name, XATTR_NAME_NFSV4_ACL,
|
||||||
stackbuf.xattr, sizeof stackbuf.xattr);
|
stackbuf.xattr, sizeof stackbuf.xattr);
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ gettime (struct timespec *ts)
|
||||||
#else
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday (&tv, NULL);
|
gettimeofday (&tv, NULL);
|
||||||
ts->tv_sec = tv.tv_sec;
|
*ts = (struct timespec) { .tv_sec = tv.tv_sec,
|
||||||
ts->tv_nsec = tv.tv_usec * 1000;
|
.tv_nsec = tv.tv_usec * 1000 };
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,10 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
|
||||||
ULONGLONG since_1970 =
|
ULONGLONG since_1970 =
|
||||||
since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000;
|
since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000;
|
||||||
ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10;
|
ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10;
|
||||||
tv->tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000;
|
*tv = (struct timeval) {
|
||||||
tv->tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000;
|
.tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000,
|
||||||
|
.tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000
|
||||||
|
};
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -127,10 +129,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
|
||||||
struct timeval otv;
|
struct timeval otv;
|
||||||
int result = gettimeofday (&otv, (struct timezone *) tz);
|
int result = gettimeofday (&otv, (struct timezone *) tz);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
*tv = otv;
|
||||||
tv->tv_sec = otv.tv_sec;
|
|
||||||
tv->tv_usec = otv.tv_usec;
|
|
||||||
}
|
|
||||||
# else
|
# else
|
||||||
int result = gettimeofday (tv, (struct timezone *) tz);
|
int result = gettimeofday (tv, (struct timezone *) tz);
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -143,8 +142,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
|
||||||
# error "Only 1-second nominal clock resolution found. Is that intended?" \
|
# error "Only 1-second nominal clock resolution found. Is that intended?" \
|
||||||
"If so, compile with the -DOK_TO_USE_1S_CLOCK option."
|
"If so, compile with the -DOK_TO_USE_1S_CLOCK option."
|
||||||
# endif
|
# endif
|
||||||
tv->tv_sec = time (NULL);
|
*tv = (struct timeval) { .tv_sec = time (NULL), .tv_usec = 0 };
|
||||||
tv->tv_usec = 0;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@ nanosleep (const struct timespec *requested_delay,
|
||||||
static_assert (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
|
static_assert (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
|
||||||
const time_t limit = 24 * 24 * 60 * 60;
|
const time_t limit = 24 * 24 * 60 * 60;
|
||||||
time_t seconds = requested_delay->tv_sec;
|
time_t seconds = requested_delay->tv_sec;
|
||||||
struct timespec intermediate;
|
struct timespec intermediate = *requested_delay;
|
||||||
intermediate.tv_nsec = requested_delay->tv_nsec;
|
|
||||||
|
|
||||||
while (limit < seconds)
|
while (limit < seconds)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,10 @@ pselect (int nfds, fd_set *restrict rfds,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tv.tv_sec = timeout->tv_sec;
|
tv = (struct timeval) {
|
||||||
tv.tv_usec = (timeout->tv_nsec + 999) / 1000;
|
.tv_sec = timeout->tv_sec,
|
||||||
|
.tv_usec = (timeout->tv_nsec + 999) / 1000
|
||||||
|
};
|
||||||
tvp = &tv;
|
tvp = &tv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -122,10 +122,8 @@ get_stat_atime (struct stat const *st)
|
||||||
#ifdef STAT_TIMESPEC
|
#ifdef STAT_TIMESPEC
|
||||||
return STAT_TIMESPEC (st, st_atim);
|
return STAT_TIMESPEC (st, st_atim);
|
||||||
#else
|
#else
|
||||||
struct timespec t;
|
return (struct timespec) { .tv_sec = st->st_atime,
|
||||||
t.tv_sec = st->st_atime;
|
.tv_nsec = get_stat_atime_ns (st) };
|
||||||
t.tv_nsec = get_stat_atime_ns (st);
|
|
||||||
return t;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,10 +134,8 @@ get_stat_ctime (struct stat const *st)
|
||||||
#ifdef STAT_TIMESPEC
|
#ifdef STAT_TIMESPEC
|
||||||
return STAT_TIMESPEC (st, st_ctim);
|
return STAT_TIMESPEC (st, st_ctim);
|
||||||
#else
|
#else
|
||||||
struct timespec t;
|
return (struct timespec) { .tv_sec = st->st_ctime,
|
||||||
t.tv_sec = st->st_ctime;
|
.tv_nsec = get_stat_ctime_ns (st) };
|
||||||
t.tv_nsec = get_stat_ctime_ns (st);
|
|
||||||
return t;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,10 +146,8 @@ get_stat_mtime (struct stat const *st)
|
||||||
#ifdef STAT_TIMESPEC
|
#ifdef STAT_TIMESPEC
|
||||||
return STAT_TIMESPEC (st, st_mtim);
|
return STAT_TIMESPEC (st, st_mtim);
|
||||||
#else
|
#else
|
||||||
struct timespec t;
|
return (struct timespec) { .tv_sec = st->st_mtime,
|
||||||
t.tv_sec = st->st_mtime;
|
.tv_nsec = get_stat_mtime_ns (st) };
|
||||||
t.tv_nsec = get_stat_mtime_ns (st);
|
|
||||||
return t;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,8 +162,8 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
|
||||||
|| defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
|
|| defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
|
||||||
t = STAT_TIMESPEC (st, st_birthtim);
|
t = STAT_TIMESPEC (st, st_birthtim);
|
||||||
#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
|
#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
|
||||||
t.tv_sec = st->st_birthtime;
|
t = (struct timespec) { .tv_sec = st->st_birthtime,
|
||||||
t.tv_nsec = st->st_birthtimensec;
|
.tv_nsec = st->st_birthtimensec };
|
||||||
#elif defined _WIN32 && ! defined __CYGWIN__
|
#elif defined _WIN32 && ! defined __CYGWIN__
|
||||||
/* Native Windows platforms (but not Cygwin) put the "file creation
|
/* Native Windows platforms (but not Cygwin) put the "file creation
|
||||||
time" in st_ctime (!). See
|
time" in st_ctime (!). See
|
||||||
|
|
@ -177,13 +171,11 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
|
||||||
# if _GL_WINDOWS_STAT_TIMESPEC
|
# if _GL_WINDOWS_STAT_TIMESPEC
|
||||||
t = st->st_ctim;
|
t = st->st_ctim;
|
||||||
# else
|
# else
|
||||||
t.tv_sec = st->st_ctime;
|
t = (struct timespec) { .tv_sec = st->st_ctime };
|
||||||
t.tv_nsec = 0;
|
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
/* Birth time is not supported. */
|
/* Birth time is not supported. */
|
||||||
t.tv_sec = -1;
|
t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 };
|
||||||
t.tv_nsec = -1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
|
#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
|
||||||
|
|
@ -195,10 +187,7 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
|
||||||
sometimes returns junk in the birth time fields; work around this
|
sometimes returns junk in the birth time fields; work around this
|
||||||
bug if it is detected. */
|
bug if it is detected. */
|
||||||
if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
|
if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
|
||||||
{
|
t = (struct timespec) { .tv_sec = -1, .tv_nsec = -1 };
|
||||||
t.tv_sec = -1;
|
|
||||||
t.tv_nsec = -1;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,7 @@ enum { LOG10_TIMESPEC_RESOLUTION = LOG10_TIMESPEC_HZ };
|
||||||
_GL_TIMESPEC_INLINE struct timespec
|
_GL_TIMESPEC_INLINE struct timespec
|
||||||
make_timespec (time_t s, long int ns)
|
make_timespec (time_t s, long int ns)
|
||||||
{
|
{
|
||||||
struct timespec r;
|
return (struct timespec) { .tv_sec = s, .tv_nsec = ns };
|
||||||
r.tv_sec = s;
|
|
||||||
r.tv_nsec = ns;
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return negative, zero, positive if A < B, A == B, A > B, respectively. */
|
/* Return negative, zero, positive if A < B, A == B, A > B, respectively. */
|
||||||
|
|
|
||||||
|
|
@ -405,10 +405,10 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
|
||||||
struct timeval *t;
|
struct timeval *t;
|
||||||
if (ts)
|
if (ts)
|
||||||
{
|
{
|
||||||
timeval[0].tv_sec = ts[0].tv_sec;
|
timeval[0] = (struct timeval) { .tv_sec = ts[0].tv_sec,
|
||||||
timeval[0].tv_usec = ts[0].tv_nsec / 1000;
|
.tv_usec = ts[0].tv_nsec / 1000 };
|
||||||
timeval[1].tv_sec = ts[1].tv_sec;
|
timeval[1] = (struct timeval) { .tv_sec = ts[1].tv_sec,
|
||||||
timeval[1].tv_usec = ts[1].tv_nsec / 1000;
|
.tv_usec = ts[1].tv_nsec / 1000 };
|
||||||
t = timeval;
|
t = timeval;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -502,8 +502,8 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
|
||||||
struct utimbuf *ut;
|
struct utimbuf *ut;
|
||||||
if (ts)
|
if (ts)
|
||||||
{
|
{
|
||||||
utimbuf.actime = ts[0].tv_sec;
|
utimbuf = (struct utimbuf) { .actime = ts[0].tv_sec,
|
||||||
utimbuf.modtime = ts[1].tv_sec;
|
.modtime = ts[1].tv_sec };
|
||||||
ut = &utimbuf;
|
ut = &utimbuf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -621,10 +621,10 @@ lutimens (char const *file, struct timespec const timespec[2])
|
||||||
int result;
|
int result;
|
||||||
if (ts)
|
if (ts)
|
||||||
{
|
{
|
||||||
timeval[0].tv_sec = ts[0].tv_sec;
|
timeval[0] = (struct timeval) { .tv_sec = ts[0].tv_sec,
|
||||||
timeval[0].tv_usec = ts[0].tv_nsec / 1000;
|
.tv_usec = ts[0].tv_nsec / 1000 };
|
||||||
timeval[1].tv_sec = ts[1].tv_sec;
|
timeval[1] = (struct timeval) { .tv_sec = ts[1].tv_sec,
|
||||||
timeval[1].tv_usec = ts[1].tv_nsec / 1000;
|
.tv_usec = ts[1].tv_nsec / 1000 };
|
||||||
t = timeval;
|
t = timeval;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# gnulib-common.m4 serial 86
|
# gnulib-common.m4 serial 87
|
||||||
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
|
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
|
@ -1053,6 +1053,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
|
||||||
dnl -Wno-float-conversion >= 4.9 >= 3.9
|
dnl -Wno-float-conversion >= 4.9 >= 3.9
|
||||||
dnl -Wno-float-equal >= 3 >= 3.9
|
dnl -Wno-float-equal >= 3 >= 3.9
|
||||||
dnl -Wimplicit-fallthrough >= 7 >= 3.9
|
dnl -Wimplicit-fallthrough >= 7 >= 3.9
|
||||||
|
dnl -Wno-missing-field-initializers >= 4.0, < 11
|
||||||
dnl -Wno-pedantic >= 4.8 >= 3.9
|
dnl -Wno-pedantic >= 4.8 >= 3.9
|
||||||
dnl -Wno-sign-compare >= 3 >= 3.9
|
dnl -Wno-sign-compare >= 3 >= 3.9
|
||||||
dnl -Wno-sign-conversion >= 4.3 >= 3.9
|
dnl -Wno-sign-conversion >= 4.3 >= 3.9
|
||||||
|
|
@ -1078,6 +1079,9 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
|
||||||
#if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
#if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||||
-Wimplicit-fallthrough
|
-Wimplicit-fallthrough
|
||||||
#endif
|
#endif
|
||||||
|
#if __GNUC__ >= 4 && __GNUC__ < 11 && !defined __clang__
|
||||||
|
-Wno-missing-field-initializers
|
||||||
|
#endif
|
||||||
#if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
#if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||||
-Wno-pedantic
|
-Wno-pedantic
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue