-
Notifications
You must be signed in to change notification settings - Fork 0
/
glibc-port-2-6-32-kernel-compat.patch
635 lines (617 loc) · 20.4 KB
/
glibc-port-2-6-32-kernel-compat.patch
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/configure glibc-2.28/sysdeps/unix/sysv/linux/configure
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/configure 2019-12-10 19:22:48.312609655 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/configure 2019-12-10 19:26:19.577974298 -0500
@@ -51,7 +51,7 @@
# set arch_minimum_kernel already, let that override our defaults here.
# Note that we presume such a fragment has set libc_cv_gcc_unwind_find_fde
# if appropriate too.
-test -n "$arch_minimum_kernel" || arch_minimum_kernel=3.2.0
+test -n "$arch_minimum_kernel" || arch_minimum_kernel=2.6.32
if test -n "$minimum_kernel"; then
user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/configure.ac glibc-2.28/sysdeps/unix/sysv/linux/configure.ac
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/configure.ac 2019-12-10 19:22:48.312609655 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/configure.ac 2019-12-10 19:26:19.577974298 -0500
@@ -33,7 +33,7 @@
# set arch_minimum_kernel already, let that override our defaults here.
# Note that we presume such a fragment has set libc_cv_gcc_unwind_find_fde
# if appropriate too.
-test -n "$arch_minimum_kernel" || arch_minimum_kernel=3.2.0
+test -n "$arch_minimum_kernel" || arch_minimum_kernel=2.6.32
if test -n "$minimum_kernel"; then
changequote(,)
user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/getrlimit64.c glibc-2.28/sysdeps/unix/sysv/linux/getrlimit64.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/getrlimit64.c 2019-12-10 19:22:48.347609729 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/getrlimit64.c 2019-12-10 19:26:19.577974298 -0500
@@ -1,17 +1,14 @@
/* Linux getrlimit64 implementation (64 bits rlim_t).
Copyright (C) 2010-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
-
The GNU C 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.
-
The GNU C 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 the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
@@ -35,7 +32,40 @@
int
__getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
{
- return INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+ #ifdef __NR_prlimit64
+ int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+ if (res == 0 || errno != ENOSYS)
+ return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports either
+ __NR_ugetrlimit and/or __NR_getrlimit. */
+#if defined (__NR_ugetrlimit) || defined (__NR_getrlimit)
+# ifndef __NR_ugetrlimit
+# define __NR_ugetrlimit __NR_getrlimit
+# endif
+# if __RLIM_T_MATCHES_RLIM64_T
+# define rlimits32 (*rlimits)
+# else
+ struct rlimit rlimits32;
+# endif
+
+ if (INLINE_SYSCALL_CALL (ugetrlimit, resource, &rlimits32) < 0)
+ return -1;
+
+# if !__RLIM_T_MATCHES_RLIM64_T
+ if (rlimits32.rlim_cur == RLIM_INFINITY)
+ rlimits->rlim_cur = RLIM64_INFINITY;
+ else
+ rlimits->rlim_cur = rlimits32.rlim_cur;
+ if (rlimits32.rlim_max == RLIM_INFINITY)
+ rlimits->rlim_max = RLIM64_INFINITY;
+ else
+ rlimits->rlim_max = rlimits32.rlim_max;
+# endif /* !__RLIM_T_MATCHES_RLIM64_T */
+#endif /* defined (__NR_ugetrlimit) || defined (__NR_getrlimit) */
+
+ return 0;
}
libc_hidden_def (__getrlimit64)
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/internal_statvfs.c glibc-2.28/sysdeps/unix/sysv/linux/internal_statvfs.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/internal_statvfs.c 2019-12-10 19:22:48.355609746 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/internal_statvfs.c 2019-12-10 19:26:19.578974297 -0500
@@ -39,6 +39,190 @@
# define STATFS statfs
# define STATVFS statvfs
# define INTERNAL_STATVFS __internal_statvfs
+
+# ifndef __ASSUME_STATFS_F_FLAGS
+int
+__statvfs_getflags (const char *name, int fstype, int fd)
+{
+ struct stat64 st;
+
+ if ((fd < 0 ? stat64 (name, &st) : fstat64 (fd, &st)) < 0)
+ return 0;
+
+ const char *fsname = NULL;
+ const char *fsname2 = NULL;
+ const char *fsname3 = NULL;
+
+ /* Map the filesystem type we got from the statfs call to a string. */
+ switch (fstype)
+ {
+ case EXT2_SUPER_MAGIC:
+ fsname = "ext4";
+ fsname2 = "ext3";
+ fsname3 = "ext2";
+ break;
+ case DEVPTS_SUPER_MAGIC:
+ fsname= "devpts";
+ break;
+ case SHMFS_SUPER_MAGIC:
+ fsname = "tmpfs";
+ break;
+ case PROC_SUPER_MAGIC:
+ fsname = "proc";
+ break;
+ case USBDEVFS_SUPER_MAGIC:
+ fsname = "usbdevfs";
+ break;
+ case AUTOFS_SUPER_MAGIC:
+ fsname = "autofs";
+ break;
+ case NFS_SUPER_MAGIC:
+ fsname = "nfs";
+ break;
+ case SYSFS_MAGIC:
+ fsname = "sysfs";
+ break;
+ case REISERFS_SUPER_MAGIC:
+ fsname = "reiserfs";
+ break;
+ case XFS_SUPER_MAGIC:
+ fsname = "xfs";
+ break;
+ case JFS_SUPER_MAGIC:
+ fsname = "jfs";
+ break;
+ case HPFS_SUPER_MAGIC:
+ fsname = "hpfs";
+ break;
+ case DEVFS_SUPER_MAGIC:
+ fsname = "devfs";
+ break;
+ case ISOFS_SUPER_MAGIC:
+ fsname = "iso9660";
+ break;
+ case MSDOS_SUPER_MAGIC:
+ fsname = "msdos";
+ break;
+ case NTFS_SUPER_MAGIC:
+ fsname = "ntfs";
+ break;
+ case LOGFS_MAGIC_U32:
+ fsname = "logfs";
+ break;
+ case BTRFS_SUPER_MAGIC:
+ fsname = "btrfs";
+ break;
+ case CGROUP_SUPER_MAGIC:
+ fsname = "cgroup";
+ break;
+ case LUSTRE_SUPER_MAGIC:
+ fsname = "lustre";
+ break;
+ case F2FS_SUPER_MAGIC:
+ fsname = "f2fs";
+ break;
+ case EFIVARFS_MAGIC:
+ fsname = "efivarfs";
+ break;
+ }
+
+ FILE *mtab = __setmntent ("/proc/mounts", "r");
+ if (mtab == NULL)
+ mtab = __setmntent (_PATH_MOUNTED, "r");
+
+ int result = 0;
+ if (mtab != NULL)
+ {
+ bool success = false;
+ struct mntent mntbuf;
+ char tmpbuf[1024];
+
+ /* No locking needed. */
+ (void) __fsetlocking (mtab, FSETLOCKING_BYCALLER);
+
+ again:
+ while (__getmntent_r (mtab, &mntbuf, tmpbuf, sizeof (tmpbuf)))
+ {
+ /* In a first round we look for a given mount point, if
+ we have a name. */
+ if (name != NULL && strcmp (name, mntbuf.mnt_dir) != 0)
+ continue;
+ /* We need to look at the entry only if the filesystem
+ name matches. If we have a filesystem name. */
+ else if (fsname != NULL
+ && strcmp (fsname, mntbuf.mnt_type) != 0
+ && (fsname2 == NULL
+ || strcmp (fsname2, mntbuf.mnt_type) != 0)
+ && (fsname3 == NULL
+ || strcmp (fsname3, mntbuf.mnt_type) != 0))
+ continue;
+
+ /* Find out about the device the current entry is for. */
+ struct stat64 fsst;
+ if (stat64 (mntbuf.mnt_dir, &fsst) >= 0
+ && st.st_dev == fsst.st_dev)
+ {
+ /* Bingo, we found the entry for the device FD is on.
+ Now interpret the option string. */
+ char *cp = mntbuf.mnt_opts;
+ char *opt;
+
+ while ((opt = __strsep (&cp, ",")) != NULL)
+ if (strcmp (opt, "ro") == 0)
+ result |= ST_RDONLY;
+ else if (strcmp (opt, "nosuid") == 0)
+ result |= ST_NOSUID;
+ else if (strcmp (opt, "noexec") == 0)
+ result |= ST_NOEXEC;
+ else if (strcmp (opt, "nodev") == 0)
+ result |= ST_NODEV;
+ else if (strcmp (opt, "sync") == 0)
+ result |= ST_SYNCHRONOUS;
+ else if (strcmp (opt, "mand") == 0)
+ result |= ST_MANDLOCK;
+ else if (strcmp (opt, "noatime") == 0)
+ result |= ST_NOATIME;
+ else if (strcmp (opt, "nodiratime") == 0)
+ result |= ST_NODIRATIME;
+ else if (strcmp (opt, "relatime") == 0)
+ result |= ST_RELATIME;
+
+ /* We can stop looking for more entries. */
+ success = true;
+ break;
+ }
+ }
+ /* Maybe the kernel names for the filesystems changed or the
+ statvfs call got a name which was not the mount point. Check
+ again, this time without checking for name matches first. */
+ if (! success && (name != NULL || fsname != NULL))
+ {
+ if (name != NULL)
+ /* Try without a mount point name. */
+ name = NULL;
+ else
+ {
+ /* Try without a filesystem name. */
+ assert (fsname != NULL);
+ fsname = fsname2 = fsname3 = NULL;
+ }
+
+ /* It is not strictly allowed to use rewind here. But
+ this code is part of the implementation so it is
+ acceptable. */
+ rewind (mtab);
+
+ goto again;
+ }
+
+ /* Close the file. */
+ __endmntent (mtab);
+ }
+
+ return result;
+}
+# endif
+
#else
extern int __statvfs_getflags (const char *name, int fstype, int fd);
#endif
@@ -83,5 +267,16 @@
/* XXX I have no idea how to compute f_favail. Any idea??? */
buf->f_favail = buf->f_ffree;
+ #ifndef __ASSUME_STATFS_F_FLAGS
+ buf->f_flag = fsbuf->f_flags ^ ST_VALID;
+ if ((fsbuf->f_flags & ST_VALID) == 0)
+ /* Determining the flags is tricky. We have to read /proc/mounts or
+ the /etc/mtab file and search for the entry which matches the given
+ file. The way we can test for matching filesystem is using the
+ device number. */
+ buf->f_flag = __statvfs_getflags (name, fsbuf->f_type, fd);
+ else
+ #endif
+
buf->f_flag = fsbuf->f_flags ^ ST_VALID;
}
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/kernel-features.h glibc-2.28/sysdeps/unix/sysv/linux/kernel-features.h
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/kernel-features.h 2019-12-10 19:22:48.363609763 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/kernel-features.h 2019-12-10 19:26:19.578974297 -0500
@@ -72,8 +72,21 @@
#define __ASSUME_PREADV 1
#define __ASSUME_PWRITEV 1
+/* Support for /proc/self/task/$tid/comm and /proc/$pid/task/$tid/comm was
+ added in 2.6.33. */
+#if __LINUX_KERNEL_VERSION >= 0x020621
+# define __ASSUME_PROC_PID_TASK_COMM 1
+#endif
+
+/* statfs fills in f_flags since 2.6.36. */
+#if __LINUX_KERNEL_VERSION >= 0x020624
+# define __ASSUME_STATFS_F_FLAGS 1
+#endif
+
/* Support for sendmmsg functionality was added in 3.0. */
-#define __ASSUME_SENDMMSG 1
+#if __LINUX_KERNEL_VERSION >= 0x030000
+# define __ASSUME_SENDMMSG 1
+#endif
/* On most architectures, most socket syscalls are supported for all
supported kernel versions, but on some socketcall architectures
@@ -85,8 +98,14 @@
#define __ASSUME_RECVFROM_SYSCALL 1
#define __ASSUME_SENDTO_SYSCALL 1
#define __ASSUME_ACCEPT4_SYSCALL 1
-#define __ASSUME_RECVMMSG_SYSCALL 1
-#define __ASSUME_SENDMMSG_SYSCALL 1
+
+#if __LINUX_KERNEL_VERSION >= 0x020621
+# define __ASSUME_RECVMMSG_SYSCALL 1
+#endif
+
+#if __LINUX_KERNEL_VERSION >= 0x030000
+# define __ASSUME_SENDMMSG_SYSCALL 1
+#endif
/* Support for SysV IPC through wired syscalls. All supported architectures
either support ipc syscall and/or all the ipc correspondent syscalls. */
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/prlimit.c glibc-2.28/sysdeps/unix/sysv/linux/prlimit.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/prlimit.c 2019-12-10 19:22:48.411609865 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/prlimit.c 2019-12-10 19:26:19.578974297 -0500
@@ -19,6 +19,7 @@
#include <sys/resource.h>
#include <sys/syscall.h>
+#ifdef __NR_prlimit64
int
prlimit (__pid_t pid, enum __rlimit_resource resource,
@@ -75,3 +76,13 @@
return res;
}
+
+#else
+int
+prlimit (__pid_t pid, enum __rlimit_resource resource,
+ const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
+{
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS);
+}
+stub_warning (prlimit)
+#endif
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/recvmmsg.c glibc-2.28/sysdeps/unix/sysv/linux/recvmmsg.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/recvmmsg.c 2019-12-10 19:22:48.414609871 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/recvmmsg.c 2019-12-10 19:26:19.578974297 -0500
@@ -21,16 +21,66 @@
#include <sysdep-cancel.h>
#include <sys/syscall.h>
-#include <socketcall.h>
#include <kernel-features.h>
+#ifdef __NR_recvmmsg
+
int
recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
struct timespec *tmo)
{
-#ifdef __ASSUME_RECVMMSG_SYSCALL
return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-#else
+}
+#elif defined __NR_socketcall
+# include <socketcall.h>
+# ifdef __ASSUME_RECVMMSG_SOCKETCALL
+int
+recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
+ struct timespec *tmo)
+{
return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo);
-#endif
}
+
+# else
+static int have_recvmmsg;
+
+int
+recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
+ struct timespec *tmo)
+{
+ if (__glibc_likely (have_recvmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags,
+ tmo);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_recvmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_recvmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_recvmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+}
+# endif /* __ASSUME_RECVMMSG_SOCKETCALL */
+#else
+# include <socket/recvmmsg.c>
+#endif
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/sendmmsg.c glibc-2.28/sysdeps/unix/sysv/linux/sendmmsg.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/sendmmsg.c 2019-12-10 19:22:48.416609875 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/sendmmsg.c 2019-12-10 19:26:19.578974297 -0500
@@ -21,17 +21,68 @@
#include <sysdep-cancel.h>
#include <sys/syscall.h>
-#include <socketcall.h>
#include <kernel-features.h>
+#ifdef __NR_sendmmsg
+
+int
+__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+}
+libc_hidden_def (__sendmmsg)
+weak_alias (__sendmmsg, sendmmsg)
+#elif defined __NR_socketcall
+# include <socketcall.h>
+# ifdef __ASSUME_SENDMMSG_SOCKETCALL
int
__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
{
-#ifdef __ASSUME_SENDMMSG_SYSCALL
- return SYSCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-#else
return SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
-#endif
}
+
+# else
+static int have_sendmmsg;
+
+int
+__sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags)
+{
+ if (__glibc_likely (have_sendmmsg >= 0))
+ {
+ int ret = SOCKETCALL_CANCEL (sendmmsg, fd, vmessages, vlen, flags);
+ /* The kernel returns -EINVAL for unknown socket operations.
+ We need to convert that error to an ENOSYS error. */
+ if (__builtin_expect (ret < 0, 0)
+ && have_sendmmsg == 0
+ && errno == EINVAL)
+ {
+ /* Try another call, this time with an invalid file
+ descriptor and all other parameters cleared. This call
+ will not cause any harm and it will return
+ immediately. */
+ ret = SOCKETCALL_CANCEL (invalid, -1);
+ if (errno == EINVAL)
+ {
+ have_sendmmsg = -1;
+ __set_errno (ENOSYS);
+ }
+ else
+ {
+ have_sendmmsg = 1;
+ __set_errno (EINVAL);
+ }
+ return -1;
+ }
+ return ret;
+ }
+ __set_errno (ENOSYS);
+ return -1;
+}
+# endif /* __ASSUME_SENDMMSG_SOCKETCALL */
+
libc_hidden_def (__sendmmsg)
weak_alias (__sendmmsg, sendmmsg)
+
+#else
+# include <socket/sendmmsg.c>
+#endif
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/setrlimit64.c glibc-2.28/sysdeps/unix/sysv/linux/setrlimit64.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/setrlimit64.c 2019-12-10 19:22:48.418609880 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/setrlimit64.c 2019-12-10 19:26:19.579974297 -0500
@@ -1,17 +1,17 @@
/* Linux setrlimit64 implementation (64 bits off_t).
Copyright (C) 2010-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
-
+
The GNU C 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.
-
+
The GNU C 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 the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
@@ -36,7 +36,36 @@
int
__setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
{
- return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+ int res;
+
+#ifdef __NR_prlimit64
+ res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+ if (res == 0 || errno != ENOSYS)
+ return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports
+ __NR_setrlimit. */
+#ifdef __NR_setrlimit
+# if !__RLIM_T_MATCHES_RLIM64_T
+ struct rlimit rlimits32;
+
+ if (rlimits->rlim_cur >= RLIM_INFINITY)
+ rlimits32.rlim_cur = RLIM_INFINITY;
+ else
+ rlimits32.rlim_cur = rlimits->rlim_cur;
+ if (rlimits->rlim_max >= RLIM_INFINITY)
+ rlimits32.rlim_max = RLIM_INFINITY;
+ else
+ rlimits32.rlim_max = rlimits->rlim_max;
+# else
+# define rlimits32 (*rlimits)
+# endif
+
+ res = INLINE_SYSCALL_CALL (setrlimit, resource, &rlimits32);
+#endif
+
+ return res;
}
/* Alpha defines a versioned setrlimit{64}. */
#ifndef USE_VERSIONED_RLIMIT
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/setrlimit.c glibc-2.28/sysdeps/unix/sysv/linux/setrlimit.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/setrlimit.c 2019-12-10 19:22:48.418609880 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/setrlimit.c 2019-12-10 19:26:19.579974297 -0500
@@ -34,6 +34,9 @@
int
__setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)
{
+
+# ifdef __NR_prlimit64
+
struct rlimit64 rlim64;
if (rlim->rlim_cur == RLIM_INFINITY)
@@ -45,7 +48,11 @@
else
rlim64.rlim_max = rlim->rlim_max;
- return INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+ int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+ if (res == 0 || errno != ENOSYS)
+ return res;
+# endif
+ return INLINE_SYSCALL_CALL (setrlimit, resource, rlim);
}
libc_hidden_def (__setrlimit)
diff -Naur glibc-2.28.orig/sysdeps/unix/sysv/linux/tst-setgetname.c glibc-2.28/sysdeps/unix/sysv/linux/tst-setgetname.c
--- glibc-2.28.orig/sysdeps/unix/sysv/linux/tst-setgetname.c 2019-12-10 19:22:48.425609895 -0500
+++ glibc-2.28/sysdeps/unix/sysv/linux/tst-setgetname.c 2019-12-10 19:26:19.579974297 -0500
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <kernel-features.h>
/* New name of process. */
#define NEW_NAME "setname"
@@ -100,6 +101,18 @@
{
res = get_self_comm (gettid (), name_check, TASK_COMM_LEN);
+ #ifndef __ASSUME_PROC_PID_TASK_COMM
+ /* On this first test we look for ENOENT to be returned from
+ get_self_comm to indicate that the kernel is older than
+ 2.6.33 and doesn't contain comm within the proc structure.
+ In that case we skip the entire test. */
+ if (res == ENOENT)
+ {
+ printf ("SKIP: The kernel does not have /proc/self/task/%%lu/comm.\n");
+ return 0;
+ }
+ #endif
+
if (res == 0)
{
if (strncmp (name, name_check, strlen (BIG_NAME)) == 0)