1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
https://bugs.gentoo.org/863689
https://github.com/ostreedev/ostree/commit/edba4b33be10c05253bfa94895dfbc8477e44d76
https://github.com/ostreedev/ostree/commit/0a908a180fcce98c2565b9fb34470e5953918260
From edba4b33be10c05253bfa94895dfbc8477e44d76 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Wed, 3 Aug 2022 10:37:40 -0400
Subject: [PATCH] Remove unused `linux/fs.h` includes
Prep for fixing conflicts introduced by newer glibc.
cc https://github.com/ostreedev/ostree/issues/2685
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -30,7 +30,6 @@
#include <sys/xattr.h>
#include <glib/gprintf.h>
#include <sys/ioctl.h>
-#include <linux/fs.h>
#include <ext2fs/ext2_fs.h>
#include "otutil.h"
--- a/src/ostree/ot-main.c
+++ b/src/ostree/ot-main.c
@@ -28,7 +28,6 @@
#include <string.h>
#include <sys/statvfs.h>
#include <sys/mount.h>
-#include <linux/fs.h>
#include "ot-main.h"
#include "ostree.h"
From 0a908a180fcce98c2565b9fb34470e5953918260 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Wed, 3 Aug 2022 10:43:43 -0400
Subject: [PATCH] Move FIFREEZE/FITHAW ioctl invocations into linuxfsutil.c
Should help avoid conflicts between glibc and linux headers.
Closes: https://github.com/ostreedev/ostree/issues/2685
--- a/src/libostree/ostree-linuxfsutil.c
+++ b/src/libostree/ostree-linuxfsutil.c
@@ -24,10 +24,12 @@
#include <fcntl.h>
#include <sys/ioctl.h>
+// This should be the only file including linux/fs.h; see
+// https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
+// https://github.com/ostreedev/ostree/issues/2685
+#include <linux/fs.h>
#include <ext2fs/ext2_fs.h>
-#include "otutil.h"
-
/**
* _ostree_linuxfs_fd_alter_immutable_flag:
* @fd: A file descriptor
@@ -88,3 +90,21 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
return TRUE;
}
+
+/* Wrapper for FIFREEZE ioctl.
+ * This is split into a separate wrapped API for
+ * reasons around conflicts between glibc and linux/fs.h
+ * includes; see above.
+ */
+int
+_ostree_linuxfs_filesystem_freeze (int fd)
+{
+ return TEMP_FAILURE_RETRY (ioctl (fd, FIFREEZE, 0));
+}
+
+/* Wrapper for FITHAW ioctl. See above. */
+int
+_ostree_linuxfs_filesystem_thaw (int fd)
+{
+ return TEMP_FAILURE_RETRY (ioctl (fd, FITHAW, 0));
+}
--- a/src/libostree/ostree-linuxfsutil.h
+++ b/src/libostree/ostree-linuxfsutil.h
@@ -29,4 +29,7 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
GCancellable *cancellable,
GError **error);
+int _ostree_linuxfs_filesystem_freeze (int fd);
+int _ostree_linuxfs_filesystem_thaw (int fd);
+
G_END_DECLS
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -29,7 +29,6 @@
#include <sys/ioctl.h>
#include <stdbool.h>
#include <sys/poll.h>
-#include <linux/fs.h>
#include <err.h>
#ifdef HAVE_LIBMOUNT
@@ -1476,7 +1475,7 @@ fsfreeze_thaw_cycle (OstreeSysroot *self,
* EOPNOTSUPP: If the filesystem doesn't support it
*/
int saved_errno = errno;
- (void) TEMP_FAILURE_RETRY (ioctl (rootfs_dfd, FITHAW, 0));
+ _ostree_linuxfs_filesystem_thaw (rootfs_dfd);
errno = saved_errno;
/* But if we got an error from poll, let's log it */
if (r < 0)
@@ -1517,7 +1516,7 @@ fsfreeze_thaw_cycle (OstreeSysroot *self,
return glnx_throw (error, "aborting due to test-fifreeze");
}
/* Do a freeze/thaw cycle; TODO add a FIFREEZETHAW ioctl */
- if (ioctl (rootfs_dfd, FIFREEZE, 0) != 0)
+ if (_ostree_linuxfs_filesystem_freeze (rootfs_dfd) != 0)
{
/* Not supported, we're running in the unit tests (as non-root), or
* the filesystem is already frozen (EBUSY).
@@ -1539,7 +1538,7 @@ fsfreeze_thaw_cycle (OstreeSysroot *self,
return glnx_throw_errno_prefix (error, "ioctl(FIFREEZE)");
}
/* And finally thaw, then signal our completion to the watchdog */
- if (TEMP_FAILURE_RETRY (ioctl (rootfs_dfd, FITHAW, 0)) != 0)
+ if (_ostree_linuxfs_filesystem_thaw (rootfs_dfd) != 0)
{
/* Warn but don't error if the filesystem was already thawed */
if (errno == EINVAL)
|