-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHANGES
2156 lines (1867 loc) · 77.7 KB
/
CHANGES
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This file summarizes the changes that have been made since publication
to the program examples printed in "The Linux Programming Interface".
Background on some of these changes can be found in the online errata
for TLPI, available at http://man7.org/tlpi/errata/.
2010-11-13
sockets/us_abstract_bind.c
The code was improved as per the erratum for page 1176.
2011-01-17
timers/real_timer.c
A mistake in the ordering of the code in main() was fixed.
See the erratum for page 483.
2011-02-17
psem/thread_incr_psem.c
Fixed an error in a comment. See the erratum for page 1102.
2011-04-05
threads/thread_multijoin.c.
Fixed a race condition. See the erratum for page 649.
threads/prod_condvar.c
Fixed a race condition. The problem was similar to that
described in the erratum for page 649.
threads/prod_no_condvar.c
Fixed a race condition. The problem was similar to that
described in the erratum for page 649.
2011-04-19
altio/demo_sigio.c
Fixed a race condition. See the erratum for page 1349.
daemons/daemon_SIGHUP.c
Fixed a race condition. See the erratum for page 774.
2011-05-18
signals/t_kill.c
Fixed an error in a diagnostic message. See the erratum
for page 406.
2011-07-06
Makefile
Added missing "memalloc" to the directory list.
memalloc/free_and_sbrk.c
Added feature test macro definition (_BSD_SOURCE).
See the erratum for page 142.
2011-08-11
acl/acl_view.c
Fixed a small bug as per the erratum for page 336.
2011-09-04
pipes/popen_glob.c
procexec/make_zombie.c
sockets/inet_sockets.c
Removed an unnecessary assignment statement that added
a terminating null byte to the string buffer output by
snprintf(). See the erratum for page 555.
2011-12-05
dirs_links/t_unlink.c
Added a comment referring to the erratum for page 348.
2011-12-06
pty/unbuffer.c
Change parent exit status when read() returns <= 0
from EXIT_FAILURE to EXIT_SUCCESS.
2011-12-13
signals/catch_rtsigs.c
Restore 3 lines that were accidentally omitted at the
end of this program. See the erratum for page 463.
2011-12-31
threads/thread_incr.c
Make global variable 'glob' volatile, so that the program
more easily produces "incorrect" behavior, even in the face
of compiler optimizations. See the erratum for page 632.
2012-02-16
lib/alt_functions.c
Fix indentation in ALT_posix_openpt().
2012-04-03
lib/Makefile
lib/Build_ename.sh
Refactor, so that Build_ename.sh produces output on stdout,
rather than to a named file.
2012-04-06
lib/itimerspec_from_str.c
Conditionally make the content of this file empty if
compiling on MacOSX, since that operating system doesn't
define the 'itimerspec' structure.
(Only in "dist" version of code.)
Makefile.inc.MacOSX
Remove '-lrt' from the IMPL_LDLIBS definition, since there
is no librt on MacOSX.
2012-05-04
fileio/seek_io.c
Fix a typo in comment at top of the program.
(Only in "dist" version of code.)
2012-05-11
psem/Makefile
Correct the makefile to use "cc -pthreads" for POSIX
semaphores. Formerly, the makefile used "cc -lrt", but
recent toolchain changes mean that that this no longer works
("cc -pthreads" always worked.) See the erratum for page 1061.
(Thanks to Robert P. J. Day.)
pshm/Makefile
Correct a bug in the makefile that caused link errors.
(Formerly, the makefile worked, but this was fortuitous;
recent toolchain changes revealed the bug.)
2012-05-13
pshm/README
Fix a wordo.
2012-05-20
README
Various small fixes.
(Thanks to Robert P. J. Day.)
2012-05-25
BUILDING
Various small fixes.
(Thanks to Robert P. J. Day.)
2012-05-26
memalloc/free_and_sbrk.c
Fix an error in the code comments at the top of the program.
(Only in "dist" version of code.)
(Thanks to Robert P. J. Day.)
2012-05-31
svmsg/svmsg_info.c
svsem/svsem_info.c
svshm/svshm_info.c
Eliminate unnecessary inclusion of <sys/ipc.h> header file.
(Thanks to Robert P. J. Day.)
2012-06-05
COPYING
Renamed to COPYING.agpl-v3
Added new files:
COPYING.gpl-v3
Copy of the GNU General Public License, version 3
COPYING.lgpl-v3
Copy of the GNU Lesser General Public License, version 3
lib/*
Changed the license of the library functions in the /lib
directory to GNU Lesser General Public License, version 3.
sockets/read_line_buf.c
sockets/read_line_buf.h
Created links for the sockets/read_line_buf.{c,h} files in the
lib/ directory, so that these files are licensed LGPLv3.
README
Updated to note the licensing of the library functions.
2012-07-05
filesys/t_statfs.c
filesys/t_statvfs.c
Changed several printf() statements to use unsigned types for
various fields, since (in the case of the 'statvfs' structure at
least) these fields are specified as unsigned in SUSv[34].
(The 'statfs' structure isn't covered by SUSv[34], but using
unsigned types seems reasonable and safe.)
2012-07-22
filelock/create_pid_file.c
Small wording fix in a comment.
(Only in "dist" version of code.)
procexec/execlp.c
Small wording fix in a comment.
svshm/svshm_xfr_reader.c
Small wording fix in a comment.
(Only in "dist" version of code.)
sysinfo/procfs_pidmax.c
Small wording fix in a comment.
(Only in "dist" version of code.)
threads/one_time_init.c
Small wording fix in a comment.
2012-07-26
filebuff/direct_read.c
Fix an error in comment describing program arguments.
(Thanks to Jason Orendorff.)
(Only in "dist" version of code.)
2012-08-03
loginacct/dump_utmpx.c
loginacct/utmpx_login.c
loginacct/view_lastlog.c
Remove unneeded casts.
See the errata for pages 824, 829, and 831.
2012-09-10
loginacct/dump_utmpx.c
Fix error introduced in 2012-08-03 changes.
altio/epoll_input.c
Improve a comment.
See the erratum for page 1363.
2012-09-27
svsem/Makefile
Fixed a bug in the Makefile that causes svsem_demo.c
not to be built.
(Thanks to Jinnan Wang.)
2012-09-30
timers/real_timer.c
Use NULL instead of 0 for last argument of setitimer() call.
See the erratum for page 484.
(Thanks to Trevor Woerner.)
2012-10-02
Makefile.inc
Add "-Wno-unused-but-set-variable" to compiler flags
(the IMPL_CFLAGS macro), to prevent compilation warnings
in three of the example programs. (Those warnings do not
correspond to real problems in the code.) The
"-Wunused-but-set-variable" flag was added (and turned on
by default) in gcc 4.6, which was released on 2011-03-35
(i.e., after TLPI was written).
2012-10-15
loginacct/dump_utmpx.c
loginacct/utmpx_login.c
loginacct/view_lastlog.c
Revert the changes of 2012-08-03. These were made overlooking
the fact that in the 'utmpx' structure, 'tv_sec' is defined as
being of type 'int32_t', not 'time_t', so that the 2012-08-03
changes in fact cause warnings on 64-bit systems.
As a consequence, three (as yet unapplied) errata
for pages 824, 829, and 831 are removed.
2012-10-18
procexec/demo_clone.c
Minor fix to a comment (s/will affect/may affect/).
Declare the variable that holds return status of write()
as 'ssize_t'.
(Thanks to Trevor Woerner.)
2012-12-17
sockets/i6d_ucase_sv.c
Fix typo in a comment.
(Only in "dist" version of code.)
(Thanks to Kanak Kshetri.)
sockets/i6d_ucase_cl.c
Fix typo in a comment.
(Only in "dist" version of code.)
2012-12-24
procexec/demo_clone.c
Add a comment at the top of the program clarifying that the
user must select a valid set of flags for the clone() call.
(Thanks to Jeffrey Thompson.)
2013-01-02
altio/poll_pipes.c
Fix typos in two errExit() string arguments.
See the erratum for page 1340.
2013-02-11
sockets/id_echo_sv.c
Remove unneeded use of the variable 'addrlen'.
See the erratum for page 1241.
2013-03-09
procpri/sched_set.c
Fix a bug in the handling of the command-line arguments.
See the erratum for page 743.
2013-03-10
procpri/Makefile
Move demo_sched_fifo from GEN_EXE to LINUX_EXE.
(Thanks to Antonio Jose Rodrigues.)
timers/Makefile
Remove demo_timerfd from GEN_EXE target.
(Thanks to Antonio Jose Rodrigues.)
2013-03-11
sysinfo/t_uname.c
Make definition of _GNU_SOURCE conditional on __linux__.
See the erratum for page 230.
2013-03-18
threads/detached_attrib.c
Fix a typo in a string:
errExitEN(s, "pthread_attr_getdetachstate");
==>
errExitEN(s, "pthread_attr_setdetachstate");
Interestingly, this error was not present in the printed
version of the code (page 628 of TLPI).
(Thanks to Kanak Kshetri.)
2013-04-05
svmsg/Makefile
Fix a typo that meant that 'svmsg_send' was not compiled.
(Thanks to George Yoshida.)
2013-06-05
xattr/xattr_view.c
Fix error-handling code for usage diagnostic.
See the erratum for page 317.
2013-07-11
timers/itimerspec_from_str.c
Change itimerspecFromStr() so that it does not modify
its string argument.
See the errata for pages 502 and 503.
2013-09-13
procexec/acct_on.c
Add missing argument to the call to usageErr();
See the erratum for page 592.
(Thanks to Liu Jiaming.)
2013-09-17
mmap/mmcopy.c
Correct argument pasted to msync() (s/src/dst/).
(Thanks to Robert P. J. Day.)
2013-09-18
filebuff/write_bytes.c
Minor to changes to comments at top of the program.
filebuff/Makefile
Add entries to produce the non-vanilla flavors of the
write_bytes program:
write_bytes_fdatasync (do fdatasync() after each write)
write_bytes_fsync (do fsync() after each write)
write_bytes_o_fsync (open the file with O_SYNC)
2013-09-22
procpri/t_setpriority.c
Fix typo in a diagnostic message.
See the erratum for page 737.
2013-09-23
procpri/demo_sched_fifo.c
s/useCPU("child ")/useCPU("parent")/ near the end of
the program.
(Thanks to Liu Jiaming.)
2013-09-23
README
Fixed a few typos.
(Thanks to Robert P. J. Day.)
2013-10-18
svmsg/svmsg_file_client.c
Fix typo in a comment.
svmsg/svmsg_file_client.c
Remove a redundant msgctl(IPC_RMID) operation.
See the erratum for page 961.
(Thanks to Liu Jiaming.)
2013-10-22
pipes/popen_glob.c
s/==/=/ inside a printf() string.
See the erratum for page 905.
(Thanks to Liu Jiaming.)
2013-10-22
mmap/mmcat.c
mmap/mmcopy.c
Add code to check for a zero-length input file.
See the erratum for page 1023.
(Thanks to Liu Jiaming.)
2013-10-25
filelock/t_flock.c
Fix an error in the message printed by usageErr().
See the erratum for page 1121.
(Thanks to Liu Jiaming.)
2013-10-30
mmap/mmcat.c
mmap/mmcopy.c
Fix a typo syntax error introduced in 2013-10-22 edits.
(Thanks to Yongzhi Pan.)
2013-10-30
pipes/pipe_ls_wc.c
Fix a typo in comment at top of the program.
(Only in "dist" version of code.)
2013-11-01
sockets/ud_ucase.h
Fix a wordo in comment.
See the erratum for page 1171.
(Thanks to Liu Jiaming.)
2013-11-07
sockets/id_echo_cl.c
Fix a typo in usageErr() error message.
See the erratum for page 1242.
(Thanks to Liu Jiaming.)
2013-11-11
altio/poll_pipes.c
Fix a bogus comment, and a glitch in a printf() call.
See the erratum for page 1341.
(Thanks to Liu Jiaming.)
altio/self_pipe.c
Fix a division error in the last printf() call
(divide by 1000, not 10000).
(Thanks to Liu Jiaming.)
altio/t_select.c
Fix a division error in the last printf() call
(divide by 1000, not 10000).
See the erratum for page 1336.
(Thanks to Liu Jiaming.)
2013-11-5
dirs_links/nftw_dir_tree.c
Fix wordo in a comment
(Only in "dist" version of code.)
dirs_links/view_symlink.c
Added a comment explaining use of lstat().
(Only in "dist" version of code.)
2013-11-25
pmsg/mq_notify_thread.c
Remove an unnecessary call to pthread_exit().
See the erratum for page 1082.
2013-12-04
threads/thread_incr_mutex,c
Add "volatile" qualifier to declaration of 'glob'
See the erratum for page 636.
(Thanks to Arnaud Frugier.)
2013-12-05
sockets/is_echo_sv.c
sockets/is_echo_v2_sv.c
sockets/scm_cred_recv.c
sockets/scm_rights_recv.c
sockets/socknames.c
sockets/us_xfr_sv.c
sockets/us_xfr_v2_sv.c
Change last argument of accept() from 'NULL' to '0'.
2013-12-05
sockets/i6d_ucase_cl.c
sockets/ud_ucase_cl.c
Change last argument of recvfrom() from 'NULL' to '0'.
2014-01-02
shlibs/dynload.c
Add a comment explaining SUSv4 TC1 changes that permit more
natural casts of function pointers returned by dlsym().
See the "update" erratum for page 864.
(Only in "dist" version of code.)
2014-03-12
Makefile.inc
Add "-D_DEFAULT_SOURCE" to IMPL_CFLAGS. This avoids the
# warning "_BSD_SOURCE and _SVID_SOURCE are
deprecated, use _DEFAULT_SOURCE"
warnings that are produced when compiling code that
defines _SVID_SOURCE or _BSD_SOURCE against glibc headers
from version 2.20 onward.
sysinfo/procfs_user_exe.c
Move inclusion of our header files (ugid_functions.h and
tlpi_hdr.h) to follow other #include lines (as is done in
all other code).
vmem/madvise_dontneed.c
Fix a typo in a comment.
threads/thread_cleanup.c
Add mutex locking around assignment to 'glob'; see the
erratum for page 679.
(Only in "dist" version of code.)
(Thanks to Jingtian Zhang.)
2014-05-21
inotify/demo_inotify.c
Properly align 'buf' on an 8-byte boundary.
See the erratum for page 383.
(Thanks to Matt Wojciak and Heinrich Schuchardt.)
2014-05-31
Makefile
Add 'filebuff' and 'syslim' directories
2014-06-20
timers/timed_read.c
Fix an off-by-one error in the read() call.
2014-07-09
inotify/inotify_dtree.c
inotify/rand_dtree.c
New files: an application that provides a thorough-going
demonstration of the use of inotify for monitoring directory
subtrees, and an associated test program.
2014-07-10
pmsg/Makefile
timers/Makefile
Minor fixes
2014-07-24
sockets/i6d_ucase_cl.c
sockets/ud_ucase_cl.c
Change last argument of recvfrom() from "0" to "NULL".
(With this change, the code now matches that shown in the book.)
sockets/is_echo_sv.c
sockets/socknames.c
sockets/us_xfr_sv.c
Change last argument of accept() from "0" to "NULL".
(With this change, the code now matches that shown in the book.)
sockets/is_echo_v2_sv.c
sockets/scm_cred_recv.c
sockets/scm_rights_recv.c
sockets/us_xfr_v2_sv.c
Change last argument of accept() from "0" to "NULL".
2014-11-05
pmsg/pmsg_create.c
Change the default value assigned to 'attr.mq_msgsize'.
See the erratum for page 1069.
2014-11-12
acl/Makefile
Simplify Makefile by including 'libacl' in LDLIBS.
cap/Makefile
Remove crufty, unneeded rule; and simplify the Makefile
by including 'libcrypt' in LDLIBS.
pmsg/Makefile
Remove unneeded rule for building 'mq_notify_thread'.
psem/Makefile
Remove unneeded rule
progconc/Makefile
Remove unneeded rule for building 'syscall_speed'.
timers/Makefile
Most of the programs in this directory must be linked
against the realtime library, librt; simplify the Makefile
by linking all of the programs against that library.
2014-11-14
Makefile.inc
Remove "-Wno-unused-but-set-variable" from IMPL_CFLAGS.
Remove redundant "-Wpointer-arith", which is anyway enabled
by -pedantic.
Remove unneeded "-Wno-format-y2k".
Remove unneeded "-Wno-unused-parameter".
progconc/syscall_speed.c
Minor change so that -Wunused-but-set-variable does not
give a warning.
signals/demo_SIGFPE.c
Minor change so that -Wunused-but-set-variable does not
give a warning.
signals/t_sigsuspend.c
Minor change so that -Wunused-but-set-variable does not
give a warning.
(Only in "dist" version of code.)
2014-11-15
lib/*
Various files in this directory that were hard links
to files that were also linked in other directories
are now symbolic links.
2014-11-22
threads/pthread_barrier_demo.c
New program demonstrating use of POSIX threads barriers API.
threads/thread_incr_rwlock.c
New program demonstrating use of POSIX threads rwlocks.
threads/thread_incr_spinlock.c
New program demonstrating use of POSIX threads spinlocks.
threads/thread_incr_mutex.c
Update header comments to refer to new spinlocks and
rwlocks programs.
threads/Makefile
Update to include targets for new program.
2014-11-29
altio/poll_pipes.c
Change the 'timeout' argument in the poll() call from -1 to 0.
(See the erratum for page 1341.)
2014-11-30
procexec/execlp.c
Minor comment and whitespace fixes.
2014-12-01
pmsg/mq_notify_sigwaitinfo.c
Minor layout fix and removal of a redundant comment.
pmsg/mq_notify_sig.c
pmsg/mq_notify_thread.c
Remove a redundant comment.
(Only in "dist" version of code.)
pmsg/mq_notify_via_signal.c
pmsg/mq_notify_via_thread.c
New files demonstrating message queue notification via
signals and via threads.
pmsg/mq_notify_sigwaitinfo.c
pmsg/mq_notify_sig.c
pmsg/mq_notify_thread.c
Add comments noting that these programs do not handle the case
where a message is already on the queue by the time the first
attempt is made to register for message notification, along
with reference to code examples that address this point.
2014-12-03
sockets/list_host_addresses.c
A new small program demonstrating the use of getifaddrs(3).
socket/Makefile
Add list_host_addresses.c.
2014-12-09
threads/thread_lock_speed.c
A new program allowing the performance of mutexes and
spin locks to be compared in a few different scenarios.
2014-12-12
dirs_links/file_type_stats.c
Handle non-stat()-able files correctly.
dirs_links
Rework so that 'all' target includes examples using nftw()
2014-12-17
README
The source code licensing for the "main" program examples
has changed from GNU Affero GPLv3 or later to plain
GNU GPLv3 or later.
2015-01-26
filelock/i_fcntl_locking.c
Added support for the OFD locking commands (F_OFD_SETLK,
F_OFD_SETLKW, F_OFD_GETLKW) that were added to Linux in
version 3.15.
(Only in "dist" version of code.)
2015-01-28
cap/check_password_caps.c
Fix a typo in a comment.
(Only in "dist" version of code.)
2015-01-30
threads/thread_multijoin.c
Fix minor whitespace error.
(See the erratum for page 651.)
2015-03-13
shlibs/dynload.c
Switch to using the more natural cast permitted by
POSIX.1-2008 TC1 (2013). See also the erratum for page 864.
(Only in "dist" version of code.)
2015-03-13
shlibs/dynload.c
Tweak comment on dlsym() cast permitted by
POSIX.1-2008 TC1 (2013).
(Only in "dist" version of code.)
2015-03-25
namespaces/Makefile
namespaces/demo_userns.c
namespaces/demo_uts_namespaces.c
namespaces/hostname.c
namespaces/multi_pidns.c
namespaces/ns_child_exec.c
namespaces/ns_exec.c
namespaces/ns_run.c
namespaces/orphan.c
namespaces/pidns_init_sleep.c
namespaces/simple_init.c
namespaces/t_setns_userns.c
namespaces/unshare.c
namespaces/userns_child_exec.c
namespaces/userns_setns_test.c
Add various new namespaces-related programs, covered in
my article series on LWN.net, starting at
https://lwn.net/Articles/531114/
2015-03-25
Makefile
README
Adjusted for addition of "namespaces" subdirectory
2015-04-21
inotify/rand_dtree.c
Add "#define _XOPEN_SOURCE 500" so that the program
builds cleanly from the command line. (It already built
fine using the Makefile.)
namespaces/README
Add a README explaining the origin of these programs.
sockets/scm_cred_recv.c
sockets/scm_cred_send.c
sockets/scm_rights_recv.c
sockets/scm_rights_send.c
Add a comment explaining use of a union to force alignment.
2015-05-09
sysinfo/procfs_pidmax.c
lseek() to start of /proc/sys/kernel/pidmax.c file before
writing to it. (See the erratum for page 228.)
2015-09-09
seccomp/libseccomp_demo.c
seccomp/seccomp_control_open.c
seccomp/seccomp_deny_open.c
seccomp/seccomp_perf.c
Added some seccomp examples. For more information see my
slides on seccomp at http://man7.org/conf and Jake Edge's
LWN.net write-up of one of my seccomp presentations at
http://lwn.net/Articles/656307/.
2015-10-28
pmsg/mq_notify_via_thread.c
Rework code to remove a race condition.
2015-11-05
signal/intquit.c
signal/ouch.c
signal/sig_receiver.c:
Add a comment explaining that sigaction() is preferred over
signal() when establishing signal handlers.
(Only in "dist" version of code.)
2016-04-01
procexec/t_execle.c
Add an argument to the execle() call.
2016-04-14
sockets/is_seqnum_sv.c
sockets/is_seqnum_v2_sv.c
Remove unneeded '&' in argument to write().
2016-04-20
files/t_stat.c
Use <sys/sysmacros.h> instead of <sys/types.h>
to get the definitions of major() and minor().
2016-04-29
*/Makefile
Fix misnamed macro (LPLIB --> TLPI_LIB).
(Thanks to Ivo Tisch.)
lib/Makefile
Better dependency checking
2016-05-05
psem/Makefile
Fix the target logic for psem_timedwait, so that it builds
correctly on systems where the vDSO doesn't export
clock_gettime(). (the x86 vDSO does export clock_gettime(),
which hid the error when building there.)
2016-05-11
namespaces/userns_child_exec.c
Check that a command line argument is supplied.
2016-05-13
shlibs/dynload.c
Remove unneeded check for NULL symbol value.
(See the erratum for page 865.)
2016-06-05
filesys/t_mount.c
Support MS_LAZYTIME and MS_RELATIME flags
(Only in "dist" version of code.)
2016-06-28
namespaces/unshare.c
Fix typo in usage() message.
2016-07-01
psem/psem_timedwait.c
threads/thread_multijoin.c
Use slightly better text ('num-secs' vs 'nsecs') in
"usage" message.
2016-07-25
sockets/ud_ucase_sv.c
sockets/us_xfr_sv.c
Add a length check for the server socket pathname.
(Only in "dist" version of code.)
(See the errata for pages 1168 and 1172.)
2016-12-14
namespaces/userns_overview.go
Add a Go program that introspects the user namespace
hierarchy of the system.
2017-04-19
sockets/us_abstract_bind.c
Fix a wording error in a comment (\0abc ==> /0xyz).
2017-05-03
namespaces/userns_child_exec.c
Close unneeded file descriptor before doing execve().
2017-06-09
loginacct/dump_utmpx.c
loginacct/view_lastlog.c
Fix handling of 'time_t' fields for cases where
fields may actually be smaller than 'time_t'.
(See the errata for pages 825 and 831.)
2017-06-12
threads/thread_lock_speed.c
Add '-q' command-line option to cause the program to operate
quietly.
2017-07-14
namespaces/ns_child_exec.c
Instead of '&argv[0]', use the simpler equivalent 'argv'
2017-08-15
getopt/t_getopt.c
Add '__attribute__ ((__noreturn__))' to declaration of
usageError() to prevent "this statement may fall through"
warnings from "gcc -Wimplicit-fallthrough" in switch()
statement in main().
(Only in "dist" version of code.)
2017-08-15
inotify/rand_dtree.c
Eliminate compiler warning about redefinition of
_XOPEN_SOURCE.
2017-10-01
threads/thread_lock_speed.c
Add a alarm timer to prevent runaway/forgotten process
from burning CPU time forever
2017-10-02
inotify/inotify_dtree.c
Remove some superfluous signal-related code.
(Thanks to Mirko Parthey.)
2017-10-16
namespaces/multi_pidns.c
Allocate stacks for the child processes on the heap rather
than in static memory. Marcos Paulo de Souza pointed out
that the children were being killed by SIGSEGV after they
had completed the sleep() calls. (Some further investigation
showed that all children except the *last* are killed with
SIGSEGV.) It appears that they are killed after the child
start function returns. The problem goes away if the
children are allocated stacks in separate memory areas by
calling malloc() (which is the change made in this patch)
or in separate statically allocated buffers.
The reason that the children were killed is based on (my
misunderstanding of) the subtleties of the magic done
in the glibc clone() wrapper function. (See, for example,
the x86-64 implementation in the glibc source file
sysdeps/unix/sysv/linux/x86_64/clone.S.) The
previous code was relying on the fact that the parent's
memory was duplicated in the child during the clone() system
call, and the assumption that that duplicated memory could be
used in the child. However, before executing the clone()
system call, the clone() wrapper function saves some
information (that will be used by the child) onto the stack.
This happens in the address space of the parent, before the
memory is duplicated in the system call. Since the previous
code was making use of the same statically allocated buffer
(i.e., the same address as was used for the parent's stack)
for the child stack, the consequence was that the steps in
the clone() wrapper function were corrupting the stack of the
*parent* process, which ultimately resulted in (all but the
last of) the child processes crashing.
2017-10-17
namespaces/demo_userns.c
namespaces/demo_uts_namespaces.c
namespaces/ns_child_exec.c
namespaces/pidns_init_sleep.c
namespaces/userns_cap_sig_expt.c
namespaces/userns_child_exec.c
namespaces/userns_setns_test.c
Allocate child stack on heap, rather than statically.
Although this is not strictly necessary in these programs
(since only one clone() child is created in each of the
programs), using dynamically allocated memory is good
pedagogical practice, to prevent problems such as were
revealed in the namespaces/multi_pidns.c program.
2017-11-10
pipes/fifo_seqnum_client.c
Fix a small typo in an error diagnostic message.
See the erratum for page 915.
(Thanks to Matthew Meffan.)
2017-11-13
seccomp/seccomp_deny_open.c
Extend the filter to also deny openat() calls. This means
the filter will also work with glibc 2.26 and later, where
the wrapper function for open() now calls openat().
seccomp/seccomp_control_open.c
Extend the filter to also handle openat() calls. This means
the filter will also work with glibc 2.26 and later, where
the wrapper function for open() now calls openat().
2017-11-18
seccomp/seccomp_logging.c
Add a new program to provide a simple demonstration of
the feature added in Linux 4.14 to log allowed system
calls to the audit log.
2017-11-25
dirs_links/nftw_dir_tree.c
Check that the file being visited is stat()-able before
inspecting (sbuf->st_mode & S_IFMT).
See the erratum for page 361.
2017-11-29
namespaces/userns_child_exec.c
Add '-r' option as synonym for '-z'. This is for consistency
with unshare(1), where '-r' is used to create the 'root'
mappings.
2017-12-05
pmsg/mq_notify_thread.c
pmsg/mq_notify_via_thread.c
Add "#include <signal.h>". See the erratum for page 1082.
2018-03-01
seccomp/seccomp_multiarch.c
Add a new program that tests system call numbers for the same
system call for different Intel architectures. This can be
used to demonstrate that execve() can be used to switch the
architecture of the program that a process is running, and
thus why *every* invocation of a seccomp filter must begin
with a test to verify the architecture (since the
architecture may change during the life of a
process/life of the seccomp filter).
2018-03-01
shlibs/dynload.c
Nest use of pragma in push/pop, so that its scope is
just a single line.
(Only in "dist" version of code.)
2018-03-07
seccomp/seccomp_arg64.c
Add a program that shows how to deal with 64-bit
system call arguments from within a seccomp filter.
2018-03-19
[Fix some errors reported by cppcheck(1); thanks to Benedikt Krieger]
dirs_links/list_files_readdir_r.c
Fix a memory leak in error return path.
procexec/execlp.c
Fix some memory leaks.
tty/ttyname.c
Correctly handle NULL return from realloc().
2018-05-03
xattr/xattr_view.c
Fix a casting error when printing EA value in hex.
(See the erratum for page 318.)
2018-05-03
namespaces/userns_functions.c
namespaces/userns_functions.h
Place some useful functions for working with user namespaces
into a separate source file.
2018-05-03
namespaces/t_setns_userns.c
namespaces/unshare.c
namespaces/userns_child_exec.c
namespaces/userns_setns_test.c
Drop private implementations of display_creds_and_caps()/
update_map()/proc_setgroups_write() in favor of versions
in namespaces/userns_functions.c.
2018-05-03
cap/cap_text.c
A simple program to help the user understand text-form
capabilities. The program takes a text-form capability
as an argument and outputs the corresponding bit-mask
representation of the capability sets.
2018-05-09
namespaces/userns_setns_test.c
Various minor refactoring.
2018-05-09
namespaces/demo_userns.c
Correctly free memory allocated by libcap APIs.
2018-05-13
pmsg/mq_notify_siginfo.c
Demonstrate POSIX message queue notification using signals
(an improved version of the pmsg/mq_notify_sig.c program
shown in the book).
vdso/gettimeofday.c
vdso/Makefile
A short program to demonstrate the performance benefits of
implementing some traditional system calls as user-space
interfaces in the VDSO.