Compare commits
2 Commits
imports/c8
...
c8
Author | SHA1 | Date | |
---|---|---|---|
0a7de6811e | |||
|
8acb4d5db4 |
139
SOURCES/1134.patch
Normal file
139
SOURCES/1134.patch
Normal file
@ -0,0 +1,139 @@
|
||||
From 08f5ab3c3a1877e4a8965a9075bd7675f64eae53 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <withnall@endlessm.com>
|
||||
Date: Fri, 27 Sep 2019 14:46:18 +0100
|
||||
Subject: [PATCH 1/2] gfile: Factor out flags when copying files
|
||||
|
||||
This introduces no functional changes; just reduces duplication in the
|
||||
code a little.
|
||||
|
||||
Signed-off-by: Philip Withnall <withnall@endlessm.com>
|
||||
---
|
||||
gio/gfile.c | 15 +++++++++------
|
||||
1 file changed, 9 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/gio/gfile.c b/gio/gfile.c
|
||||
index 29ebaaa62..a617b4cc8 100644
|
||||
--- a/gio/gfile.c
|
||||
+++ b/gio/gfile.c
|
||||
@@ -3184,6 +3184,7 @@ file_copy_fallback (GFile *source,
|
||||
const char *target;
|
||||
char *attrs_to_read;
|
||||
gboolean do_set_attributes = FALSE;
|
||||
+ GFileCreateFlags create_flags;
|
||||
|
||||
/* need to know the file type */
|
||||
info = g_file_query_info (source,
|
||||
@@ -3274,18 +3275,21 @@ file_copy_fallback (GFile *source,
|
||||
* If a future API like g_file_replace_with_info() is added, switch
|
||||
* this code to use that.
|
||||
*/
|
||||
+ create_flags = G_FILE_CREATE_PRIVATE;
|
||||
+ if (flags & G_FILE_COPY_OVERWRITE)
|
||||
+ create_flags |= G_FILE_CREATE_REPLACE_DESTINATION;
|
||||
+
|
||||
if (G_IS_LOCAL_FILE (destination))
|
||||
{
|
||||
if (flags & G_FILE_COPY_OVERWRITE)
|
||||
out = (GOutputStream*)_g_local_file_output_stream_replace (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
|
||||
FALSE, NULL,
|
||||
flags & G_FILE_COPY_BACKUP,
|
||||
- G_FILE_CREATE_REPLACE_DESTINATION |
|
||||
- G_FILE_CREATE_PRIVATE, info,
|
||||
+ create_flags, info,
|
||||
cancellable, error);
|
||||
else
|
||||
out = (GOutputStream*)_g_local_file_output_stream_create (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
|
||||
- FALSE, G_FILE_CREATE_PRIVATE, info,
|
||||
+ FALSE, create_flags, info,
|
||||
cancellable, error);
|
||||
}
|
||||
else if (flags & G_FILE_COPY_OVERWRITE)
|
||||
@@ -3293,13 +3297,12 @@ file_copy_fallback (GFile *source,
|
||||
out = (GOutputStream *)g_file_replace (destination,
|
||||
NULL,
|
||||
flags & G_FILE_COPY_BACKUP,
|
||||
- G_FILE_CREATE_REPLACE_DESTINATION |
|
||||
- G_FILE_CREATE_PRIVATE,
|
||||
+ create_flags,
|
||||
cancellable, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
- out = (GOutputStream *)g_file_create (destination, G_FILE_CREATE_PRIVATE, cancellable, error);
|
||||
+ out = (GOutputStream *)g_file_create (destination, create_flags, cancellable, error);
|
||||
}
|
||||
|
||||
if (!out)
|
||||
--
|
||||
2.37.3
|
||||
|
||||
From b37d628c01da0bd61348b3ac73b7a436af008d8d Mon Sep 17 00:00:00 2001
|
||||
From: Philip Withnall <withnall@endlessm.com>
|
||||
Date: Fri, 27 Sep 2019 15:02:32 +0100
|
||||
Subject: [PATCH 2/2] =?UTF-8?q?gfile:=20Don=E2=80=99t=20copy=20files=20as?=
|
||||
=?UTF-8?q?=20private=20if=20using=20default=20permissions?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
If a copy operation is started with `G_FILE_COPY_TARGET_DEFAULT_PERMS`,
|
||||
don’t create the destination file as private. Instead, create it with
|
||||
the process’ current umask (i.e. ‘default permissions’).
|
||||
|
||||
This is a partial re-work of commit d8f8f4d637ce43f8699ba94c9b, with
|
||||
input from Ondrej Holy.
|
||||
|
||||
Signed-off-by: Philip Withnall <withnall@endlessm.com>
|
||||
|
||||
Fixes: #174
|
||||
---
|
||||
gio/gfile.c | 22 +++++++++++++++++++---
|
||||
1 file changed, 19 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gio/gfile.c b/gio/gfile.c
|
||||
index a617b4cc8..447da3cfb 100644
|
||||
--- a/gio/gfile.c
|
||||
+++ b/gio/gfile.c
|
||||
@@ -3274,8 +3274,22 @@ file_copy_fallback (GFile *source,
|
||||
*
|
||||
* If a future API like g_file_replace_with_info() is added, switch
|
||||
* this code to use that.
|
||||
+ *
|
||||
+ * Use %G_FILE_CREATE_PRIVATE unless
|
||||
+ * - we were told to create the file with default permissions (i.e. the
|
||||
+ * process’ umask),
|
||||
+ * - or if the source file is on a file system which doesn’t support
|
||||
+ * `unix::mode` (in which case it probably also makes sense to create the
|
||||
+ * destination with default permissions because the source cannot be
|
||||
+ * private),
|
||||
+ * - or if the destination file is a `GLocalFile`, in which case we can
|
||||
+ * directly open() it with the permissions from the source file.
|
||||
*/
|
||||
- create_flags = G_FILE_CREATE_PRIVATE;
|
||||
+ create_flags = G_FILE_CREATE_NONE;
|
||||
+ if (!(flags & G_FILE_COPY_TARGET_DEFAULT_PERMS) &&
|
||||
+ g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE) &&
|
||||
+ !G_IS_LOCAL_FILE (destination))
|
||||
+ create_flags |= G_FILE_CREATE_PRIVATE;
|
||||
if (flags & G_FILE_COPY_OVERWRITE)
|
||||
create_flags |= G_FILE_CREATE_REPLACE_DESTINATION;
|
||||
|
||||
@@ -3285,11 +3299,13 @@ file_copy_fallback (GFile *source,
|
||||
out = (GOutputStream*)_g_local_file_output_stream_replace (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
|
||||
FALSE, NULL,
|
||||
flags & G_FILE_COPY_BACKUP,
|
||||
- create_flags, info,
|
||||
+ create_flags,
|
||||
+ (flags & G_FILE_COPY_TARGET_DEFAULT_PERMS) ? NULL : info,
|
||||
cancellable, error);
|
||||
else
|
||||
out = (GOutputStream*)_g_local_file_output_stream_create (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
|
||||
- FALSE, create_flags, info,
|
||||
+ FALSE, create_flags,
|
||||
+ (flags & G_FILE_COPY_TARGET_DEFAULT_PERMS) ? NULL : info,
|
||||
cancellable, error);
|
||||
}
|
||||
else if (flags & G_FILE_COPY_OVERWRITE)
|
||||
--
|
||||
2.37.3
|
||||
|
401
SOURCES/1549.patch
Normal file
401
SOURCES/1549.patch
Normal file
@ -0,0 +1,401 @@
|
||||
From d0821da5244fd08c756a5f84ec0d3063c72d1ac6 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Thu, 26 Apr 2018 10:36:36 +0200
|
||||
Subject: [PATCH] gio: Add g_unix_mount_get_options
|
||||
|
||||
GVfsUDisks2VolumeMonitor handles x-gvfs-hide/x-gvfs-show mount options
|
||||
used to overwrite our heuristics whether the mount should be shown, or
|
||||
hidden. Unfortunately, it works currently only for mounts with
|
||||
corresponding fstab entries, because the options are read over
|
||||
g_unix_mount_point_get_options. Let's introduce g_unix_mount_get_options
|
||||
to allow reading of the options for all sort of mounts (e.g. created
|
||||
over pam_mount, or manually mounted).
|
||||
|
||||
(Minor fixes to the documentation by Philip Withnall
|
||||
<withnall@endlessm.com>.)
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=668132
|
||||
---
|
||||
docs/reference/gio/gio-sections.txt | 1 +
|
||||
gio/gunixmounts.c | 37 +++++++++++++++++++++++++++++
|
||||
gio/gunixmounts.h | 2 ++
|
||||
3 files changed, 40 insertions(+)
|
||||
|
||||
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
|
||||
index 2eb7efc748..0a35f9541b 100644
|
||||
--- a/docs/reference/gio/gio-sections.txt
|
||||
+++ b/docs/reference/gio/gio-sections.txt
|
||||
@@ -1546,6 +1546,7 @@ g_unix_mount_copy
|
||||
g_unix_mount_get_mount_path
|
||||
g_unix_mount_get_device_path
|
||||
g_unix_mount_get_fs_type
|
||||
+g_unix_mount_get_options
|
||||
g_unix_mount_is_readonly
|
||||
g_unix_mount_is_system_internal
|
||||
g_unix_mount_guess_icon
|
||||
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
|
||||
index c74b0cfaf4..f2db27e661 100644
|
||||
--- a/gio/gunixmounts.c
|
||||
+++ b/gio/gunixmounts.c
|
||||
@@ -126,6 +126,7 @@ struct _GUnixMountEntry {
|
||||
char *mount_path;
|
||||
char *device_path;
|
||||
char *filesystem_type;
|
||||
+ char *options;
|
||||
gboolean is_read_only;
|
||||
gboolean is_system_internal;
|
||||
};
|
||||
@@ -412,6 +413,7 @@ static GUnixMountEntry *
|
||||
create_unix_mount_entry (const char *device_path,
|
||||
const char *mount_path,
|
||||
const char *filesystem_type,
|
||||
+ const char *options,
|
||||
gboolean is_read_only)
|
||||
{
|
||||
GUnixMountEntry *mount_entry = NULL;
|
||||
@@ -420,6 +422,7 @@ create_unix_mount_entry (const char *device_path,
|
||||
mount_entry->device_path = g_strdup (device_path);
|
||||
mount_entry->mount_path = g_strdup (mount_path);
|
||||
mount_entry->filesystem_type = g_strdup (filesystem_type);
|
||||
+ mount_entry->options = g_strdup (options);
|
||||
mount_entry->is_read_only = is_read_only;
|
||||
|
||||
mount_entry->is_system_internal =
|
||||
@@ -498,6 +501,7 @@ _g_get_unix_mounts (void)
|
||||
mount_entry = create_unix_mount_entry (device_path,
|
||||
mnt_fs_get_target (fs),
|
||||
mnt_fs_get_fstype (fs),
|
||||
+ mnt_fs_get_options (fs),
|
||||
is_read_only);
|
||||
|
||||
return_list = g_list_prepend (return_list, mount_entry);
|
||||
@@ -592,6 +596,7 @@ _g_get_unix_mounts (void)
|
||||
mount_entry = create_unix_mount_entry (device_path,
|
||||
mntent->mnt_dir,
|
||||
mntent->mnt_type,
|
||||
+ mntent->mnt_opts,
|
||||
is_read_only);
|
||||
|
||||
g_hash_table_insert (mounts_hash,
|
||||
@@ -705,6 +710,7 @@ _g_get_unix_mounts (void)
|
||||
mount_entry = create_unix_mount_entry (mntent.mnt_special,
|
||||
mntent.mnt_mountp,
|
||||
mntent.mnt_fstype,
|
||||
+ mntent.mnt_opts,
|
||||
is_read_only);
|
||||
|
||||
return_list = g_list_prepend (return_list, mount_entry);
|
||||
@@ -771,6 +777,7 @@ _g_get_unix_mounts (void)
|
||||
mount_entry = create_unix_mount_entry (vmt2dataptr (vmount_info, VMT_OBJECT),
|
||||
vmt2dataptr (vmount_info, VMT_STUB),
|
||||
fs_info == NULL ? "unknown" : fs_info->vfsent_name,
|
||||
+ NULL,
|
||||
is_read_only);
|
||||
|
||||
return_list = g_list_prepend (return_list, mount_entry);
|
||||
@@ -846,6 +853,7 @@ _g_get_unix_mounts (void)
|
||||
mount_entry = create_unix_mount_entry (mntent[i].f_mntfromname,
|
||||
mntent[i].f_mntonname,
|
||||
mntent[i].f_fstypename,
|
||||
+ NULL,
|
||||
is_read_only);
|
||||
|
||||
return_list = g_list_prepend (return_list, mount_entry);
|
||||
@@ -1989,6 +1997,7 @@ g_unix_mount_free (GUnixMountEntry *mount_entry)
|
||||
g_free (mount_entry->mount_path);
|
||||
g_free (mount_entry->device_path);
|
||||
g_free (mount_entry->filesystem_type);
|
||||
+ g_free (mount_entry->options);
|
||||
g_free (mount_entry);
|
||||
}
|
||||
|
||||
@@ -2013,6 +2022,7 @@ g_unix_mount_copy (GUnixMountEntry *mount_entry)
|
||||
copy->mount_path = g_strdup (mount_entry->mount_path);
|
||||
copy->device_path = g_strdup (mount_entry->device_path);
|
||||
copy->filesystem_type = g_strdup (mount_entry->filesystem_type);
|
||||
+ copy->options = g_strdup (mount_entry->options);
|
||||
copy->is_read_only = mount_entry->is_read_only;
|
||||
copy->is_system_internal = mount_entry->is_system_internal;
|
||||
|
||||
@@ -2096,6 +2106,10 @@ g_unix_mount_compare (GUnixMountEntry *mount1,
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
+ res = g_strcmp0 (mount1->options, mount2->options);
|
||||
+ if (res != 0)
|
||||
+ return res;
|
||||
+
|
||||
res = mount1->is_read_only - mount2->is_read_only;
|
||||
if (res != 0)
|
||||
return res;
|
||||
@@ -2151,6 +2165,29 @@ g_unix_mount_get_fs_type (GUnixMountEntry *mount_entry)
|
||||
return mount_entry->filesystem_type;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * g_unix_mount_get_options:
|
||||
+ * @mount_entry: a #GUnixMountEntry.
|
||||
+ *
|
||||
+ * Gets a comma-separated list of mount options for the unix mount. For example,
|
||||
+ * `rw,relatime,seclabel,data=ordered`.
|
||||
+ *
|
||||
+ * This is similar to g_unix_mount_point_get_options(), but it takes
|
||||
+ * a #GUnixMountEntry as an argument.
|
||||
+ *
|
||||
+ * Returns: (nullable): a string containing the options, or %NULL if not
|
||||
+ * available.
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+const gchar *
|
||||
+g_unix_mount_get_options (GUnixMountEntry *mount_entry)
|
||||
+{
|
||||
+ g_return_val_if_fail (mount_entry != NULL, NULL);
|
||||
+
|
||||
+ return mount_entry->options;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* g_unix_mount_is_readonly:
|
||||
* @mount_entry: a #GUnixMount.
|
||||
diff --git a/gio/gunixmounts.h b/gio/gunixmounts.h
|
||||
index 04d6b0726b..a392d497f1 100644
|
||||
--- a/gio/gunixmounts.h
|
||||
+++ b/gio/gunixmounts.h
|
||||
@@ -81,6 +81,8 @@ GLIB_AVAILABLE_IN_ALL
|
||||
const char * g_unix_mount_get_device_path (GUnixMountEntry *mount_entry);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
const char * g_unix_mount_get_fs_type (GUnixMountEntry *mount_entry);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+const char * g_unix_mount_get_options (GUnixMountEntry *mount_entry);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
gboolean g_unix_mount_is_readonly (GUnixMountEntry *mount_entry);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
--
|
||||
GitLab
|
||||
|
||||
From 51ec01382137251e08948bbd860a5fbfde41e5ba Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 23 Jun 2020 08:23:16 +0200
|
||||
Subject: [PATCH 1/2] gunixmounts: Add g_unix_mount_point_at
|
||||
|
||||
There is already g_unix_mount_at function which allows to find certain
|
||||
unix mount for given mount path. It would be useful to have similar
|
||||
function for mount points, which will allow to replace custom codes in
|
||||
gvfs. Let's add g_unix_mount_point_at.
|
||||
---
|
||||
docs/reference/gio/gio-sections.txt | 1 +
|
||||
gio/gunixmounts.c | 46 +++++++++++++++++++++++++++++
|
||||
gio/gunixmounts.h | 3 ++
|
||||
3 files changed, 50 insertions(+)
|
||||
|
||||
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
|
||||
index 2eb7efc74..5c9cbc34c 100644
|
||||
--- a/docs/reference/gio/gio-sections.txt
|
||||
+++ b/docs/reference/gio/gio-sections.txt
|
||||
@@ -1568,6 +1568,7 @@ g_unix_mount_point_guess_symbolic_icon
|
||||
g_unix_mount_point_guess_name
|
||||
g_unix_mount_point_guess_can_eject
|
||||
g_unix_mount_points_get
|
||||
+g_unix_mount_point_at
|
||||
g_unix_mounts_get
|
||||
g_unix_mount_at
|
||||
g_unix_mounts_changed_since
|
||||
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
|
||||
index 4d19217ca..144da4d29 100644
|
||||
--- a/gio/gunixmounts.c
|
||||
+++ b/gio/gunixmounts.c
|
||||
@@ -1596,6 +1596,52 @@ g_unix_mount_points_get (guint64 *time_read)
|
||||
return _g_get_unix_mount_points ();
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * g_unix_mount_point_at:
|
||||
+ * @mount_path: (type filename): path for a possible unix mount point.
|
||||
+ * @time_read: (out) (optional): guint64 to contain a timestamp.
|
||||
+ *
|
||||
+ * Gets a #GUnixMountPoint for a given mount path. If @time_read is set, it
|
||||
+ * will be filled with a unix timestamp for checking if the mount points have
|
||||
+ * changed since with g_unix_mount_points_changed_since().
|
||||
+ *
|
||||
+ * If more mount points have the same mount path, the last matching mount point
|
||||
+ * is returned.
|
||||
+ *
|
||||
+ * Returns: (transfer full) (nullable): a #GUnixMountPoint, or %NULL if no match
|
||||
+ * is found.
|
||||
+ *
|
||||
+ * Since: 2.66
|
||||
+ **/
|
||||
+GUnixMountPoint *
|
||||
+g_unix_mount_point_at (const char *mount_path,
|
||||
+ guint64 *time_read)
|
||||
+{
|
||||
+ GList *mount_points, *l;
|
||||
+ GUnixMountPoint *mount_point, *found;
|
||||
+
|
||||
+ mount_points = g_unix_mount_points_get (time_read);
|
||||
+
|
||||
+ found = NULL;
|
||||
+ for (l = mount_points; l != NULL; l = l->next)
|
||||
+ {
|
||||
+ mount_point = l->data;
|
||||
+
|
||||
+ if (strcmp (mount_path, mount_point->mount_path) == 0)
|
||||
+ {
|
||||
+ if (found != NULL)
|
||||
+ g_unix_mount_point_free (found);
|
||||
+
|
||||
+ found = mount_point;
|
||||
+ }
|
||||
+ else
|
||||
+ g_unix_mount_point_free (mount_point);
|
||||
+ }
|
||||
+ g_list_free (mount_points);
|
||||
+
|
||||
+ return found;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* g_unix_mounts_changed_since:
|
||||
* @time: guint64 to contain a timestamp.
|
||||
diff --git a/gio/gunixmounts.h b/gio/gunixmounts.h
|
||||
index 04d6b0726..ab9d3dbb9 100644
|
||||
--- a/gio/gunixmounts.h
|
||||
+++ b/gio/gunixmounts.h
|
||||
@@ -128,6 +128,9 @@ GIcon * g_unix_mount_point_guess_symbolic_icon (GUnixMountPoint *mount
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
GList * g_unix_mount_points_get (guint64 *time_read);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+GUnixMountPoint *g_unix_mount_point_at (const char *mount_path,
|
||||
+ guint64 *time_read);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
GList * g_unix_mounts_get (guint64 *time_read);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
--
|
||||
2.41.0
|
||||
|
||||
From 6daee34fac29df6f182e7e2aa656e0b34bd916a5 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Tue, 23 Jun 2020 08:36:26 +0200
|
||||
Subject: [PATCH 2/2] gfile: Add support for x-gvfs-notrash option to ignore
|
||||
mounts
|
||||
|
||||
Add support for x-gvfs-notrash mount option, which allows to disable
|
||||
trash functionality for certain mounts. This might be especially useful
|
||||
e.g. to prevent trash folder creation on enterprise shares, which are
|
||||
also accessed from Windows...
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1096200
|
||||
---
|
||||
gio/gfile.c | 4 ++-
|
||||
gio/glocalfile.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 66 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gio/gfile.c b/gio/gfile.c
|
||||
index 447da3cfb..43c5c3d74 100644
|
||||
--- a/gio/gfile.c
|
||||
+++ b/gio/gfile.c
|
||||
@@ -4166,7 +4166,9 @@ g_file_delete_finish (GFile *file,
|
||||
* Sends @file to the "Trashcan", if possible. This is similar to
|
||||
* deleting it, but the user can recover it before emptying the trashcan.
|
||||
* Not all file systems support trashing, so this call can return the
|
||||
- * %G_IO_ERROR_NOT_SUPPORTED error.
|
||||
+ * %G_IO_ERROR_NOT_SUPPORTED error. Since GLib 2.66, the `x-gvfs-notrash` unix
|
||||
+ * mount option can be used to disable g_file_trash() support for certain
|
||||
+ * mounts, the %G_IO_ERROR_NOT_SUPPORTED error will be returned in that case.
|
||||
*
|
||||
* If @cancellable is not %NULL, then the operation can be cancelled by
|
||||
* triggering the cancellable object from another thread. If the operation
|
||||
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
|
||||
index e7481454e..cb0ecdafb 100644
|
||||
--- a/gio/glocalfile.c
|
||||
+++ b/gio/glocalfile.c
|
||||
@@ -1858,6 +1858,52 @@ try_make_relative (const char *path,
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
+static gboolean
|
||||
+ignore_trash_mount (GUnixMountEntry *mount)
|
||||
+{
|
||||
+ GUnixMountPoint *mount_point = NULL;
|
||||
+ const gchar *mount_options;
|
||||
+ gboolean retval = TRUE;
|
||||
+
|
||||
+ if (g_unix_mount_is_system_internal (mount))
|
||||
+ return TRUE;
|
||||
+
|
||||
+ mount_options = g_unix_mount_get_options (mount);
|
||||
+ if (mount_options == NULL)
|
||||
+ {
|
||||
+ mount_point = g_unix_mount_point_at (g_unix_mount_get_mount_path (mount),
|
||||
+ NULL);
|
||||
+ if (mount_point != NULL)
|
||||
+ mount_options = g_unix_mount_point_get_options (mount_point);
|
||||
+ }
|
||||
+
|
||||
+ if (mount_options == NULL ||
|
||||
+ strstr (mount_options, "x-gvfs-notrash") == NULL)
|
||||
+ retval = FALSE;
|
||||
+
|
||||
+ g_clear_pointer (&mount_point, g_unix_mount_point_free);
|
||||
+
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+ignore_trash_path (const gchar *topdir)
|
||||
+{
|
||||
+ GUnixMountEntry *mount;
|
||||
+ gboolean retval = TRUE;
|
||||
+
|
||||
+ mount = g_unix_mount_at (topdir, NULL);
|
||||
+ if (mount == NULL)
|
||||
+ goto out;
|
||||
+
|
||||
+ retval = ignore_trash_mount (mount);
|
||||
+
|
||||
+ out:
|
||||
+ g_clear_pointer (&mount, g_unix_mount_free);
|
||||
+
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
gboolean
|
||||
_g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
|
||||
{
|
||||
@@ -1886,6 +1932,13 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
|
||||
if (topdir == NULL)
|
||||
return FALSE;
|
||||
|
||||
+ if (ignore_trash_path (topdir))
|
||||
+ {
|
||||
+ g_free (topdir);
|
||||
+
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
globaldir = g_build_filename (topdir, ".Trash", NULL);
|
||||
if (g_lstat (globaldir, &global_stat) == 0 &&
|
||||
S_ISDIR (global_stat.st_mode) &&
|
||||
@@ -2041,7 +2094,16 @@ g_local_file_trash (GFile *file,
|
||||
file, G_IO_ERROR_NOT_SUPPORTED);
|
||||
return FALSE;
|
||||
}
|
||||
-
|
||||
+
|
||||
+ if (ignore_trash_path (topdir))
|
||||
+ {
|
||||
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
+ _("Trashing on system internal mounts is not supported"));
|
||||
+ g_free (topdir);
|
||||
+
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
/* Try looking for global trash dir $topdir/.Trash/$uid */
|
||||
globaldir = g_build_filename (topdir, ".Trash", NULL);
|
||||
if (g_lstat (globaldir, &global_stat) == 0 &&
|
||||
--
|
||||
2.41.0
|
||||
|
702
SOURCES/54.patch
Normal file
702
SOURCES/54.patch
Normal file
@ -0,0 +1,702 @@
|
||||
From 9e5a53d576765819d1c7c233515b9f6e5d77eb61 Mon Sep 17 00:00:00 2001
|
||||
From: Emmanuele Bassi <ebassi@gnome.org>
|
||||
Date: Wed, 17 Jan 2018 16:38:45 +0000
|
||||
Subject: [PATCH] Add reference counting types
|
||||
|
||||
We have a common pattern for reference counting in GLib, but we always
|
||||
implement it with ad hoc code. This is a good chance at trying to
|
||||
standardise the implementation and make it public, so that other code
|
||||
using GLib can take advantage of shared behaviour and semantics.
|
||||
|
||||
Instead of simply taking an integer variable, we should create type
|
||||
aliases, to immediately distinguish the reference counting semantics of
|
||||
the code; we can handle mixing atomic reference counting with a
|
||||
non-atomic type (and vice versa) by using differently signed values for
|
||||
the atomic and non-atomic cases.
|
||||
|
||||
The gatomicrefcount type is modelled on the Linux kernel refcount_t
|
||||
type; the grefcount type is added to let single-threaded code bases to
|
||||
avoid paying the price of atomic memory barriers on reference counting
|
||||
operations.
|
||||
---
|
||||
docs/reference/glib/glib-docs.xml | 1 +
|
||||
docs/reference/glib/glib-sections.txt | 15 ++
|
||||
glib/Makefile.am | 2 +
|
||||
glib/glib.h | 1 +
|
||||
glib/grefcount.c | 285 ++++++++++++++++++++++++++
|
||||
glib/grefcount.h | 52 +++++
|
||||
glib/gtypes.h | 3 +
|
||||
glib/meson.build | 2 +
|
||||
8 files changed, 361 insertions(+)
|
||||
create mode 100644 glib/grefcount.c
|
||||
create mode 100644 glib/grefcount.h
|
||||
|
||||
diff --git a/docs/reference/glib/glib-docs.xml b/docs/reference/glib/glib-docs.xml
|
||||
index a0716c1727..26cdafb67b 100644
|
||||
--- a/docs/reference/glib/glib-docs.xml
|
||||
+++ b/docs/reference/glib/glib-docs.xml
|
||||
@@ -119,6 +119,7 @@
|
||||
<xi:include href="xml/gvariant.xml"/>
|
||||
<xi:include href="gvariant-varargs.xml"/>
|
||||
<xi:include href="gvariant-text.xml"/>
|
||||
+ <xi:include href="xml/refcount.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter id="deprecated">
|
||||
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
|
||||
index 0183b0898a..331d92c75f 100644
|
||||
--- a/docs/reference/glib/glib-sections.txt
|
||||
+++ b/docs/reference/glib/glib-sections.txt
|
||||
@@ -3449,3 +3449,18 @@ g_hostname_is_ip_address
|
||||
g_uuid_string_is_valid
|
||||
g_uuid_string_random
|
||||
</SECTION>
|
||||
+
|
||||
+<SECTION>
|
||||
+<FILE>refcount</FILE>
|
||||
+grefcount
|
||||
+g_ref_count_init
|
||||
+g_ref_count_inc
|
||||
+g_ref_count_dec
|
||||
+g_ref_count_compare
|
||||
+<SUBSECTION>
|
||||
+gatomicrefcount
|
||||
+g_atomic_ref_count_init
|
||||
+g_atomic_ref_count_inc
|
||||
+g_atomic_ref_count_dec
|
||||
+g_atomic_ref_count_compare
|
||||
+</SECTION>
|
||||
diff --git a/glib/Makefile.am b/glib/Makefile.am
|
||||
index 0497061265..4d04e09daa 100644
|
||||
--- a/glib/Makefile.am
|
||||
+++ b/glib/Makefile.am
|
||||
@@ -149,6 +149,7 @@ libglib_2_0_la_SOURCES = \
|
||||
gquark.c \
|
||||
gqueue.c \
|
||||
grand.c \
|
||||
+ grefcount.c \
|
||||
gregex.c \
|
||||
gscanner.c \
|
||||
gscripttable.h \
|
||||
@@ -284,6 +285,7 @@ glibsubinclude_HEADERS = \
|
||||
gquark.h \
|
||||
gqueue.h \
|
||||
grand.h \
|
||||
+ grefcount.h \
|
||||
gregex.h \
|
||||
gscanner.h \
|
||||
gsequence.h \
|
||||
diff --git a/glib/glib.h b/glib/glib.h
|
||||
index 4f5a7f702f..84299c4f90 100644
|
||||
--- a/glib/glib.h
|
||||
+++ b/glib/glib.h
|
||||
@@ -69,6 +69,7 @@
|
||||
#include <glib/gquark.h>
|
||||
#include <glib/gqueue.h>
|
||||
#include <glib/grand.h>
|
||||
+#include <glib/grefcount.h>
|
||||
#include <glib/gregex.h>
|
||||
#include <glib/gscanner.h>
|
||||
#include <glib/gsequence.h>
|
||||
diff --git a/glib/grefcount.c b/glib/grefcount.c
|
||||
new file mode 100644
|
||||
index 0000000000..10e35a217d
|
||||
--- /dev/null
|
||||
+++ b/glib/grefcount.c
|
||||
@@ -0,0 +1,285 @@
|
||||
+/* grefcount.c: Reference counting
|
||||
+ *
|
||||
+ * Copyright 2018 Emmanuele Bassi
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+/**
|
||||
+ * SECTION:refcount
|
||||
+ * @Title: Reference counting
|
||||
+ * @Short_description: Reference counting types and functions
|
||||
+ *
|
||||
+ * Reference counting is a garbage collection mechanism that is based on
|
||||
+ * assigning a counter to a data type, or any memory area; the counter is
|
||||
+ * increased whenever a new reference to that data type is acquired, and
|
||||
+ * decreased whenever the reference is released. Once the last reference
|
||||
+ * is released, the resources associated to that data type are freed.
|
||||
+ *
|
||||
+ * GLib uses reference counting in many of its data types, and provides
|
||||
+ * the #grefcount and #gatomicrefcount types to implement safe and atomic
|
||||
+ * reference counting semantics in new data types.
|
||||
+ *
|
||||
+ * It is important to note that #grefcount and #gatomicrefcount should be
|
||||
+ * considered completely opaque types; you should always use the provided
|
||||
+ * API to increase and decrease the counters, and you should never check
|
||||
+ * their content directly, or compare their content with other values.
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+
|
||||
+#include "config.h"
|
||||
+
|
||||
+#include "grefcount.h"
|
||||
+
|
||||
+#include "gatomic.h"
|
||||
+#include "gmessages.h"
|
||||
+
|
||||
+/**
|
||||
+ * grefcount:
|
||||
+ *
|
||||
+ * A type for implementing non-atomic reference count semantics.
|
||||
+ *
|
||||
+ * Use g_ref_count_init() to initialize it; g_ref_count_inc() to
|
||||
+ * increase the counter, and g_ref_count_dec() to decrease it.
|
||||
+ *
|
||||
+ * It is safe to use #grefcount only if you're expecting to operate
|
||||
+ * on the reference counter from a single thread. It is entirely up
|
||||
+ * to you to ensure that all reference count changes happen in the
|
||||
+ * same thread.
|
||||
+ *
|
||||
+ * See also: #gatomicrefcount
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+
|
||||
+/**
|
||||
+ * gatomicrefcount:
|
||||
+ *
|
||||
+ * A type for implementing atomic reference count semantics.
|
||||
+ *
|
||||
+ * Use g_atomic_ref_count_init() to initialize it; g_atomic_ref_count_inc()
|
||||
+ * to increase the counter, and g_atomic_ref_count_dec() to decrease it.
|
||||
+ *
|
||||
+ * It is safe to use #gatomicrefcount if you're expecting to operate on the
|
||||
+ * reference counter from multiple threads.
|
||||
+ *
|
||||
+ * See also: #grefcount
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+
|
||||
+/**
|
||||
+ * g_ref_count_init:
|
||||
+ * @rc: the address of a reference count variable
|
||||
+ *
|
||||
+ * Initializes a reference count variable.
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+void
|
||||
+g_ref_count_init (grefcount *rc)
|
||||
+{
|
||||
+ g_return_if_fail (rc != NULL);
|
||||
+
|
||||
+ /* Non-atomic refcounting is implemented using the negative range
|
||||
+ * of signed integers:
|
||||
+ *
|
||||
+ * G_MININT Z¯< 0 > Z⺠G_MAXINT
|
||||
+ * |----------------------------|----------------------------|
|
||||
+ *
|
||||
+ * Acquiring a reference moves us towards MININT, and releasing a
|
||||
+ * reference moves us towards 0.
|
||||
+ */
|
||||
+ *rc = -1;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * g_ref_count_inc:
|
||||
+ * @rc: the address of a reference count variable
|
||||
+ *
|
||||
+ * Increases the reference count.
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+void
|
||||
+g_ref_count_inc (grefcount *rc)
|
||||
+{
|
||||
+ grefcount rrc;
|
||||
+
|
||||
+ g_return_if_fail (rc != NULL);
|
||||
+
|
||||
+ rrc = *rc;
|
||||
+
|
||||
+ g_return_if_fail (rrc < 0);
|
||||
+
|
||||
+ /* Check for saturation */
|
||||
+ if (rrc == G_MININT)
|
||||
+ {
|
||||
+ g_critical ("Reference count %p has reached saturation", rc);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ rrc -= 1;
|
||||
+
|
||||
+ *rc = rrc;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * g_ref_count_dec:
|
||||
+ * @rc: the address of a reference count variable
|
||||
+ *
|
||||
+ * Decreases the reference count.
|
||||
+ *
|
||||
+ * Returns: %TRUE if the reference count reached 0, and %FALSE otherwise
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+gboolean
|
||||
+g_ref_count_dec (grefcount *rc)
|
||||
+{
|
||||
+ grefcount rrc;
|
||||
+
|
||||
+ g_return_val_if_fail (rc != NULL, FALSE);
|
||||
+
|
||||
+ rrc = *rc;
|
||||
+
|
||||
+ g_return_val_if_fail (rrc < 0, FALSE);
|
||||
+
|
||||
+ rrc += 1;
|
||||
+ if (rrc == 0)
|
||||
+ return TRUE;
|
||||
+
|
||||
+ *rc = rrc;
|
||||
+
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * g_ref_count_compare:
|
||||
+ * @rc: the address of a reference count variable
|
||||
+ * @val: the value to compare
|
||||
+ *
|
||||
+ * Compares the current value of @rc with @val.
|
||||
+ *
|
||||
+ * Returns: %TRUE if the reference count is the same
|
||||
+ * as the given value
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+gboolean
|
||||
+g_ref_count_compare (grefcount *rc,
|
||||
+ gint val)
|
||||
+{
|
||||
+ grefcount rrc;
|
||||
+
|
||||
+ g_return_val_if_fail (rc != NULL, FALSE);
|
||||
+ g_return_val_if_fail (val >= 0, FALSE);
|
||||
+
|
||||
+ rrc = *rc;
|
||||
+
|
||||
+ if (val == G_MAXINT)
|
||||
+ return rrc == G_MININT;
|
||||
+
|
||||
+ return rrc == -val;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * g_atomic_ref_count_init:
|
||||
+ * @arc: the address of an atomic reference count variable
|
||||
+ *
|
||||
+ * Atomically initializes a reference count variable.
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+void
|
||||
+g_atomic_ref_count_init (gatomicrefcount *arc)
|
||||
+{
|
||||
+ g_return_if_fail (arc != NULL);
|
||||
+
|
||||
+ /* Atomic refcounting is implemented using the positive range
|
||||
+ * of signed integers:
|
||||
+ *
|
||||
+ * G_MININT Z¯< 0 > Z⺠G_MAXINT
|
||||
+ * |----------------------------|----------------------------|
|
||||
+ *
|
||||
+ * Acquiring a reference moves us towards MAXINT, and releasing a
|
||||
+ * reference moves us towards 0.
|
||||
+ */
|
||||
+ g_atomic_int_set (arc, 1);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * g_atomic_ref_count_inc:
|
||||
+ * @arc: the address of an atomic reference count variable
|
||||
+ *
|
||||
+ * Atomically increases the reference count.
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+void
|
||||
+g_atomic_ref_count_inc (gatomicrefcount *arc)
|
||||
+{
|
||||
+ g_return_if_fail (arc != NULL);
|
||||
+ g_return_if_fail (g_atomic_int_get (arc) > 0);
|
||||
+
|
||||
+ if (g_atomic_int_get (arc) == G_MAXINT)
|
||||
+ {
|
||||
+ g_critical ("Reference count has reached saturation");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ g_atomic_int_inc (arc);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * g_atomic_ref_count_dec:
|
||||
+ * @arc: the address of an atomic reference count variable
|
||||
+ *
|
||||
+ * Atomically decreases the reference count.
|
||||
+ *
|
||||
+ * Returns: %TRUE if the reference count reached 0, and %FALSE otherwise
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+gboolean
|
||||
+g_atomic_ref_count_dec (gatomicrefcount *arc)
|
||||
+{
|
||||
+ g_return_val_if_fail (arc != NULL, FALSE);
|
||||
+ g_return_val_if_fail (g_atomic_int_get (arc) > 0, FALSE);
|
||||
+
|
||||
+ return g_atomic_int_dec_and_test (arc);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * g_atomic_ref_count_compare:
|
||||
+ * @arc: the address of an atomic reference count variable
|
||||
+ * @val: the value to compare
|
||||
+ *
|
||||
+ * Atomically compares the current value of @arc with @val.
|
||||
+ *
|
||||
+ * Returns: %TRUE if the reference count is the same
|
||||
+ * as the given value
|
||||
+ *
|
||||
+ * Since: 2.58
|
||||
+ */
|
||||
+gboolean
|
||||
+g_atomic_ref_count_compare (gatomicrefcount *arc,
|
||||
+ gint val)
|
||||
+{
|
||||
+ g_return_val_if_fail (arc != NULL, FALSE);
|
||||
+ g_return_val_if_fail (val >= 0, FALSE);
|
||||
+
|
||||
+ return g_atomic_int_get (arc) == val;
|
||||
+}
|
||||
diff --git a/glib/grefcount.h b/glib/grefcount.h
|
||||
new file mode 100644
|
||||
index 0000000000..b24c71e8cb
|
||||
--- /dev/null
|
||||
+++ b/glib/grefcount.h
|
||||
@@ -0,0 +1,52 @@
|
||||
+/* grefcount.h: Reference counting
|
||||
+ *
|
||||
+ * Copyright 2018 Emmanuele Bassi
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#ifndef __GREFCOUNT_H__
|
||||
+#define __GREFCOUNT_H__
|
||||
+
|
||||
+#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
|
||||
+#error "Only <glib.h> can be included directly."
|
||||
+#endif
|
||||
+
|
||||
+#include <glib/gtypes.h>
|
||||
+
|
||||
+G_BEGIN_DECLS
|
||||
+
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+void g_ref_count_init (grefcount *rc);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+void g_ref_count_inc (grefcount *rc);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+gboolean g_ref_count_dec (grefcount *rc);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+gboolean g_ref_count_compare (grefcount *rc,
|
||||
+ gint val);
|
||||
+
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+void g_atomic_ref_count_init (gatomicrefcount *arc);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+void g_atomic_ref_count_inc (gatomicrefcount *arc);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+gboolean g_atomic_ref_count_dec (gatomicrefcount *arc);
|
||||
+GLIB_AVAILABLE_IN_2_56
|
||||
+gboolean g_atomic_ref_count_compare (gatomicrefcount *arc,
|
||||
+ gint val);
|
||||
+
|
||||
+G_END_DECLS
|
||||
+
|
||||
+#endif /* __GREFCOUNT_H__ */
|
||||
diff --git a/glib/gtypes.h b/glib/gtypes.h
|
||||
index 09d9bd1456..67adb7f1f8 100644
|
||||
--- a/glib/gtypes.h
|
||||
+++ b/glib/gtypes.h
|
||||
@@ -510,6 +510,9 @@ struct _GTimeVal
|
||||
glong tv_usec;
|
||||
};
|
||||
|
||||
+typedef gint grefcount;
|
||||
+typedef volatile gint gatomicrefcount;
|
||||
+
|
||||
G_END_DECLS
|
||||
|
||||
/* We prefix variable declarations so they can
|
||||
diff --git a/glib/meson.build b/glib/meson.build
|
||||
index 036d1f4d60..76d354c2a7 100644
|
||||
--- a/glib/meson.build
|
||||
+++ b/glib/meson.build
|
||||
@@ -76,6 +76,7 @@ glib_sub_headers = files(
|
||||
'gquark.h',
|
||||
'gqueue.h',
|
||||
'grand.h',
|
||||
+ 'grefcount.h',
|
||||
'gregex.h',
|
||||
'gscanner.h',
|
||||
'gsequence.h',
|
||||
@@ -159,6 +160,7 @@ glib_sources = files(
|
||||
'gquark.c',
|
||||
'gqueue.c',
|
||||
'grand.c',
|
||||
+ 'grefcount.c',
|
||||
'gregex.c',
|
||||
'gscanner.c',
|
||||
'gsequence.c',
|
||||
--
|
||||
GitLab
|
||||
|
||||
From 827c208cbf9cc0ef17b8c4531a40aafe1edc3f01 Mon Sep 17 00:00:00 2001
|
||||
From: Emmanuele Bassi <ebassi@gnome.org>
|
||||
Date: Mon, 4 Jun 2018 11:38:40 +0100
|
||||
Subject: [PATCH] Use macros for refcount types API
|
||||
|
||||
If we're using GCC we can use __extension__ to inline the grefcount and
|
||||
gatomicrefcount API, and avoid the function call.
|
||||
|
||||
These macros are only enabled if G_DISABLE_CHECKS is defined, as they
|
||||
remove critical warnings when the reference counters achieve saturation.
|
||||
---
|
||||
glib/grefcount.c | 20 +++++++-------
|
||||
glib/grefcount.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 80 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/glib/grefcount.c b/glib/grefcount.c
|
||||
index 10e35a217d..37085316b9 100644
|
||||
--- a/glib/grefcount.c
|
||||
+++ b/glib/grefcount.c
|
||||
@@ -89,7 +89,7 @@
|
||||
* Since: 2.58
|
||||
*/
|
||||
void
|
||||
-g_ref_count_init (grefcount *rc)
|
||||
+(g_ref_count_init) (grefcount *rc)
|
||||
{
|
||||
g_return_if_fail (rc != NULL);
|
||||
|
||||
@@ -114,7 +114,7 @@ g_ref_count_init (grefcount *rc)
|
||||
* Since: 2.58
|
||||
*/
|
||||
void
|
||||
-g_ref_count_inc (grefcount *rc)
|
||||
+(g_ref_count_inc) (grefcount *rc)
|
||||
{
|
||||
grefcount rrc;
|
||||
|
||||
@@ -147,7 +147,7 @@ g_ref_count_inc (grefcount *rc)
|
||||
* Since: 2.58
|
||||
*/
|
||||
gboolean
|
||||
-g_ref_count_dec (grefcount *rc)
|
||||
+(g_ref_count_dec) (grefcount *rc)
|
||||
{
|
||||
grefcount rrc;
|
||||
|
||||
@@ -179,8 +179,8 @@ g_ref_count_dec (grefcount *rc)
|
||||
* Since: 2.58
|
||||
*/
|
||||
gboolean
|
||||
-g_ref_count_compare (grefcount *rc,
|
||||
- gint val)
|
||||
+(g_ref_count_compare) (grefcount *rc,
|
||||
+ gint val)
|
||||
{
|
||||
grefcount rrc;
|
||||
|
||||
@@ -204,7 +204,7 @@ g_ref_count_compare (grefcount *rc,
|
||||
* Since: 2.58
|
||||
*/
|
||||
void
|
||||
-g_atomic_ref_count_init (gatomicrefcount *arc)
|
||||
+(g_atomic_ref_count_init) (gatomicrefcount *arc)
|
||||
{
|
||||
g_return_if_fail (arc != NULL);
|
||||
|
||||
@@ -229,7 +229,7 @@ g_atomic_ref_count_init (gatomicrefcount *arc)
|
||||
* Since: 2.58
|
||||
*/
|
||||
void
|
||||
-g_atomic_ref_count_inc (gatomicrefcount *arc)
|
||||
+(g_atomic_ref_count_inc) (gatomicrefcount *arc)
|
||||
{
|
||||
g_return_if_fail (arc != NULL);
|
||||
g_return_if_fail (g_atomic_int_get (arc) > 0);
|
||||
@@ -254,7 +254,7 @@ g_atomic_ref_count_inc (gatomicrefcount *arc)
|
||||
* Since: 2.58
|
||||
*/
|
||||
gboolean
|
||||
-g_atomic_ref_count_dec (gatomicrefcount *arc)
|
||||
+(g_atomic_ref_count_dec) (gatomicrefcount *arc)
|
||||
{
|
||||
g_return_val_if_fail (arc != NULL, FALSE);
|
||||
g_return_val_if_fail (g_atomic_int_get (arc) > 0, FALSE);
|
||||
@@ -275,8 +275,8 @@ g_atomic_ref_count_dec (gatomicrefcount *arc)
|
||||
* Since: 2.58
|
||||
*/
|
||||
gboolean
|
||||
-g_atomic_ref_count_compare (gatomicrefcount *arc,
|
||||
- gint val)
|
||||
+(g_atomic_ref_count_compare) (gatomicrefcount *arc,
|
||||
+ gint val)
|
||||
{
|
||||
g_return_val_if_fail (arc != NULL, FALSE);
|
||||
g_return_val_if_fail (val >= 0, FALSE);
|
||||
diff --git a/glib/grefcount.h b/glib/grefcount.h
|
||||
index b24c71e8cb..dec9a5ffb8 100644
|
||||
--- a/glib/grefcount.h
|
||||
+++ b/glib/grefcount.h
|
||||
@@ -47,6 +47,76 @@ GLIB_AVAILABLE_IN_2_58
|
||||
gboolean g_atomic_ref_count_compare (gatomicrefcount *arc,
|
||||
gint val);
|
||||
|
||||
+/* On GCC we can use __extension__ to inline the API without using
|
||||
+ * ancillary functions; we only do this when disabling checks, as
|
||||
+ * it disables warnings when saturating the reference counters
|
||||
+ */
|
||||
+#if defined(__GNUC__) && defined(G_DISABLE_CHECKS)
|
||||
+
|
||||
+# define g_ref_count_init(rc) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \
|
||||
+ (void) (0 ? *(rc) ^ *(rc) : 1); \
|
||||
+ *(rc) = -1; \
|
||||
+ }))
|
||||
+
|
||||
+# define g_ref_count_inc(rc) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \
|
||||
+ (void) (0 ? *(rc) ^ *(rc) : 1); \
|
||||
+ if (*(rc) == G_MININT) ; else { \
|
||||
+ *(rc) -= 1; \
|
||||
+ } \
|
||||
+ }))
|
||||
+
|
||||
+# define g_ref_count_dec(rc) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \
|
||||
+ grefcount __rc = *(rc); \
|
||||
+ __rc += 1; \
|
||||
+ if (__rc == 0) ; else { \
|
||||
+ *(rc) = __rc; \
|
||||
+ } \
|
||||
+ (gboolean) (__rc == 0); \
|
||||
+ }))
|
||||
+
|
||||
+# define g_ref_count_compare(rc,val) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \
|
||||
+ (void) (0 ? *(rc) ^ (val) : 1); \
|
||||
+ (gboolean) (*(rc) == -(val)); \
|
||||
+ }))
|
||||
+
|
||||
+# define g_atomic_ref_count_init(rc) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \
|
||||
+ (void) (0 ? *(rc) ^ *(rc) : 1); \
|
||||
+ g_atomic_int_set ((rc), 1); \
|
||||
+ }))
|
||||
+
|
||||
+# define g_atomic_ref_count_inc(rc) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \
|
||||
+ (void) (0 ? *(rc) ^ *(rc) : 1); \
|
||||
+ (void) (g_atomic_int_get (rc) == G_MAXINT ? 0 : g_atomic_int_inc ((rc))); \
|
||||
+ }))
|
||||
+
|
||||
+# define g_atomic_ref_count_dec(rc) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \
|
||||
+ (void) (0 ? *(rc) ^ *(rc) : 1); \
|
||||
+ g_atomic_int_dec_and_test ((rc)); \
|
||||
+ }))
|
||||
+
|
||||
+# define g_atomic_ref_count_compare(rc,val) \
|
||||
+ (G_GNUC_EXTENSION ({ \
|
||||
+ G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \
|
||||
+ (void) (0 ? *(rc) ^ (val) : 1); \
|
||||
+ (gboolean) (g_atomic_int_get (rc) == (val)); \
|
||||
+ }))
|
||||
+
|
||||
+#endif /* __GNUC__ && G_DISABLE_CHECKS */
|
||||
+
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GREFCOUNT_H__ */
|
||||
--
|
||||
GitLab
|
||||
|
||||
From 09c149453ac969dedb1cb2d15d489d1dd81412bf Mon Sep 17 00:00:00 2001
|
||||
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
||||
Date: Sat, 13 Oct 2018 23:10:33 +0200
|
||||
Subject: [PATCH] grefcount: add missing gatomic.h
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Without gatomic.h, build fails on:
|
||||
In file included from garcbox.c:24:0:
|
||||
garcbox.c: In function ‘g_atomic_rc_box_acquire’:
|
||||
grefcount.h:101:13: error: implicit declaration of function ‘g_atomic_int_get’; did you mean ‘__atomic_store’? [-Werror=implicit-function-declaration]
|
||||
(void) (g_atomic_int_get (rc) == G_MAXINT ? 0 : g_atomic_int_inc ((rc))); \
|
||||
^
|
||||
garcbox.c:292:3: note: in expansion of macro ‘g_atomic_ref_count_inc’
|
||||
g_atomic_ref_count_inc (&real_box->ref_count);
|
||||
|
||||
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
||||
---
|
||||
glib/grefcount.h | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/glib/grefcount.h b/glib/grefcount.h
|
||||
index dec9a5ffb8..b6eced1b7d 100644
|
||||
--- a/glib/grefcount.h
|
||||
+++ b/glib/grefcount.h
|
||||
@@ -23,6 +23,7 @@
|
||||
#error "Only <glib.h> can be included directly."
|
||||
#endif
|
||||
|
||||
+#include <glib/gatomic.h>
|
||||
#include <glib/gtypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
--
|
||||
GitLab
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Name: glib2
|
||||
Version: 2.56.4
|
||||
Release: 159%{?dist}
|
||||
Release: 162%{?dist}
|
||||
Summary: A library of handy utility functions
|
||||
|
||||
License: LGPLv2+
|
||||
@ -113,6 +113,18 @@ Patch19: gnetworkmonitornm.patch
|
||||
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/13
|
||||
Patch20: 13.patch
|
||||
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=2125184
|
||||
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1134
|
||||
Patch21: 1134.patch
|
||||
|
||||
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/54
|
||||
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/400
|
||||
Patch22: 54.patch
|
||||
|
||||
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1549
|
||||
# Also: https://gitlab.gnome.org/GNOME/glib/-/commit/d0821da5244fd08c756a5f84ec0d3063c72d1ac6
|
||||
Patch23: 1549.patch
|
||||
|
||||
%description
|
||||
GLib is the low-level core library that forms the basis for projects
|
||||
such as GTK+ and GNOME. It provides data structure handling for C,
|
||||
@ -310,6 +322,18 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
|
||||
%{_datadir}/installed-tests
|
||||
|
||||
%changelog
|
||||
* Thu Sep 21 2023 Michael Catanzaro <mcatanzaro@redhat.com> - 2.56.4-162
|
||||
- Add support to ignore trash for certain mounts
|
||||
- Resolves: RHEL-2836
|
||||
|
||||
* Tue Jan 03 2023 Michael Catanzaro <mcatanzaro@redhat.com> - 2.56.4-161
|
||||
- Backport grefcount API
|
||||
- Resolves: #2153205
|
||||
|
||||
* Wed Nov 16 2022 Michael Catanzaro <mcatanzaro@redhat.com> - 2.56.4-160
|
||||
- Fix G_FILE_COPY_TARGET_DEFAULT_PERMS, should not create private files
|
||||
- Resolves: #2125184
|
||||
|
||||
* Fri Apr 22 2022 Michael Catanzaro <mcatanzaro@redhat.com> - 2.56.4-159
|
||||
- Add --interface-info-[body|header] modes to gdbus-codegen
|
||||
- Related: #2061994
|
||||
|
Loading…
Reference in New Issue
Block a user