New upstream version 2021.6

This commit is contained in:
Simon McVittie committed 2021-12-13 11:29:22 +00:00
commit 3f5d22676d
66 files changed
+3711 -3447

No files matched your search

+1 -1
View File
@@ -261,7 +261,7 @@ text_percent_internal (const char *text,
const guint textlen = MIN (input_textlen, ncolumns - bar_min);
const guint barlen = MIN (MAX_PROGRESSBAR_COLUMNS, ncolumns - (textlen + 1));
if (textlen > 0)
if (text && textlen > 0)
{
fwrite (text, 1, textlen, stdout);
fputc (' ', stdout);
+18
View File
@@ -173,6 +173,24 @@ glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter,
return TRUE;
}
/**
* glnx_dirfd_iterator_rewind:
* @dfd_iter: A directory iterator
*
* Rewind to the beginning of @dfd_iter. The next call to
* glnx_dirfd_iterator_next_dent() will provide the first entry in the
* directory.
*/
void
glnx_dirfd_iterator_rewind (GLnxDirFdIterator *dfd_iter)
{
GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter;
g_return_if_fail (dfd_iter->initialized);
rewinddir (real_dfd_iter->d);
}
/**
* glnx_dirfd_iterator_next_dent_ensure_dtype:
* @dfd_iter: A directory iterator
+1
View File
@@ -66,6 +66,7 @@ gboolean glnx_dirfd_iterator_next_dent_ensure_dtype (GLnxDirFdIterator *dfd_ite
struct dirent **out_dent,
GCancellable *cancellable,
GError **error);
void glnx_dirfd_iterator_rewind (GLnxDirFdIterator *dfd_iter);
void glnx_dirfd_iterator_clear (GLnxDirFdIterator *dfd_iter);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxDirFdIterator, glnx_dirfd_iterator_clear)
+40 -11
View File
@@ -1000,8 +1000,11 @@ glnx_file_copy_at (int src_dfd,
if (glnx_regfile_copy_bytes (src_fd, tmp_dest.fd, (off_t) -1) < 0)
return glnx_throw_errno_prefix (error, "regfile copy");
if (fchown (tmp_dest.fd, src_stbuf->st_uid, src_stbuf->st_gid) != 0)
return glnx_throw_errno_prefix (error, "fchown");
if (!(copyflags & GLNX_FILE_COPY_NOCHOWN))
{
if (fchown (tmp_dest.fd, src_stbuf->st_uid, src_stbuf->st_gid) != 0)
return glnx_throw_errno_prefix (error, "fchown");
}
if (!(copyflags & GLNX_FILE_COPY_NOXATTRS))
{
@@ -1105,6 +1108,11 @@ glnx_file_replace_contents_with_perms_at (int dfd,
{
char *dnbuf = strdupa (subpath);
const char *dn = dirname (dnbuf);
gboolean increasing_mtime = (flags & GLNX_FILE_REPLACE_INCREASING_MTIME) != 0;
gboolean nodatasync = (flags & GLNX_FILE_REPLACE_NODATASYNC) != 0;
gboolean datasync_new = (flags & GLNX_FILE_REPLACE_DATASYNC_NEW) != 0;
struct stat stbuf;
gboolean has_stbuf = FALSE;
dfd = glnx_dirfd_canonicalize (dfd);
@@ -1128,34 +1136,55 @@ glnx_file_replace_contents_with_perms_at (int dfd,
if (glnx_loop_write (tmpf.fd, buf, len) < 0)
return glnx_throw_errno_prefix (error, "write");
if (!(flags & GLNX_FILE_REPLACE_NODATASYNC))
if (!nodatasync || increasing_mtime)
{
struct stat stbuf;
gboolean do_sync;
if (!glnx_fstatat_allow_noent (dfd, subpath, &stbuf, AT_SYMLINK_NOFOLLOW, error))
return FALSE;
if (errno == ENOENT)
do_sync = (flags & GLNX_FILE_REPLACE_DATASYNC_NEW) > 0;
has_stbuf = errno != ENOENT;
}
if (!nodatasync)
{
gboolean do_sync;
if (!has_stbuf)
do_sync = datasync_new;
else
do_sync = TRUE;
if (do_sync)
{
if (fdatasync (tmpf.fd) != 0)
if (TEMP_FAILURE_RETRY (fdatasync (tmpf.fd)) != 0)
return glnx_throw_errno_prefix (error, "fdatasync");
}
}
if (uid != (uid_t) -1)
{
if (fchown (tmpf.fd, uid, gid) != 0)
if (TEMP_FAILURE_RETRY (fchown (tmpf.fd, uid, gid)) != 0)
return glnx_throw_errno_prefix (error, "fchown");
}
if (fchmod (tmpf.fd, mode) != 0)
if (TEMP_FAILURE_RETRY (fchmod (tmpf.fd, mode)) != 0)
return glnx_throw_errno_prefix (error, "fchmod");
if (increasing_mtime && has_stbuf)
{
struct stat fd_stbuf;
if (fstat (tmpf.fd, &fd_stbuf) != 0)
return glnx_throw_errno_prefix (error, "fstat");
/* We want to ensure that the new file has a st_mtime (i.e. the second precision)
* is incrementing to avoid mtime check issues when files change often.
*/
if (fd_stbuf.st_mtime <= stbuf.st_mtime)
{
struct timespec ts[2] = { {0, UTIME_OMIT}, {stbuf.st_mtime + 1, 0} };
if (TEMP_FAILURE_RETRY (futimens (tmpf.fd, ts)) != 0)
return glnx_throw_errno_prefix (error, "futimens");
}
}
if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_REPLACE,
dfd, subpath, error))
return FALSE;
+6 -3
View File
@@ -43,7 +43,7 @@ G_BEGIN_DECLS
static inline
const char *glnx_basename (const char *path)
{
gchar *base = strrchr (path, G_DIR_SEPARATOR);
const gchar *base = strrchr (path, G_DIR_SEPARATOR);
if (base)
return base + 1;
@@ -55,7 +55,7 @@ const char *glnx_basename (const char *path)
static inline void
glnx_stdio_file_cleanup (void *filep)
{
FILE *f = filep;
FILE *f = (FILE*)filep;
if (f)
fclose (f);
}
@@ -143,12 +143,14 @@ glnx_file_get_contents_utf8_at (int dfd,
* GLnxFileReplaceFlags:
* @GLNX_FILE_REPLACE_DATASYNC_NEW: Call fdatasync() even if the file did not exist
* @GLNX_FILE_REPLACE_NODATASYNC: Never call fdatasync()
* @GLNX_FILE_REPLACE_INCREASING_MTIME: Ensure that st_mtime increases (in second precision)
*
* Flags controlling file replacement.
*/
typedef enum {
GLNX_FILE_REPLACE_DATASYNC_NEW = (1 << 0),
GLNX_FILE_REPLACE_NODATASYNC = (1 << 1),
GLNX_FILE_REPLACE_INCREASING_MTIME = (1 << 2),
} GLnxFileReplaceFlags;
gboolean
@@ -187,7 +189,8 @@ glnx_regfile_copy_bytes (int fdf, int fdt, off_t max_bytes);
typedef enum {
GLNX_FILE_COPY_OVERWRITE = (1 << 0),
GLNX_FILE_COPY_NOXATTRS = (1 << 1),
GLNX_FILE_COPY_DATASYNC = (1 << 2)
GLNX_FILE_COPY_DATASYNC = (1 << 2),
GLNX_FILE_COPY_NOCHOWN = (1 << 3)
} GLnxFileCopyFlags;
gboolean
+2 -2
View File
@@ -52,7 +52,7 @@ G_BEGIN_DECLS
unsigned _i_; \
for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
_len_ += strlen(_appendees_[_i_]); \
_p_ = _d_ = alloca(_len_ + 1); \
_p_ = _d_ = (char*) alloca(_len_ + 1); \
for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
_p_ = stpcpy(_p_, _appendees_[_i_]); \
*_p_ = 0; \
@@ -136,7 +136,7 @@ G_BEGIN_DECLS
guard && ({ g_hash_table_iter_init (&it, ht), TRUE; }); \
guard = FALSE) \
for (kt k; guard; guard = FALSE) \
for (vt v; g_hash_table_iter_next (&it, (gpointer)&k, (gpointer)&v);)
for (vt v; g_hash_table_iter_next (&it, (void**)&k, (void**)&v);)
/* Cleaner method to iterate over a GHashTable. I.e. rather than
+1 -1
View File
@@ -181,7 +181,7 @@ get_xattrs_impl (const char *path,
{
if (errno == ERANGE)
{
g_free (xattr_names);
g_free (g_steal_pointer (&xattr_names));
goto again;
}
glnx_set_prefix_error_from_errno (error, "%s", "llistxattr");