blob: 689ee2a5c42180c12f258620313f1079cfe723c1 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 89000d9cb226cd864fa247f2428c9eaf7f414882 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 14 Aug 2022 10:02:15 -0700
4Subject: [PATCH] portability: Avoid glibc and linux mount.h conflict
5
6With glibc 2.36+ linux/mount.h> and <sys/mount.h> headers are
7no longer directly compatible
8
9Upstream-Status: Submitted [https://github.com/landley/toybox/pull/364]
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 lib/portability.h | 6 +++++-
13 1 file changed, 5 insertions(+), 1 deletion(-)
14
15--- a/lib/portability.h
16+++ b/lib/portability.h
17@@ -180,11 +180,29 @@ void *memmem(const void *haystack, size_
18 #endif
19
20 // Linux headers not listed by POSIX or LSB
21-#include <sys/mount.h>
22 #ifdef __linux__
23 #include <sys/statfs.h>
24 #include <sys/swap.h>
25 #include <sys/sysinfo.h>
26+
27+#ifndef BLKDISCARD
28+#define BLKDISCARD _IO(0x12,119)
29+#endif
30+#ifndef BLKSECDISCARD
31+#define BLKSECDISCARD _IO(0x12,125)
32+#endif
33+#ifndef BLKZEROOUT
34+#define BLKZEROOUT _IO(0x12,127)
35+#endif
36+#ifndef FIFREEZE
37+#define FIFREEZE _IOWR('X', 119, int) /* Freeze */
38+#endif
39+#ifndef FITHAW
40+#define FITHAW _IOWR('X', 120, int) /* Thaw */
41+#endif
42+
43+#else
44+#include <sys/mount.h>
45 #endif
46
47 #ifdef __APPLE__
48--- a/toys/other/switch_root.c
49+++ b/toys/other/switch_root.c
50@@ -19,6 +19,7 @@ config SWITCH_ROOT
51
52 #define FOR_switch_root
53 #include "toys.h"
54+#include <sys/mount.h>
55 #include <sys/vfs.h>
56
57 GLOBALS(
58--- a/toys/other/blkdiscard.c
59+++ b/toys/other/blkdiscard.c
60@@ -31,8 +31,7 @@ config BLKDISCARD
61
62 #define FOR_blkdiscard
63 #include "toys.h"
64-
65-#include <linux/fs.h>
66+#include <sys/mount.h>
67
68 GLOBALS(
69 long o, l;
70--- a/toys/other/blockdev.c
71+++ b/toys/other/blockdev.c
72@@ -31,7 +31,7 @@ config BLOCKDEV
73
74 #define FOR_blockdev
75 #include "toys.h"
76-#include <linux/fs.h>
77+#include <sys/mount.h>
78
79 GLOBALS(
80 long setbsz, setra;
81--- a/toys/other/fsfreeze.c
82+++ b/toys/other/fsfreeze.c
83@@ -18,7 +18,6 @@ config FSFREEZE
84
85 #define FOR_fsfreeze
86 #include "toys.h"
87-#include <linux/fs.h>
88
89 void fsfreeze_main(void)
90 {
91--- a/lib/portability.c
92+++ b/lib/portability.c
93@@ -5,7 +5,7 @@
94 */
95
96 #include "toys.h"
97-
98+#include <sys/mount.h>
99 // We can't fork() on nommu systems, and vfork() requires an exec() or exit()
100 // before resuming the parent (because they share a heap until then). And no,
101 // we can't implement our own clone() call that does the equivalent of fork()
102--- a/toys/lsb/mount.c
103+++ b/toys/lsb/mount.c
104@@ -58,6 +58,7 @@ config MOUNT
105
106 #define FOR_mount
107 #include "toys.h"
108+#include <sys/mount.h>
109
110 GLOBALS(
111 struct arg_list *o;
112--- a/toys/lsb/umount.c
113+++ b/toys/lsb/umount.c
114@@ -30,6 +30,7 @@ config UMOUNT
115
116 #define FOR_umount
117 #include "toys.h"
118+#include <sys/mount.h>
119
120 GLOBALS(
121 struct arg_list *t;
122--- a/toys/other/eject.c
123+++ b/toys/other/eject.c
124@@ -22,6 +22,7 @@ config EJECT
125
126 #define FOR_eject
127 #include "toys.h"
128+#include <sys/mount.h>
129 #include <scsi/sg.h>
130 #include <scsi/scsi.h>
131 #include <linux/cdrom.h>
132--- a/toys/other/freeramdisk.c
133+++ b/toys/other/freeramdisk.c
134@@ -16,6 +16,7 @@ config FREERAMDISK
135 */
136
137 #include "toys.h"
138+#include <sys/mount.h>
139
140 void freeramdisk_main(void)
141 {
142--- a/toys/other/nbd_client.c
143+++ b/toys/other/nbd_client.c
144@@ -36,6 +36,7 @@ config NBD_CLIENT
145 #define FOR_nbd_client
146 #include "toys.h"
147 #include <linux/nbd.h>
148+#include <linux/fs.h>
149
150 void nbd_client_main(void)
151 {
152--- a/toys/other/partprobe.c
153+++ b/toys/other/partprobe.c
154@@ -18,6 +18,7 @@ config PARTPROBE
155 */
156
157 #include "toys.h"
158+#include <sys/mount.h>
159
160 static void do_partprobe(int fd, char *name)
161 {