Compare commits
462 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6af5a4accf | ||
![]() |
ec8974914f | ||
![]() |
b9775297cd | ||
![]() |
4a6b33f1ee | ||
![]() |
7dd7ff0f33 | ||
![]() |
126732bcc1 | ||
![]() |
23d6dcd125 | ||
![]() |
9fd9e96130 | ||
![]() |
f0a7fc5b43 | ||
![]() |
d82e0d7dd8 | ||
![]() |
5545fc3046 | ||
![]() |
a638056838 | ||
![]() |
1f524c4544 | ||
![]() |
47b8f66ced | ||
![]() |
52da8a514a | ||
![]() |
5cd7c104bd | ||
![]() |
173edca09e | ||
![]() |
506b219237 | ||
![]() |
6c83d7d5bf | ||
![]() |
a059f72b09 | ||
![]() |
afcebd136f | ||
![]() |
3d3c192621 | ||
![]() |
92b3ee855f | ||
![]() |
650ab3b077 | ||
![]() |
474cca1e9d | ||
![]() |
c0cae7f702 | ||
![]() |
3f7e5358e5 | ||
![]() |
3d352f5228 | ||
![]() |
540eca9d9d | ||
![]() |
19cd47fd26 | ||
![]() |
cf62cc435f | ||
![]() |
8b6bdafc39 | ||
![]() |
27790828d1 | ||
![]() |
d782ffb822 | ||
![]() |
5a84ac3fe3 | ||
![]() |
343b7d7488 | ||
![]() |
aefea76cf8 | ||
![]() |
4976edb1a6 | ||
![]() |
171ba532bc | ||
![]() |
bfd2e8c25f | ||
![]() |
b2d225a669 | ||
![]() |
a5f01bbfb5 | ||
![]() |
7e2285a48a | ||
![]() |
3e964eeb96 | ||
![]() |
aec9f902f0 | ||
![]() |
764eb40cc9 | ||
![]() |
95a5b23a38 | ||
![]() |
5d833a9f5b | ||
![]() |
3e51b2f6fc | ||
![]() |
852105dc44 | ||
![]() |
a7473ef379 | ||
![]() |
f7f3792390 | ||
![]() |
2d674a9336 | ||
![]() |
24a38bc1cb | ||
![]() |
82b1739dce | ||
![]() |
fc6b272f41 | ||
![]() |
c9baff669d | ||
![]() |
72ee74b9be | ||
![]() |
cc21808764 | ||
![]() |
78021eace1 | ||
![]() |
65d1a8a4ae | ||
![]() |
187a8e08d5 | ||
![]() |
c9a81c1f91 | ||
![]() |
d580636e97 | ||
![]() |
6ca264a151 | ||
![]() |
aa505d588f | ||
![]() |
96c6fa9202 | ||
![]() |
25706eafac | ||
![]() |
8aa9926839 | ||
![]() |
ff3953efe1 | ||
![]() |
ec5e5ae27a | ||
![]() |
3cc4c8ba9b | ||
![]() |
81672479af | ||
![]() |
6a5170a15f | ||
![]() |
1f4aaaeb5e | ||
![]() |
79148c2945 | ||
![]() |
5767201eaf | ||
![]() |
221c342d50 | ||
![]() |
b56e174322 | ||
![]() |
5afa957915 | ||
![]() |
af3b67b213 | ||
![]() |
93d7b823b4 | ||
![]() |
4a1255bc38 | ||
![]() |
15976a0670 | ||
![]() |
24ba78cb77 | ||
![]() |
15f0b1f624 | ||
![]() |
823311ea3b | ||
![]() |
f67a1f7f64 | ||
![]() |
e625eea4f9 | ||
![]() |
f6297ebe73 | ||
![]() |
372c9b9647 | ||
![]() |
63c65b984a | ||
![]() |
06c6ea654f | ||
![]() |
ab8bfca794 | ||
![]() |
386579a45a | ||
![]() |
f1040fc470 | ||
![]() |
585fd00624 | ||
![]() |
e045e1f386 | ||
![]() |
bf7883ebca | ||
![]() |
a844fb1552 | ||
![]() |
35022f987c | ||
![]() |
8a240aca9e | ||
![]() |
68e7661ca7 | ||
![]() |
e88e3b2797 | ||
![]() |
df68781fca | ||
![]() |
f855f9daaf | ||
![]() |
c5758f2090 | ||
![]() |
3e9b4330a9 | ||
![]() |
c072e13162 | ||
![]() |
f2271428d4 | ||
![]() |
cef379bb03 | ||
![]() |
3e624cd9dc | ||
![]() |
5297d4f5b2 | ||
![]() |
b7c8f59fef | ||
![]() |
13f77e9fd5 | ||
![]() |
472189da15 | ||
![]() |
e5ec81a354 | ||
![]() |
4c3be42cdf | ||
![]() |
24450a5ab7 | ||
![]() |
df7be11b38 | ||
![]() |
52f74c8010 | ||
![]() |
ddf818dad5 | ||
![]() |
e65caf3696 | ||
![]() |
a0af318a8d | ||
![]() |
c008b0ce10 | ||
![]() |
258de82819 | ||
![]() |
c243105e6b | ||
![]() |
3bb4700f98 | ||
![]() |
6bd4ca5644 | ||
![]() |
a01cf5d782 | ||
![]() |
7292a59593 | ||
![]() |
765d8408e9 | ||
![]() |
6da9cb4ba7 | ||
![]() |
3780d7e449 | ||
![]() |
a43f97c4e3 | ||
![]() |
4ee59ab3ed | ||
![]() |
0f283709c9 | ||
![]() |
7a1f355fb5 | ||
![]() |
030ade7590 | ||
![]() |
1ddc789f5a | ||
![]() |
3d115217e4 | ||
![]() |
f31049c17f | ||
![]() |
e6bec9b793 | ||
![]() |
982032fd26 | ||
![]() |
2499c305f9 | ||
![]() |
f6c2faebfa | ||
![]() |
98eb6d57df | ||
![]() |
f60cd2593f | ||
![]() |
2723ebba9a | ||
![]() |
badda27f61 | ||
![]() |
0d57270395 | ||
![]() |
3e1d48fd12 | ||
![]() |
83a420674b | ||
![]() |
9f5c98a76a | ||
![]() |
fc5b6b0328 | ||
![]() |
4dda0095a1 | ||
![]() |
bef2fd9722 | ||
![]() |
ad401d1eaf | ||
![]() |
a92311074b | ||
![]() |
9ede75b1ce | ||
![]() |
fe5f8d0074 | ||
![]() |
0028ffac74 | ||
![]() |
792b189317 | ||
![]() |
43bac63e33 | ||
![]() |
450b5f336d | ||
![]() |
4eafdbdbe8 | ||
![]() |
27fa604418 | ||
![]() |
3c1feedfd1 | ||
![]() |
2023d8eb5b | ||
![]() |
a17fc9902e | ||
![]() |
d6e8280cd8 | ||
![]() |
cbefa47006 | ||
![]() |
b4e20a898e | ||
![]() |
6795dcc4fc | ||
![]() |
fbf658fece | ||
![]() |
593b315c70 | ||
![]() |
56ed92922e | ||
![]() |
9954876417 | ||
![]() |
d96c3254e8 | ||
![]() |
e1619ee151 | ||
![]() |
e09048aaf5 | ||
![]() |
a421016671 | ||
![]() |
f1e7add2bf | ||
![]() |
528864e460 | ||
![]() |
1760dfc051 | ||
![]() |
5d0404e3b3 | ||
![]() |
18595cede8 | ||
![]() |
e5efb6a798 | ||
![]() |
f1e9f613d9 | ||
![]() |
e7dc1e42cd | ||
![]() |
d04f16f600 | ||
![]() |
338b43cd6a | ||
![]() |
394ffc1d97 | ||
![]() |
0251fcd400 | ||
![]() |
eaf4cb6bbb | ||
![]() |
a85ee030ab | ||
![]() |
d8caa679e0 | ||
![]() |
f7bccf3724 | ||
![]() |
38bbec3731 | ||
![]() |
a128f03b30 | ||
![]() |
f0e10d9351 | ||
![]() |
ffa71b4afa | ||
![]() |
9f355169f4 | ||
![]() |
0e14946a20 | ||
![]() |
c204501e3e | ||
![]() |
194b80f974 | ||
![]() |
ec61f0a3af | ||
![]() |
f225f180e3 | ||
![]() |
e74944eee5 | ||
![]() |
eaa924b69e | ||
![]() |
1d59e3e592 | ||
![]() |
5113a3efff | ||
![]() |
1594d0bf9c | ||
![]() |
47057875e7 | ||
![]() |
ef9b54cfe6 | ||
![]() |
04d18f5587 | ||
![]() |
73575f11a9 | ||
![]() |
998bf6e088 | ||
![]() |
34e43ceb0d | ||
![]() |
7209df9e91 | ||
![]() |
0e95d84892 | ||
![]() |
965c2d8760 | ||
![]() |
9fb01d49d6 | ||
![]() |
e42b6f9e15 | ||
![]() |
2ee48b4b4b | ||
![]() |
f4031e8a9a | ||
![]() |
85854b245e | ||
![]() |
09eaf9f5b3 | ||
![]() |
89d44e720b | ||
![]() |
7224913d16 | ||
![]() |
026b81e980 | ||
![]() |
6571cd4073 | ||
![]() |
67ab4f7718 | ||
![]() |
f71145d20d | ||
![]() |
407fbc9e13 | ||
![]() |
5ffa0114c0 | ||
![]() |
08084370fd | ||
![]() |
70c6b773ca | ||
![]() |
0d339e7ffb | ||
![]() |
f0558da598 | ||
![]() |
ec1aa3bc48 | ||
![]() |
26c231f13b | ||
![]() |
99c7b70d1d | ||
![]() |
92f26b6202 | ||
![]() |
0c6565c810 | ||
![]() |
d8aeb3a72a | ||
![]() |
2cf987f5c3 | ||
![]() |
53fe81e752 | ||
![]() |
e716c0f121 | ||
![]() |
1048124120 | ||
![]() |
84a12fbc21 | ||
![]() |
1d97bb8b39 | ||
![]() |
4ea629b9e1 | ||
![]() |
ad200fbc8c | ||
![]() |
b47d7a5fd4 | ||
![]() |
5d897c82b9 | ||
![]() |
4d0f1d7b28 | ||
![]() |
2d2c8c2078 | ||
![]() |
8bc04b98c7 | ||
![]() |
71947dcb91 | ||
![]() |
9c2a1d0de6 | ||
![]() |
94165394ff | ||
![]() |
3aa221aa1d | ||
![]() |
a0df73b493 | ||
![]() |
5bccc94598 | ||
![]() |
a5f44604f7 | ||
![]() |
8c6151bd63 | ||
![]() |
d531a0a307 | ||
![]() |
3639d2431f | ||
![]() |
44cf581732 | ||
![]() |
b65bde04e7 | ||
![]() |
28a6eef3be | ||
![]() |
69b35075f3 | ||
![]() |
744054779f | ||
![]() |
b19c5d51f8 | ||
![]() |
22048b44db | ||
![]() |
1488a9b34d | ||
![]() |
d5b5bb3103 | ||
![]() |
f8be752874 | ||
![]() |
520047c3c4 | ||
![]() |
ae2d48a366 | ||
![]() |
472edf825e | ||
![]() |
cc51bc6fdb | ||
![]() |
55cb17c677 | ||
![]() |
ee876e03b9 | ||
![]() |
579ca216b4 | ||
![]() |
a20d24ded2 | ||
![]() |
1e2673fd98 | ||
![]() |
16c88e493f | ||
![]() |
1e570bf8e3 | ||
![]() |
d9087a2d85 | ||
![]() |
e08710a289 | ||
![]() |
b03e991113 | ||
![]() |
a51aa0d0e2 | ||
![]() |
f82659c552 | ||
![]() |
f653c86229 | ||
![]() |
edcbd379d5 | ||
![]() |
3d3ddf082b | ||
![]() |
f6eb1f1d1f | ||
![]() |
b47e023767 | ||
![]() |
529f7bf358 | ||
![]() |
9f037266ee | ||
![]() |
c7896f1251 | ||
![]() |
361306c131 | ||
![]() |
f48f9341a5 | ||
![]() |
d686298315 | ||
![]() |
9f88b0370d | ||
![]() |
2dbd71b77a | ||
![]() |
483b1e3aa8 | ||
![]() |
c8f3a1c057 | ||
![]() |
ef914f7d83 | ||
![]() |
0efc6c716a | ||
![]() |
4f9f76cd62 | ||
![]() |
8d95b8b338 | ||
![]() |
7abd426438 | ||
![]() |
8fab6e0463 | ||
![]() |
c9aa3cc950 | ||
![]() |
f9ad49c2a5 | ||
![]() |
3eca0cc846 | ||
![]() |
9f6baa127a | ||
![]() |
f79e587cf3 | ||
![]() |
1d2c070071 | ||
![]() |
7828692f97 | ||
![]() |
cacaa90c63 | ||
![]() |
b23a2837db | ||
![]() |
30430fbe30 | ||
![]() |
50b08e7b85 | ||
![]() |
43fed15129 | ||
![]() |
bebb12fd0e | ||
![]() |
b4692ce388 | ||
![]() |
df96787019 | ||
![]() |
d2a9c4a8e7 | ||
![]() |
fbaf1517c3 | ||
![]() |
57038a41fa | ||
![]() |
521c57aca5 | ||
![]() |
ede0532c58 | ||
![]() |
547bbe4876 | ||
![]() |
fe1484f3db | ||
![]() |
d161561290 | ||
![]() |
2cf4f4fb74 | ||
![]() |
b6fd45163a | ||
![]() |
4d76a85df1 | ||
![]() |
d77540c8e4 | ||
![]() |
784df1e4e3 | ||
![]() |
6d82d7bcd5 | ||
![]() |
2614421601 | ||
![]() |
200e235dee | ||
![]() |
0636ce1a7f | ||
![]() |
6042b30c58 | ||
![]() |
604d1eb21a | ||
![]() |
14b43bcaee | ||
![]() |
c79f3883cd | ||
![]() |
df42cd3dbd | ||
![]() |
01bbe8311a | ||
![]() |
21928b97b0 | ||
![]() |
e82e54df2c | ||
![]() |
ecc6da6bf5 | ||
![]() |
b35ff065ec | ||
![]() |
187c355bf4 | ||
![]() |
70516a04fe | ||
![]() |
fcd65d2418 | ||
![]() |
9073ff54c1 | ||
![]() |
840d8e4733 | ||
![]() |
5ad3803dac | ||
![]() |
e04d02cc3a | ||
![]() |
51153fb18c | ||
![]() |
2268e3a32a | ||
![]() |
8b88dc7f71 | ||
![]() |
eecb3d5552 | ||
![]() |
f629355b2f | ||
![]() |
78274fe2b4 | ||
![]() |
4744e27350 | ||
![]() |
31cfc9aa5e | ||
![]() |
a2ead9a486 | ||
![]() |
db2b12fa91 | ||
![]() |
cbf66c5f06 | ||
![]() |
037984c80e | ||
![]() |
9337c692bc | ||
![]() |
c438bdb0d2 | ||
![]() |
144787fe30 | ||
![]() |
8eb81d482c | ||
![]() |
0363998d0a | ||
![]() |
806572d058 | ||
![]() |
81ea383998 | ||
![]() |
8442dc45b6 | ||
![]() |
cfede42fc3 | ||
![]() |
982d59afea | ||
![]() |
ca024e3378 | ||
![]() |
dbf8f6ba0e | ||
![]() |
02805bd1fc | ||
![]() |
965d14726a | ||
![]() |
b0772db56a | ||
![]() |
d695143329 | ||
![]() |
59aa65c9b2 | ||
![]() |
ffc5bf686d | ||
![]() |
ec3c59518d | ||
![]() |
cfe32ef5ba | ||
![]() |
8be5a0fa94 | ||
![]() |
bd4be59fb2 | ||
![]() |
a6d3be9dd5 | ||
![]() |
40913ad219 | ||
![]() |
afd1fd8d41 | ||
![]() |
38111b9622 | ||
![]() |
41153ca4f2 | ||
![]() |
3df2306981 | ||
![]() |
022c5a802f | ||
![]() |
832d85cbbc | ||
![]() |
f72318243c | ||
![]() |
a82d207b8d | ||
![]() |
53e3244dba | ||
![]() |
37427748d1 | ||
![]() |
6e26f9b447 | ||
![]() |
5bfbfbfc22 | ||
![]() |
2c431e8ec4 | ||
![]() |
8aeec251e3 | ||
![]() |
f2d887d7d5 | ||
![]() |
fe98cfee37 | ||
![]() |
cad10a7f80 | ||
![]() |
3734f4ae48 | ||
![]() |
4b13b2e2bf | ||
![]() |
f6a58604a0 | ||
![]() |
65ceb56dd5 | ||
![]() |
cce69be668 | ||
![]() |
a54658c158 | ||
![]() |
335bb5a35b | ||
![]() |
982161e062 | ||
![]() |
5a81678219 | ||
![]() |
168952cea6 | ||
![]() |
5dc1be1df8 | ||
![]() |
cb08b0132f | ||
![]() |
eb6e141adb | ||
![]() |
c6c704fda6 | ||
![]() |
eef7649e71 | ||
![]() |
f8d50f60b3 | ||
![]() |
476eb1b345 | ||
![]() |
c32908cee3 | ||
![]() |
dc1504121b | ||
![]() |
c6a91ec992 | ||
![]() |
689c3e1fcd | ||
![]() |
1bd76bf981 | ||
![]() |
2e7257a2e3 | ||
![]() |
76b83902dc | ||
![]() |
2de297334b | ||
![]() |
b4664769dc | ||
![]() |
7f217d7726 | ||
![]() |
8a1a2f6ca4 | ||
![]() |
bd66d2b59a | ||
![]() |
9f630a1889 | ||
![]() |
04ab68a4dd | ||
![]() |
a7c9cbe1a2 | ||
![]() |
97903dfc47 | ||
![]() |
25ff71b0c7 | ||
![]() |
324be70f80 | ||
![]() |
b8a81fb885 | ||
![]() |
0a35a80b93 | ||
![]() |
c9143a63fe | ||
![]() |
6625b74e90 | ||
![]() |
bd3bf2ce41 | ||
![]() |
f7cadaa843 | ||
![]() |
e173f0b384 | ||
![]() |
1e4a880125 | ||
![]() |
d8f0e320c2 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,3 +10,5 @@
|
||||
test*.img
|
||||
/.buildpath
|
||||
/.project
|
||||
/dracut-version.sh
|
||||
/install/dracut-install
|
||||
|
26
AUTHORS
26
AUTHORS
@@ -1,16 +1,16 @@
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
Victor Lowther <victor.lowther@gmail.com>
|
||||
Amadeusz Żołnowski <aidecoe@aidecoe.name>
|
||||
Philippe Seewer <philippe.seewer@bfh.ch>
|
||||
Warren Togami <wtogami@redhat.com>
|
||||
Amadeusz Żołnowski <aidecoe@aidecoe.name>
|
||||
Will Woods <wwoods@redhat.com>
|
||||
Jeremy Katz <katzj@redhat.com>
|
||||
David Dillow <dave@thedillows.org>
|
||||
Will Woods <wwoods@redhat.com>
|
||||
Michal Soltys <soltys@ziu.info>
|
||||
Dave Young <dyoung@redhat.com>
|
||||
Amerigo Wang <amwang@redhat.com>
|
||||
Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
Dave Young <dyoung@redhat.com>
|
||||
Colin Guthrie <colin@mageia.org>
|
||||
Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
Andreas Thienemann <andreas@bawue.net>
|
||||
Hans de Goede <hdegoede@redhat.com>
|
||||
Peter Jones <pjones@redhat.com>
|
||||
@@ -18,30 +18,34 @@ John Reiser <jreiser@bitwagon.com>
|
||||
Luca Berra <bluca@vodka.it>
|
||||
Daniel Drake <dsd@laptop.org>
|
||||
Marc Grimme <grimme@atix.de>
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
Dan Horák <dhorak@redhat.com>
|
||||
Jesse Keating <jkeating@redhat.com>
|
||||
Roberto Sassu <roberto.sassu@polito.it>
|
||||
Anton Blanchard <anton@samba.org>
|
||||
Bill Nottingham <notting@redhat.com>
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
David Cantrell <dcantrell@redhat.com>
|
||||
Jon Ander Hernandez <jonan.h@gmail.com>
|
||||
Juan RP <xtraeme@gmail.com>
|
||||
Lance Albertson <lance@osuosl.org>
|
||||
Marian Ganisin <mganisin@redhat.com>
|
||||
Michael Ploujnikov <plouj@somanetworks.com>
|
||||
Peter Rajnoha <prajnoha@redhat.com>
|
||||
Alan Jenkins <alan-jenkins@tuffmail.co.uk>
|
||||
Alan Pevec <apevec@redhat.com>
|
||||
Ian Dall <ian@beware.dropbear.id.au>
|
||||
James Buren <ryuo@frugalware.org>
|
||||
Joey Boggs <jboggs@redhat.com>
|
||||
Jon Ander Hernandez <jonan.h@gmail.com>
|
||||
Mike Snitzer <snitzer@redhat.com>
|
||||
Peter Rajnoha <prajnoha@redhat.com>
|
||||
Przemysław Rudy <prudy1@o2.pl>
|
||||
Thomas Lange <lange@informatik.uni-koeln.de>
|
||||
Vladislav Bogdanov <bubble@hoster-ok.com>
|
||||
Alexander Todorov <atodorov@redhat.com>
|
||||
Andy Lutomirski <luto@mit.edu>
|
||||
Anssi Hannula <anssi@mageia.org>
|
||||
Christian Heinz <christian.ch.heinz@gmail.com>
|
||||
Dave Jones <davej@redhat.com>
|
||||
Dennis Gilmore <dennis@ausil.us>
|
||||
Duane Griffin <duaneg@dghda.com>
|
||||
Frederic Crozat <fcrozat@mandriva.com>
|
||||
Glen Gray <slaine@slaine.org>
|
||||
@@ -50,20 +54,26 @@ James Laska <jlaska@redhat.com>
|
||||
Jan Stodola <jstodola@redhat.com>
|
||||
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
||||
Leho Kraav <leho@kraav.com>
|
||||
Lennert Buytenhek <buytenh@wantstofly.org>
|
||||
Lubomir Rintel <lkundrak@v3.sk>
|
||||
Matt <smoothsailing72@hotmail.com>
|
||||
Matt Smith <shadowfax@gmx.com>
|
||||
Michal Schmidt <mschmidt@redhat.com>
|
||||
Milan Broz <mbroz@redhat.com>
|
||||
Munehiro Matsuda <haro@kgt.co.jp>
|
||||
Nikoli <nikoli@lavabit.com>
|
||||
Olivier Blin <dev@blino.org>
|
||||
Paolo Bonzini <pbonzini@redhat.com>
|
||||
Peter Robinson <pbrobinson@fedoraproject.org>
|
||||
Pádraig Brady <P@draigBrady.com>
|
||||
Quentin Armitage <quentin@armitage.org.uk>
|
||||
Sergey Fionov <fionov@gmail.com>
|
||||
Srinivasa T N <seenutn@linux.vnet.ibm.com>
|
||||
Thilo Bangert <thilo.bangert@gmx.net>
|
||||
Thomas Lange <lange@informatik.uni-koeln.de>
|
||||
Tomasz Torcz <tomek@pipebreaker.pl>
|
||||
Vadim Kuznetsov <vadimk@gentoo.org>
|
||||
Ville Skyttä <ville.skytta@iki.fi>
|
||||
Vivek Goyal <vgoyal@redhat.com>
|
||||
Wim Muskee <wimmuskee@gmail.com>
|
||||
Yanko Kaneti <yaneti@declera.com>
|
||||
maximilian attems <max@stro.at>
|
||||
|
97
Makefile
97
Makefile
@@ -1,4 +1,4 @@
|
||||
VERSION=018
|
||||
VERSION=023
|
||||
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
|
||||
|
||||
prefix ?= /usr
|
||||
@@ -8,12 +8,54 @@ pkglibdir ?= ${libdir}/dracut
|
||||
sysconfdir ?= ${prefix}/etc
|
||||
bindir ?= ${prefix}/bin
|
||||
mandir ?= ${prefix}/share/man
|
||||
CFLAGS ?= -O2 -g -Wall
|
||||
CFLAGS += -std=gnu99
|
||||
|
||||
man1pages = lsinitrd.1
|
||||
|
||||
man5pages = dracut.conf.5
|
||||
|
||||
man7pages = dracut.cmdline.7
|
||||
|
||||
man8pages = dracut.8 \
|
||||
dracut-catimages.8 \
|
||||
mkinitrd.8 \
|
||||
modules.d/98systemd/dracut-cmdline.service.8 \
|
||||
modules.d/98systemd/dracut-initqueue.service.8 \
|
||||
modules.d/98systemd/dracut-pre-pivot.service.8 \
|
||||
modules.d/98systemd/dracut-pre-trigger.service.8 \
|
||||
modules.d/98systemd/dracut-pre-udev.service.8 \
|
||||
modules.d/98systemd/initrd-switch-root.service.8 \
|
||||
modules.d/98systemd/udevadm-cleanup-db.service.8
|
||||
|
||||
manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
|
||||
|
||||
manpages = dracut.8 dracut.cmdline.7 dracut.conf.5 dracut-catimages.8
|
||||
|
||||
.PHONY: install clean archive rpm testimage test all check AUTHORS doc
|
||||
|
||||
all: syncheck
|
||||
all: syncheck dracut-version.sh dracut-install
|
||||
|
||||
DRACUT_INSTALL_OBJECTS = \
|
||||
install/dracut-install.o \
|
||||
install/hashmap.o\
|
||||
install/log.o \
|
||||
install/util.o
|
||||
|
||||
# deps generated with gcc -MM
|
||||
install/dracut-install.o: install/dracut-install.c install/log.h install/macro.h \
|
||||
install/hashmap.h install/util.h
|
||||
install/hashmap.o: install/hashmap.c install/util.h install/macro.h install/log.h \
|
||||
install/hashmap.h
|
||||
install/log.o: install/log.c install/log.h install/macro.h install/util.h
|
||||
install/util.o: install/util.c install/util.h install/macro.h install/log.h
|
||||
|
||||
install/dracut-install: $(DRACUT_INSTALL_OBJECTS)
|
||||
|
||||
dracut-install: install/dracut-install
|
||||
ln -fs $< $@
|
||||
|
||||
indent:
|
||||
indent -i8 -nut -br -linux -l120 install/dracut-install.c
|
||||
|
||||
doc: $(manpages) dracut.html
|
||||
|
||||
@@ -32,12 +74,12 @@ dracut.html: dracut.asc $(manpages)
|
||||
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
|
||||
rm dracut.xml
|
||||
|
||||
install: doc
|
||||
install: doc dracut-version.sh
|
||||
mkdir -p $(DESTDIR)$(pkglibdir)
|
||||
mkdir -p $(DESTDIR)$(bindir)
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)
|
||||
mkdir -p $(DESTDIR)$(pkglibdir)/modules.d
|
||||
mkdir -p $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 $(DESTDIR)$(mandir)/man8
|
||||
mkdir -p $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 $(DESTDIR)$(mandir)/man8
|
||||
install -m 0755 dracut.sh $(DESTDIR)$(bindir)/dracut
|
||||
install -m 0755 dracut-catimages.sh $(DESTDIR)$(bindir)/dracut-catimages
|
||||
install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(bindir)/mkinitrd
|
||||
@@ -45,25 +87,29 @@ install: doc
|
||||
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
|
||||
install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh
|
||||
ln -s dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions
|
||||
install -m 0755 dracut-version.sh $(DESTDIR)$(pkglibdir)/dracut-version.sh
|
||||
ln -fs dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions
|
||||
install -m 0755 dracut-logger.sh $(DESTDIR)$(pkglibdir)/dracut-logger.sh
|
||||
install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore
|
||||
cp -arx modules.d $(DESTDIR)$(pkglibdir)
|
||||
install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8/dracut.8
|
||||
install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8/dracut-catimages.8
|
||||
install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5/dracut.conf.5
|
||||
install -m 0644 dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.cmdline.7
|
||||
ln -s dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
|
||||
for i in $(man1pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man1/$${i##*/}; done
|
||||
for i in $(man5pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man5/$${i##*/}; done
|
||||
for i in $(man7pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man7/$${i##*/}; done
|
||||
for i in $(man8pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man8/$${i##*/}; done
|
||||
ln -fs dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
|
||||
if [ -n "$(systemdsystemunitdir)" ]; then \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
|
||||
install -m 0644 dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir); \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants; \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants; \
|
||||
ln -s ../dracut-shutdown.service \
|
||||
$(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants/dracut-shutdown.service; \
|
||||
ln -s ../dracut-shutdown.service \
|
||||
$(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \
|
||||
fi
|
||||
if [ -f install/dracut-install ]; then \
|
||||
install -m 0755 install/dracut-install $(DESTDIR)$(pkglibdir)/dracut-install; \
|
||||
fi
|
||||
|
||||
dracut-version.sh:
|
||||
@echo "DRACUT_VERSION=$(VERSION)-$(GITVERSION)" > dracut-version.sh
|
||||
|
||||
clean:
|
||||
$(RM) *~
|
||||
@@ -71,6 +117,7 @@ clean:
|
||||
$(RM) */*/*~
|
||||
$(RM) test-*.img
|
||||
$(RM) dracut-*.rpm dracut-*.tar.bz2
|
||||
$(RM) dracut-install install/dracut-install $(DRACUT_INSTALL_OBJECTS)
|
||||
$(RM) $(manpages) dracut.html
|
||||
$(MAKE) -C test clean
|
||||
|
||||
@@ -90,11 +137,11 @@ dracut-$(VERSION).tar.bz2: doc
|
||||
rpm: dracut-$(VERSION).tar.bz2
|
||||
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
|
||||
cp dracut-$(VERSION).tar.bz2 "$$rpmbuild"; \
|
||||
$$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
|
||||
LC_MESSAGES=C $$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
|
||||
(cd "$$rpmbuild"; rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
|
||||
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
|
||||
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
|
||||
( mv "$$rpmbuild"/noarch/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
|
||||
( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
|
||||
|
||||
syncheck:
|
||||
@ret=0;for i in dracut-initramfs-restore.sh dracut-logger.sh \
|
||||
@@ -109,21 +156,29 @@ syncheck:
|
||||
done;exit $$ret
|
||||
|
||||
check: all syncheck
|
||||
$(MAKE) -C test check
|
||||
@[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
|
||||
@$(MAKE) -C test check
|
||||
|
||||
testimage: all
|
||||
./dracut.sh -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
|
||||
testimages: all
|
||||
./dracut.sh -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
./dracut.sh -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
|
||||
@echo wrote test-dracut.img
|
||||
@echo wrote test-dracut.img
|
||||
|
||||
hostimage: all
|
||||
./dracut.sh -H -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
|
||||
AUTHORS:
|
||||
git shortlog --numbered --summary -e |while read a rest; do echo $$rest;done > AUTHORS
|
||||
|
||||
dracut.html.sign: dracut-$(VERSION).tar.bz2
|
||||
gpg-sign-all dracut-$(VERSION).tar.bz2 dracut.html
|
||||
|
||||
upload: dracut.html.sign
|
||||
kup put dracut-$(VERSION).tar.bz2 dracut-$(VERSION).tar.sign /pub/linux/utils/boot/dracut/
|
||||
kup put dracut.html dracut.html.sign /pub/linux/utils/boot/dracut/
|
||||
|
110
NEWS
110
NEWS
@@ -1,3 +1,113 @@
|
||||
dracut-023
|
||||
==========
|
||||
- resume from hibernate fixes
|
||||
- -N option for --no-hostonly
|
||||
- support for systemd crypto handling
|
||||
- new dracut module "crypt-loop"
|
||||
- deprecate the old kernel command line options
|
||||
- more documentation
|
||||
- honor CFLAGS for dracut-install build
|
||||
- multipath fixes
|
||||
- / is mounted according to rootflags parameter but forced ro at first.
|
||||
Later it is remounted according to /etc/fstab + rootflags parameter
|
||||
and "ro"/"rw".
|
||||
- support for xfs / reiserfs separate journal device
|
||||
- new "ro_mnt" option to force ro mount of / and /usr
|
||||
- root on cifs support
|
||||
- dracut-install: fixed issue for /var/tmp containing a symlink
|
||||
- only lazy resolve with ldd, if the /var/tmp partition is not mounted with "noexec"
|
||||
- i18n: fixed inclusion of "include" keymaps
|
||||
|
||||
dracut-022
|
||||
==========
|
||||
- fixed host-only kernel module bug
|
||||
|
||||
dracut-021
|
||||
==========
|
||||
- fixed systemd in the initramfs (requires systemd >= 187)
|
||||
- dracut-install: massive speedup with /var on the same filesystem with COW copy
|
||||
- dracut-install: moved to /usr/lib/dracut until it becomes a general purpose tool
|
||||
- new options: "rd.usrmount.ro" and "rd.skipfsck"
|
||||
- less mount/umount
|
||||
- apply "ro" on the kernel command line also to /usr
|
||||
- mount according to fstab, if neither "ro" or "rw" is specified
|
||||
- skip fsck for xfs and btrfs. remount is enough
|
||||
- give emergency_shell if /usr mount failed
|
||||
- dracut now uses getopt:
|
||||
* options can be position independent now!!
|
||||
* we can now use --option=<arg>
|
||||
- added option "--kver=<kernel-version>", and the image location can be omitted
|
||||
# dracut --kver 3.5.0-0.rc7.git1.2.fc18.x86_64
|
||||
- dracut.sh: for --include copy also the symbolic links
|
||||
- man pages: lsinitrd and mkinitrd added
|
||||
- network: We do not support renaming in the kernel namespace anymore (as udev does
|
||||
that not anymore). So, if a user wants to use ifname, he has to rename
|
||||
to a custom namespace. "eth[0-9]+" is not allowed anymore. !!!!!
|
||||
- resume: moved the resume process to the initqueue.
|
||||
This should prevent accidently mounting the root file system.
|
||||
- testsuite: add support for: make V=1 TESTS="01 20 40" check
|
||||
$ sudo make V=1 clean check
|
||||
now runs the testsuite in verbose mode
|
||||
|
||||
$ sudo make TESTS="01 20 40" clean check
|
||||
now only runs the 01, 20 and 40 tests.
|
||||
|
||||
dracut-020
|
||||
==========
|
||||
- changed rd.dasd kernel parameter
|
||||
- arm kernel modules added to kernel-modules
|
||||
- make udevdir systemdutildir systemdsystemunitdir global vars
|
||||
your distribution should ship those settings in
|
||||
/etc/dracut.conf.d/01-distro.conf
|
||||
see dracut.conf.d/fedora.conf.example
|
||||
- kernel modules are now only handled with /sys/modules and modules.dep
|
||||
- systemd fixups
|
||||
- mdraid: wait for md devices to be clean, before shutdown
|
||||
- ifup fixed for ipv6
|
||||
- add PARTUUID as root=PARTUUID=<partition uuid> parameter
|
||||
- fixed instmods() return code and set pipefail globally
|
||||
- add 04watchdog dracut module
|
||||
- dracut-shutdown.service: fixed ordering to be before shutdown.target
|
||||
- make use of "ln -r" instead of shell functions, if new coreutils is installed
|
||||
- network: support vlan tagged bonding
|
||||
- new dracut module qemu and qemu-net to install all kernel driver
|
||||
- fs-lib/fs-lib.sh: removed test mounting of btrfs and xfs
|
||||
- no more "mknod" in the initramfs!!
|
||||
- replaced all "tr" calls with "sed"
|
||||
- speedup with lazy kernel module dependency resolving
|
||||
- lots of speedup optimizations and last but not least
|
||||
- dracut-install:
|
||||
- new binary to significanlty speedup the installation process
|
||||
- dracut-functions.sh makes use of it, if installed
|
||||
|
||||
|
||||
dracut-019
|
||||
==========
|
||||
- initqueue/online hook
|
||||
- fixes for ifcfg write out
|
||||
- rootfs-block: avoid remount when options don't change
|
||||
- Debian multiarch support
|
||||
- virtfs root filesystem support
|
||||
- cope with systemd-udevd
|
||||
- mount tmpfs with strictatime
|
||||
- include all kernel/drivers/net/phy drivers
|
||||
- add debug_on() and debug_off() functions
|
||||
- add arguments for source_hook() and source_all()
|
||||
- cleanup hook
|
||||
- plymouth: get consoledev from /sys/class/tty/console/active
|
||||
- experimental systemd dracut module for systemd in the initramfs
|
||||
- install xhci-hcd kernel module
|
||||
- dracut: new "--mount" option
|
||||
- lsinitrd: new option --printsize
|
||||
- ARM storage kernel modules added
|
||||
- s390 cms conf file support
|
||||
- /etc/initrd-release in the initrd
|
||||
- vlan support
|
||||
- full bonding and bridge support
|
||||
- removed scsi_wait_scan kernel module from standard install
|
||||
- support rd.luks.allow-discards and honor options in crypttab
|
||||
- lots of bugfixes
|
||||
|
||||
dracut-018
|
||||
==========
|
||||
- lvm: ignore lvm mirrors
|
||||
|
@@ -103,6 +103,9 @@ init has the following hook points to inject scripts:
|
||||
a timeout.
|
||||
|
||||
/lib/dracut/hooks/pre-pivot/*.sh
|
||||
scripts to run before latter initramfs cleanups
|
||||
|
||||
/lib/dracut/hooks/cleanup/*.sh
|
||||
scripts to run before the real init is executed and the initramfs
|
||||
disappears
|
||||
All processes started before should be killed here.
|
||||
|
30
README.testsuite
Normal file
30
README.testsuite
Normal file
@@ -0,0 +1,30 @@
|
||||
For the testsuite to work, you will have to install at least the following software packages:
|
||||
dash
|
||||
asciidoc
|
||||
mdadm
|
||||
lvm2
|
||||
cryptsetup
|
||||
nfs-utils
|
||||
netbsd-iscsi
|
||||
nbd
|
||||
dhcp (dhcp-server on openSUSE)
|
||||
iscsi-initiator-utils
|
||||
TEST-04-FULL-SYSTEMD: systemd >= 187
|
||||
|
||||
How to run the testsuite:
|
||||
|
||||
$ sudo make clean check
|
||||
|
||||
in verbose mode:
|
||||
$ sudo make V=1 clean check
|
||||
|
||||
only specific test:
|
||||
$ sudo make TESTS="01 20 40" clean check
|
||||
only runs the 01, 20 and 40 tests.
|
||||
|
||||
debug a specific test case:
|
||||
$ cd TEST-01-BASIC
|
||||
$ sudo make clean setup run
|
||||
... change some kernel parameters ...
|
||||
$ sudo make run
|
||||
to run the test without doing the setup
|
8
TODO
8
TODO
@@ -6,15 +6,19 @@ Items are ordered in priority.
|
||||
|
||||
INITRAMFS TODO
|
||||
|
||||
- use info and warn prefix
|
||||
- add sosreport
|
||||
- generate systemd unit dracut-initramfs-restore in /run/systemd dynamically
|
||||
- put "root=" parsing hooks in separate hook dir
|
||||
- call "root=" parsing hooks after getting new rootpath from dhcp
|
||||
- put mount hook in main initqueue loop
|
||||
- put mount hook in main initqueue loop / careful about resume!
|
||||
- the hard-coded list of udev rules that we care about is kind of lame.
|
||||
- automatic kexec fallback
|
||||
- panic fallback
|
||||
|
||||
GENERATOR TODO
|
||||
|
||||
- add interpreter/plugin-scripts to be sourced at the beginning or end (can use dracut-functions)
|
||||
- provide "installkernel" and "new-kernel-pkg"
|
||||
- add mechanism for module specific command line options
|
||||
- pkg-config integration, to make it easy for other packages to use us.
|
||||
- add recovery image creator (mkrecovery)
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -116,7 +116,7 @@ dlog_init() {
|
||||
|
||||
if [ -z "$fileloglvl" ]; then
|
||||
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
|
||||
elif [ $fileloglvl -gt 0 ]; then
|
||||
elif (( $fileloglvl >= 0 )); then
|
||||
__oldumask=$(umask)
|
||||
umask 0377
|
||||
! [ -e "$logfile" ] && >"$logfile"
|
||||
@@ -138,7 +138,7 @@ dlog_init() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $sysloglvl -gt 0 ]; then
|
||||
if (( $sysloglvl >= 0 )); then
|
||||
if ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null
|
||||
then
|
||||
# We cannot log to syslog, so turn this facility off.
|
||||
@@ -148,7 +148,7 @@ dlog_init() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $sysloglvl -gt 0 -o $kmsgloglvl -gt 0 ]; then
|
||||
if (($sysloglvl >= 0)) || (($kmsgloglvl >= 0 )); then
|
||||
if [ -n "$dracutbasedir" ]; then
|
||||
readonly syslogfacility=user
|
||||
else
|
||||
@@ -159,11 +159,44 @@ dlog_init() {
|
||||
|
||||
local lvl; local maxloglvl_l=0
|
||||
for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
|
||||
[ $lvl -gt $maxloglvl_l ] && maxloglvl_l=$lvl
|
||||
(( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl
|
||||
done
|
||||
readonly maxloglvl=$maxloglvl_l
|
||||
export maxloglvl
|
||||
|
||||
|
||||
if (($stdloglvl < 6)) && (($kmsgloglvl < 6)) && (($fileloglvl < 6)); then
|
||||
unset dtrace
|
||||
dtrace() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 5)) && (($kmsgloglvl < 5)) && (($fileloglvl < 5)); then
|
||||
unset ddebug
|
||||
ddebug() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 4)) && (($kmsgloglvl < 4)) && (($fileloglvl < 4)); then
|
||||
unset dinfo
|
||||
dinfo() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 3)) && (($kmsgloglvl < 3)) && (($fileloglvl < 3)); then
|
||||
unset dwarn
|
||||
dwarn() { :; };
|
||||
unset dwarning
|
||||
dwarning() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 2)) && (($kmsgloglvl < 2)) && (($fileloglvl < 2)); then
|
||||
unset derror
|
||||
derror() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 1)) && (($kmsgloglvl < 1)) && (($fileloglvl < 1)); then
|
||||
unset dfatal
|
||||
dfatal() { :; };
|
||||
fi
|
||||
|
||||
[ -n "$errmsg" ] && derror "$errmsg"
|
||||
|
||||
return $ret
|
||||
@@ -275,14 +308,14 @@ _do_dlog() {
|
||||
local lvlc=$(_lvl2char "$lvl") || return 0
|
||||
local msg="$lvlc: $*"
|
||||
|
||||
[ $lvl -le $stdloglvl ] && echo "$msg" >&2
|
||||
if [ $lvl -le $sysloglvl ]; then
|
||||
(( $lvl <= $stdloglvl )) && echo "$msg" >&2
|
||||
if (( $lvl <= $sysloglvl )); then
|
||||
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) "$msg"
|
||||
fi
|
||||
if [ $lvl -le $fileloglvl -a -w "$logfile" -a -f "$logfile" ]; then
|
||||
if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
|
||||
echo "$msg" >>"$logfile"
|
||||
fi
|
||||
[ $lvl -le $kmsgloglvl ] && \
|
||||
(( $lvl <= $kmsgloglvl )) && \
|
||||
echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
|
||||
}
|
||||
|
||||
@@ -304,9 +337,9 @@ _do_dlog() {
|
||||
# echo "This is a warning" | dwarn
|
||||
dlog() {
|
||||
[ -z "$maxloglvl" ] && return 0
|
||||
[ $1 -le $maxloglvl ] || return 0
|
||||
(( $1 <= $maxloglvl )) || return 0
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
if (( $# > 1 )); then
|
||||
_do_dlog "$@"
|
||||
else
|
||||
while read line; do
|
||||
|
@@ -8,9 +8,10 @@
|
||||
[Unit]
|
||||
Description=Restore /run/initramfs
|
||||
After=getty@tty1.service prefdm.service
|
||||
Before=reboot.service
|
||||
Before=systemd-reboot.service shutdown.target
|
||||
DefaultDependencies=no
|
||||
ConditionPathExists=/run/initramfs/.need_shutdown
|
||||
ConditionPathExists=!/run/initramfs/bin/sh
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/lib/dracut/dracut-initramfs-restore
|
||||
|
110
dracut.8.asc
110
dracut.8.asc
@@ -14,6 +14,12 @@ SYNOPSIS
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
Create an initramfs <image> for the kernel with the version <kernel version>.
|
||||
If <kernel version> is omitted, then the version of the actual running
|
||||
kernel is used. If <image> is omitted or empty, then the default location
|
||||
/boot/initramfs-<kernel version>.img is used.
|
||||
|
||||
dracut creates an initial image used by the kernel for preloading the block
|
||||
device modules (such as IDE, SCSI or RAID) which are needed to access the root
|
||||
filesystem, mounting the root filesystem and booting into the real system.
|
||||
@@ -22,10 +28,65 @@ At boot time, the kernel unpacks that archive into RAM disk, mounts and uses it
|
||||
as initial root file system. All finding of the root device happens in this
|
||||
early userspace.
|
||||
|
||||
For a complete list of kernel command line options see *dracut.cmdline*(7)
|
||||
For a complete list of kernel command line options see *dracut.cmdline*(7).
|
||||
|
||||
EXAMPLE
|
||||
-------
|
||||
|
||||
To create a initramfs image, the most simple command is:
|
||||
----
|
||||
# dracut
|
||||
----
|
||||
|
||||
This will generate a general purpose initramfs image, with all possible
|
||||
functionality resulting of the combination of the installed dracut modules and
|
||||
system tools. The image is /boot/initramfs-_++<kernel version>++_.img and
|
||||
contains the kernel modules of the currently active kernel with version
|
||||
_++<kernel version>++_.
|
||||
|
||||
If the initramfs image already exists, dracut will display an error message, and
|
||||
to overwrite the existing image, you have to use the --force option.
|
||||
----
|
||||
# dracut --force
|
||||
----
|
||||
|
||||
If you want to specify another filename for the resulting image you would issue
|
||||
a command like:
|
||||
----
|
||||
# dracut foobar.img
|
||||
----
|
||||
|
||||
To generate an image for a specific kernel version, the command would be:
|
||||
----
|
||||
# dracut foobar.img 2.6.40-1.rc5.f20
|
||||
----
|
||||
|
||||
A shortcut to generate the image at the default location for a specific kernel
|
||||
version is:
|
||||
----
|
||||
# dracut --kver 2.6.40-1.rc5.f20
|
||||
----
|
||||
|
||||
If you want to create lighter, smaller initramfs images, you may want to specify
|
||||
the --host-only or -H option. Using this option, the resulting image will
|
||||
contain only those dracut modules, kernel modules and filesystems, which are
|
||||
needed to boot this specific machine. This has the drawback, that you can't put
|
||||
the disk on another controller or machine, and that you can't switch to another
|
||||
root filesystem, without recreating the initramfs image. The usage of the
|
||||
--host-only option is only for experts and you will have to keep the broken
|
||||
pieces. At least keep a copy of a general purpose image (and corresponding
|
||||
kernel) as a fallback to rescue your system.
|
||||
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**--kver** _<kernel version>_::
|
||||
set the kernel version. This enables to specify the kernel version, without
|
||||
specifying the location of the initramfs image. For example:
|
||||
----
|
||||
# dracut --kver 3.5.0-0.rc7.git1.2.fc18.x86_64
|
||||
----
|
||||
|
||||
**-f, --force**::
|
||||
overwrite existing initramfs file.
|
||||
|
||||
@@ -46,7 +107,7 @@ example:
|
||||
**-o, --omit** _<list of dracut modules>_::
|
||||
omit a space-separated list of dracut modules. This parameter can be
|
||||
specified multiple times.
|
||||
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
@@ -130,7 +191,7 @@ example:
|
||||
specify a space-separated list of kernel filesystem modules to exclusively
|
||||
include in the generic initramfs. This parameter can be specified multiple
|
||||
times.
|
||||
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
@@ -183,10 +244,16 @@ example:
|
||||
inhibit installation of any fsck tools
|
||||
|
||||
**--strip**::
|
||||
strip binaries in the initramfs (default)
|
||||
strip binaries in the initramfs
|
||||
|
||||
**--nostrip**::
|
||||
do not strip binaries in the initramfs
|
||||
do not strip binaries in the initramfs (default)
|
||||
|
||||
**--hardlink**::
|
||||
hardlink files in the initramfs (default)
|
||||
|
||||
**--nohardlink**::
|
||||
do not hardlink files in the initramfs
|
||||
|
||||
**--prefix** _<dir>_::
|
||||
prefix initramfs files with the specified directory
|
||||
@@ -232,8 +299,8 @@ Default:
|
||||
This is useful when running dracut from a git checkout.
|
||||
|
||||
**-H, --hostonly**::
|
||||
Host-Only mode: Install only what is needed for booting
|
||||
the local host instead of a generic host.
|
||||
Host-Only mode: Install only what is needed for booting the local host
|
||||
instead of a generic host and generate host-specific configuration.
|
||||
+
|
||||
[WARNING]
|
||||
====
|
||||
@@ -241,13 +308,13 @@ If chrooted to another root other than the real root device, use "--fstab" and
|
||||
provide a valid _/etc/fstab_.
|
||||
====
|
||||
|
||||
**--no-hostonly**::
|
||||
**-N, --no-hostonly**::
|
||||
Disable Host-Only mode
|
||||
|
||||
**--fstab**::
|
||||
Use _/etc/fstab_ instead of _/proc/self/mountinfo_.
|
||||
|
||||
**--add_fstab** _<filename>_ ::
|
||||
**--add-fstab** _<filename>_ ::
|
||||
Add entries of _<filename>_ to the initramfs /etc/fstab.
|
||||
|
||||
**--mount** "_<device>_ _<mountpoint>_ _<filesystem type>_ _<filesystem options>_"::
|
||||
@@ -267,7 +334,6 @@ provide a valid _/etc/fstab_.
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
+
|
||||
----
|
||||
# dracut --install "/bin/foo /sbin/bar" ...
|
||||
----
|
||||
@@ -358,29 +424,21 @@ link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org]
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
*Harald Hoyer*::
|
||||
Project Leader and Developer
|
||||
Harald Hoyer
|
||||
|
||||
*Victor Lowther*::
|
||||
Developer
|
||||
Victor Lowther
|
||||
|
||||
*Philippe Seewer*::
|
||||
Developer
|
||||
Philippe Seewer
|
||||
|
||||
*Warren Togami*::
|
||||
Developer
|
||||
Warren Togami
|
||||
|
||||
*Amadeusz Żołnowski*::
|
||||
Developer
|
||||
Amadeusz Żołnowski
|
||||
|
||||
*Jeremy Katz*::
|
||||
Developer
|
||||
Jeremy Katz
|
||||
|
||||
*David Dillow*::
|
||||
Developer
|
||||
David Dillow
|
||||
|
||||
*Will Woods*::
|
||||
Developer
|
||||
Will Woods
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
27
dracut.asc
27
dracut.asc
@@ -154,7 +154,7 @@ To generate an image for a specific kernel version, the command would be:
|
||||
A shortcut to generate the image at the default location for a specific kernel
|
||||
version is:
|
||||
----
|
||||
# dracut '' 2.6.40-1.rc5.f20
|
||||
# dracut --kver 2.6.40-1.rc5.f20
|
||||
----
|
||||
|
||||
If you want to create lighter, smaller initramfs images, you may want to specify
|
||||
@@ -459,6 +459,13 @@ dracut shell commands are printed as they are executed
|
||||
# less /run/initramfs/init.log
|
||||
# dmesg | less
|
||||
----
|
||||
. With dracut >= 022 and systemd, you can inspect the rd.debug output with:
|
||||
----
|
||||
# journalctl -ab
|
||||
----
|
||||
|
||||
If you want to save that output, simply mount /boot by hand or insert an USB stick and mount that.
|
||||
Then you can store the output for later inspection.
|
||||
|
||||
[[information-to-include-in-your-report]]
|
||||
=== Information to include in your report
|
||||
@@ -472,14 +479,13 @@ configuration file (e.g. _/etc/grub.conf_) or from _/proc/cmdline_.
|
||||
* A copy of your disk partition information from _/etc/fstab_, which might be
|
||||
obtained booting an old working initramfs or a rescue medium.
|
||||
* A device listing from device-mapper. This can be obtained by running the
|
||||
command
|
||||
command
|
||||
+
|
||||
----
|
||||
# dmsetup ls --tree
|
||||
----
|
||||
+
|
||||
* A list of block device attributes including vol_id compatible mode. This can
|
||||
be obtained by running the commands:
|
||||
* A list of block device attributes. This can be obtained by running the commands:
|
||||
+
|
||||
----
|
||||
# blkid -p
|
||||
@@ -854,12 +860,17 @@ This hook is mainly to mount the real root device.
|
||||
|
||||
=== Hook: pre-pivot
|
||||
|
||||
This hook is called before cleanup hook, This is a good place for
|
||||
actions other than cleanups which need to be called before pivot.
|
||||
|
||||
|
||||
=== Hook: cleanup
|
||||
|
||||
This hook is the last hook and is called before init finally switches root to
|
||||
the real root device. This is a good place to clean up and kill processes not
|
||||
needed anymore.
|
||||
|
||||
|
||||
|
||||
=== Cleanup and switch_root
|
||||
|
||||
Init kills all udev processes, cleans up the environment, sets up the arguments
|
||||
@@ -1018,6 +1029,12 @@ include::dracut.conf.5.asc[]
|
||||
[[dracutcmdline7]]
|
||||
include::dracut.cmdline.7.asc[]
|
||||
|
||||
[[lsinitrd1]]
|
||||
include::lsinitrd.1.asc[]
|
||||
|
||||
[[mkinitrd8]]
|
||||
include::mkinitrd.8.asc[]
|
||||
|
||||
:leveloffset: 0
|
||||
[appendix]
|
||||
License
|
||||
|
@@ -47,6 +47,7 @@ root=/dev/disk/by-label/Root
|
||||
root=LABEL=Root
|
||||
root=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
root=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
root=PARTUUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
----
|
||||
|
||||
**rootfstype=**_<filesystem type>_:: "auto" if not specified, e.g.:
|
||||
@@ -60,10 +61,35 @@ rootfstype=ext3
|
||||
_/etc/fstab_ of the real root will be parsed for special mount options and
|
||||
mounted accordingly.
|
||||
|
||||
**ro**::
|
||||
force mounting _/_ and _/usr_ (if it is a separate device) read-only. If
|
||||
none of ro and rw is present, both are mounted according to _/etc/fstab_.
|
||||
|
||||
**rw**::
|
||||
force mounting _/_ and _/usr_ (if it is a separate device) read-write.
|
||||
See also ro option.
|
||||
|
||||
**rd.fstab=0**::
|
||||
do not honor special mount options for the root filesystem found in
|
||||
_/etc/fstab_ of the real root.
|
||||
|
||||
**resume=**_<path to resume partition>_::
|
||||
resume from a swap partition
|
||||
+
|
||||
E.g.:
|
||||
+
|
||||
----
|
||||
resume=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1
|
||||
resume=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
----
|
||||
|
||||
**rd.skipfsck**::
|
||||
skip fsck for rootfs and _/usr_. If you're mounting _/usr_ read-only and
|
||||
the init system performs fsck before remount, you might want to use this
|
||||
option to avoid duplication.
|
||||
|
||||
|
||||
Misc
|
||||
~~~~
|
||||
**rd.driver.blacklist=**_<drivername>[,<drivername>,...]_::
|
||||
@@ -78,6 +104,12 @@ Misc
|
||||
force loading kernel module <drivername> after all automatic loading modules
|
||||
have been loaded. This parameter can be specified multiple times.
|
||||
|
||||
**rd.retry=**_<seconds>_::
|
||||
specify how long dracut should wait for devices to appear.
|
||||
The default is 30 seconds. After 2/3 of the time, degraded raids are force
|
||||
started. If you have hardware, which takes a very long time to announce its
|
||||
drives, you might want to extend this value.
|
||||
|
||||
[[dracutkerneldebug]]
|
||||
Debug
|
||||
~~~~~
|
||||
@@ -94,7 +126,7 @@ Debug
|
||||
**rd.break**::
|
||||
drop to a shell at the end
|
||||
|
||||
**rd.break=**_{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot}_::
|
||||
**rd.break=**_{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|cleanup}_::
|
||||
drop to a shell on defined breakpoint
|
||||
|
||||
**rd.udev.info**::
|
||||
@@ -180,6 +212,16 @@ crypto LUKS
|
||||
LUKS UUID, so you don't have to specify the full UUID.
|
||||
This parameter can be specified multiple times.
|
||||
|
||||
**rd.luks.allow-discards=**_<luks uuid>_::
|
||||
Allow using of discards (TRIM) requests for LUKS partitions with the given UUID.
|
||||
Any "luks-" of the LUKS UUID is removed before comparing to _<luks uuid>_.
|
||||
The comparisons also matches, if _<luks uuid>_ is only the beginning of the
|
||||
LUKS UUID, so you don't have to specify the full UUID.
|
||||
This parameter can be specified multiple times.
|
||||
|
||||
**rd.luks.allow-discards::
|
||||
Allow using of discards (TRIM) requests on all LUKS partitions.
|
||||
|
||||
**rd.luks.crypttab=0**::
|
||||
do not check, if LUKS partition is in _/etc/crypttab_
|
||||
|
||||
@@ -197,6 +239,29 @@ rd.luks.key=/foo/bar.key
|
||||
----
|
||||
+
|
||||
As you see, you can skip colons in such a case.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
Dracut pipes key to cryptsetup with _-d -_ argument, therefore you need to pipe
|
||||
to crypsetup luksFormat with _-d -_, too!
|
||||
|
||||
Here follows example for key encrypted with GPG:
|
||||
|
||||
----
|
||||
gpg --quiet --decrypt rootkey.gpg \
|
||||
| cryptsetup -d - -v \
|
||||
--cipher serpent-cbc-essiv:sha256 \
|
||||
--key-size 256 luksFormat /dev/sda3
|
||||
----
|
||||
|
||||
If you use plain keys, just add path to _-d_ option:
|
||||
|
||||
----
|
||||
cryptsetup -d rootkey.key -v \
|
||||
--cipher serpent-cbc-essiv:sha256 \
|
||||
--key-size 256 luksFormat /dev/sda3
|
||||
----
|
||||
===============================
|
||||
|
||||
MD RAID
|
||||
~~~~~~~
|
||||
@@ -263,22 +328,51 @@ Network
|
||||
**ip=**_<interface>_:_{dhcp|on|any|dhcp6|auto6}_[:[_<mtu>_][:_<macaddr>_]]::
|
||||
This parameter can be specified multiple times.
|
||||
+
|
||||
=====================
|
||||
dhcp|on|any|dhcp6::: get ip from dhcp server on a specific interface
|
||||
auto6::: do IPv6 autoconfiguration
|
||||
<macaddr>::: optionally set <macaddr> on the <interface>
|
||||
<macaddr>::: optionally **set** <macaddr> on the <interface>. This
|
||||
cannot be used in conjunction with the **ifname** argument for the
|
||||
same <interface>.
|
||||
=====================
|
||||
|
||||
[IMPORTANT]
|
||||
=====================
|
||||
It is recommended to either bind <interface> to a MAC with the **ifname**
|
||||
argument. Or use biosdevname to name your interfaces, which will then have names according to their hardware location.
|
||||
|
||||
em<port>::: for embedded NICs
|
||||
p<slot>#<port>_<virtual instance>::: for cards in PCI slots
|
||||
=====================
|
||||
|
||||
**ip=**_<client-IP>_:_<server-IP>_:_<gateway-IP>_:_<netmask>_:_<client_hostname>_:_<interface>_:_{none|off|dhcp|on|any|dhcp6|auto6|ibft}_[:[_<mtu>_][:_<macaddr>_]]::
|
||||
explicit network configuration. If you want do define a IPv6 address, put it
|
||||
in brackets (e.g. [2001:DB8::1]). This parameter can be specified multiple
|
||||
times.
|
||||
+
|
||||
<macaddr>::: optionally set <macaddr> on the <interface>
|
||||
=====================
|
||||
<macaddr>::: optionally **set** <macaddr> on the <interface>. This
|
||||
cannot be used in conjunction with the **ifname** argument for the
|
||||
same <interface>.
|
||||
=====================
|
||||
|
||||
[IMPORTANT]
|
||||
=====================
|
||||
It is recommended to either bind <interface> to a MAC with the **ifname**
|
||||
argument. Or use biosdevname to name your interfaces, which will then have names according to their hardware location.
|
||||
|
||||
em<port>::: for embedded NICs
|
||||
p<slot>#<port>_<virtual instance>::: for cards in PCI slots
|
||||
=====================
|
||||
|
||||
**ifname=**_<interface>_:_<MAC>_::
|
||||
Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
|
||||
Note: If you use this option you _must_ specify an ifname= argument for all
|
||||
interfaces used in ip= or fcoe= arguments. This parameter can be specified
|
||||
multiple times.
|
||||
Assign network device name <interface> (ie "bootnet") to the NIC with MAC <MAC>.
|
||||
+
|
||||
[IMPORTANT]
|
||||
|
||||
Do **not** use the default kernel naming scheme for the interface name,
|
||||
as it can conflict with the kernel names. So, don't use "eth[0-9]+" for the
|
||||
interface name. Better name it "bootnet" or "bluesocket".
|
||||
|
||||
**bootdev=**_<interface>_::
|
||||
specify network interface to use routing and netroot information from.
|
||||
@@ -290,8 +384,23 @@ auto6::: do IPv6 autoconfiguration
|
||||
**biosdevname=0**::
|
||||
boolean, turn off biosdevname network interface renaming
|
||||
|
||||
**rd.neednet=1**::
|
||||
boolean, bring up network even without netroot set
|
||||
**vlan=_<vlanname>_:_<phydevice>_**::
|
||||
Setup vlan device named <vlanname> on <phydeivce>.
|
||||
We support the four styles of vlan names: VLAN_PLUS_VID (vlan0005), VLAN_PLUS_VID_NO_PAD (vlan5),
|
||||
DEV_PLUS_VID (eth0.0005), DEV_PLUS_VID_NO_PAD (eth0.5)
|
||||
|
||||
**bond=_<bondname>_[:_<bondslaves>_:[:_<options>_]]**::
|
||||
Setup bonding device <bondname> on top of <bondslaves>.
|
||||
<bondslaves> is a comma-separated list of physical (ethernet) interfaces.
|
||||
<options> is a comma-separated list on bonding options (modinfo bonding for details)
|
||||
in format compatible with initscripts. If <options> includes multi-valued arp_ip_target option,
|
||||
then its values should be separated by semicolon.
|
||||
Bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
|
||||
|
||||
**bridge=_<bridgename>_:_<ethnames>_**::
|
||||
Setup bridge <bridgename> with <ethnames>. <ethnames> is a comma-separated
|
||||
list of physical (ethernet) interfaces. Bridge without parameters assumes bridge=br0:eth0
|
||||
|
||||
|
||||
NFS
|
||||
~~~
|
||||
@@ -318,6 +427,21 @@ NFS
|
||||
**rd.nfs.domain=**_<NFSv4 domain name>_::
|
||||
Set the NFSv4 domain name. Will overwrite the settings in _/etc/idmap.conf_.
|
||||
|
||||
CIFS
|
||||
~~~
|
||||
**root=**cifs://[_<username>_[:_<password>_]@]_<server-ip>_:_<root-dir>_::
|
||||
mount cifs share from <server-ip>:/<root-dir>, if no server-ip is given, use
|
||||
dhcp next_server. if server-ip is an IPv6 address it has to be put in
|
||||
brackets, e.g. [2001:DB8::1]. If a username or password are not specified
|
||||
as part of the root, then they must be passed on the command line through
|
||||
cifsuser/cifspass.
|
||||
|
||||
**cifsuser=_<username>_::
|
||||
Set the cifs username, if not specified as part of the root.
|
||||
|
||||
**cifspass=_<password>_::
|
||||
Set the cifs password, if not specified as part of the root.
|
||||
|
||||
iSCSI
|
||||
~~~~~
|
||||
**root=**iscsi:[_<username>_:_<password>_[:_<reverse>_:_<password>_]@][_<servername>_]:[_<protocol>_]:[_<port>_][:[_<iscsi_iface_name>_]:[_<netdev_name>_]]:[_<LUN>_]:_<targetname>_::
|
||||
@@ -381,8 +505,10 @@ FCoE
|
||||
**fcoe=**_<edd|interface|MAC>_:_{dcb|nodcb}_::
|
||||
Try to connect to a FCoE SAN through the NIC specified by _<interface>_ or
|
||||
_<MAC>_ or EDD settings. For the second argument, currently only nodcb is
|
||||
supported. This parameter can be specified multiple times. Note: letters in
|
||||
the MAC-address must be lowercase!
|
||||
supported. This parameter can be specified multiple times.
|
||||
+
|
||||
[NOTE]
|
||||
letters in the MAC-address must be lowercase!
|
||||
|
||||
NBD
|
||||
~~~
|
||||
@@ -396,14 +522,9 @@ NBD
|
||||
|
||||
DASD
|
||||
~~~~
|
||||
**rd.dasd_mod.dasd=**....::
|
||||
**rd.dasd=**....::
|
||||
same syntax as the kernel module parameter (s390 only)
|
||||
|
||||
**rd.dasd=**_<dasd_adaptor device bus ID>_[,readonly=_X_][,use_diag=_X_][,erplog=_X_]::
|
||||
activate DASD device with the given adaptor device bus ID and setting the
|
||||
sysfs attributes to the specified values. This parameter can be specified
|
||||
multiple times.
|
||||
|
||||
ZFCP
|
||||
~~~~
|
||||
**rd.zfcp=**_<zfcp adaptor device bus ID>_,_<WWPN>_,_<FCPLUN>_::
|
||||
@@ -472,7 +593,7 @@ rdbreak:: rd.break
|
||||
|
||||
rd_CCW:: rd.ccw
|
||||
|
||||
rd_DASD_MOD:: rd.dasd_mod.dasd
|
||||
rd_DASD_MOD:: rd.dasd
|
||||
|
||||
rd_DASD:: rd.dasd
|
||||
|
||||
@@ -607,8 +728,7 @@ _/etc/cmdline.d/*.conf_::
|
||||
|
||||
AUTHOR
|
||||
------
|
||||
*Harald Hoyer*::
|
||||
Project Leader and Developer
|
||||
Harald Hoyer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
@@ -43,6 +43,9 @@ lvmconf="yes"
|
||||
# inhibit installation of any fsck tools
|
||||
#nofscks="yes"
|
||||
|
||||
# mount / and /usr read-only by default
|
||||
#ro_mnt="no"
|
||||
|
||||
# set the directory for temporary files
|
||||
# default: /var/tmp
|
||||
#tmpdir=/tmp
|
||||
|
@@ -65,7 +65,8 @@ line are not interpreted.
|
||||
Strip binaries in the initramfs (default=yes)
|
||||
|
||||
*hostonly=*"__{yes|no}__"::
|
||||
Host-Only mode: Install only what is needed for booting the local host instead of a generic host.
|
||||
Host-Only mode: Install only what is needed for booting the local host
|
||||
instead of a generic host and generate host-specific configuration.
|
||||
|
||||
*tmpdir=*"__<temporary directory>__"::
|
||||
Specify temporary directory to use.
|
||||
@@ -96,6 +97,9 @@ If chrooted to another root other than the real root device, use --fstab and pro
|
||||
*nofscks=*"__{yes|no}__"::
|
||||
If specified, inhibit installation of any fsck tools.
|
||||
|
||||
*ro_mnt*
|
||||
Mount _/_ and _/usr_ read-only by default.
|
||||
|
||||
*kernel_only=*"__{yes|no}__"::
|
||||
Only install kernel drivers and firmware files. (default=no)
|
||||
|
||||
|
@@ -2,9 +2,12 @@
|
||||
|
||||
# i18n
|
||||
i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP"
|
||||
add_dracutmodules+=" rpmversion "
|
||||
omit_dracutmodules+=" dash "
|
||||
omit_drivers+=" .*/fs/ocfs/.* "
|
||||
stdloglvl=3
|
||||
realinitpath="/usr/lib/systemd/systemd"
|
||||
install_items+=" vi /etc/virc ps grep cat rm "
|
||||
prefix="/"
|
||||
systemdutildir=/usr/lib/systemd
|
||||
systemdsystemunitdir=/usr/lib/systemd/system
|
||||
udevdir=/usr/lib/udev
|
||||
add_dracutmodules+=" systemd "
|
||||
realinitpath="/usr/lib/systemd/systemd"
|
||||
|
@@ -1,9 +0,0 @@
|
||||
# /etc/dracut.conf.d/gentoo-openrc.conf
|
||||
# Dracut config file customized for Gentoo Base System release 2
|
||||
|
||||
#
|
||||
# Modules
|
||||
#
|
||||
|
||||
# i18n
|
||||
i18n_vars="/etc/conf.d/keymaps:keymap-KEYMAP,extended_keymaps-EXT_KEYMAPS /etc/conf.d/consolefont:consolefont-FONT,consoletranslation-FONT_MAP /etc/rc.conf:unicode-UNICODE"
|
5
dracut.conf.d/gentoo-systemd.conf.example
Normal file
5
dracut.conf.d/gentoo-systemd.conf.example
Normal file
@@ -0,0 +1,5 @@
|
||||
# /etc/dracut.conf.d/gentoo-systemd.conf
|
||||
|
||||
# Paths of systemd dirs on Gentoo
|
||||
systemdutildir=/usr/lib/systemd
|
||||
systemdsystemunitdir=/usr/lib/systemd/system
|
@@ -1,9 +1,12 @@
|
||||
# /etc/dracut.conf.d/gentoo.conf
|
||||
# Dracut config file customized for Gentoo Base System release 1
|
||||
# /etc/dracut.conf.d/gentoo-openrc.conf
|
||||
# Dracut config file customized for Gentoo Base System release 2
|
||||
|
||||
udevdir=/lib/udev
|
||||
ro_mnt=yes
|
||||
|
||||
#
|
||||
# Modules
|
||||
#
|
||||
|
||||
# i18n
|
||||
i18n_vars="/etc/conf.d/keymaps:KEYMAP,EXTENDED_KEYMAPS-EXT_KEYMAPS /etc/conf.d/consolefont:CONSOLEFONT-FONT,CONSOLETRANSLATION-FONT_MAP /etc/rc.conf:UNICODE"
|
||||
i18n_vars="/etc/conf.d/keymaps:keymap-KEYMAP,extended_keymaps-EXT_KEYMAPS /etc/conf.d/consolefont:consolefont-FONT,consoletranslation-FONT_MAP /etc/rc.conf:unicode-UNICODE"
|
||||
|
511
dracut.sh
511
dracut.sh
@@ -24,14 +24,50 @@
|
||||
#
|
||||
|
||||
# store for logging
|
||||
dracut_args="$@"
|
||||
dracut_args=( "$@" )
|
||||
|
||||
set -o pipefail
|
||||
|
||||
usage() {
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||||
. $dracutbasedir/dracut-version.sh
|
||||
fi
|
||||
|
||||
# 80x25 linebreak here ^
|
||||
cat << EOF
|
||||
Usage: $0 [OPTION]... <initramfs> <kernel-version>
|
||||
Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
|
||||
|
||||
Version: $DRACUT_VERSION
|
||||
|
||||
Creates initial ramdisk images for preloading modules
|
||||
|
||||
-h, --help Display all options
|
||||
|
||||
If a [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
|
||||
For example:
|
||||
|
||||
# dracut --add-drivers "module1 module2" ...
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
long_usage() {
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||||
. $dracutbasedir/dracut-version.sh
|
||||
fi
|
||||
|
||||
# 80x25 linebreak here ^
|
||||
cat << EOF
|
||||
Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
|
||||
|
||||
Version: $DRACUT_VERSION
|
||||
|
||||
Creates initial ramdisk images for preloading modules
|
||||
|
||||
--kver [VERSION] Set kernel version to [VERSION].
|
||||
-f, --force Overwrite existing initramfs file.
|
||||
-m, --modules [LIST] Specify a space-separated list of dracut modules to
|
||||
call when building the initramfs. Modules are located
|
||||
@@ -55,6 +91,8 @@ Creates initial ramdisk images for preloading modules
|
||||
--no-kernel Do not install kernel drivers and firmware files
|
||||
--strip Strip binaries in the initramfs
|
||||
--nostrip Do not strip binaries in the initramfs (default)
|
||||
--hardlink Hardlink files in the initramfs (default)
|
||||
--nohardlink Do not hardlink files in the initramfs
|
||||
--prefix [DIR] Prefix initramfs files with [DIR]
|
||||
--noprefix Do not prefix initramfs files (default)
|
||||
--mdadmconf Include local /etc/mdadm.conf
|
||||
@@ -63,6 +101,7 @@ Creates initial ramdisk images for preloading modules
|
||||
--nolvmconf Do not include local /etc/lvm/lvm.conf
|
||||
--fscks [LIST] Add a space-separated list of fsck helpers.
|
||||
--nofscks Inhibit installation of any fsck helpers.
|
||||
--ro-mnt Mount / and /usr read-only by default.
|
||||
-h, --help This message
|
||||
--debug Output debug information of the build process
|
||||
--profile Output profile information of the build process
|
||||
@@ -88,7 +127,7 @@ Creates initial ramdisk images for preloading modules
|
||||
Useful when running dracut from a git checkout.
|
||||
-H, --hostonly Host-Only mode: Install only what is needed for
|
||||
booting the local host instead of a generic host.
|
||||
--no-hostonly Disables Host-Only mode
|
||||
-N, --no-hostonly Disables Host-Only mode
|
||||
--fstab Use /etc/fstab to determine the root device.
|
||||
--add-fstab [FILE] Add file to the initramfs fstab
|
||||
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
|
||||
@@ -123,11 +162,15 @@ Creates initial ramdisk images for preloading modules
|
||||
-M, --show-modules Print included module's name to standard output during
|
||||
build.
|
||||
--keep Keep the temporary initramfs for debugging purposes
|
||||
--printsize Print out the module install size
|
||||
--sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
|
||||
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
|
||||
For example:
|
||||
# dracut --add-drivers "module1 module2" ...
|
||||
|
||||
# dracut --add-drivers "module1 module2" ...
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -138,9 +181,10 @@ EOF
|
||||
# example:
|
||||
# push stack 1 2 "3 4"
|
||||
push() {
|
||||
local _i
|
||||
local __stack=$1; shift
|
||||
for i in "$@"; do
|
||||
eval ${__stack}'[${#'${__stack}'[@]}]="$i"'
|
||||
for _i in "$@"; do
|
||||
eval ${__stack}'[${#'${__stack}'[@]}]="$_i"'
|
||||
done
|
||||
}
|
||||
|
||||
@@ -156,16 +200,16 @@ push() {
|
||||
pop() {
|
||||
local __stack=$1; shift
|
||||
local __resultvar=$1
|
||||
local myresult;
|
||||
local _value;
|
||||
# check for empty stack
|
||||
eval '[[ ${#'${__stack}'[@]} -eq 0 ]] && return 1'
|
||||
|
||||
eval myresult='${'${__stack}'[${#'${__stack}'[@]}-1]}'
|
||||
eval _value='${'${__stack}'[${#'${__stack}'[@]}-1]}'
|
||||
|
||||
if [[ "$__resultvar" ]]; then
|
||||
eval $__resultvar="'$myresult'"
|
||||
eval $__resultvar="'$_value'"
|
||||
else
|
||||
echo "$myresult"
|
||||
echo "$_value"
|
||||
fi
|
||||
eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
|
||||
return 0
|
||||
@@ -189,54 +233,116 @@ read_arg() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Little helper function for reading args from the commandline to a stack.
|
||||
# it automatically handles -a b and -a=b variants, and returns 1 if
|
||||
# we need to shift $3.
|
||||
push_arg() {
|
||||
# $1 = arg name
|
||||
# $2 = arg value
|
||||
# $3 = arg parameter
|
||||
local rematch='^[^=]*=(.*)$'
|
||||
if [[ $2 =~ $rematch ]]; then
|
||||
push "$1" "${BASH_REMATCH[1]}"
|
||||
else
|
||||
push "$1" "$3"
|
||||
# There is no way to shift our callers args, so
|
||||
# return 1 to indicate they should do it instead.
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
verbosity_mod_l=0
|
||||
unset kernel
|
||||
unset outfile
|
||||
|
||||
while (($# > 0)); do
|
||||
case ${1%%=*} in
|
||||
-a|--add) push_arg add_dracutmodules_l "$@" || shift;;
|
||||
--force-add) push_arg force_add_dracutmodules_l "$@" || shift;;
|
||||
--add-drivers) push_arg add_drivers_l "$@" || shift;;
|
||||
--omit-drivers) push_arg omit_drivers_l "$@" || shift;;
|
||||
-m|--modules) push_arg dracutmodules_l "$@" || shift;;
|
||||
-o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
|
||||
-d|--drivers) push_arg drivers_l "$@" || shift;;
|
||||
--filesystems) push_arg filesystems_l "$@" || shift;;
|
||||
-I|--install) push_arg install_items_l "$@" || shift;;
|
||||
--fwdir) push_arg fw_dir_l "$@" || shift;;
|
||||
--fscks) push_arg fscks_l "$@" || shift;;
|
||||
--add-fstab) push_arg add_fstab_l "$@" || shift;;
|
||||
--mount) push_arg fstab_lines "$@" || shift;;
|
||||
# Workaround -i, --include taking 2 arguments
|
||||
set -- "${@/--include/++include}"
|
||||
|
||||
# This prevents any long argument ending with "-i"
|
||||
# -i, like --opt-i but I think we can just prevent that
|
||||
set -- "${@/%-i/++include}"
|
||||
|
||||
TEMP=$(unset POSIXLY_CORRECT; getopt \
|
||||
-o "a:m:o:d:I:k:c:L:fvqlHhMN" \
|
||||
--long kver: \
|
||||
--long add: \
|
||||
--long force-add: \
|
||||
--long add-drivers: \
|
||||
--long omit-drivers: \
|
||||
--long modules: \
|
||||
--long omit: \
|
||||
--long drivers: \
|
||||
--long filesystems: \
|
||||
--long install: \
|
||||
--long fwdir: \
|
||||
--long libdirs: \
|
||||
--long fscks: \
|
||||
--long add-fstab: \
|
||||
--long mount: \
|
||||
--long nofscks: \
|
||||
--long ro-mnt \
|
||||
--long kmoddir: \
|
||||
--long conf: \
|
||||
--long confdir: \
|
||||
--long tmpdir: \
|
||||
--long stdlog: \
|
||||
--long compress: \
|
||||
--long prefix: \
|
||||
--long force \
|
||||
--long kernel-only \
|
||||
--long no-kernel \
|
||||
--long strip \
|
||||
--long nostrip \
|
||||
--long hardlink \
|
||||
--long nohardlink \
|
||||
--long noprefix \
|
||||
--long mdadmconf \
|
||||
--long nomdadmconf \
|
||||
--long lvmconf \
|
||||
--long nolvmconf \
|
||||
--long debug \
|
||||
--long profile \
|
||||
--long sshkey: \
|
||||
--long verbose \
|
||||
--long quiet \
|
||||
--long local \
|
||||
--long hostonly \
|
||||
--long no-hostonly \
|
||||
--long fstab \
|
||||
--long help \
|
||||
--long bzip2 \
|
||||
--long lzma \
|
||||
--long xz \
|
||||
--long no-compress \
|
||||
--long gzip \
|
||||
--long list-modules \
|
||||
--long show-modules \
|
||||
--long keep \
|
||||
--long printsize \
|
||||
-- "$@")
|
||||
|
||||
if (( $? != 0 )); then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval set -- "$TEMP"
|
||||
|
||||
while :; do
|
||||
case $1 in
|
||||
--kver) kernel="$2"; shift;;
|
||||
-a|--add) push add_dracutmodules_l "$2"; shift;;
|
||||
--force-add) push force_add_dracutmodules_l "$2"; shift;;
|
||||
--add-drivers) push add_drivers_l "$2"; shift;;
|
||||
--omit-drivers) push omit_drivers_l "$2"; shift;;
|
||||
-m|--modules) push dracutmodules_l "$2"; shift;;
|
||||
-o|--omit) push omit_dracutmodules_l "$2"; shift;;
|
||||
-d|--drivers) push drivers_l "$2"; shift;;
|
||||
--filesystems) push filesystems_l "$2"; shift;;
|
||||
-I|--install) push install_items_l "$2"; shift;;
|
||||
--fwdir) push fw_dir_l "$2"; shift;;
|
||||
--libdirs) push libdirs_l "$2"; shift;;
|
||||
--fscks) push fscks_l "$2"; shift;;
|
||||
--add-fstab) push add_fstab_l "$2"; shift;;
|
||||
--mount) push fstab_lines "$2"; shift;;
|
||||
--nofscks) nofscks_l="yes";;
|
||||
-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
|
||||
-c|--conf) read_arg conffile "$@" || shift;;
|
||||
--confdir) read_arg confdir "$@" || shift;;
|
||||
--tmpdir) read_arg tmpdir_l "$@" || shift;;
|
||||
-L|--stdlog) read_arg stdloglvl_l "$@" || shift;;
|
||||
--compress) read_arg compress_l "$@" || shift;;
|
||||
--prefix) read_arg prefix_l "$@" || shift;;
|
||||
--ro-mnt) ro_mnt_l="yes";;
|
||||
-k|--kmoddir) drivers_dir_l="$2"; shift;;
|
||||
-c|--conf) conffile="$2"; shift;;
|
||||
--confdir) confdir="$2"; shift;;
|
||||
--tmpdir) tmpdir_l="$2"; shift;;
|
||||
-L|--stdlog) stdloglvl_l="$2"; shift;;
|
||||
--compress) compress_l="$2"; shift;;
|
||||
--prefix) prefix_l="$2"; shift;;
|
||||
-f|--force) force=yes;;
|
||||
--kernel-only) kernel_only="yes"; no_kernel="no";;
|
||||
--no-kernel) kernel_only="no"; no_kernel="yes";;
|
||||
--strip) do_strip_l="yes";;
|
||||
--nostrip) do_strip_l="no";;
|
||||
--hardlink) do_hardlink_l="yes";;
|
||||
--nohardlink) do_hardlink_l="no";;
|
||||
--noprefix) prefix_l="/";;
|
||||
--mdadmconf) mdadmconf_l="yes";;
|
||||
--nomdadmconf) mdadmconf_l="no";;
|
||||
@@ -244,60 +350,87 @@ while (($# > 0)); do
|
||||
--nolvmconf) lvmconf_l="no";;
|
||||
--debug) debug="yes";;
|
||||
--profile) profile="yes";;
|
||||
--sshkey) read_arg sshkey "$@" || shift;;
|
||||
--sshkey) sshkey="$2"; shift;;
|
||||
-v|--verbose) ((verbosity_mod_l++));;
|
||||
-q|--quiet) ((verbosity_mod_l--));;
|
||||
-l|--local) allowlocal="yes" ;;
|
||||
-l|--local)
|
||||
allowlocal="yes"
|
||||
[[ -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] \
|
||||
&& dracutbasedir="$(readlink -f ${0%/*})"
|
||||
;;
|
||||
-H|--hostonly) hostonly_l="yes" ;;
|
||||
--no-hostonly) hostonly_l="no" ;;
|
||||
-N|--no-hostonly) hostonly_l="no" ;;
|
||||
--fstab) use_fstab_l="yes" ;;
|
||||
-h|--help) usage; exit 1 ;;
|
||||
-h|--help) long_usage; exit 1 ;;
|
||||
-i|--include) push include_src "$2"
|
||||
push include_target "$3"
|
||||
shift 2;;
|
||||
shift;;
|
||||
--bzip2) compress_l="bzip2";;
|
||||
--lzma) compress_l="lzma";;
|
||||
--xz) compress_l="xz";;
|
||||
--no-compress) _no_compress_l="cat";;
|
||||
--gzip) compress_l="gzip";;
|
||||
--list-modules)
|
||||
do_list="yes";
|
||||
;;
|
||||
--list-modules) do_list="yes";;
|
||||
-M|--show-modules)
|
||||
show_modules_l="yes"
|
||||
;;
|
||||
--keep) keep="yes";;
|
||||
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
|
||||
--printsize) printsize="yes";;
|
||||
|
||||
--) shift; break;;
|
||||
|
||||
*) # should not even reach this point
|
||||
printf "\n!Unknown option: '%s'\n\n" "$1" >&2; usage; exit 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# getopt cannot handle multiple arguments, so just handle "-I,--include"
|
||||
# the old fashioned way
|
||||
|
||||
while (($# > 0)); do
|
||||
case ${1%%=*} in
|
||||
++include) push include_src "$2"
|
||||
push include_target "$3"
|
||||
shift 2;;
|
||||
*)
|
||||
if ! [[ ${outfile+x} ]]; then
|
||||
outfile=$1
|
||||
elif ! [[ ${kernel+x} ]]; then
|
||||
kernel=$1
|
||||
else
|
||||
printf "\nUnknown arguments: %s\n\n" "$*" >&2
|
||||
usage; exit 1;
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if ! [[ $kernel ]]; then
|
||||
kernel=$(uname -r)
|
||||
fi
|
||||
[[ $outfile ]] || outfile="/boot/initramfs-$kernel.img"
|
||||
|
||||
if ! [[ $outfile ]]; then
|
||||
outfile="/boot/initramfs-$kernel.img"
|
||||
fi
|
||||
|
||||
for i in /usr/sbin /sbin /usr/bin /bin; do
|
||||
rl=$i
|
||||
if [ -L "$i" ]; then
|
||||
rl=$(readlink -f $i)
|
||||
fi
|
||||
NPATH+=":$rl"
|
||||
if [[ "$NPATH" != "*:$rl*" ]] ; then
|
||||
NPATH+=":$rl"
|
||||
fi
|
||||
done
|
||||
export PATH="${NPATH#:}"
|
||||
unset NPATH
|
||||
unset LD_LIBRARY_PATH
|
||||
unset GREP_OPTIONS
|
||||
|
||||
export DRACUT_LOG_LEVEL=warning
|
||||
[[ $debug ]] && {
|
||||
export DRACUT_LOG_LEVEL=debug
|
||||
export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
|
||||
set -x
|
||||
}
|
||||
@@ -310,9 +443,6 @@ unset GREP_OPTIONS
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
|
||||
[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] && \
|
||||
dracutbasedir="$(readlink -f ${0%/*})"
|
||||
|
||||
# if we were not passed a config file, try the default one
|
||||
if [[ ! -f $conffile ]]; then
|
||||
[[ $allowlocal ]] && conffile="$dracutbasedir/dracut.conf" || \
|
||||
@@ -400,6 +530,13 @@ if (( ${#fw_dir_l[@]} )); then
|
||||
done
|
||||
fi
|
||||
|
||||
if (( ${#libdirs_l[@]} )); then
|
||||
libdirs=''
|
||||
while pop libdirs_l val; do
|
||||
libdirs+="$val "
|
||||
done
|
||||
fi
|
||||
|
||||
[[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
|
||||
[[ ! $stdloglvl ]] && stdloglvl=4
|
||||
stdloglvl=$((stdloglvl + verbosity_mod_l))
|
||||
@@ -408,6 +545,9 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
|
||||
|
||||
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
|
||||
[[ $do_strip_l ]] && do_strip=$do_strip_l
|
||||
[[ $do_strip ]] || do_strip=no
|
||||
[[ $do_hardlink_l ]] && do_hardlink=$do_hardlink_l
|
||||
[[ $do_hardlink ]] || do_hardlink=yes
|
||||
[[ $prefix_l ]] && prefix=$prefix_l
|
||||
[[ $prefix = "/" ]] && unset prefix
|
||||
[[ $hostonly_l ]] && hostonly=$hostonly_l
|
||||
@@ -418,10 +558,10 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
|
||||
[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
|
||||
[[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
|
||||
[[ $tmpdir ]] || tmpdir=/var/tmp
|
||||
[[ $do_strip ]] || do_strip=no
|
||||
[[ $compress_l ]] && compress=$compress_l
|
||||
[[ $show_modules_l ]] && show_modules=$show_modules_l
|
||||
[[ $nofscks_l ]] && nofscks="yes"
|
||||
[[ $ro_mnt_l ]] && ro_mnt="yes"
|
||||
# eliminate IFS hackery when messing with fw_dir
|
||||
fw_dir=${fw_dir//:/ }
|
||||
|
||||
@@ -441,16 +581,37 @@ fi
|
||||
[[ $hostonly = yes ]] && hostonly="-h"
|
||||
[[ $hostonly != "-h" ]] && unset hostonly
|
||||
|
||||
readonly TMPDIR="$tmpdir"
|
||||
readonly initdir=$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)
|
||||
[ -d "$initdir" ] || {
|
||||
echo "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXX failed." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
export DRACUT_KERNEL_LAZY="1"
|
||||
export DRACUT_RESOLVE_LAZY="1"
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
|
||||
. $dracutbasedir/dracut-functions.sh
|
||||
else
|
||||
echo "Cannot find $dracutbasedir/dracut-functions.sh." >&2
|
||||
echo "Are you running from a git checkout?" >&2
|
||||
echo "Try passing -l as an argument to $0" >&2
|
||||
echo "dracut: Cannot find $dracutbasedir/dracut-functions.sh." >&2
|
||||
echo "dracut: Are you running from a git checkout?" >&2
|
||||
echo "dracut: Try passing -l as an argument to $0" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify bash version, curret minimum is 3.1
|
||||
inst /bin/sh
|
||||
if ! $DRACUT_INSTALL ${initdir+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then
|
||||
unset DRACUT_RESOLVE_LAZY
|
||||
export DRACUT_RESOLVE_DEPS=1
|
||||
fi
|
||||
rm -fr ${initdir}/*
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||||
. $dracutbasedir/dracut-version.sh
|
||||
fi
|
||||
|
||||
# Verify bash version, current minimum is 3.1
|
||||
if (( ${BASH_VERSINFO[0]} < 3 ||
|
||||
( ${BASH_VERSINFO[0]} == 3 && ${BASH_VERSINFO[1]} < 1 ) )); then
|
||||
dfatal 'You need at least Bash 3.1 to use dracut, sorry.'
|
||||
@@ -490,8 +651,13 @@ done
|
||||
omit_drivers="${omit_drivers_corrected%|}"
|
||||
unset omit_drivers_corrected
|
||||
|
||||
|
||||
ddebug "Executing $0 $dracut_args"
|
||||
# prepare args for logging
|
||||
for ((i=0; i < ${#dracut_args[@]}; i++)); do
|
||||
strstr "${dracut_args[$i]}" " " && \
|
||||
dracut_args[$i]="\"${dracut_args[$i]}\""
|
||||
#" keep vim happy
|
||||
done
|
||||
ddebug "Executing: $0 ${dracut_args[@]}"
|
||||
|
||||
[[ $do_list = yes ]] && {
|
||||
for mod in $dracutbasedir/modules.d/*; do
|
||||
@@ -503,18 +669,6 @@ ddebug "Executing $0 $dracut_args"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Detect lib paths
|
||||
[[ $libdir ]] || for libdir in /lib64 /lib; do
|
||||
[[ -d $libdir ]] && break
|
||||
done || {
|
||||
dfatal 'No lib directory?!!!'
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ $usrlibdir ]] || for usrlibdir in /usr/lib64 /usr/lib; do
|
||||
[[ -d $usrlibdir ]] && break
|
||||
done || dwarn 'No usr/lib directory!'
|
||||
|
||||
# This is kinda legacy -- eventually it should go away.
|
||||
case $dracutmodules in
|
||||
""|auto) dracutmodules="all" ;;
|
||||
@@ -522,15 +676,10 @@ esac
|
||||
|
||||
abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
|
||||
|
||||
srcmods="/lib/modules/$kernel/"
|
||||
[[ $drivers_dir ]] && {
|
||||
if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then
|
||||
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
|
||||
exit 1
|
||||
fi
|
||||
srcmods="$drivers_dir"
|
||||
[[ -f $srcmods/modules.dep ]] || {
|
||||
dfatal "$srcmods/modules.dep is missing. Did you run depmod?"
|
||||
exit 1
|
||||
}
|
||||
export srcmods
|
||||
|
||||
if [[ -f $outfile && ! $force ]]; then
|
||||
dfatal "Will not override existing initramfs ($outfile) without --force"
|
||||
@@ -544,20 +693,13 @@ if [[ ! -d "$outdir" ]]; then
|
||||
dfatal "Can't write $outfile: Directory $outdir does not exist."
|
||||
exit 1
|
||||
elif [[ ! -w "$outdir" ]]; then
|
||||
dfatal "No permission to write $outdir."
|
||||
dfatal "No permission to write to $outdir."
|
||||
exit 1
|
||||
elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
|
||||
dfatal "No permission to write $outfile."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
readonly TMPDIR="$tmpdir"
|
||||
readonly initdir=$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)
|
||||
[ -d "$initdir" ] || {
|
||||
dfatal "mktemp failed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# clean up after ourselves no matter how we die.
|
||||
trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf "$initdir";exit $ret;' EXIT
|
||||
# clean up after ourselves no matter how we die.
|
||||
@@ -627,12 +769,32 @@ for dev in "${host_devs[@]}"; do
|
||||
done
|
||||
done
|
||||
|
||||
export initdir dracutbasedir dracutmodules drivers \
|
||||
[[ -d $udevdir ]] \
|
||||
|| udevdir=$(pkg-config udev --variable=udevdir 2>/dev/null)
|
||||
if ! [[ -d "$udevdir" ]]; then
|
||||
[[ -d /lib/udev ]] && udevdir=/lib/udev
|
||||
[[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
|
||||
fi
|
||||
|
||||
[[ -d $systemdutildir ]] \
|
||||
|| systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null)
|
||||
[[ -d $systemdsystemunitdir ]] \
|
||||
|| systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
|
||||
|
||||
if ! [[ -d "$systemdutildir" ]]; then
|
||||
[[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
|
||||
[[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
|
||||
fi
|
||||
[[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
|
||||
|
||||
export initdir dracutbasedir dracutmodules \
|
||||
fw_dir drivers_dir debug no_kernel kernel_only \
|
||||
add_drivers omit_drivers mdadmconf lvmconf filesystems \
|
||||
use_fstab fstab_lines libdir usrlibdir fscks nofscks \
|
||||
omit_drivers mdadmconf lvmconf \
|
||||
use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
|
||||
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
|
||||
debug host_fs_types host_devs sshkey add_fstab
|
||||
debug host_fs_types host_devs sshkey add_fstab \
|
||||
DRACUT_VERSION udevdir systemdutildir systemdsystemunitdir \
|
||||
prefix filesystems drivers
|
||||
|
||||
# Create some directory structure first
|
||||
[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
|
||||
@@ -641,13 +803,14 @@ export initdir dracutbasedir dracutmodules drivers \
|
||||
[[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib"
|
||||
|
||||
if [[ $prefix ]]; then
|
||||
for d in bin etc lib "$libdir" sbin tmp usr var; do
|
||||
for d in bin etc lib sbin tmp usr var $libdirs; do
|
||||
strstr "$d" "/" && continue
|
||||
ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log; do
|
||||
for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/log $libdirs; do
|
||||
[[ -e "${initdir}${prefix}/$d" ]] && continue
|
||||
if [ -L "/$d" ]; then
|
||||
inst_symlink "/$d" "${prefix}/$d"
|
||||
@@ -664,8 +827,8 @@ if [[ $kernel_only != yes ]]; then
|
||||
fi
|
||||
done
|
||||
|
||||
ln -sfn /run "$initdir/var/run"
|
||||
ln -sfn /run/lock "$initdir/var/lock"
|
||||
ln -sfn ../run "$initdir/var/run"
|
||||
ln -sfn ../run/lock "$initdir/var/lock"
|
||||
else
|
||||
for d in lib "$libdir"; do
|
||||
[[ -e "${initdir}${prefix}/$d" ]] && continue
|
||||
@@ -682,16 +845,22 @@ if [[ $kernel_only != yes ]]; then
|
||||
for _d in $hookdirs; do
|
||||
mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
|
||||
done
|
||||
if [[ "$UID" = "0" ]]; then
|
||||
[ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3
|
||||
[ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11
|
||||
[ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$initdir/.kernelmodseen"
|
||||
|
||||
mods_to_load=""
|
||||
# check all our modules to see if they should be sourced.
|
||||
# This builds a list of modules that we will install next.
|
||||
for_each_module_dir check_module
|
||||
for_each_module_dir check_mount
|
||||
|
||||
strstr "$mods_to_load" "fips" && export DRACUT_FIPS_MODE=1
|
||||
|
||||
_isize=0 #initramfs size
|
||||
modules_loaded=" "
|
||||
# source our modules.
|
||||
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
|
||||
@@ -700,27 +869,78 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
|
||||
[[ $show_modules = yes ]] && echo "$_d_mod" || \
|
||||
dinfo "*** Including module: $_d_mod ***"
|
||||
if [[ $kernel_only = yes ]]; then
|
||||
module_installkernel $_d_mod
|
||||
module_installkernel $_d_mod || {
|
||||
dfatal "installkernel failed in module $_d_mod"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
module_install $_d_mod
|
||||
if [[ $no_kernel != yes ]]; then
|
||||
module_installkernel $_d_mod
|
||||
module_installkernel $_d_mod || {
|
||||
dfatal "installkernel failed in module $_d_mod"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
mods_to_load=${mods_to_load// $_d_mod /}
|
||||
modules_loaded+="$_d_mod "
|
||||
|
||||
#print the module install size
|
||||
if [ -n "$printsize" ]; then
|
||||
_isize_new=$(du -sk ${initdir}|cut -f1)
|
||||
_isize_delta=$(($_isize_new - $_isize))
|
||||
echo "$_d_mod install size: ${_isize_delta}k"
|
||||
_isize=$_isize_new
|
||||
fi
|
||||
fi
|
||||
done
|
||||
unset moddir
|
||||
|
||||
for i in $modules_loaded; do
|
||||
mkdir -p $initdir/lib/dracut
|
||||
echo "$i" >> $initdir/lib/dracut/modules.txt
|
||||
done
|
||||
|
||||
dinfo "*** Including modules done ***"
|
||||
|
||||
## final stuff that has to happen
|
||||
if [[ $no_kernel != yes ]]; then
|
||||
|
||||
# generate module dependencies for the initrd
|
||||
if [[ -d $initdir/lib/modules/$kernel ]] && \
|
||||
! depmod -a -b "$initdir" $kernel; then
|
||||
dfatal "\"depmod -a $kernel\" failed."
|
||||
exit 1
|
||||
if [[ $drivers ]]; then
|
||||
hostonly='' instmods $drivers
|
||||
fi
|
||||
|
||||
if [[ $add_drivers ]]; then
|
||||
hostonly='' instmods -c $add_drivers
|
||||
fi
|
||||
if [[ $filesystems ]]; then
|
||||
hostonly='' instmods -c $filesystems
|
||||
fi
|
||||
|
||||
dinfo "*** Installing kernel module dependencies and firmware ***"
|
||||
dracut_kernel_post
|
||||
dinfo "*** Installing kernel module dependencies and firmware done ***"
|
||||
fi
|
||||
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
(( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]}
|
||||
|
||||
while pop fstab_lines line; do
|
||||
echo "$line 0 0" >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
for f in $add_fstab; do
|
||||
cat $f >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then
|
||||
dinfo "*** Resolving executable dependencies ***"
|
||||
find "$initdir" -type f \
|
||||
'(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
|
||||
-not -path '*.ko' -print0 \
|
||||
| xargs -r -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H}
|
||||
dinfo "*** Resolving executable dependencies done***"
|
||||
fi
|
||||
fi
|
||||
|
||||
while pop include_src src && pop include_target tgt; do
|
||||
@@ -740,9 +960,9 @@ while pop include_src src && pop include_target tgt; do
|
||||
mkdir -m 0755 -p "$s"
|
||||
chmod --reference="$i" "$s"
|
||||
fi
|
||||
cp -a -t "$s" "$i"/*
|
||||
cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
|
||||
else
|
||||
cp -a -t "$s" "$i"
|
||||
cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -750,19 +970,6 @@ while pop include_src src && pop include_target tgt; do
|
||||
done
|
||||
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
for item in $install_items; do
|
||||
dracut_install -o "$item"
|
||||
done
|
||||
unset item
|
||||
|
||||
while pop fstab_lines line; do
|
||||
echo "$line 0 0" >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
for f in $add_fstab; do
|
||||
cat $f >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
# make sure that library links are correct and up to date
|
||||
for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
|
||||
[[ -f $f ]] && inst_simple "$f"
|
||||
@@ -776,9 +983,6 @@ if [[ $kernel_only != yes ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -fr "$initdir/.kernelmodseen"
|
||||
|
||||
|
||||
if (($maxloglvl >= 5)); then
|
||||
ddebug "Listing sizes of included files:"
|
||||
du -c "$initdir" | sort -n | ddebug
|
||||
@@ -786,7 +990,7 @@ fi
|
||||
|
||||
# strip binaries
|
||||
if [[ $do_strip = yes ]] ; then
|
||||
for p in strip grep find; do
|
||||
for p in strip xargs find; do
|
||||
if ! type -P $p >/dev/null; then
|
||||
derror "Could not find '$p'. You should run $0 with '--nostrip'."
|
||||
do_strip=no
|
||||
@@ -794,36 +998,45 @@ if [[ $do_strip = yes ]] ; then
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $do_strip = yes ]] ; then
|
||||
for f in $(find "$initdir" -type f \
|
||||
\( -perm -0100 -or -perm -0010 -or -perm -0001 \
|
||||
-or -path '*/lib/modules/*.ko' \) ); do
|
||||
dinfo "Stripping $f"
|
||||
strip -g "$f" 2>/dev/null|| :
|
||||
done
|
||||
fi
|
||||
|
||||
type hardlink &>/dev/null && {
|
||||
hardlink "$initdir" 2>&1
|
||||
}
|
||||
|
||||
if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then
|
||||
dinfo "*** pre-unlinking files ***"
|
||||
for dir in "$initdir/bin" \
|
||||
"$initdir/sbin" \
|
||||
"$initdir/usr/bin" \
|
||||
"$initdir/usr/sbin"; do
|
||||
[[ -L "$dir" ]] && continue
|
||||
for i in "$dir"/*; do
|
||||
[[ -L $i ]] && continue
|
||||
[[ -x $i ]] && prelink -u $i &>/dev/null
|
||||
done
|
||||
done
|
||||
dinfo "*** pre-unlinking files done ***"
|
||||
fi
|
||||
|
||||
if [[ $do_strip = yes ]] ; then
|
||||
dinfo "*** Stripping files ***"
|
||||
find "$initdir" -type f \
|
||||
'(' -perm -0100 -or -perm -0010 -or -perm -0001 \
|
||||
-or -path '*/lib/modules/*.ko' ')' -print0 \
|
||||
| xargs -r -0 strip -g 2>/dev/null
|
||||
dinfo "*** Stripping files done ***"
|
||||
fi
|
||||
|
||||
if [[ $do_hardlink = yes ]] ; then
|
||||
type hardlink &>/dev/null && {
|
||||
dinfo "*** hardlinking files ***"
|
||||
hardlink "$initdir" 2>&1
|
||||
dinfo "*** hardlinking files done ***"
|
||||
}
|
||||
fi
|
||||
|
||||
dinfo "*** Creating image file ***"
|
||||
if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
|
||||
$compress > "$outfile"; ); then
|
||||
dfatal "dracut: creation of $outfile failed"
|
||||
exit 1
|
||||
fi
|
||||
dinfo "*** Creating image file done ***"
|
||||
|
||||
dinfo "Wrote $outfile:"
|
||||
dinfo "$(ls -l "$outfile")"
|
||||
|
63
dracut.spec
63
dracut.spec
@@ -19,13 +19,17 @@ Group: System Environment/Base
|
||||
%if 0%{?suse_version}
|
||||
Group: System/Base
|
||||
%endif
|
||||
License: GPLv2+
|
||||
|
||||
# The entire source code is GPLv2+
|
||||
# except install/* which is LGPLv2.1+
|
||||
License: GPLv2+ and LGPLv2.1+
|
||||
|
||||
URL: https://dracut.wiki.kernel.org/
|
||||
|
||||
# Source can be generated by
|
||||
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz
|
||||
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: dash bash git
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
@@ -76,9 +80,13 @@ Requires: hardlink
|
||||
Requires: gzip xz
|
||||
Requires: module-init-tools >= 3.7-9
|
||||
Requires: sed
|
||||
Requires: file
|
||||
Requires: kpartx
|
||||
Requires: udev > 166
|
||||
Requires: kbd kbd-misc
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
Requires: util-linux >= 2.21
|
||||
Conflicts: systemd < 187
|
||||
%else
|
||||
Requires: util-linux-ng >= 2.21
|
||||
%endif
|
||||
@@ -105,7 +113,7 @@ Provides: dracut-generic = %{version}-%{release}
|
||||
This package requires everything which is needed to build a generic
|
||||
all purpose initramfs with network support with dracut.
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 6
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 6 || 0%{?suse_version}
|
||||
%package fips
|
||||
Summary: Dracut modules to build a dracut initramfs with an integrity check
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
@@ -177,23 +185,34 @@ make install DESTDIR=$RPM_BUILD_ROOT \
|
||||
%endif
|
||||
sysconfdir=/etc mandir=%{_mandir}
|
||||
|
||||
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/10rpmversion/dracut-version
|
||||
echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dracut-version.sh
|
||||
|
||||
%if 0%{?fedora} == 0 && 0%{?rhel} == 0
|
||||
%if 0%{?fedora} == 0 && 0%{?rhel} == 0 && 0%{?suse_version} == 0
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni
|
||||
%endif
|
||||
|
||||
# we do not support dash in the initramfs
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00dash
|
||||
|
||||
# remove gentoo specific modules
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash
|
||||
|
||||
%if %{defined _unitdir}
|
||||
# with systemd IMA and selinux modules do not make sense
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/96securityfs
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/97masterkey
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98integrity
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98selinux
|
||||
%endif
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/boot/dracut
|
||||
mkdir -p $RPM_BUILD_ROOT/var/lib/dracut/overlay
|
||||
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log
|
||||
touch $RPM_BUILD_ROOT%{_localstatedir}/log/dracut.log
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/initramfs
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
|
||||
install -m 0644 dracut.conf.d/fedora.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/01-dist.conf
|
||||
install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/40-fips.conf
|
||||
%endif
|
||||
@@ -231,22 +250,28 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%dir %{dracutlibdir}/modules.d
|
||||
%{dracutlibdir}/dracut-functions.sh
|
||||
%{dracutlibdir}/dracut-functions
|
||||
%{dracutlibdir}/dracut-version.sh
|
||||
%{dracutlibdir}/dracut-logger.sh
|
||||
%{dracutlibdir}/dracut-initramfs-restore
|
||||
%{dracutlibdir}/dracut-install
|
||||
%config(noreplace) /etc/dracut.conf
|
||||
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel}
|
||||
%config /etc/dracut.conf.d/01-dist.conf
|
||||
%endif
|
||||
%dir /etc/dracut.conf.d
|
||||
%{_mandir}/man8/dracut.8*
|
||||
%{_mandir}/man8/*service.8*
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
|
||||
%{_mandir}/man8/mkinitrd.8*
|
||||
%{_mandir}/man1/lsinitrd.1*
|
||||
%endif
|
||||
%{_mandir}/man7/dracut.kernel.7*
|
||||
%{_mandir}/man7/dracut.cmdline.7*
|
||||
%{_mandir}/man5/dracut.conf.5*
|
||||
%{dracutlibdir}/modules.d/00bootchart
|
||||
%{dracutlibdir}/modules.d/00dash
|
||||
%{dracutlibdir}/modules.d/04watchdog
|
||||
%{dracutlibdir}/modules.d/05busybox
|
||||
%{dracutlibdir}/modules.d/10i18n
|
||||
%{dracutlibdir}/modules.d/10rpmversion
|
||||
%{dracutlibdir}/modules.d/30convertfs
|
||||
%{dracutlibdir}/modules.d/45url-lib
|
||||
%{dracutlibdir}/modules.d/50plymouth
|
||||
@@ -260,7 +285,9 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{dracutlibdir}/modules.d/90lvm
|
||||
%{dracutlibdir}/modules.d/90mdraid
|
||||
%{dracutlibdir}/modules.d/90multipath
|
||||
%{dracutlibdir}/modules.d/90qemu
|
||||
%{dracutlibdir}/modules.d/91crypt-gpg
|
||||
%{dracutlibdir}/modules.d/91crypt-loop
|
||||
%{dracutlibdir}/modules.d/95debug
|
||||
%{dracutlibdir}/modules.d/95resume
|
||||
%{dracutlibdir}/modules.d/95rootfs-block
|
||||
@@ -270,14 +297,18 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{dracutlibdir}/modules.d/95zfcp
|
||||
%{dracutlibdir}/modules.d/95terminfo
|
||||
%{dracutlibdir}/modules.d/95udev-rules
|
||||
%{dracutlibdir}/modules.d/95virtfs
|
||||
%if %{undefined _unitdir}
|
||||
%{dracutlibdir}/modules.d/96securityfs
|
||||
%{dracutlibdir}/modules.d/97biosdevname
|
||||
%{dracutlibdir}/modules.d/97masterkey
|
||||
%{dracutlibdir}/modules.d/98ecryptfs
|
||||
%{dracutlibdir}/modules.d/98integrity
|
||||
%{dracutlibdir}/modules.d/98pollcdrom
|
||||
%{dracutlibdir}/modules.d/98selinux
|
||||
%{dracutlibdir}/modules.d/98integrity
|
||||
%endif
|
||||
%{dracutlibdir}/modules.d/97biosdevname
|
||||
%{dracutlibdir}/modules.d/98ecryptfs
|
||||
%{dracutlibdir}/modules.d/98pollcdrom
|
||||
%{dracutlibdir}/modules.d/98syslog
|
||||
%{dracutlibdir}/modules.d/98systemd
|
||||
%{dracutlibdir}/modules.d/98usrmount
|
||||
%{dracutlibdir}/modules.d/99base
|
||||
%{dracutlibdir}/modules.d/99fs-lib
|
||||
@@ -287,8 +318,8 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
|
||||
%dir %{_sharedstatedir}/initramfs
|
||||
%if %{defined _unitdir}
|
||||
%{_unitdir}/*.service
|
||||
%{_unitdir}/*/*.service
|
||||
%{_unitdir}/dracut-shutdown.service
|
||||
%{_unitdir}/shutdown.target.wants/dracut-shutdown.service
|
||||
%endif
|
||||
|
||||
%files network
|
||||
@@ -297,13 +328,15 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{dracutlibdir}/modules.d/95fcoe
|
||||
%{dracutlibdir}/modules.d/95iscsi
|
||||
%{dracutlibdir}/modules.d/90livenet
|
||||
%{dracutlibdir}/modules.d/90qemu-net
|
||||
%{dracutlibdir}/modules.d/95cifs
|
||||
%{dracutlibdir}/modules.d/95nbd
|
||||
%{dracutlibdir}/modules.d/95nfs
|
||||
%{dracutlibdir}/modules.d/95ssh-client
|
||||
%{dracutlibdir}/modules.d/45ifcfg
|
||||
%{dracutlibdir}/modules.d/95znet
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
|
||||
%files fips
|
||||
%defattr(-,root,root,0755)
|
||||
%{dracutlibdir}/modules.d/01fips
|
||||
|
7
install/Makefile
Normal file
7
install/Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
all:
|
||||
$(MAKE) -C ..
|
||||
|
||||
clean:
|
||||
$(MAKE) -C .. clean
|
||||
|
||||
.PHONY: all clean
|
811
install/dracut-install.c
Normal file
811
install/dracut-install.c
Normal file
@@ -0,0 +1,811 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/* dracut-install.c -- install files and executables
|
||||
|
||||
Copyright (C) 2012 Harald Hoyer
|
||||
Copyright (C) 2012 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
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 program 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 program; If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define PROGRAM_VERSION_STRING "1"
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <libgen.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "hashmap.h"
|
||||
#include "util.h"
|
||||
|
||||
static bool arg_hmac = false;
|
||||
static bool arg_createdir = false;
|
||||
static int arg_loglevel = -1;
|
||||
static bool arg_optional = false;
|
||||
static bool arg_all = false;
|
||||
static bool arg_resolvelazy = false;
|
||||
static bool arg_resolvedeps = false;
|
||||
static char *destrootdir = NULL;
|
||||
|
||||
static Hashmap *items = NULL;
|
||||
static Hashmap *items_failed = NULL;
|
||||
|
||||
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst);
|
||||
|
||||
static size_t dir_len(char const *file)
|
||||
{
|
||||
size_t length;
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = strlen(file); 0 < length; length--)
|
||||
if (file[length] == '/')
|
||||
break;
|
||||
return length;
|
||||
}
|
||||
|
||||
static char *convert_abs_rel(const char *from, const char *target)
|
||||
{
|
||||
/* we use the 4*MAXPATHLEN, which should not overrun */
|
||||
char relative_from[MAXPATHLEN * 4];
|
||||
char *realtarget = NULL;
|
||||
char *p, *q;
|
||||
const char *realfrom = from;
|
||||
int level = 0, fromlevel = 0, targetlevel = 0;
|
||||
int l, i, rl;
|
||||
int dirlen;
|
||||
|
||||
p = strdup(target);
|
||||
dirlen = dir_len(p);
|
||||
p[dirlen] = '\0';
|
||||
q = realpath(p, NULL);
|
||||
|
||||
if (q == NULL) {
|
||||
free(p);
|
||||
log_warning("convert_abs_rel(): target '%s' directory has no realpath.", target);
|
||||
return strdup(from);
|
||||
}
|
||||
|
||||
asprintf(&realtarget, "%s/%s", q, &p[dirlen + 1]);
|
||||
free(p);
|
||||
free(q);
|
||||
|
||||
/* now calculate the relative path from <from> to <target> and
|
||||
store it in <relative_from>
|
||||
*/
|
||||
relative_from[0] = 0;
|
||||
rl = 0;
|
||||
|
||||
/* count the pathname elements of realtarget */
|
||||
for (targetlevel = 0, i = 0; realtarget[i]; i++)
|
||||
if (realtarget[i] == '/')
|
||||
targetlevel++;
|
||||
|
||||
/* count the pathname elements of realfrom */
|
||||
for (fromlevel = 0, i = 0; realfrom[i]; i++)
|
||||
if (realfrom[i] == '/')
|
||||
fromlevel++;
|
||||
|
||||
/* count the pathname elements, which are common for both paths */
|
||||
for (level = 0, i = 0; realtarget[i] && (realtarget[i] == realfrom[i]); i++)
|
||||
if (realtarget[i] == '/')
|
||||
level++;
|
||||
|
||||
free(realtarget);
|
||||
|
||||
/* add "../" to the relative_from path, until the common pathname is
|
||||
reached */
|
||||
for (i = level; i < targetlevel; i++) {
|
||||
if (i != level)
|
||||
relative_from[rl++] = '/';
|
||||
relative_from[rl++] = '.';
|
||||
relative_from[rl++] = '.';
|
||||
}
|
||||
|
||||
/* set l to the next uncommon pathname element in realfrom */
|
||||
for (l = 1, i = 1; i < level; i++)
|
||||
for (l++; realfrom[l] && realfrom[l] != '/'; l++) ;
|
||||
/* skip next '/' */
|
||||
l++;
|
||||
|
||||
/* append the uncommon rest of realfrom to the relative_from path */
|
||||
for (i = level; i <= fromlevel; i++) {
|
||||
if (rl)
|
||||
relative_from[rl++] = '/';
|
||||
while (realfrom[l] && realfrom[l] != '/')
|
||||
relative_from[rl++] = realfrom[l++];
|
||||
l++;
|
||||
}
|
||||
|
||||
relative_from[rl] = 0;
|
||||
return strdup(relative_from);
|
||||
}
|
||||
|
||||
static int ln_r(const char *src, const char *dst)
|
||||
{
|
||||
int ret;
|
||||
const char *points_to = convert_abs_rel(src, dst);
|
||||
log_info("ln -s '%s' '%s'", points_to, dst);
|
||||
ret = symlink(points_to, dst);
|
||||
|
||||
if (ret != 0) {
|
||||
log_error("ERROR: ln -s '%s' '%s': %m", points_to, dst);
|
||||
free((char *)points_to);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free((char *)points_to);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Perform the O(1) btrfs clone operation, if possible.
|
||||
Upon success, return 0. Otherwise, return -1 and set errno. */
|
||||
static inline int clone_file(int dest_fd, int src_fd)
|
||||
{
|
||||
#undef BTRFS_IOCTL_MAGIC
|
||||
#define BTRFS_IOCTL_MAGIC 0x94
|
||||
#undef BTRFS_IOC_CLONE
|
||||
#define BTRFS_IOC_CLONE _IOW (BTRFS_IOCTL_MAGIC, 9, int)
|
||||
return ioctl(dest_fd, BTRFS_IOC_CLONE, src_fd);
|
||||
}
|
||||
|
||||
static bool use_clone = true;
|
||||
|
||||
static int cp(const char *src, const char *dst)
|
||||
{
|
||||
int pid;
|
||||
int ret;
|
||||
|
||||
if (use_clone) {
|
||||
struct stat sb;
|
||||
int dest_desc, source_desc;
|
||||
|
||||
if (lstat(src, &sb) != 0)
|
||||
goto normal_copy;
|
||||
|
||||
if (S_ISLNK(sb.st_mode))
|
||||
goto normal_copy;
|
||||
|
||||
source_desc = open(src, O_RDONLY | O_CLOEXEC);
|
||||
if (source_desc < 0)
|
||||
goto normal_copy;
|
||||
|
||||
dest_desc =
|
||||
open(dst, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC,
|
||||
(sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));
|
||||
|
||||
if (dest_desc < 0) {
|
||||
close(source_desc);
|
||||
goto normal_copy;
|
||||
}
|
||||
|
||||
ret = clone_file(dest_desc, source_desc);
|
||||
close(source_desc);
|
||||
if (ret == 0) {
|
||||
if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0)
|
||||
fchown(dest_desc, -1, sb.st_gid);
|
||||
close(dest_desc);
|
||||
return ret;
|
||||
}
|
||||
close(dest_desc);
|
||||
|
||||
/* clone did not work, remove the file */
|
||||
unlink(dst);
|
||||
/* do not try clone again */
|
||||
use_clone = false;
|
||||
}
|
||||
|
||||
normal_copy:
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode", "-fL", src, dst, NULL);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (waitpid(pid, &ret, 0) < 0) {
|
||||
if (errno != EINTR) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int resolve_deps(const char *src)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
char *buf = malloc(LINE_MAX);
|
||||
size_t linesize = LINE_MAX;
|
||||
FILE *fptr;
|
||||
char *cmd;
|
||||
|
||||
if (strstr(src, ".so") == 0) {
|
||||
int fd;
|
||||
fd = open(src, O_RDONLY | O_CLOEXEC);
|
||||
read(fd, buf, LINE_MAX);
|
||||
buf[LINE_MAX - 1] = '\0';
|
||||
close(fd);
|
||||
if (buf[0] == '#' && buf[1] == '!') {
|
||||
/* we have a shebang */
|
||||
char *p, *q;
|
||||
for (p = &buf[2]; *p && isspace(*p); p++) ;
|
||||
for (q = p; *q && (!isspace(*q)); q++) ;
|
||||
*q = '\0';
|
||||
log_debug("Script install: '%s'", p);
|
||||
ret = dracut_install(p, p, false, true, false);
|
||||
if (ret != 0)
|
||||
log_error("ERROR: failed to install '%s'", p);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* run ldd */
|
||||
asprintf(&cmd, "ldd %s 2>&1", src);
|
||||
fptr = popen(cmd, "r");
|
||||
|
||||
while (!feof(fptr)) {
|
||||
char *p, *q;
|
||||
|
||||
if (getline(&buf, &linesize, fptr) <= 0)
|
||||
continue;
|
||||
|
||||
log_debug("ldd: '%s'", buf);
|
||||
|
||||
if (strstr(buf, "not a dynamic executable"))
|
||||
break;
|
||||
|
||||
if (strstr(buf, "loader cannot load itself"))
|
||||
break;
|
||||
|
||||
p = strstr(buf, "/");
|
||||
if (p) {
|
||||
int r;
|
||||
for (q = p; *q && *q != ' ' && *q != '\n'; q++) ;
|
||||
*q = '\0';
|
||||
r = dracut_install(p, p, false, false, true);
|
||||
if (r != 0)
|
||||
log_error("ERROR: failed to install '%s' for '%s'", p, src);
|
||||
else
|
||||
log_debug("Lib install: '%s'", p);
|
||||
ret += r;
|
||||
|
||||
/* also install lib.so for lib.so.* files */
|
||||
q = strstr(p, ".so.");
|
||||
if (q) {
|
||||
q += 3;
|
||||
*q = '\0';
|
||||
|
||||
/* ignore errors for base lib symlink */
|
||||
if (dracut_install(p, p, false, false, true) == 0)
|
||||
log_debug("Lib install: '%s'", p);
|
||||
}
|
||||
}
|
||||
}
|
||||
pclose(fptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Install ".<filename>.hmac" file for FIPS self-checks */
|
||||
static int hmac_install(const char *src, const char *dst)
|
||||
{
|
||||
char *srcpath = strdup(src);
|
||||
char *dstpath = strdup(dst);
|
||||
char *srchmacname = NULL;
|
||||
char *dsthmacname = NULL;
|
||||
size_t dlen = dir_len(src);
|
||||
|
||||
if (endswith(src, ".hmac"))
|
||||
return 0;
|
||||
|
||||
srcpath[dlen] = '\0';
|
||||
dstpath[dir_len(dst)] = '\0';
|
||||
asprintf(&srchmacname, "%s/.%s.hmac", srcpath, &src[dlen + 1]);
|
||||
asprintf(&dsthmacname, "%s/.%s.hmac", dstpath, &src[dlen + 1]);
|
||||
log_debug("hmac cp '%s' '%s')", srchmacname, dsthmacname);
|
||||
dracut_install(srchmacname, dsthmacname, false, false, true);
|
||||
free(dsthmacname);
|
||||
free(srchmacname);
|
||||
free(srcpath);
|
||||
free(dstpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst)
|
||||
{
|
||||
struct stat sb, db;
|
||||
char *dname = NULL;
|
||||
char *fulldstpath = NULL;
|
||||
char *fulldstdir = NULL;
|
||||
int ret;
|
||||
bool src_exists = true;
|
||||
char *i, *existing;
|
||||
|
||||
log_debug("dracut_install('%s', '%s')", src, dst);
|
||||
|
||||
existing = hashmap_get(items_failed, src);
|
||||
if (existing) {
|
||||
if (strcmp(existing, src) == 0) {
|
||||
log_debug("hash hit items_failed for '%s'", src);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hashdst) {
|
||||
existing = hashmap_get(items, dst);
|
||||
if (existing) {
|
||||
if (strcmp(existing, dst) == 0) {
|
||||
log_debug("hash hit items for '%s'", dst);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lstat(src, &sb) < 0) {
|
||||
src_exists = false;
|
||||
if (!isdir) {
|
||||
i = strdup(src);
|
||||
hashmap_put(items_failed, i, i);
|
||||
/* src does not exist */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
i = strdup(dst);
|
||||
hashmap_put(items, i, i);
|
||||
|
||||
asprintf(&fulldstpath, "%s%s", destrootdir, dst);
|
||||
|
||||
ret = stat(fulldstpath, &sb);
|
||||
|
||||
if (ret != 0 && (errno != ENOENT)) {
|
||||
log_error("ERROR: stat '%s': %m", fulldstpath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
log_debug("'%s' already exists", fulldstpath);
|
||||
free(fulldstpath);
|
||||
/* dst does already exist */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check destination directory */
|
||||
fulldstdir = strdup(fulldstpath);
|
||||
fulldstdir[dir_len(fulldstdir)] = '\0';
|
||||
|
||||
ret = stat(fulldstdir, &db);
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno != ENOENT) {
|
||||
log_error("ERROR: stat '%s': %m", fulldstdir);
|
||||
return 1;
|
||||
}
|
||||
/* create destination directory */
|
||||
log_debug("dest dir '%s' does not exist", fulldstdir);
|
||||
dname = strdup(dst);
|
||||
dname[dir_len(dname)] = '\0';
|
||||
ret = dracut_install(dname, dname, true, false, true);
|
||||
|
||||
free(dname);
|
||||
|
||||
if (ret != 0) {
|
||||
log_error("ERROR: failed to create directory '%s'", fulldstdir);
|
||||
free(fulldstdir);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
free(fulldstdir);
|
||||
|
||||
if (isdir && !src_exists) {
|
||||
log_info("mkdir '%s'", fulldstpath);
|
||||
return mkdir(fulldstpath, 0755);
|
||||
}
|
||||
|
||||
/* ready to install src */
|
||||
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
log_info("mkdir '%s'", fulldstpath);
|
||||
return mkdir(fulldstpath, sb.st_mode | S_IWUSR);
|
||||
}
|
||||
|
||||
if (S_ISLNK(sb.st_mode)) {
|
||||
char *abspath;
|
||||
char *absdestpath = NULL;
|
||||
|
||||
abspath = realpath(src, NULL);
|
||||
|
||||
if (abspath == NULL)
|
||||
return 1;
|
||||
|
||||
if (dracut_install(abspath, abspath, false, resolvedeps, hashdst)) {
|
||||
log_debug("'%s' install error", abspath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lstat(abspath, &sb) != 0) {
|
||||
log_debug("lstat '%s': %m", abspath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lstat(fulldstpath, &sb) != 0) {
|
||||
|
||||
asprintf(&absdestpath, "%s%s", destrootdir, abspath);
|
||||
|
||||
ln_r(absdestpath, fulldstpath);
|
||||
|
||||
free(absdestpath);
|
||||
}
|
||||
|
||||
free(abspath);
|
||||
if (arg_hmac) {
|
||||
/* copy .hmac files also */
|
||||
hmac_install(src, dst);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
|
||||
if (resolvedeps)
|
||||
ret += resolve_deps(src);
|
||||
if (arg_hmac) {
|
||||
/* copy .hmac files also */
|
||||
hmac_install(src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
log_info("cp '%s' '%s'", src, fulldstpath);
|
||||
ret += cp(src, fulldstpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void item_free(char *i)
|
||||
{
|
||||
assert(i);
|
||||
free(i);
|
||||
}
|
||||
|
||||
static void usage(int status)
|
||||
{
|
||||
/* */
|
||||
printf("\
|
||||
Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE...\n\
|
||||
or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST\n\
|
||||
\n\
|
||||
Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n\
|
||||
\n\
|
||||
-D --destrootdir Install all files to DESTROOTDIR as the root\n\
|
||||
-a --all Install all SOURCE arguments to DESTROOTDIR\n\
|
||||
-o --optional If SOURCE does not exist, do not fail\n\
|
||||
-d --dir SOURCE is a directory\n\
|
||||
-l --ldd Also install shebang executables and libraries\n\
|
||||
-R --resolvelazy Only install shebang executables and libraries for all SOURCE files\n\
|
||||
-f --fips Also install all '.SOURCE.hmac' files\n\
|
||||
-v --verbose Show more output\n\
|
||||
--debug Show debug output\n\
|
||||
--version Show package version\n\
|
||||
-h --help Show this help\n\
|
||||
\n\
|
||||
Example:\n\
|
||||
# mkdir -p /var/tmp/test-root\n\
|
||||
# %s -D /var/tmp/test-root --ldd -a sh tr\n\
|
||||
# tree /var/tmp/test-root\n\
|
||||
/var/tmp/test-root\n\
|
||||
|-- lib64 -> usr/lib64\n\
|
||||
`-- usr\n\
|
||||
|-- bin\n\
|
||||
| |-- bash\n\
|
||||
| |-- sh -> bash\n\
|
||||
| `-- tr\n\
|
||||
`-- lib64\n\
|
||||
|-- ld-2.15.90.so\n\
|
||||
|-- ld-linux-x86-64.so.2 -> ld-2.15.90.so\n\
|
||||
|-- libc-2.15.90.so\n\
|
||||
|-- libc.so\n\
|
||||
|-- libc.so.6 -> libc-2.15.90.so\n\
|
||||
|-- libdl-2.15.90.so\n\
|
||||
|-- libdl.so -> libdl-2.15.90.so\n\
|
||||
|-- libdl.so.2 -> libdl-2.15.90.so\n\
|
||||
|-- libtinfo.so.5 -> libtinfo.so.5.9\n\
|
||||
`-- libtinfo.so.5.9\n\
|
||||
", program_invocation_short_name, program_invocation_short_name, program_invocation_short_name);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
static int parse_argv(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
|
||||
enum {
|
||||
ARG_VERSION = 0x100,
|
||||
ARG_DEBUG
|
||||
};
|
||||
|
||||
static const struct option const options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, ARG_VERSION},
|
||||
{"dir", no_argument, NULL, 'd'},
|
||||
{"debug", no_argument, NULL, ARG_DEBUG},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"ldd", no_argument, NULL, 'l'},
|
||||
{"resolvelazy", no_argument, NULL, 'R'},
|
||||
{"optional", no_argument, NULL, 'o'},
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
{"fips", no_argument, NULL, 'H'},
|
||||
{"destrootdir", required_argument, NULL, 'D'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
while ((c = getopt_long(argc, argv, "adhloD:DHILR", options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case ARG_VERSION:
|
||||
puts(PROGRAM_VERSION_STRING);
|
||||
return 0;
|
||||
case 'd':
|
||||
arg_createdir = true;
|
||||
break;
|
||||
case ARG_DEBUG:
|
||||
arg_loglevel = LOG_DEBUG;
|
||||
break;
|
||||
case 'v':
|
||||
arg_loglevel = LOG_INFO;
|
||||
break;
|
||||
case 'o':
|
||||
arg_optional = true;
|
||||
break;
|
||||
case 'l':
|
||||
arg_resolvedeps = true;
|
||||
break;
|
||||
case 'R':
|
||||
arg_resolvelazy = true;
|
||||
break;
|
||||
case 'a':
|
||||
arg_all = true;
|
||||
break;
|
||||
case 'D':
|
||||
destrootdir = strdup(optarg);
|
||||
break;
|
||||
case 'H':
|
||||
arg_hmac = true;
|
||||
break;
|
||||
case 'h':
|
||||
usage(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!optind || optind == argc) {
|
||||
log_error("No SOURCE argument given");
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int resolve_lazy(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int destrootdirlen = strlen(destrootdir);
|
||||
int ret = 0;
|
||||
char *item;
|
||||
for (i = 0; i < argc; i++) {
|
||||
const char *src = argv[i];
|
||||
char *p = argv[i];
|
||||
char *existing;
|
||||
|
||||
log_debug("resolve_deps('%s')", src);
|
||||
|
||||
if (strstr(src, destrootdir)) {
|
||||
p = &argv[i][destrootdirlen];
|
||||
}
|
||||
|
||||
existing = hashmap_get(items, p);
|
||||
if (existing) {
|
||||
if (strcmp(existing, p) == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
item = strdup(p);
|
||||
hashmap_put(items, item, item);
|
||||
|
||||
ret += resolve_deps(src);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int install_all(int argc, char **argv)
|
||||
{
|
||||
int r = 0;
|
||||
int i;
|
||||
for (i = 0; i < argc; i++) {
|
||||
int ret;
|
||||
log_debug("Handle '%s'", argv[i]);
|
||||
|
||||
if (strchr(argv[i], '/') == NULL) {
|
||||
char *path;
|
||||
char *p, *q;
|
||||
bool end = false;
|
||||
path = getenv("PATH");
|
||||
if (path == NULL) {
|
||||
log_error("PATH is not set");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
path = strdup(path);
|
||||
p = path;
|
||||
log_debug("PATH=%s", path);
|
||||
do {
|
||||
char *newsrc = NULL;
|
||||
char *dest;
|
||||
struct stat sb;
|
||||
|
||||
for (q = p; *q && *q != ':'; q++) ;
|
||||
|
||||
if (*q == '\0')
|
||||
end = true;
|
||||
else
|
||||
*q = '\0';
|
||||
|
||||
asprintf(&newsrc, "%s/%s", p, argv[i]);
|
||||
p = q + 1;
|
||||
|
||||
if (stat(newsrc, &sb) != 0) {
|
||||
free(newsrc);
|
||||
ret = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
dest = strdup(newsrc);
|
||||
|
||||
log_debug("dracut_install '%s'", newsrc);
|
||||
ret = dracut_install(newsrc, dest, arg_createdir, arg_resolvedeps, true);
|
||||
if (ret == 0) {
|
||||
end = true;
|
||||
log_debug("dracut_install '%s' OK", newsrc);
|
||||
}
|
||||
free(newsrc);
|
||||
free(dest);
|
||||
} while (!end);
|
||||
free(path);
|
||||
} else {
|
||||
char *dest = strdup(argv[i]);
|
||||
ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true);
|
||||
free(dest);
|
||||
}
|
||||
|
||||
if ((ret != 0) && (!arg_optional)) {
|
||||
log_error("ERROR: installing '%s'", argv[i]);
|
||||
r = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int r;
|
||||
char *i;
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
|
||||
log_set_target(LOG_TARGET_CONSOLE);
|
||||
log_parse_environment();
|
||||
|
||||
if (arg_loglevel >= 0)
|
||||
log_set_max_level(arg_loglevel);
|
||||
|
||||
log_open();
|
||||
|
||||
umask(0022);
|
||||
|
||||
if (destrootdir == NULL || strlen(destrootdir) == 0) {
|
||||
destrootdir = getenv("DESTROOTDIR");
|
||||
if (destrootdir == NULL || strlen(destrootdir) == 0) {
|
||||
log_error("Environment DESTROOTDIR or argument -D is not set!");
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
destrootdir = strdup(destrootdir);
|
||||
}
|
||||
|
||||
if (strcmp(destrootdir, "/") == 0) {
|
||||
log_error("Environment DESTROOTDIR or argument -D is set to '/'!");
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
i = destrootdir;
|
||||
destrootdir = realpath(destrootdir, NULL);
|
||||
if (!destrootdir) {
|
||||
log_error("Environment DESTROOTDIR or argument -D is set to '%s': %m", i);
|
||||
r = EXIT_FAILURE;
|
||||
goto finish;
|
||||
}
|
||||
free(i);
|
||||
|
||||
items = hashmap_new(string_hash_func, string_compare_func);
|
||||
items_failed = hashmap_new(string_hash_func, string_compare_func);
|
||||
|
||||
if (!items || !items_failed) {
|
||||
log_error("Out of memory");
|
||||
r = EXIT_FAILURE;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
r = EXIT_SUCCESS;
|
||||
|
||||
if (((optind + 1) < argc) && (strcmp(argv[optind + 1], destrootdir) == 0)) {
|
||||
/* ugly hack for compat mode "inst src $destrootdir" */
|
||||
if ((optind + 2) == argc) {
|
||||
argc--;
|
||||
} else {
|
||||
/* ugly hack for compat mode "inst src $destrootdir dst" */
|
||||
if ((optind + 3) == argc) {
|
||||
argc--;
|
||||
argv[optind + 1] = argv[optind + 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_resolvelazy) {
|
||||
r = resolve_lazy(argc - optind, &argv[optind]);
|
||||
} else if (arg_all || (argc - optind > 2) || ((argc - optind) == 1)) {
|
||||
r = install_all(argc - optind, &argv[optind]);
|
||||
} else {
|
||||
/* simple "inst src dst" */
|
||||
r = dracut_install(argv[optind], argv[optind + 1], arg_createdir, arg_resolvedeps, true);
|
||||
if ((r != 0) && (!arg_optional)) {
|
||||
log_error("ERROR: installing '%s' to '%s'", argv[optind], argv[optind + 1]);
|
||||
r = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_optional)
|
||||
r = EXIT_SUCCESS;
|
||||
|
||||
finish:
|
||||
|
||||
while ((i = hashmap_steal_first(items)))
|
||||
item_free(i);
|
||||
|
||||
while ((i = hashmap_steal_first(items_failed)))
|
||||
item_free(i);
|
||||
|
||||
hashmap_free(items);
|
||||
hashmap_free(items_failed);
|
||||
|
||||
free(destrootdir);
|
||||
|
||||
return r;
|
||||
}
|
731
install/hashmap.c
Normal file
731
install/hashmap.c
Normal file
@@ -0,0 +1,731 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd 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.
|
||||
|
||||
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "hashmap.h"
|
||||
#include "macro.h"
|
||||
|
||||
#define NBUCKETS 127
|
||||
|
||||
struct hashmap_entry {
|
||||
const void *key;
|
||||
void *value;
|
||||
struct hashmap_entry *bucket_next, *bucket_previous;
|
||||
struct hashmap_entry *iterate_next, *iterate_previous;
|
||||
};
|
||||
|
||||
struct Hashmap {
|
||||
hash_func_t hash_func;
|
||||
compare_func_t compare_func;
|
||||
|
||||
struct hashmap_entry *iterate_list_head, *iterate_list_tail;
|
||||
unsigned n_entries;
|
||||
|
||||
bool from_pool;
|
||||
};
|
||||
|
||||
#define BY_HASH(h) ((struct hashmap_entry**) ((uint8_t*) (h) + ALIGN(sizeof(Hashmap))))
|
||||
|
||||
struct pool {
|
||||
struct pool *next;
|
||||
unsigned n_tiles;
|
||||
unsigned n_used;
|
||||
};
|
||||
|
||||
static struct pool *first_hashmap_pool = NULL;
|
||||
static void *first_hashmap_tile = NULL;
|
||||
|
||||
static struct pool *first_entry_pool = NULL;
|
||||
static void *first_entry_tile = NULL;
|
||||
|
||||
static void* allocate_tile(struct pool **first_pool, void **first_tile, size_t tile_size) {
|
||||
unsigned i;
|
||||
|
||||
if (*first_tile) {
|
||||
void *r;
|
||||
|
||||
r = *first_tile;
|
||||
*first_tile = * (void**) (*first_tile);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (_unlikely_(!*first_pool) || _unlikely_((*first_pool)->n_used >= (*first_pool)->n_tiles)) {
|
||||
unsigned n;
|
||||
size_t size;
|
||||
struct pool *p;
|
||||
|
||||
n = *first_pool ? (*first_pool)->n_tiles : 0;
|
||||
n = MAX(512U, n * 2);
|
||||
size = PAGE_ALIGN(ALIGN(sizeof(struct pool)) + n*tile_size);
|
||||
n = (size - ALIGN(sizeof(struct pool))) / tile_size;
|
||||
|
||||
p = malloc(size);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
p->next = *first_pool;
|
||||
p->n_tiles = n;
|
||||
p->n_used = 0;
|
||||
|
||||
*first_pool = p;
|
||||
}
|
||||
|
||||
i = (*first_pool)->n_used++;
|
||||
|
||||
return ((uint8_t*) (*first_pool)) + ALIGN(sizeof(struct pool)) + i*tile_size;
|
||||
}
|
||||
|
||||
static void deallocate_tile(void **first_tile, void *p) {
|
||||
* (void**) p = *first_tile;
|
||||
*first_tile = p;
|
||||
}
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
||||
static void drop_pool(struct pool *p) {
|
||||
while (p) {
|
||||
struct pool *n;
|
||||
n = p->next;
|
||||
free(p);
|
||||
p = n;
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((destructor)) static void cleanup_pool(void) {
|
||||
/* Be nice to valgrind */
|
||||
|
||||
drop_pool(first_hashmap_pool);
|
||||
drop_pool(first_entry_pool);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
unsigned string_hash_func(const void *p) {
|
||||
unsigned hash = 5381;
|
||||
const signed char *c;
|
||||
|
||||
/* DJB's hash function */
|
||||
|
||||
for (c = p; *c; c++)
|
||||
hash = (hash << 5) + hash + (unsigned) *c;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
int string_compare_func(const void *a, const void *b) {
|
||||
return strcmp(a, b);
|
||||
}
|
||||
|
||||
unsigned trivial_hash_func(const void *p) {
|
||||
return PTR_TO_UINT(p);
|
||||
}
|
||||
|
||||
int trivial_compare_func(const void *a, const void *b) {
|
||||
return a < b ? -1 : (a > b ? 1 : 0);
|
||||
}
|
||||
|
||||
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
|
||||
bool b;
|
||||
Hashmap *h;
|
||||
size_t size;
|
||||
|
||||
b = is_main_thread();
|
||||
|
||||
size = ALIGN(sizeof(Hashmap)) + NBUCKETS * sizeof(struct hashmap_entry*);
|
||||
|
||||
if (b) {
|
||||
h = allocate_tile(&first_hashmap_pool, &first_hashmap_tile, size);
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
memset(h, 0, size);
|
||||
} else {
|
||||
h = malloc0(size);
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
h->hash_func = hash_func ? hash_func : trivial_hash_func;
|
||||
h->compare_func = compare_func ? compare_func : trivial_compare_func;
|
||||
|
||||
h->n_entries = 0;
|
||||
h->iterate_list_head = h->iterate_list_tail = NULL;
|
||||
|
||||
h->from_pool = b;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func) {
|
||||
assert(h);
|
||||
|
||||
if (*h)
|
||||
return 0;
|
||||
|
||||
if (!(*h = hashmap_new(hash_func, compare_func)))
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash) {
|
||||
assert(h);
|
||||
assert(e);
|
||||
|
||||
/* Insert into hash table */
|
||||
e->bucket_next = BY_HASH(h)[hash];
|
||||
e->bucket_previous = NULL;
|
||||
if (BY_HASH(h)[hash])
|
||||
BY_HASH(h)[hash]->bucket_previous = e;
|
||||
BY_HASH(h)[hash] = e;
|
||||
|
||||
/* Insert into iteration list */
|
||||
e->iterate_previous = h->iterate_list_tail;
|
||||
e->iterate_next = NULL;
|
||||
if (h->iterate_list_tail) {
|
||||
assert(h->iterate_list_head);
|
||||
h->iterate_list_tail->iterate_next = e;
|
||||
} else {
|
||||
assert(!h->iterate_list_head);
|
||||
h->iterate_list_head = e;
|
||||
}
|
||||
h->iterate_list_tail = e;
|
||||
|
||||
h->n_entries++;
|
||||
assert(h->n_entries >= 1);
|
||||
}
|
||||
|
||||
static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash) {
|
||||
assert(h);
|
||||
assert(e);
|
||||
|
||||
/* Remove from iteration list */
|
||||
if (e->iterate_next)
|
||||
e->iterate_next->iterate_previous = e->iterate_previous;
|
||||
else
|
||||
h->iterate_list_tail = e->iterate_previous;
|
||||
|
||||
if (e->iterate_previous)
|
||||
e->iterate_previous->iterate_next = e->iterate_next;
|
||||
else
|
||||
h->iterate_list_head = e->iterate_next;
|
||||
|
||||
/* Remove from hash table bucket list */
|
||||
if (e->bucket_next)
|
||||
e->bucket_next->bucket_previous = e->bucket_previous;
|
||||
|
||||
if (e->bucket_previous)
|
||||
e->bucket_previous->bucket_next = e->bucket_next;
|
||||
else
|
||||
BY_HASH(h)[hash] = e->bucket_next;
|
||||
|
||||
assert(h->n_entries >= 1);
|
||||
h->n_entries--;
|
||||
}
|
||||
|
||||
static void remove_entry(Hashmap *h, struct hashmap_entry *e) {
|
||||
unsigned hash;
|
||||
|
||||
assert(h);
|
||||
assert(e);
|
||||
|
||||
hash = h->hash_func(e->key) % NBUCKETS;
|
||||
|
||||
unlink_entry(h, e, hash);
|
||||
|
||||
if (h->from_pool)
|
||||
deallocate_tile(&first_entry_tile, e);
|
||||
else
|
||||
free(e);
|
||||
}
|
||||
|
||||
void hashmap_free(Hashmap*h) {
|
||||
|
||||
if (!h)
|
||||
return;
|
||||
|
||||
hashmap_clear(h);
|
||||
|
||||
if (h->from_pool)
|
||||
deallocate_tile(&first_hashmap_tile, h);
|
||||
else
|
||||
free(h);
|
||||
}
|
||||
|
||||
void hashmap_free_free(Hashmap *h) {
|
||||
void *p;
|
||||
|
||||
while ((p = hashmap_steal_first(h)))
|
||||
free(p);
|
||||
|
||||
hashmap_free(h);
|
||||
}
|
||||
|
||||
void hashmap_clear(Hashmap *h) {
|
||||
if (!h)
|
||||
return;
|
||||
|
||||
while (h->iterate_list_head)
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
}
|
||||
|
||||
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key) {
|
||||
struct hashmap_entry *e;
|
||||
assert(h);
|
||||
assert(hash < NBUCKETS);
|
||||
|
||||
for (e = BY_HASH(h)[hash]; e; e = e->bucket_next)
|
||||
if (h->compare_func(e->key, key) == 0)
|
||||
return e;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int hashmap_put(Hashmap *h, const void *key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
|
||||
assert(h);
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if ((e = hash_scan(h, hash, key))) {
|
||||
|
||||
if (e->value == value)
|
||||
return 0;
|
||||
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
if (h->from_pool)
|
||||
e = allocate_tile(&first_entry_pool, &first_entry_tile, sizeof(struct hashmap_entry));
|
||||
else
|
||||
e = new(struct hashmap_entry, 1);
|
||||
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
|
||||
e->key = key;
|
||||
e->value = value;
|
||||
|
||||
link_entry(h, e, hash);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int hashmap_replace(Hashmap *h, const void *key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
|
||||
assert(h);
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if ((e = hash_scan(h, hash, key))) {
|
||||
e->key = key;
|
||||
e->value = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return hashmap_put(h, key, value);
|
||||
}
|
||||
|
||||
void* hashmap_get(Hashmap *h, const void *key) {
|
||||
unsigned hash;
|
||||
struct hashmap_entry *e;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
return e->value;
|
||||
}
|
||||
|
||||
void* hashmap_remove(Hashmap *h, const void *key) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
void *data;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
data = e->value;
|
||||
remove_entry(h, e);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned old_hash, new_hash;
|
||||
|
||||
if (!h)
|
||||
return -ENOENT;
|
||||
|
||||
old_hash = h->hash_func(old_key) % NBUCKETS;
|
||||
if (!(e = hash_scan(h, old_hash, old_key)))
|
||||
return -ENOENT;
|
||||
|
||||
new_hash = h->hash_func(new_key) % NBUCKETS;
|
||||
if (hash_scan(h, new_hash, new_key))
|
||||
return -EEXIST;
|
||||
|
||||
unlink_entry(h, e, old_hash);
|
||||
|
||||
e->key = new_key;
|
||||
e->value = value;
|
||||
|
||||
link_entry(h, e, new_hash);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value) {
|
||||
struct hashmap_entry *e, *k;
|
||||
unsigned old_hash, new_hash;
|
||||
|
||||
if (!h)
|
||||
return -ENOENT;
|
||||
|
||||
old_hash = h->hash_func(old_key) % NBUCKETS;
|
||||
if (!(e = hash_scan(h, old_hash, old_key)))
|
||||
return -ENOENT;
|
||||
|
||||
new_hash = h->hash_func(new_key) % NBUCKETS;
|
||||
|
||||
if ((k = hash_scan(h, new_hash, new_key)))
|
||||
if (e != k)
|
||||
remove_entry(h, k);
|
||||
|
||||
unlink_entry(h, e, old_hash);
|
||||
|
||||
e->key = new_key;
|
||||
e->value = value;
|
||||
|
||||
link_entry(h, e, new_hash);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* hashmap_remove_value(Hashmap *h, const void *key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
if (e->value != value)
|
||||
return NULL;
|
||||
|
||||
remove_entry(h, e);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key) {
|
||||
struct hashmap_entry *e;
|
||||
|
||||
assert(i);
|
||||
|
||||
if (!h)
|
||||
goto at_end;
|
||||
|
||||
if (*i == ITERATOR_LAST)
|
||||
goto at_end;
|
||||
|
||||
if (*i == ITERATOR_FIRST && !h->iterate_list_head)
|
||||
goto at_end;
|
||||
|
||||
e = *i == ITERATOR_FIRST ? h->iterate_list_head : (struct hashmap_entry*) *i;
|
||||
|
||||
if (e->iterate_next)
|
||||
*i = (Iterator) e->iterate_next;
|
||||
else
|
||||
*i = ITERATOR_LAST;
|
||||
|
||||
if (key)
|
||||
*key = e->key;
|
||||
|
||||
return e->value;
|
||||
|
||||
at_end:
|
||||
*i = ITERATOR_LAST;
|
||||
|
||||
if (key)
|
||||
*key = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key) {
|
||||
struct hashmap_entry *e;
|
||||
|
||||
assert(i);
|
||||
|
||||
if (!h)
|
||||
goto at_beginning;
|
||||
|
||||
if (*i == ITERATOR_FIRST)
|
||||
goto at_beginning;
|
||||
|
||||
if (*i == ITERATOR_LAST && !h->iterate_list_tail)
|
||||
goto at_beginning;
|
||||
|
||||
e = *i == ITERATOR_LAST ? h->iterate_list_tail : (struct hashmap_entry*) *i;
|
||||
|
||||
if (e->iterate_previous)
|
||||
*i = (Iterator) e->iterate_previous;
|
||||
else
|
||||
*i = ITERATOR_FIRST;
|
||||
|
||||
if (key)
|
||||
*key = e->key;
|
||||
|
||||
return e->value;
|
||||
|
||||
at_beginning:
|
||||
*i = ITERATOR_FIRST;
|
||||
|
||||
if (key)
|
||||
*key = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i) {
|
||||
unsigned hash;
|
||||
struct hashmap_entry *e;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
*i = (Iterator) e;
|
||||
|
||||
return e->value;
|
||||
}
|
||||
|
||||
void* hashmap_first(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
return h->iterate_list_head->value;
|
||||
}
|
||||
|
||||
void* hashmap_first_key(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
return (void*) h->iterate_list_head->key;
|
||||
}
|
||||
|
||||
void* hashmap_last(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_tail)
|
||||
return NULL;
|
||||
|
||||
return h->iterate_list_tail->value;
|
||||
}
|
||||
|
||||
void* hashmap_steal_first(Hashmap *h) {
|
||||
void *data;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
data = h->iterate_list_head->value;
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void* hashmap_steal_first_key(Hashmap *h) {
|
||||
void *key;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
key = (void*) h->iterate_list_head->key;
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
unsigned hashmap_size(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return 0;
|
||||
|
||||
return h->n_entries;
|
||||
}
|
||||
|
||||
bool hashmap_isempty(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return true;
|
||||
|
||||
return h->n_entries == 0;
|
||||
}
|
||||
|
||||
int hashmap_merge(Hashmap *h, Hashmap *other) {
|
||||
struct hashmap_entry *e;
|
||||
|
||||
assert(h);
|
||||
|
||||
if (!other)
|
||||
return 0;
|
||||
|
||||
for (e = other->iterate_list_head; e; e = e->iterate_next) {
|
||||
int r;
|
||||
|
||||
if ((r = hashmap_put(h, e->key, e->value)) < 0)
|
||||
if (r != -EEXIST)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hashmap_move(Hashmap *h, Hashmap *other) {
|
||||
struct hashmap_entry *e, *n;
|
||||
|
||||
assert(h);
|
||||
|
||||
/* The same as hashmap_merge(), but every new item from other
|
||||
* is moved to h. This function is guaranteed to succeed. */
|
||||
|
||||
if (!other)
|
||||
return;
|
||||
|
||||
for (e = other->iterate_list_head; e; e = n) {
|
||||
unsigned h_hash, other_hash;
|
||||
|
||||
n = e->iterate_next;
|
||||
|
||||
h_hash = h->hash_func(e->key) % NBUCKETS;
|
||||
|
||||
if (hash_scan(h, h_hash, e->key))
|
||||
continue;
|
||||
|
||||
other_hash = other->hash_func(e->key) % NBUCKETS;
|
||||
|
||||
unlink_entry(other, e, other_hash);
|
||||
link_entry(h, e, h_hash);
|
||||
}
|
||||
}
|
||||
|
||||
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) {
|
||||
unsigned h_hash, other_hash;
|
||||
struct hashmap_entry *e;
|
||||
|
||||
if (!other)
|
||||
return 0;
|
||||
|
||||
assert(h);
|
||||
|
||||
h_hash = h->hash_func(key) % NBUCKETS;
|
||||
if (hash_scan(h, h_hash, key))
|
||||
return -EEXIST;
|
||||
|
||||
other_hash = other->hash_func(key) % NBUCKETS;
|
||||
if (!(e = hash_scan(other, other_hash, key)))
|
||||
return -ENOENT;
|
||||
|
||||
unlink_entry(other, e, other_hash);
|
||||
link_entry(h, e, h_hash);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Hashmap *hashmap_copy(Hashmap *h) {
|
||||
Hashmap *copy;
|
||||
|
||||
assert(h);
|
||||
|
||||
if (!(copy = hashmap_new(h->hash_func, h->compare_func)))
|
||||
return NULL;
|
||||
|
||||
if (hashmap_merge(copy, h) < 0) {
|
||||
hashmap_free(copy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
char **hashmap_get_strv(Hashmap *h) {
|
||||
char **sv;
|
||||
Iterator it;
|
||||
char *item;
|
||||
int n;
|
||||
|
||||
sv = new(char*, h->n_entries+1);
|
||||
if (!sv)
|
||||
return NULL;
|
||||
|
||||
n = 0;
|
||||
HASHMAP_FOREACH(item, h, it)
|
||||
sv[n++] = item;
|
||||
sv[n] = NULL;
|
||||
|
||||
return sv;
|
||||
}
|
91
install/hashmap.h
Normal file
91
install/hashmap.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef foohashmaphfoo
|
||||
#define foohashmaphfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd 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.
|
||||
|
||||
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Pretty straightforward hash table implementation. As a minor
|
||||
* optimization a NULL hashmap object will be treated as empty hashmap
|
||||
* for all read operations. That way it is not necessary to
|
||||
* instantiate an object for each Hashmap use. */
|
||||
|
||||
typedef struct Hashmap Hashmap;
|
||||
typedef struct _IteratorStruct _IteratorStruct;
|
||||
typedef _IteratorStruct* Iterator;
|
||||
|
||||
#define ITERATOR_FIRST ((Iterator) 0)
|
||||
#define ITERATOR_LAST ((Iterator) -1)
|
||||
|
||||
typedef unsigned (*hash_func_t)(const void *p);
|
||||
typedef int (*compare_func_t)(const void *a, const void *b);
|
||||
|
||||
unsigned string_hash_func(const void *p);
|
||||
int string_compare_func(const void *a, const void *b);
|
||||
|
||||
unsigned trivial_hash_func(const void *p);
|
||||
int trivial_compare_func(const void *a, const void *b);
|
||||
|
||||
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
|
||||
void hashmap_free(Hashmap *h);
|
||||
void hashmap_free_free(Hashmap *h);
|
||||
Hashmap *hashmap_copy(Hashmap *h);
|
||||
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func);
|
||||
|
||||
int hashmap_put(Hashmap *h, const void *key, void *value);
|
||||
int hashmap_replace(Hashmap *h, const void *key, void *value);
|
||||
void* hashmap_get(Hashmap *h, const void *key);
|
||||
void* hashmap_remove(Hashmap *h, const void *key);
|
||||
void* hashmap_remove_value(Hashmap *h, const void *key, void *value);
|
||||
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value);
|
||||
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value);
|
||||
|
||||
int hashmap_merge(Hashmap *h, Hashmap *other);
|
||||
void hashmap_move(Hashmap *h, Hashmap *other);
|
||||
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key);
|
||||
|
||||
unsigned hashmap_size(Hashmap *h);
|
||||
bool hashmap_isempty(Hashmap *h);
|
||||
|
||||
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key);
|
||||
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key);
|
||||
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i);
|
||||
|
||||
void hashmap_clear(Hashmap *h);
|
||||
void *hashmap_steal_first(Hashmap *h);
|
||||
void *hashmap_steal_first_key(Hashmap *h);
|
||||
void* hashmap_first(Hashmap *h);
|
||||
void* hashmap_first_key(Hashmap *h);
|
||||
void* hashmap_last(Hashmap *h);
|
||||
|
||||
char **hashmap_get_strv(Hashmap *h);
|
||||
|
||||
#define HASHMAP_FOREACH(e, h, i) \
|
||||
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), NULL); (e); (e) = hashmap_iterate((h), &(i), NULL))
|
||||
|
||||
#define HASHMAP_FOREACH_KEY(e, k, h, i) \
|
||||
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), (const void**) &(k)); (e); (e) = hashmap_iterate((h), &(i), (const void**) &(k)))
|
||||
|
||||
#define HASHMAP_FOREACH_BACKWARDS(e, h, i) \
|
||||
for ((i) = ITERATOR_LAST, (e) = hashmap_iterate_backwards((h), &(i), NULL); (e); (e) = hashmap_iterate_backwards((h), &(i), NULL))
|
||||
|
||||
#endif
|
12
install/hashmap.lo
Normal file
12
install/hashmap.lo
Normal file
@@ -0,0 +1,12 @@
|
||||
# src/shared/hashmap.lo - a libtool object file
|
||||
# Generated by libtool (GNU libtool) 2.4.2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# Name of the PIC object.
|
||||
pic_object='.libs/hashmap.o'
|
||||
|
||||
# Name of the non-PIC object
|
||||
non_pic_object='hashmap.o'
|
||||
|
294
install/log.c
Normal file
294
install/log.c
Normal file
@@ -0,0 +1,294 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd 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.
|
||||
|
||||
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "macro.h"
|
||||
|
||||
#define SNDBUF_SIZE (8*1024*1024)
|
||||
|
||||
static LogTarget log_target = LOG_TARGET_CONSOLE;
|
||||
static int log_max_level = LOG_WARNING;
|
||||
static int log_facility = LOG_DAEMON;
|
||||
|
||||
static int console_fd = STDERR_FILENO;
|
||||
|
||||
static bool show_location = false;
|
||||
|
||||
/* Akin to glibc's __abort_msg; which is private and we hence cannot
|
||||
* use here. */
|
||||
static char *log_abort_msg = NULL;
|
||||
|
||||
void log_close_console(void) {
|
||||
|
||||
if (console_fd < 0)
|
||||
return;
|
||||
|
||||
if (getpid() == 1) {
|
||||
if (console_fd >= 3)
|
||||
close_nointr_nofail(console_fd);
|
||||
|
||||
console_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int log_open_console(void) {
|
||||
|
||||
if (console_fd >= 0)
|
||||
return 0;
|
||||
|
||||
if (getpid() == 1) {
|
||||
|
||||
console_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
||||
if (console_fd < 0) {
|
||||
log_error("Failed to open /dev/console for logging: %s", strerror(-console_fd));
|
||||
return console_fd;
|
||||
}
|
||||
|
||||
log_debug("Successfully opened /dev/console for logging.");
|
||||
} else
|
||||
console_fd = STDERR_FILENO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int log_open(void) {
|
||||
return log_open_console();
|
||||
}
|
||||
|
||||
|
||||
void log_close(void) {
|
||||
log_close_console();
|
||||
}
|
||||
|
||||
|
||||
void log_set_max_level(int level) {
|
||||
assert((level & LOG_PRIMASK) == level);
|
||||
|
||||
log_max_level = level;
|
||||
}
|
||||
|
||||
void log_set_facility(int facility) {
|
||||
log_facility = facility;
|
||||
}
|
||||
|
||||
static int write_to_console(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *buffer) {
|
||||
|
||||
char location[64];
|
||||
struct iovec iovec[5];
|
||||
unsigned n = 0;
|
||||
|
||||
if (console_fd < 0)
|
||||
return 0;
|
||||
|
||||
zero(iovec);
|
||||
|
||||
IOVEC_SET_STRING(iovec[n++], "dracut-install: ");
|
||||
|
||||
if (show_location) {
|
||||
snprintf(location, sizeof(location), "(%s:%u) ", file, line);
|
||||
IOVEC_SET_STRING(iovec[n++], location);
|
||||
}
|
||||
|
||||
IOVEC_SET_STRING(iovec[n++], buffer);
|
||||
IOVEC_SET_STRING(iovec[n++], "\n");
|
||||
|
||||
if (writev(console_fd, iovec, n) < 0)
|
||||
return -errno;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int log_dispatch(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *buffer) {
|
||||
|
||||
int r = 0;
|
||||
|
||||
if (log_target == LOG_TARGET_NULL)
|
||||
return 0;
|
||||
|
||||
/* Patch in LOG_DAEMON facility if necessary */
|
||||
if ((level & LOG_FACMASK) == 0)
|
||||
level = log_facility | LOG_PRI(level);
|
||||
|
||||
do {
|
||||
char *e;
|
||||
int k = 0;
|
||||
|
||||
buffer += strspn(buffer, NEWLINE);
|
||||
|
||||
if (buffer[0] == 0)
|
||||
break;
|
||||
|
||||
if ((e = strpbrk(buffer, NEWLINE)))
|
||||
*(e++) = 0;
|
||||
|
||||
k = write_to_console(level, file, line, func, buffer);
|
||||
if (k < 0)
|
||||
return k;
|
||||
buffer = e;
|
||||
} while (buffer);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int log_metav(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format,
|
||||
va_list ap) {
|
||||
|
||||
char buffer[LINE_MAX];
|
||||
int saved_errno, r;
|
||||
|
||||
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||
return 0;
|
||||
|
||||
saved_errno = errno;
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
char_array_0(buffer);
|
||||
|
||||
r = log_dispatch(level, file, line, func, buffer);
|
||||
errno = saved_errno;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int log_meta(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format, ...) {
|
||||
|
||||
int r;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
r = log_metav(level, file, line, func, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
_noreturn_ static void log_assert(const char *text, const char *file, int line, const char *func, const char *format) {
|
||||
static char buffer[LINE_MAX];
|
||||
|
||||
snprintf(buffer, sizeof(buffer), format, text, file, line, func);
|
||||
|
||||
char_array_0(buffer);
|
||||
log_abort_msg = buffer;
|
||||
|
||||
log_dispatch(LOG_CRIT, file, line, func, buffer);
|
||||
abort();
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) {
|
||||
log_assert(text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
|
||||
}
|
||||
|
||||
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) {
|
||||
log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
|
||||
}
|
||||
|
||||
void log_set_target(LogTarget target) {
|
||||
assert(target >= 0);
|
||||
assert(target < _LOG_TARGET_MAX);
|
||||
|
||||
log_target = target;
|
||||
}
|
||||
|
||||
int log_set_target_from_string(const char *e) {
|
||||
LogTarget t;
|
||||
|
||||
t = log_target_from_string(e);
|
||||
if (t < 0)
|
||||
return -EINVAL;
|
||||
|
||||
log_set_target(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int log_set_max_level_from_string(const char *e) {
|
||||
int t;
|
||||
|
||||
t = log_level_from_string(e);
|
||||
if (t < 0)
|
||||
return t;
|
||||
|
||||
log_set_max_level(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void log_parse_environment(void) {
|
||||
const char *e;
|
||||
|
||||
if ((e = getenv("DRACUT_LOG_TARGET")))
|
||||
if (log_set_target_from_string(e) < 0)
|
||||
log_warning("Failed to parse log target %s. Ignoring.", e);
|
||||
|
||||
if ((e = getenv("DRACUT_LOG_LEVEL")))
|
||||
if (log_set_max_level_from_string(e) < 0)
|
||||
log_warning("Failed to parse log level %s. Ignoring.", e);
|
||||
|
||||
}
|
||||
|
||||
LogTarget log_get_target(void) {
|
||||
return log_target;
|
||||
}
|
||||
|
||||
int log_get_max_level(void) {
|
||||
return log_max_level;
|
||||
}
|
||||
|
||||
|
||||
static const char *const log_target_table[] = {
|
||||
[LOG_TARGET_CONSOLE] = "console",
|
||||
[LOG_TARGET_AUTO] = "auto",
|
||||
[LOG_TARGET_SAFE] = "safe",
|
||||
[LOG_TARGET_NULL] = "null"
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(log_target, LogTarget);
|
115
install/log.h
Normal file
115
install/log.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef foologhfoo
|
||||
#define foologhfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd 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.
|
||||
|
||||
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <syslog.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
typedef enum LogTarget{
|
||||
LOG_TARGET_CONSOLE,
|
||||
LOG_TARGET_KMSG,
|
||||
LOG_TARGET_JOURNAL,
|
||||
LOG_TARGET_JOURNAL_OR_KMSG,
|
||||
LOG_TARGET_SYSLOG,
|
||||
LOG_TARGET_SYSLOG_OR_KMSG,
|
||||
LOG_TARGET_AUTO, /* console if stderr is tty, JOURNAL_OR_KMSG otherwise */
|
||||
LOG_TARGET_SAFE, /* console if stderr is tty, KMSG otherwise */
|
||||
LOG_TARGET_NULL,
|
||||
_LOG_TARGET_MAX,
|
||||
_LOG_TARGET_INVALID = -1
|
||||
} LogTarget;
|
||||
|
||||
void log_set_target(LogTarget target);
|
||||
void log_set_max_level(int level);
|
||||
void log_set_facility(int facility);
|
||||
|
||||
int log_set_target_from_string(const char *e);
|
||||
int log_set_max_level_from_string(const char *e);
|
||||
|
||||
void log_show_color(bool b);
|
||||
void log_show_location(bool b);
|
||||
|
||||
int log_show_color_from_string(const char *e);
|
||||
int log_show_location_from_string(const char *e);
|
||||
|
||||
LogTarget log_get_target(void);
|
||||
int log_get_max_level(void);
|
||||
|
||||
int log_open(void);
|
||||
void log_close(void);
|
||||
void log_forget_fds(void);
|
||||
|
||||
void log_close_syslog(void);
|
||||
void log_close_journal(void);
|
||||
void log_close_kmsg(void);
|
||||
void log_close_console(void);
|
||||
|
||||
void log_parse_environment(void);
|
||||
|
||||
int log_meta(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format, ...) _printf_attr_(5,6);
|
||||
|
||||
int log_metav(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format,
|
||||
va_list ap);
|
||||
|
||||
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func);
|
||||
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func);
|
||||
|
||||
/* This modifies the buffer passed! */
|
||||
int log_dump_internal(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *buffer);
|
||||
|
||||
#define log_full(level, ...) log_meta(level, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
|
||||
#define log_debug(...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_info(...) log_meta(LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_notice(...) log_meta(LOG_NOTICE, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_warning(...) log_meta(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_error(...) log_meta(LOG_ERR, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
|
||||
/* This modifies the buffer passed! */
|
||||
#define log_dump(level, buffer) log_dump_internal(level, __FILE__, __LINE__, __func__, buffer)
|
||||
|
||||
const char *log_target_to_string(LogTarget target);
|
||||
LogTarget log_target_from_string(const char *s);
|
||||
|
||||
const char *log_level_to_string(int i);
|
||||
int log_level_from_string(const char *s);
|
||||
|
||||
#endif
|
192
install/macro.h
Normal file
192
install/macro.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef foomacrohfoo
|
||||
#define foomacrohfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd 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.
|
||||
|
||||
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define _printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
|
||||
#define _sentinel_ __attribute__ ((sentinel))
|
||||
#define _noreturn_ __attribute__((noreturn))
|
||||
#define _unused_ __attribute__ ((unused))
|
||||
#define _destructor_ __attribute__ ((destructor))
|
||||
#define _pure_ __attribute__ ((pure))
|
||||
#define _const_ __attribute__ ((const))
|
||||
#define _deprecated_ __attribute__ ((deprecated))
|
||||
#define _packed_ __attribute__ ((packed))
|
||||
#define _malloc_ __attribute__ ((malloc))
|
||||
#define _weak_ __attribute__ ((weak))
|
||||
#define _likely_(x) (__builtin_expect(!!(x),1))
|
||||
#define _unlikely_(x) (__builtin_expect(!!(x),0))
|
||||
#define _public_ __attribute__ ((visibility("default")))
|
||||
#define _hidden_ __attribute__ ((visibility("hidden")))
|
||||
#define _weakref_(x) __attribute__((weakref(#x)))
|
||||
#define _introspect_(x) __attribute__((section("introspect." x)))
|
||||
|
||||
#define XSTRINGIFY(x) #x
|
||||
#define STRINGIFY(x) XSTRINGIFY(x)
|
||||
|
||||
/* Rounds up */
|
||||
#define ALIGN(l) ALIGN_TO((l), sizeof(void*))
|
||||
static inline size_t ALIGN_TO(size_t l, size_t ali) {
|
||||
return ((l + ali - 1) & ~(ali - 1));
|
||||
}
|
||||
|
||||
#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
/*
|
||||
* container_of - cast a member of a structure out to the containing structure
|
||||
* @ptr: the pointer to the member.
|
||||
* @type: the type of the container struct this is embedded in.
|
||||
* @member: the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) \
|
||||
__extension__ ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(b) _b = (b); \
|
||||
_a > _b ? _a : _b; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define MAX3(a,b,c) \
|
||||
MAX(MAX(a,b),c)
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) \
|
||||
__extension__ ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(b) _b = (b); \
|
||||
_a < _b ? _a : _b; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define MIN3(a,b,c) \
|
||||
MIN(MIN(a,b),c)
|
||||
|
||||
#define CLAMP(x, low, high) \
|
||||
__extension__ ({ \
|
||||
typeof(x) _x = (x); \
|
||||
typeof(low) _low = (low); \
|
||||
typeof(high) _high = (high); \
|
||||
((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
|
||||
})
|
||||
|
||||
#define assert_se(expr) \
|
||||
do { \
|
||||
if (_unlikely_(!(expr))) \
|
||||
log_assert_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
|
||||
} while (false) \
|
||||
|
||||
/* We override the glibc assert() here. */
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
#define assert(expr) do {} while(false)
|
||||
#else
|
||||
#define assert(expr) assert_se(expr)
|
||||
#endif
|
||||
|
||||
#define assert_not_reached(t) \
|
||||
do { \
|
||||
log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
|
||||
} while (false)
|
||||
|
||||
#define assert_cc(expr) \
|
||||
do { \
|
||||
switch (0) { \
|
||||
case 0: \
|
||||
case !!(expr): \
|
||||
; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
|
||||
#define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||
|
||||
#define PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p)))
|
||||
#define UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||
|
||||
#define PTR_TO_ULONG(p) ((unsigned long) ((uintptr_t) (p)))
|
||||
#define ULONG_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||
|
||||
#define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
|
||||
#define INT_TO_PTR(u) ((void*) ((intptr_t) (u)))
|
||||
|
||||
#define TO_INT32(p) ((int32_t) ((intptr_t) (p)))
|
||||
#define INT32_TO_PTR(u) ((void*) ((intptr_t) (u)))
|
||||
|
||||
#define PTR_TO_LONG(p) ((long) ((intptr_t) (p)))
|
||||
#define LONG_TO_PTR(u) ((void*) ((intptr_t) (u)))
|
||||
|
||||
#define memzero(x,l) (memset((x), 0, (l)))
|
||||
#define zero(x) (memzero(&(x), sizeof(x)))
|
||||
|
||||
#define char_array_0(x) x[sizeof(x)-1] = 0;
|
||||
|
||||
#define IOVEC_SET_STRING(i, s) \
|
||||
do { \
|
||||
struct iovec *_i = &(i); \
|
||||
char *_s = (char *)(s); \
|
||||
_i->iov_base = _s; \
|
||||
_i->iov_len = strlen(_s); \
|
||||
} while(false)
|
||||
|
||||
static inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned n) {
|
||||
unsigned j;
|
||||
size_t r = 0;
|
||||
|
||||
for (j = 0; j < n; j++)
|
||||
r += i[j].iov_len;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
|
||||
unsigned j;
|
||||
|
||||
for (j = 0; j < n; j++) {
|
||||
size_t sub;
|
||||
|
||||
if (_unlikely_(k <= 0))
|
||||
break;
|
||||
|
||||
sub = MIN(i[j].iov_len, k);
|
||||
i[j].iov_len -= sub;
|
||||
i[j].iov_base = (uint8_t*) i[j].iov_base + sub;
|
||||
k -= sub;
|
||||
}
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#endif
|
187
install/util.c
Normal file
187
install/util.c
Normal file
@@ -0,0 +1,187 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd 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.
|
||||
|
||||
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
static inline pid_t gettid(void) {
|
||||
return (pid_t) syscall(SYS_gettid);
|
||||
}
|
||||
|
||||
size_t page_size(void) {
|
||||
static __thread size_t pgsz = 0;
|
||||
long r;
|
||||
|
||||
if (_likely_(pgsz > 0))
|
||||
return pgsz;
|
||||
|
||||
assert_se((r = sysconf(_SC_PAGESIZE)) > 0);
|
||||
|
||||
pgsz = (size_t) r;
|
||||
|
||||
return pgsz;
|
||||
}
|
||||
|
||||
bool endswith(const char *s, const char *postfix) {
|
||||
size_t sl, pl;
|
||||
|
||||
assert(s);
|
||||
assert(postfix);
|
||||
|
||||
sl = strlen(s);
|
||||
pl = strlen(postfix);
|
||||
|
||||
if (pl == 0)
|
||||
return true;
|
||||
|
||||
if (sl < pl)
|
||||
return false;
|
||||
|
||||
return memcmp(s + sl - pl, postfix, pl) == 0;
|
||||
}
|
||||
int close_nointr(int fd) {
|
||||
assert(fd >= 0);
|
||||
|
||||
for (;;) {
|
||||
int r;
|
||||
|
||||
r = close(fd);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
|
||||
if (errno != EINTR)
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
void close_nointr_nofail(int fd) {
|
||||
int saved_errno = errno;
|
||||
|
||||
/* like close_nointr() but cannot fail, and guarantees errno
|
||||
* is unchanged */
|
||||
|
||||
assert_se(close_nointr(fd) == 0);
|
||||
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
int open_terminal(const char *name, int mode) {
|
||||
int fd, r;
|
||||
unsigned c = 0;
|
||||
|
||||
/*
|
||||
* If a TTY is in the process of being closed opening it might
|
||||
* cause EIO. This is horribly awful, but unlikely to be
|
||||
* changed in the kernel. Hence we work around this problem by
|
||||
* retrying a couple of times.
|
||||
*
|
||||
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245
|
||||
*/
|
||||
|
||||
for (;;) {
|
||||
if ((fd = open(name, mode)) >= 0)
|
||||
break;
|
||||
|
||||
if (errno != EIO)
|
||||
return -errno;
|
||||
|
||||
if (c >= 20)
|
||||
return -errno;
|
||||
|
||||
usleep(50 * USEC_PER_MSEC);
|
||||
c++;
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
if ((r = isatty(fd)) < 0) {
|
||||
close_nointr_nofail(fd);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (!r) {
|
||||
close_nointr_nofail(fd);
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
bool streq_ptr(const char *a, const char *b) {
|
||||
|
||||
/* Like streq(), but tries to make sense of NULL pointers */
|
||||
|
||||
if (a && b)
|
||||
return streq(a, b);
|
||||
|
||||
if (!a && !b)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool is_main_thread(void) {
|
||||
static __thread int cached = 0;
|
||||
|
||||
if (_unlikely_(cached == 0))
|
||||
cached = getpid() == gettid() ? 1 : -1;
|
||||
|
||||
return cached > 0;
|
||||
}
|
||||
|
||||
int safe_atou(const char *s, unsigned *ret_u) {
|
||||
char *x = NULL;
|
||||
unsigned long l;
|
||||
|
||||
assert(s);
|
||||
assert(ret_u);
|
||||
|
||||
errno = 0;
|
||||
l = strtoul(s, &x, 0);
|
||||
|
||||
if (!x || *x || errno)
|
||||
return errno ? -errno : -EINVAL;
|
||||
|
||||
if ((unsigned long) (unsigned) l != l)
|
||||
return -ERANGE;
|
||||
|
||||
*ret_u = (unsigned) l;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *const log_level_table[] = {
|
||||
[LOG_EMERG] = "emerg",
|
||||
[LOG_ALERT] = "alert",
|
||||
[LOG_CRIT] = "crit",
|
||||
[LOG_ERR] = "err",
|
||||
[LOG_WARNING] = "warning",
|
||||
[LOG_NOTICE] = "notice",
|
||||
[LOG_INFO] = "info",
|
||||
[LOG_DEBUG] = "debug"
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(log_level, int);
|
527
install/util.h
Normal file
527
install/util.h
Normal file
@@ -0,0 +1,527 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef fooutilhfoo
|
||||
#define fooutilhfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd 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.
|
||||
|
||||
systemd 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 systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <sched.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
typedef uint64_t usec_t;
|
||||
typedef uint64_t nsec_t;
|
||||
|
||||
typedef struct dual_timestamp {
|
||||
usec_t realtime;
|
||||
usec_t monotonic;
|
||||
} dual_timestamp;
|
||||
|
||||
#define MSEC_PER_SEC 1000ULL
|
||||
#define USEC_PER_SEC 1000000ULL
|
||||
#define USEC_PER_MSEC 1000ULL
|
||||
#define NSEC_PER_SEC 1000000000ULL
|
||||
#define NSEC_PER_MSEC 1000000ULL
|
||||
#define NSEC_PER_USEC 1000ULL
|
||||
|
||||
#define USEC_PER_MINUTE (60ULL*USEC_PER_SEC)
|
||||
#define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC)
|
||||
#define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE)
|
||||
#define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE)
|
||||
#define USEC_PER_DAY (24ULL*USEC_PER_HOUR)
|
||||
#define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR)
|
||||
#define USEC_PER_WEEK (7ULL*USEC_PER_DAY)
|
||||
#define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY)
|
||||
#define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC)
|
||||
#define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC)
|
||||
#define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC)
|
||||
#define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC)
|
||||
|
||||
/* What is interpreted as whitespace? */
|
||||
#define WHITESPACE " \t\n\r"
|
||||
#define NEWLINE "\n\r"
|
||||
#define QUOTES "\"\'"
|
||||
#define COMMENTS "#;\n"
|
||||
|
||||
#define FORMAT_TIMESTAMP_MAX 64
|
||||
#define FORMAT_TIMESTAMP_PRETTY_MAX 256
|
||||
#define FORMAT_TIMESPAN_MAX 64
|
||||
#define FORMAT_BYTES_MAX 8
|
||||
|
||||
#define ANSI_HIGHLIGHT_ON "\x1B[1;39m"
|
||||
#define ANSI_HIGHLIGHT_RED_ON "\x1B[1;31m"
|
||||
#define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
|
||||
#define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
|
||||
#define ANSI_HIGHLIGHT_OFF "\x1B[0m"
|
||||
|
||||
usec_t now(clockid_t clock);
|
||||
|
||||
dual_timestamp* dual_timestamp_get(dual_timestamp *ts);
|
||||
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);
|
||||
|
||||
#define dual_timestamp_is_set(ts) ((ts)->realtime > 0)
|
||||
|
||||
usec_t timespec_load(const struct timespec *ts);
|
||||
struct timespec *timespec_store(struct timespec *ts, usec_t u);
|
||||
|
||||
usec_t timeval_load(const struct timeval *tv);
|
||||
struct timeval *timeval_store(struct timeval *tv, usec_t u);
|
||||
|
||||
size_t page_size(void);
|
||||
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
|
||||
|
||||
#define streq(a,b) (strcmp((a),(b)) == 0)
|
||||
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
|
||||
|
||||
bool streq_ptr(const char *a, const char *b);
|
||||
|
||||
#define new(t, n) ((t*) malloc(sizeof(t)*(n)))
|
||||
|
||||
#define new0(t, n) ((t*) calloc((n), sizeof(t)))
|
||||
|
||||
#define newa(t, n) ((t*) alloca(sizeof(t)*(n)))
|
||||
|
||||
#define newdup(t, p, n) ((t*) memdup(p, sizeof(t)*(n)))
|
||||
|
||||
#define malloc0(n) (calloc((n), 1))
|
||||
|
||||
static inline const char* yes_no(bool b) {
|
||||
return b ? "yes" : "no";
|
||||
}
|
||||
|
||||
static inline const char* strempty(const char *s) {
|
||||
return s ? s : "";
|
||||
}
|
||||
|
||||
static inline const char* strnull(const char *s) {
|
||||
return s ? s : "(null)";
|
||||
}
|
||||
|
||||
static inline const char *strna(const char *s) {
|
||||
return s ? s : "n/a";
|
||||
}
|
||||
|
||||
static inline bool isempty(const char *p) {
|
||||
return !p || !p[0];
|
||||
}
|
||||
|
||||
bool endswith(const char *s, const char *postfix);
|
||||
bool startswith(const char *s, const char *prefix);
|
||||
bool startswith_no_case(const char *s, const char *prefix);
|
||||
|
||||
bool first_word(const char *s, const char *word);
|
||||
|
||||
int close_nointr(int fd);
|
||||
void close_nointr_nofail(int fd);
|
||||
void close_many(const int fds[], unsigned n_fd);
|
||||
|
||||
int parse_boolean(const char *v);
|
||||
int parse_usec(const char *t, usec_t *usec);
|
||||
int parse_nsec(const char *t, nsec_t *nsec);
|
||||
int parse_bytes(const char *t, off_t *bytes);
|
||||
int parse_pid(const char *s, pid_t* ret_pid);
|
||||
int parse_uid(const char *s, uid_t* ret_uid);
|
||||
#define parse_gid(s, ret_uid) parse_uid(s, ret_uid)
|
||||
|
||||
int safe_atou(const char *s, unsigned *ret_u);
|
||||
int safe_atoi(const char *s, int *ret_i);
|
||||
|
||||
int safe_atollu(const char *s, unsigned long long *ret_u);
|
||||
int safe_atolli(const char *s, long long int *ret_i);
|
||||
|
||||
#if __WORDSIZE == 32
|
||||
static inline int safe_atolu(const char *s, unsigned long *ret_u) {
|
||||
assert_cc(sizeof(unsigned long) == sizeof(unsigned));
|
||||
return safe_atou(s, (unsigned*) ret_u);
|
||||
}
|
||||
static inline int safe_atoli(const char *s, long int *ret_u) {
|
||||
assert_cc(sizeof(long int) == sizeof(int));
|
||||
return safe_atoi(s, (int*) ret_u);
|
||||
}
|
||||
#else
|
||||
static inline int safe_atolu(const char *s, unsigned long *ret_u) {
|
||||
assert_cc(sizeof(unsigned long) == sizeof(unsigned long long));
|
||||
return safe_atollu(s, (unsigned long long*) ret_u);
|
||||
}
|
||||
static inline int safe_atoli(const char *s, long int *ret_u) {
|
||||
assert_cc(sizeof(long int) == sizeof(long long int));
|
||||
return safe_atolli(s, (long long int*) ret_u);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int safe_atou32(const char *s, uint32_t *ret_u) {
|
||||
assert_cc(sizeof(uint32_t) == sizeof(unsigned));
|
||||
return safe_atou(s, (unsigned*) ret_u);
|
||||
}
|
||||
|
||||
static inline int safe_atoi32(const char *s, int32_t *ret_i) {
|
||||
assert_cc(sizeof(int32_t) == sizeof(int));
|
||||
return safe_atoi(s, (int*) ret_i);
|
||||
}
|
||||
|
||||
static inline int safe_atou64(const char *s, uint64_t *ret_u) {
|
||||
assert_cc(sizeof(uint64_t) == sizeof(unsigned long long));
|
||||
return safe_atollu(s, (unsigned long long*) ret_u);
|
||||
}
|
||||
|
||||
static inline int safe_atoi64(const char *s, int64_t *ret_i) {
|
||||
assert_cc(sizeof(int64_t) == sizeof(long long int));
|
||||
return safe_atolli(s, (long long int*) ret_i);
|
||||
}
|
||||
|
||||
char *split(const char *c, size_t *l, const char *separator, char **state);
|
||||
char *split_quoted(const char *c, size_t *l, char **state);
|
||||
|
||||
#define FOREACH_WORD(word, length, s, state) \
|
||||
for ((state) = NULL, (word) = split((s), &(length), WHITESPACE, &(state)); (word); (word) = split((s), &(length), WHITESPACE, &(state)))
|
||||
|
||||
#define FOREACH_WORD_SEPARATOR(word, length, s, separator, state) \
|
||||
for ((state) = NULL, (word) = split((s), &(length), (separator), &(state)); (word); (word) = split((s), &(length), (separator), &(state)))
|
||||
|
||||
#define FOREACH_WORD_QUOTED(word, length, s, state) \
|
||||
for ((state) = NULL, (word) = split_quoted((s), &(length), &(state)); (word); (word) = split_quoted((s), &(length), &(state)))
|
||||
|
||||
pid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
|
||||
int get_starttime_of_pid(pid_t pid, unsigned long long *st);
|
||||
|
||||
int write_one_line_file(const char *fn, const char *line);
|
||||
int write_one_line_file_atomic(const char *fn, const char *line);
|
||||
int read_one_line_file(const char *fn, char **line);
|
||||
int read_full_file(const char *fn, char **contents, size_t *size);
|
||||
|
||||
int parse_env_file(const char *fname, const char *separator, ...) _sentinel_;
|
||||
int load_env_file(const char *fname, char ***l);
|
||||
int write_env_file(const char *fname, char **l);
|
||||
|
||||
char *strappend(const char *s, const char *suffix);
|
||||
char *strnappend(const char *s, const char *suffix, size_t length);
|
||||
|
||||
char *replace_env(const char *format, char **env);
|
||||
char **replace_env_argv(char **argv, char **env);
|
||||
|
||||
int readlink_malloc(const char *p, char **r);
|
||||
int readlink_and_make_absolute(const char *p, char **r);
|
||||
int readlink_and_canonicalize(const char *p, char **r);
|
||||
|
||||
int reset_all_signal_handlers(void);
|
||||
|
||||
char *strstrip(char *s);
|
||||
char *delete_chars(char *s, const char *bad);
|
||||
char *truncate_nl(char *s);
|
||||
|
||||
char *file_in_same_dir(const char *path, const char *filename);
|
||||
|
||||
int rmdir_parents(const char *path, const char *stop);
|
||||
|
||||
int get_process_comm(pid_t pid, char **name);
|
||||
int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
|
||||
int get_process_exe(pid_t pid, char **name);
|
||||
int get_process_uid(pid_t pid, uid_t *uid);
|
||||
|
||||
char hexchar(int x);
|
||||
int unhexchar(char c);
|
||||
char octchar(int x);
|
||||
int unoctchar(char c);
|
||||
char decchar(int x);
|
||||
int undecchar(char c);
|
||||
|
||||
char *cescape(const char *s);
|
||||
char *cunescape(const char *s);
|
||||
char *cunescape_length(const char *s, size_t length);
|
||||
|
||||
char *xescape(const char *s, const char *bad);
|
||||
|
||||
char *bus_path_escape(const char *s);
|
||||
char *bus_path_unescape(const char *s);
|
||||
|
||||
char *ascii_strlower(char *path);
|
||||
|
||||
bool dirent_is_file(const struct dirent *de);
|
||||
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix);
|
||||
|
||||
bool ignore_file(const char *filename);
|
||||
|
||||
bool chars_intersect(const char *a, const char *b);
|
||||
|
||||
char *format_timestamp(char *buf, size_t l, usec_t t);
|
||||
char *format_timestamp_pretty(char *buf, size_t l, usec_t t);
|
||||
char *format_timespan(char *buf, size_t l, usec_t t);
|
||||
|
||||
int make_stdio(int fd);
|
||||
int make_null_stdio(void);
|
||||
|
||||
unsigned long long random_ull(void);
|
||||
|
||||
#define __DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
|
||||
scope const char *name##_to_string(type i) { \
|
||||
if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
|
||||
return NULL; \
|
||||
return name##_table[i]; \
|
||||
} \
|
||||
scope type name##_from_string(const char *s) { \
|
||||
type i; \
|
||||
unsigned u = 0; \
|
||||
assert(s); \
|
||||
for (i = 0; i < (type)ELEMENTSOF(name##_table); i++) \
|
||||
if (name##_table[i] && \
|
||||
streq(name##_table[i], s)) \
|
||||
return i; \
|
||||
if (safe_atou(s, &u) >= 0 && \
|
||||
u < ELEMENTSOF(name##_table)) \
|
||||
return (type) u; \
|
||||
return (type) -1; \
|
||||
} \
|
||||
struct __useless_struct_to_allow_trailing_semicolon__
|
||||
|
||||
#define DEFINE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,)
|
||||
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,static)
|
||||
|
||||
int fd_nonblock(int fd, bool nonblock);
|
||||
int fd_cloexec(int fd, bool cloexec);
|
||||
|
||||
int close_all_fds(const int except[], unsigned n_except);
|
||||
|
||||
bool fstype_is_network(const char *fstype);
|
||||
|
||||
int chvt(int vt);
|
||||
|
||||
int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl);
|
||||
int ask(char *ret, const char *replies, const char *text, ...);
|
||||
|
||||
int reset_terminal_fd(int fd, bool switch_to_text);
|
||||
int reset_terminal(const char *name);
|
||||
|
||||
int open_terminal(const char *name, int mode);
|
||||
int acquire_terminal(const char *name, bool fail, bool force, bool ignore_tiocstty_eperm);
|
||||
int release_terminal(void);
|
||||
|
||||
int flush_fd(int fd);
|
||||
|
||||
int ignore_signals(int sig, ...);
|
||||
int default_signals(int sig, ...);
|
||||
int sigaction_many(const struct sigaction *sa, ...);
|
||||
|
||||
int close_pipe(int p[]);
|
||||
int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
|
||||
|
||||
ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
|
||||
ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
|
||||
|
||||
bool is_device_path(const char *path);
|
||||
|
||||
int dir_is_empty(const char *path);
|
||||
|
||||
void rename_process(const char name[8]);
|
||||
|
||||
void sigset_add_many(sigset_t *ss, ...);
|
||||
|
||||
char* gethostname_malloc(void);
|
||||
bool hostname_is_set(void);
|
||||
char* getlogname_malloc(void);
|
||||
|
||||
int getttyname_malloc(int fd, char **r);
|
||||
int getttyname_harder(int fd, char **r);
|
||||
|
||||
int get_ctty_devnr(pid_t pid, dev_t *d);
|
||||
int get_ctty(pid_t, dev_t *_devnr, char **r);
|
||||
|
||||
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
|
||||
int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid);
|
||||
|
||||
int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev);
|
||||
int rm_rf(const char *path, bool only_dirs, bool delete_root, bool honour_sticky);
|
||||
|
||||
int pipe_eof(int fd);
|
||||
|
||||
cpu_set_t* cpu_set_malloc(unsigned *ncpus);
|
||||
|
||||
void status_vprintf(const char *status, bool ellipse, const char *format, va_list ap);
|
||||
void status_printf(const char *status, bool ellipse, const char *format, ...);
|
||||
void status_welcome(void);
|
||||
|
||||
int fd_columns(int fd);
|
||||
unsigned columns(void);
|
||||
|
||||
int fd_lines(int fd);
|
||||
unsigned lines(void);
|
||||
|
||||
int running_in_chroot(void);
|
||||
|
||||
char *ellipsize(const char *s, size_t length, unsigned percent);
|
||||
char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent);
|
||||
|
||||
int touch(const char *path);
|
||||
|
||||
char *unquote(const char *s, const char *quotes);
|
||||
char *normalize_env_assignment(const char *s);
|
||||
|
||||
int wait_for_terminate(pid_t pid, siginfo_t *status);
|
||||
int wait_for_terminate_and_warn(const char *name, pid_t pid);
|
||||
|
||||
_noreturn_ void freeze(void);
|
||||
|
||||
bool null_or_empty(struct stat *st);
|
||||
int null_or_empty_path(const char *fn);
|
||||
|
||||
DIR *xopendirat(int dirfd, const char *name, int flags);
|
||||
|
||||
void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
|
||||
void dual_timestamp_deserialize(const char *value, dual_timestamp *t);
|
||||
|
||||
char *fstab_node_to_udev_node(const char *p);
|
||||
|
||||
bool tty_is_vc(const char *tty);
|
||||
bool tty_is_vc_resolve(const char *tty);
|
||||
bool tty_is_console(const char *tty);
|
||||
int vtnr_from_tty(const char *tty);
|
||||
const char *default_term_for_tty(const char *tty);
|
||||
|
||||
void execute_directory(const char *directory, DIR *_d, char *argv[]);
|
||||
|
||||
int kill_and_sigcont(pid_t pid, int sig);
|
||||
|
||||
bool nulstr_contains(const char*nulstr, const char *needle);
|
||||
|
||||
bool plymouth_running(void);
|
||||
|
||||
void parse_syslog_priority(char **p, int *priority);
|
||||
void skip_syslog_pid(char **buf);
|
||||
void skip_syslog_date(char **buf);
|
||||
|
||||
bool hostname_is_valid(const char *s);
|
||||
char* hostname_cleanup(char *s);
|
||||
|
||||
char* strshorten(char *s, size_t l);
|
||||
|
||||
int terminal_vhangup_fd(int fd);
|
||||
int terminal_vhangup(const char *name);
|
||||
|
||||
int vt_disallocate(const char *name);
|
||||
|
||||
int copy_file(const char *from, const char *to);
|
||||
int symlink_or_copy(const char *from, const char *to);
|
||||
int symlink_or_copy_atomic(const char *from, const char *to);
|
||||
|
||||
int fchmod_umask(int fd, mode_t mode);
|
||||
|
||||
bool display_is_local(const char *display);
|
||||
int socket_from_display(const char *display, char **path);
|
||||
|
||||
int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **home);
|
||||
int get_group_creds(const char **groupname, gid_t *gid);
|
||||
|
||||
int in_group(const char *name);
|
||||
|
||||
int glob_exists(const char *path);
|
||||
|
||||
int dirent_ensure_type(DIR *d, struct dirent *de);
|
||||
|
||||
int in_search_path(const char *path, char **search);
|
||||
int get_files_in_directory(const char *path, char ***list);
|
||||
|
||||
char *join(const char *x, ...) _sentinel_;
|
||||
|
||||
bool is_main_thread(void);
|
||||
|
||||
bool in_charset(const char *s, const char* charset);
|
||||
|
||||
int block_get_whole_disk(dev_t d, dev_t *ret);
|
||||
|
||||
int file_is_priv_sticky(const char *p);
|
||||
|
||||
int strdup_or_null(const char *a, char **b);
|
||||
|
||||
#define NULSTR_FOREACH(i, l) \
|
||||
for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
|
||||
|
||||
#define NULSTR_FOREACH_PAIR(i, j, l) \
|
||||
for ((i) = (l), (j) = strchr((i), 0)+1; (i) && *(i); (i) = strchr((j), 0)+1, (j) = *(i) ? strchr((i), 0)+1 : (i))
|
||||
|
||||
const char *ioprio_class_to_string(int i);
|
||||
int ioprio_class_from_string(const char *s);
|
||||
|
||||
const char *sigchld_code_to_string(int i);
|
||||
int sigchld_code_from_string(const char *s);
|
||||
|
||||
const char *log_facility_unshifted_to_string(int i);
|
||||
int log_facility_unshifted_from_string(const char *s);
|
||||
|
||||
const char *log_level_to_string(int i);
|
||||
int log_level_from_string(const char *s);
|
||||
|
||||
const char *sched_policy_to_string(int i);
|
||||
int sched_policy_from_string(const char *s);
|
||||
|
||||
const char *rlimit_to_string(int i);
|
||||
int rlimit_from_string(const char *s);
|
||||
|
||||
const char *ip_tos_to_string(int i);
|
||||
int ip_tos_from_string(const char *s);
|
||||
|
||||
const char *signal_to_string(int i);
|
||||
int signal_from_string(const char *s);
|
||||
|
||||
int signal_from_string_try_harder(const char *s);
|
||||
|
||||
extern int saved_argc;
|
||||
extern char **saved_argv;
|
||||
|
||||
bool kexec_loaded(void);
|
||||
|
||||
int prot_from_flags(int flags);
|
||||
|
||||
char *format_bytes(char *buf, size_t l, off_t t);
|
||||
|
||||
int fd_wait_for_event(int fd, int event, usec_t timeout);
|
||||
|
||||
void* memdup(const void *p, size_t l);
|
||||
|
||||
int is_kernel_thread(pid_t pid);
|
||||
|
||||
int fd_inc_sndbuf(int fd, size_t n);
|
||||
int fd_inc_rcvbuf(int fd, size_t n);
|
||||
|
||||
int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...);
|
||||
|
||||
int setrlimit_closest(int resource, const struct rlimit *rlim);
|
||||
|
||||
int getenv_for_pid(pid_t pid, const char *field, char **_value);
|
||||
|
||||
int can_sleep(const char *type);
|
||||
|
||||
bool is_valid_documentation_url(const char *url);
|
||||
|
||||
bool in_initrd(void);
|
||||
|
||||
void warn_melody(void);
|
||||
|
||||
#endif
|
43
lsinitrd.1.asc
Normal file
43
lsinitrd.1.asc
Normal file
@@ -0,0 +1,43 @@
|
||||
LSINITRD(1)
|
||||
=========
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
lsinitrd - tool to show the contents of an initramfs image
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
*lsinit* ['OPTION...'] [<image>]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
lsinitrd shows the contents of an initramfs image. if <image> is omitted, then
|
||||
lsinitrd uses the default image /boot/initramfs-<kernel version>.img.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**-h, --help**::
|
||||
print a help message and exit.
|
||||
|
||||
**-s, --size**::
|
||||
sort the contents of the initramfs by size.
|
||||
|
||||
AVAILABILITY
|
||||
------------
|
||||
The lsinitrd command is part of the dracut package and is available from
|
||||
link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org]
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Harald Hoyer
|
||||
|
||||
Amerigo Wang
|
||||
|
||||
Nikoli
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8)
|
16
lsinitrd.sh
16
lsinitrd.sh
@@ -19,13 +19,19 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [-s] [<initramfs file> [<filename>]]" ; exit 1 ; }
|
||||
usage()
|
||||
{
|
||||
echo "Usage: $(${0##*/}) [-s] [<initramfs file> [<filename>]]"
|
||||
}
|
||||
|
||||
[[ $# -le 2 ]] || { usage ; exit 1 ; }
|
||||
|
||||
sorted=0
|
||||
while getopts "s" opt; do
|
||||
case $opt in
|
||||
s) sorted=1;;
|
||||
\?) exit 1;;
|
||||
h) usage; exit 0;;
|
||||
\?) usage; exit 1;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
@@ -34,7 +40,7 @@ image="${1:-/boot/initramfs-$(uname -r).img}"
|
||||
[[ -f "$image" ]] || { echo "$image does not exist" ; exit 1 ; }
|
||||
|
||||
CAT=zcat
|
||||
FILE_T=$(file "$image")
|
||||
FILE_T=$(file --dereference "$image")
|
||||
|
||||
if echo "test"|xz|xz -dc --single-stream >/dev/null 2>&1; then
|
||||
XZ_SINGLE_STREAM="--single-stream"
|
||||
@@ -57,9 +63,9 @@ if [[ $# -eq 2 ]]; then
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo "$image: $(du -h $image | awk '{print $1}')"
|
||||
echo "$image: $(du -h $image | while read a b; do echo $a;done)"
|
||||
echo "========================================================================"
|
||||
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null
|
||||
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null
|
||||
echo "========================================================================"
|
||||
if [ "$sorted" -eq 1 ]; then
|
||||
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
|
||||
|
65
mkinitrd.8.asc
Normal file
65
mkinitrd.8.asc
Normal file
@@ -0,0 +1,65 @@
|
||||
MKINITRD(8)
|
||||
=========
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
mkinitrd - is a compat wrapper, which calls dracut to generate an initramfs
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
*mkinitrd* ['OPTION...'] [<initrd-image>] <kernel-version>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
mkinitrd creates an initramfs image <initrd-image> for the kernel with
|
||||
version <kernel-version> by calling "dracut".
|
||||
|
||||
[IMPORTANT]
|
||||
If a more fine grained control over the resulting image is needed,
|
||||
"dracut" should be called directly.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**--version**::
|
||||
print info about the version
|
||||
|
||||
**-v, --verbose**::
|
||||
increase verbosity level
|
||||
|
||||
**-f, --force**::
|
||||
overwrite existing initramfs file.
|
||||
|
||||
**--image-version*::
|
||||
append the kernel version to the target image
|
||||
<initrd-image>-<kernel-version>.
|
||||
|
||||
**--with=<module>**::
|
||||
add the kernel module <module> to the initramfs.
|
||||
|
||||
**--preload=<module>**::
|
||||
preload the kernel module <module> in the initramfs before any other kernel
|
||||
modules are loaded. This can be used to ensure a certain device naming, which
|
||||
should in theory be avoided and the use of symbolic links in /dev is
|
||||
encouraged.
|
||||
|
||||
**--nocompress**::
|
||||
do not compress the resulting image.
|
||||
|
||||
**--help**::
|
||||
print a help message and exit.
|
||||
|
||||
AVAILABILITY
|
||||
------------
|
||||
The mkinitrd command is part of the dracut package and is available from
|
||||
link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org]
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Harald Hoyer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8)
|
@@ -13,19 +13,17 @@ depends() {
|
||||
}
|
||||
|
||||
install() {
|
||||
inst /sbin/bootchartd
|
||||
inst /bin/bash
|
||||
inst_symlink /init /sbin/init
|
||||
inst_dir /lib/bootchart/tmpfs
|
||||
inst /lib/bootchart/bootchart-collector
|
||||
inst /etc/bootchartd.conf
|
||||
inst /sbin/accton
|
||||
inst /usr/bin/pkill /bin/pkill
|
||||
inst /bin/echo
|
||||
inst /bin/grep
|
||||
inst /bin/usleep
|
||||
inst /usr/bin/[ /bin/[
|
||||
|
||||
mknod -m 0666 "${initdir}/dev/null" c 1 3
|
||||
dracut_install bootchartd bash \
|
||||
/lib/bootchart/bootchart-collector /etc/bootchartd.conf \
|
||||
accton \
|
||||
echo \
|
||||
grep \
|
||||
usleep
|
||||
|
||||
inst /usr/bin/pkill /bin/pkill
|
||||
inst /usr/bin/[ /bin/[
|
||||
}
|
||||
|
||||
|
@@ -12,38 +12,33 @@ depends() {
|
||||
|
||||
installkernel() {
|
||||
local _fipsmodules _mod
|
||||
_fipsmodules="aead aes_generic aes-xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr"
|
||||
_fipsmodules+=" des deflate ecb eseqiv hmac seqiv sha256 sha512"
|
||||
_fipsmodules="aead aes_generic xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr gcm ghash_generic"
|
||||
_fipsmodules+=" des deflate ecb eseqiv hmac seqiv sha256 sha256_generic sha512 sha512_generic"
|
||||
_fipsmodules+=" cryptomgr crypto_null tcrypt dm-mod dm-crypt"
|
||||
|
||||
mkdir -m 0755 -p "${initdir}/etc/modprobe.d"
|
||||
|
||||
for _mod in $_fipsmodules; do
|
||||
if instmods $_mod; then
|
||||
if hostonly='' instmods -c -s $_mod; then
|
||||
echo $_mod >> "${initdir}/etc/fipsmodules"
|
||||
echo "blacklist $_mod" >> "${initdir}/etc/modprobe.d/fips.conf"
|
||||
fi
|
||||
done
|
||||
hostonly='' instmods scsi_wait_scan
|
||||
}
|
||||
|
||||
install() {
|
||||
local _dir
|
||||
inst_hook pre-trigger 01 "$moddir/fips-boot.sh"
|
||||
inst_hook pre-pivot 01 "$moddir/fips-noboot.sh"
|
||||
inst "$moddir/fips.sh" /sbin/fips.sh
|
||||
inst_script "$moddir/fips.sh" /sbin/fips.sh
|
||||
|
||||
dracut_install sha512hmac rmmod insmod mount uname umount
|
||||
|
||||
for _dir in "$usrlibdir" "$libdir"; do
|
||||
[[ -e $_dir/libsoftokn3.so ]] && \
|
||||
dracut_install $_dir/libsoftokn3.so $_dir/libsoftokn3.chk \
|
||||
$_dir/libfreebl3.so $_dir/libfreebl3.chk && \
|
||||
break
|
||||
done
|
||||
inst_libdir_file libsoftokn3.so libsoftokn3.so \
|
||||
libsoftokn3.chk libfreebl3.so libfreebl3.chk \
|
||||
'hmaccalc/sha512hmac.hmac'
|
||||
|
||||
dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac
|
||||
if command -v prelink >/dev/null; then
|
||||
dracut_install prelink
|
||||
fi
|
||||
dracut_install -o prelink
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,6 @@ install() {
|
||||
inst_hook pre-pivot 00 "$moddir/caps.sh"
|
||||
inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
|
||||
# capsh wants bash and we need bash also
|
||||
inst /bin/bash && ln -sf bash "${initdir}/bin/sh"
|
||||
inst /bin/bash
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ depends() {
|
||||
|
||||
installkernel() {
|
||||
local _fipsmodules _mod
|
||||
_fipsmodules="aesni-intel"
|
||||
_fipsmodules="aesni-intel ghash_clmulni_intel"
|
||||
|
||||
mkdir -m 0755 -p "${initdir}/etc/modprobe.d"
|
||||
|
||||
|
28
modules.d/04watchdog/module-setup.sh
Executable file
28
modules.d/04watchdog/module-setup.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_hook cmdline 00 "$moddir/watchdog.sh"
|
||||
inst_hook cmdline 50 "$moddir/watchdog.sh"
|
||||
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
|
||||
inst_hook initqueue 00 "$moddir/watchdog.sh"
|
||||
inst_hook mount 00 "$moddir/watchdog.sh"
|
||||
inst_hook mount 50 "$moddir/watchdog.sh"
|
||||
inst_hook mount 99 "$moddir/watchdog.sh"
|
||||
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
|
||||
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 00 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 99 "$moddir/watchdog.sh"
|
||||
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
|
||||
dracut_install -o wdctl
|
||||
}
|
||||
|
2
modules.d/04watchdog/watchdog-stop.sh
Executable file
2
modules.d/04watchdog/watchdog-stop.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
[ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
|
12
modules.d/04watchdog/watchdog.sh
Executable file
12
modules.d/04watchdog/watchdog.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
if [ -e /dev/watchdog ]; then
|
||||
if [ ! -e /tmp/watchdog_timeout ]; then
|
||||
wdctl -s 60 /dev/watchdog &>/dev/null
|
||||
> /tmp/watchdog_timeout
|
||||
fi
|
||||
info "Triggering watchdog"
|
||||
>/dev/watchdog
|
||||
else
|
||||
modprobe ib700wdt
|
||||
modprobe i6300esb
|
||||
fi
|
@@ -1,2 +1,2 @@
|
||||
# Console initialization - keyboard, font, etc.
|
||||
KERNEL=="tty0", RUN+="/lib/udev/console_init $root/$name"
|
||||
KERNEL=="tty0", RUN+="/sbin/initqueue --unique --name console_init_$name /lib/udev/console_init $root/$name"
|
||||
|
@@ -2,6 +2,12 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
[ -n "$DRACUT_SYSTEMD" ] && exit 0
|
||||
|
||||
if [ -x /lib/systemd/systemd-vconsole-setup ]; then
|
||||
/lib/systemd/systemd-vconsole-setup "$@"
|
||||
fi
|
||||
|
||||
[ -e /etc/vconsole.conf ] && . /etc/vconsole.conf
|
||||
|
||||
DEFAULT_FONT=LatArCyrHeb-16
|
||||
|
@@ -31,7 +31,7 @@ install() {
|
||||
*) cmd=grep ;;
|
||||
esac
|
||||
|
||||
for INCL in $($cmd "^include " $MAP | cut -d' ' -f2 | tr -d '"'); do
|
||||
for INCL in $($cmd "^include " $MAP | while read a a b; do echo ${a//\"/}; done); do
|
||||
for FN in $(find ${kbddir}/keymaps -type f -name $INCL\*); do
|
||||
findkeymap $FN
|
||||
done
|
||||
@@ -74,9 +74,11 @@ install() {
|
||||
for map in ${item[1]//,/ }
|
||||
do
|
||||
map=(${map//-/ })
|
||||
value=$(grep "^${map[0]}=" "${item[0]}")
|
||||
value=${value#*=}
|
||||
echo "${map[1]:-${map[0]}}=${value}"
|
||||
if [[ -f "${item[0]}" ]]; then
|
||||
value=$(grep "^${map[0]}=" "${item[0]}")
|
||||
value=${value#*=}
|
||||
echo "${map[1]:-${map[0]}}=${value}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
@@ -92,9 +94,9 @@ install() {
|
||||
install_all_kbd() {
|
||||
local rel f
|
||||
|
||||
find $(eval echo ${kbddir}/{${KBDSUBDIRS}}) -type f -print | \
|
||||
while read f; do
|
||||
inst_simple $f
|
||||
for _src in $(eval echo ${kbddir}/{${KBDSUBDIRS}}); do
|
||||
inst_dir "$_src"
|
||||
cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_src}" "$_src"/*
|
||||
done
|
||||
|
||||
# remove unnecessary files
|
||||
@@ -155,9 +157,10 @@ install() {
|
||||
EXT_KEYMAPS+=\ ${UNIKEYMAP}\ ${GRP_TOGGLE}
|
||||
|
||||
[[ ${KEYMAP} ]] || {
|
||||
derror 'No KEYMAP.'
|
||||
dinfo 'No KEYMAP configured.'
|
||||
return 1
|
||||
}
|
||||
|
||||
findkeymap ${KEYMAP}
|
||||
|
||||
for map in ${EXT_KEYMAPS}
|
||||
|
@@ -19,10 +19,10 @@ inst_key_val() {
|
||||
unset _value
|
||||
}
|
||||
|
||||
inst_key_val '' /etc/vconsole.conf KEYMAP vconsole.keymap KEYTABLE
|
||||
inst_key_val '' /etc/vconsole.conf FONT vconsole.font SYSFONT
|
||||
inst_key_val '' /etc/vconsole.conf FONT_MAP vconsole.font.map CONTRANS
|
||||
inst_key_val '' /etc/vconsole.conf FONT_UNIMAP vconsole.font.unimap UNIMAP
|
||||
inst_key_val '' /etc/vconsole.conf KEYMAP vconsole.keymap -d KEYTABLE
|
||||
inst_key_val '' /etc/vconsole.conf FONT vconsole.font -d SYSFONT
|
||||
inst_key_val '' /etc/vconsole.conf FONT_MAP vconsole.font.map -d CONTRANS
|
||||
inst_key_val '' /etc/vconsole.conf FONT_UNIMAP vconsole.font.unimap -d UNIMAP
|
||||
inst_key_val 1 /etc/vconsole.conf UNICODE vconsole.unicode vconsole.font.unicode
|
||||
inst_key_val '' /etc/vconsole.conf EXT_KEYMAP vconsole.keymap.ext
|
||||
|
||||
@@ -35,10 +35,8 @@ if [ -f /etc/locale.conf ]; then
|
||||
export LC_ALL
|
||||
fi
|
||||
|
||||
# FIXME: fix systemd-vconsole-setup
|
||||
#if [ -x /lib/systemd/systemd-vconsole-setup ]; then
|
||||
# /lib/systemd/systemd-vconsole-setup
|
||||
# rm -f /{etc,lib}/udev/rules.d/10-console.rules
|
||||
# rm -f /lib/udev/console_init
|
||||
# ln -s /lib/systemd/systemd-vconsole-setup /lib/udev/console_init
|
||||
#fi
|
||||
if [ -n "$DRACUT_SYSTEMD" ]; then
|
||||
rm -f /etc/udev/rules.d/10-console.rules
|
||||
rm -f /lib/udev/rules.d/10-console.rules
|
||||
rm -f /lib/udev/console_init
|
||||
fi
|
||||
|
@@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
[ -f /etc/redhat-release ]
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
local _line
|
||||
local _dracut_rpm_version
|
||||
if [ -e "$moddir/dracut-version" ]; then
|
||||
_dracut_rpm_version=$(cat "$moddir/dracut-version")
|
||||
inst "$moddir/dracut-version" /lib/dracut/$_dracut_rpm_version
|
||||
else
|
||||
if rpm -qf $(type -P $0) &>/dev/null; then
|
||||
_dracut_rpm_version=$(rpm -qf --qf '%{name}-%{version}-%{release}\n' $(type -P $0) | { ver="";while read _line;do ver=$_line;done;echo $ver;} )
|
||||
mkdir -m 0755 -p $initdir/lib/dracut
|
||||
echo $_dracut_rpm_version > $initdir/lib/dracut/$_dracut_rpm_version
|
||||
fi
|
||||
fi
|
||||
inst_hook cmdline 01 "$moddir/version.sh"
|
||||
|
||||
}
|
||||
|
@@ -12,9 +12,8 @@ depends() {
|
||||
}
|
||||
|
||||
install() {
|
||||
dracut_install bash
|
||||
dracut_install find ldconfig mv rm cp ln
|
||||
dracut_install bash find ldconfig mv rm cp ln
|
||||
inst_hook pre-pivot 99 "$moddir/do-convertfs.sh"
|
||||
inst "$moddir/convertfs.sh" /usr/bin/convertfs
|
||||
inst_script "$moddir/convertfs.sh" /usr/bin/convertfs
|
||||
}
|
||||
|
||||
|
@@ -22,15 +22,15 @@ setup_interface() {
|
||||
# disallow MTUs from 576 and below by default, so that broken
|
||||
# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
|
||||
if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then
|
||||
echo "if ! ip link set $netif mtu $mtu ; then"
|
||||
echo "ip link set $netif down"
|
||||
echo "ip link set $netif mtu $mtu"
|
||||
echo "ip link set $netif up"
|
||||
echo wait_for_if_up $netif
|
||||
echo "fi"
|
||||
fi > /tmp/net.$netif.up
|
||||
if ! ip link set $netif mtu $mtu ; then
|
||||
ip link set $netif down
|
||||
ip link set $netif mtu $mtu
|
||||
ip link set $netif up
|
||||
wait_for_if_up $netif
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif >> /tmp/net.$netif.up
|
||||
ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif
|
||||
|
||||
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
|
||||
|
||||
@@ -66,23 +66,34 @@ case $reason in
|
||||
;;
|
||||
BOUND)
|
||||
echo "dhcp: BOND setting $netif"
|
||||
if ! arping -q -D -c 2 -I $netif $new_ip_address ; then
|
||||
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
|
||||
exit 1
|
||||
unset layer2
|
||||
if [ -f /sys/class/net/$netif/device/layer2 ]; then
|
||||
read layer2 < /sys/class/net/$netif/device/layer2
|
||||
fi
|
||||
if [ "$layer2" != "0" ]; then
|
||||
if ! arping -q -D -c 2 -I $netif $new_ip_address ; then
|
||||
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
unset layer2
|
||||
setup_interface
|
||||
set | while read line; do
|
||||
[ "${line#new_}" = "$line" ] && continue
|
||||
echo "$line"
|
||||
done >/tmp/dhclient.$netif.dhcpopts
|
||||
echo online > /sys/class/net/$netif/uevent
|
||||
|
||||
if [ -e /tmp/net.$netif.manualup ]; then
|
||||
/sbin/netroot $netif -m
|
||||
rm -f /tmp/net.$netif.manualup
|
||||
else
|
||||
initqueue --onetime --name netroot-$netif netroot $netif
|
||||
fi
|
||||
{
|
||||
echo '. /lib/net-lib.sh'
|
||||
echo "setup_net $netif"
|
||||
echo "source_hook initqueue/online $netif"
|
||||
[ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
|
||||
echo "> /tmp/setup_net_$netif.ok"
|
||||
echo "rm -f $hookdir/initqueue/setup_net_$netif.sh"
|
||||
} > $hookdir/initqueue/setup_net_$netif.sh
|
||||
|
||||
echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
|
||||
>/tmp/net.$netif.up
|
||||
;;
|
||||
*) echo "dhcp: $reason";;
|
||||
esac
|
||||
|
@@ -7,15 +7,28 @@ if ! getarg ifname= >/dev/null ; then
|
||||
return
|
||||
fi
|
||||
|
||||
command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
|
||||
|
||||
{
|
||||
for p in $(getargs ifname=); do
|
||||
parse_ifname_opts $p
|
||||
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
|
||||
done
|
||||
|
||||
# Rename non named interfaces out of the way for named ones.
|
||||
for p in $(getargs ifname=); do
|
||||
parse_ifname_opts $p
|
||||
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{type}=="1", NAME!="?*", KERNEL=="%s", NAME="%%k-renamed"\n' "$ifname_if"
|
||||
if [ -f /tmp/ifname-$ifname_mac ]; then
|
||||
read oldif < /tmp/ifname-$ifname_mac
|
||||
fi
|
||||
if [ -f /tmp/ifname-$ifname_if ]; then
|
||||
read oldmac < /tmp/ifname-$ifname_if
|
||||
fi
|
||||
if [ -n "$oldif" -a -n "$oldmac" -a "$oldif" = "$ifname_if" -a "$oldmac" = "$ifname_mac" ]; then
|
||||
# skip same ifname= declaration
|
||||
continue
|
||||
fi
|
||||
|
||||
[ -n "$oldif" ] && warn "Multiple interface names specified for MAC $ifname_mac: $oldif"
|
||||
[ -n "$oldmac" ] && warn "Multiple MAC specified for $ifname_if: $oldmac"
|
||||
|
||||
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
|
||||
echo $ifname_if > /tmp/ifname-$ifname_mac
|
||||
echo $ifname_mac > /tmp/ifname-$ifname_if
|
||||
done
|
||||
} > /etc/udev/rules.d/50-ifname.rules
|
||||
} >> /etc/udev/rules.d/80-ifname.rules
|
||||
|
@@ -31,19 +31,28 @@ fi
|
||||
# bridge this interface?
|
||||
if [ -e /tmp/bridge.info ]; then
|
||||
. /tmp/bridge.info
|
||||
if [ "$netif" = "$ethname" ]; then
|
||||
for ethname in $ethnames ; do
|
||||
if [ "$netif" = "$ethname" ]; then
|
||||
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
|
||||
: # We need to really setup bond (recursive call)
|
||||
else
|
||||
netif="$bridgename"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -e /tmp/vlan.info ]; then
|
||||
. /tmp/vlan.info
|
||||
if [ "$netif" = "$phydevice" ]; then
|
||||
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
|
||||
: # We need to really setup bond (recursive call)
|
||||
else
|
||||
netif="$bridgename"
|
||||
netif="$vlanname"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# bail immediately if the interface is already up
|
||||
# or we don't need the network
|
||||
[ -f "/tmp/net.$netif.up" ] && exit 0
|
||||
|
||||
# disable manual ifup while netroot is set for simplifying our logic
|
||||
# in netroot case we prefer netroot to bringup $netif automaticlly
|
||||
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
|
||||
@@ -72,13 +81,11 @@ load_ipv6() {
|
||||
|
||||
do_ipv6auto() {
|
||||
load_ipv6
|
||||
{
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
|
||||
echo ip link set $netif up
|
||||
echo wait_for_if_up $netif
|
||||
} > /tmp/net.$netif.up
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
|
||||
ip link set $netif up
|
||||
wait_for_if_up $netif
|
||||
|
||||
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
|
||||
|
||||
@@ -88,30 +95,23 @@ do_ipv6auto() {
|
||||
echo nameserver $s
|
||||
done
|
||||
fi >> /tmp/net.$netif.resolv.conf
|
||||
|
||||
|
||||
echo online > /sys/class/net/$netif/uevent
|
||||
if [ -n "$manualup" ]; then
|
||||
/sbin/netroot $netif -m
|
||||
else
|
||||
initqueue --onetime --name netroot-$netif netroot $netif
|
||||
fi
|
||||
}
|
||||
|
||||
# Handle static ip configuration
|
||||
do_static() {
|
||||
strstr $ip '*:*:*' && load_ipv6
|
||||
|
||||
{
|
||||
echo ip link set $netif up
|
||||
echo wait_for_if_up $netif
|
||||
[ -n "$macaddr" ] && echo ip link set address $macaddr
|
||||
[ -n "$mtu" ] && echo ip link set mtu $mtu
|
||||
# do not flush addr for ipv6
|
||||
strstr $ip '*:*:*' || \
|
||||
echo ip addr flush dev $netif
|
||||
echo ip addr add $ip/$mask brd + dev $netif
|
||||
} > /tmp/net.$netif.up
|
||||
ip link set $netif up
|
||||
wait_for_if_up $netif
|
||||
[ -n "$macaddr" ] && ip link set address $macaddr
|
||||
[ -n "$mtu" ] && ip link set mtu $mtu
|
||||
if strstr $ip '*:*:*'; then
|
||||
# note no ip addr flush for ipv6
|
||||
ip addr add $ip/$mask dev $netif
|
||||
else
|
||||
ip addr flush dev $netif
|
||||
ip addr add $ip/$mask brd + dev $netif
|
||||
fi
|
||||
|
||||
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
|
||||
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
|
||||
@@ -122,20 +122,12 @@ do_static() {
|
||||
echo nameserver $s
|
||||
done
|
||||
fi >> /tmp/net.$netif.resolv.conf
|
||||
|
||||
echo online > /sys/class/net/$netif/uevent
|
||||
if [ -n "$manualup" ]; then
|
||||
/sbin/netroot $netif -m
|
||||
else
|
||||
initqueue --onetime --name netroot-$netif netroot $netif
|
||||
fi
|
||||
}
|
||||
|
||||
# loopback is always handled the same way
|
||||
if [ "$netif" = "lo" ] ; then
|
||||
ip link set lo up
|
||||
ip addr add 127.0.0.1/8 dev lo
|
||||
>/tmp/net.$netif.up
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -169,7 +161,7 @@ if [ -e /tmp/bond.info ]; then
|
||||
|
||||
for slave in $bondslaves ; do
|
||||
ip link set $slave down
|
||||
ifenslave $bondname $slave
|
||||
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
|
||||
ip link set $slave up
|
||||
wait_for_if_up $slave
|
||||
done
|
||||
@@ -188,18 +180,44 @@ fi
|
||||
|
||||
# XXX need error handling like dhclient-script
|
||||
|
||||
if [ -e /tmp/bridge.info ]; then
|
||||
. /tmp/bridge.info
|
||||
# start bridge if necessary
|
||||
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
|
||||
if [ "$ethname" = "$bondname" ] ; then
|
||||
DO_BOND_SETUP=yes ifup $bondname
|
||||
else
|
||||
ip link set $ethname up
|
||||
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
|
||||
brctl addbr $bridgename
|
||||
brctl setfd $bridgename 0
|
||||
for ethname in $ethnames ; do
|
||||
if [ "$ethname" = "$bondname" ] ; then
|
||||
DO_BOND_SETUP=yes ifup $bondname -m
|
||||
else
|
||||
ip link set $ethname up
|
||||
fi
|
||||
wait_for_if_up $ethname
|
||||
brctl addif $bridgename $ethname
|
||||
done
|
||||
fi
|
||||
wait_for_if_up $ethname
|
||||
# Create bridge and add eth to bridge
|
||||
brctl addbr $bridgename
|
||||
brctl setfd $bridgename 0
|
||||
brctl addif $bridgename $ethname
|
||||
fi
|
||||
|
||||
get_vid() {
|
||||
case "$1" in
|
||||
vlan*)
|
||||
return ${1#vlan}
|
||||
;;
|
||||
*.*)
|
||||
return ${1##*.}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ "$netif" = "$vlanname" ] && [ ! -e /tmp/net.$vlanname.up ]; then
|
||||
modprobe 8021q
|
||||
if [ "$phydevice" = "$bondname" ] ; then
|
||||
DO_BOND_SETUP=yes ifup $phydevice -m
|
||||
else
|
||||
ip link set "$phydevice" up
|
||||
fi
|
||||
wait_for_if_up "$phydevice"
|
||||
ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname; echo $?)"
|
||||
fi
|
||||
|
||||
# No ip lines default to dhcp
|
||||
@@ -238,6 +256,21 @@ for p in $(getargs ip=); do
|
||||
*)
|
||||
do_static ;;
|
||||
esac
|
||||
|
||||
case $autoconf in
|
||||
dhcp|on|any|dhcp6)
|
||||
;;
|
||||
*)
|
||||
if [ $? -eq 0 ]; then
|
||||
setup_net $netif
|
||||
source_hook initqueue/online $netif
|
||||
if [ -z "$manualup" ]; then
|
||||
/sbin/netroot $netif
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
break
|
||||
done
|
||||
exit 0
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
check() {
|
||||
local _program
|
||||
. $dracutfunctions
|
||||
|
||||
for _program in ip arping dhclient ; do
|
||||
if ! type -P $_program >/dev/null; then
|
||||
@@ -27,6 +26,7 @@ installkernel() {
|
||||
net_module_filter() {
|
||||
local _net_drivers='eth_type_trans|register_virtio_device'
|
||||
local _unwanted_drivers='/(wireless|isdn|uwb)/'
|
||||
local _ret
|
||||
# subfunctions inherit following FDs
|
||||
local _merge=8 _side2=9
|
||||
function nmf1() {
|
||||
@@ -42,6 +42,7 @@ installkernel() {
|
||||
&& ! $_fcont =~ iw_handler_get_spy ]] \
|
||||
&& echo "$_fname"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
function rotor() {
|
||||
local _f1 _f2
|
||||
@@ -51,50 +52,52 @@ installkernel() {
|
||||
echo "$_f2" 1>&${_side2}
|
||||
fi
|
||||
done | nmf1 1>&${_merge}
|
||||
return 0
|
||||
}
|
||||
# Use two parallel streams to filter alternating modules.
|
||||
set +x
|
||||
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
|
||||
[[ $debug ]] && set -x
|
||||
return 0
|
||||
}
|
||||
|
||||
{ find_kernel_modules_by_path drivers/net; find_kernel_modules_by_path drivers/s390/net; } \
|
||||
{ find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \
|
||||
| net_module_filter | instmods
|
||||
|
||||
instmods =drivers/net/phy
|
||||
instmods ecb arc4
|
||||
# bridge modules
|
||||
instmods bridge stp llc
|
||||
instmods ipv6
|
||||
# bonding
|
||||
instmods bonding
|
||||
# vlan
|
||||
instmods 8021q
|
||||
instmods af_packet
|
||||
}
|
||||
|
||||
install() {
|
||||
local _arch _i _dir
|
||||
dracut_install ip arping tr dhclient
|
||||
dracut_install -o brctl ifenslave
|
||||
inst "$moddir/ifup.sh" "/sbin/ifup"
|
||||
inst "$moddir/netroot.sh" "/sbin/netroot"
|
||||
inst "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
|
||||
inst "$moddir/net-lib.sh" "/lib/net-lib.sh"
|
||||
dracut_install ip arping dhclient sed
|
||||
dracut_install -o brctl
|
||||
inst_script "$moddir/ifup.sh" "/sbin/ifup"
|
||||
inst_script "$moddir/netroot.sh" "/sbin/netroot"
|
||||
inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
|
||||
inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh"
|
||||
inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
|
||||
inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
|
||||
inst_hook pre-udev 60 "$moddir/net-genrules.sh"
|
||||
inst_hook cmdline 91 "$moddir/dhcp-root.sh"
|
||||
inst_hook cmdline 95 "$moddir/parse-vlan.sh"
|
||||
inst_hook cmdline 96 "$moddir/parse-bond.sh"
|
||||
inst_hook cmdline 97 "$moddir/parse-bridge.sh"
|
||||
inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
|
||||
inst_hook cmdline 99 "$moddir/parse-ifname.sh"
|
||||
inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
|
||||
inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
|
||||
|
||||
_arch=$(uname -m)
|
||||
|
||||
for _dir in "$usrlibdir/tls/$_arch" "$usrlibdir/tls" "$usrlibdir/$_arch" \
|
||||
"$usrlibdir" "$libdir"; do
|
||||
for _i in "$_dir"/libnss_dns.so.* "$_dir"/libnss_mdns4_minimal.so.*; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
done
|
||||
|
||||
inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*"
|
||||
}
|
||||
|
||||
|
@@ -10,25 +10,31 @@ fix_bootif() {
|
||||
macaddr=${macaddr%:}
|
||||
# strip hardware type field from pxelinux
|
||||
[ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
|
||||
echo $macaddr
|
||||
# return macaddr with lowercase alpha characters expected by udev
|
||||
echo $macaddr | sed 'y/ABCDEF/abcdef/'
|
||||
}
|
||||
|
||||
# Don't continue if we don't need network
|
||||
[ -z "$netroot" ] && ! getargbool 0 rd.neednet && return;
|
||||
[ -z "$netroot" ] && ! [ -e "/tmp/net.ifaces" ] && return;
|
||||
|
||||
# Write udev rules
|
||||
{
|
||||
# bridge: attempt only the defined interface
|
||||
if [ -e /tmp/bridge.info ]; then
|
||||
. /tmp/bridge.info
|
||||
IFACES=$ethname
|
||||
IFACES+=" ${ethnames%% *}"
|
||||
fi
|
||||
|
||||
# bond: attempt only the defined interface (override bridge defines)
|
||||
if [ -e /tmp/bond.info ]; then
|
||||
. /tmp/bond.info
|
||||
# It is enough to fire up only one
|
||||
IFACES=${bondslaves%% *}
|
||||
IFACES+=" ${bondslaves%% *}"
|
||||
fi
|
||||
|
||||
if [ -e /tmp/vlan.info ]; then
|
||||
. /tmp/vlan.info
|
||||
IFACES+=" $phydevice"
|
||||
fi
|
||||
|
||||
ifup='/sbin/ifup $env{INTERFACE}'
|
||||
@@ -48,10 +54,7 @@ fix_bootif() {
|
||||
|
||||
# Default: We don't know the interface to use, handle all
|
||||
else
|
||||
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup"
|
||||
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup" > /etc/udev/rules.d/91-default-net.rules
|
||||
fi
|
||||
|
||||
# Run the "online" hook
|
||||
printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n'
|
||||
|
||||
} > /etc/udev/rules.d/60-net.rules
|
||||
} > /etc/udev/rules.d/90-net.rules
|
||||
|
@@ -13,7 +13,7 @@ iface_for_remote_addr() {
|
||||
}
|
||||
|
||||
iface_for_mac() {
|
||||
local interface="" mac="$(echo $1 | tr '[:upper:]' '[:lower:]')"
|
||||
local interface="" mac="$(echo $1 | sed 'y/ABCDEF/abcdef/')"
|
||||
for interface in /sys/class/net/*; do
|
||||
if [ $(cat $interface/address) = "$mac" ]; then
|
||||
echo ${interface##*/}
|
||||
@@ -59,17 +59,15 @@ ifdown() {
|
||||
ip link set $netif down
|
||||
ip addr flush dev $netif
|
||||
echo "#empty" > /etc/resolv.conf
|
||||
rm -f /tmp/net.$netif.did-setup
|
||||
# TODO: send "offline" uevent?
|
||||
}
|
||||
|
||||
setup_net() {
|
||||
local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
|
||||
[ -e /tmp/net.$netif.up ] || return 1
|
||||
[ -e /tmp/net.$netif.did-setup ] && return
|
||||
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
|
||||
[ -z "$IFACES" ] && IFACES="$netif"
|
||||
for iface in $IFACES ; do
|
||||
. /tmp/net.$iface.up
|
||||
done
|
||||
# run the scripts written by ifup
|
||||
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
|
||||
[ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
|
||||
@@ -97,9 +95,34 @@ setup_net() {
|
||||
else
|
||||
dest="$gw_ip"
|
||||
fi
|
||||
if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
|
||||
|
||||
unset layer2
|
||||
if [ -f /sys/class/net/$netif/device/layer2 ]; then
|
||||
read layer2 < /sys/class/net/$netif/device/layer2
|
||||
fi
|
||||
|
||||
if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
|
||||
info "Resolving $dest via ARP on $netif failed"
|
||||
fi
|
||||
unset layer2
|
||||
|
||||
> /tmp/net.$netif.did-setup
|
||||
}
|
||||
|
||||
save_netinfo() {
|
||||
local netif="$1" IFACES="" f="" i=""
|
||||
[ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
|
||||
# Add $netif to the front of IFACES (if it's not there already).
|
||||
set -- "$netif"
|
||||
for i in $IFACES; do [ "$i" != "$netif" ] && set -- "$@" "$i"; done
|
||||
IFACES="$*"
|
||||
for i in $IFACES; do
|
||||
for f in /tmp/dhclient.$i.*; do
|
||||
[ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.}
|
||||
done
|
||||
done
|
||||
echo $IFACES > /tmp/.net.ifaces.new
|
||||
mv /tmp/.net.ifaces.new /tmp/net.ifaces
|
||||
}
|
||||
|
||||
set_ifname() {
|
||||
@@ -251,4 +274,44 @@ ip_to_var() {
|
||||
4) dev=$1; autoconf=$2; mtu=$3; macaddr=$4 ;;
|
||||
*) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7; mtu=$8; macaddr=$9 ;;
|
||||
esac
|
||||
# anaconda-style argument cluster
|
||||
if strstr "$autoconf" "*.*.*.*"; then
|
||||
ip="$autoconf"
|
||||
gw=$(getarg gateway=)
|
||||
mask=$(getarg netmask=)
|
||||
hostname=$(getarg hostname=)
|
||||
dev=$(getarg ksdevice=)
|
||||
autoconf="none"
|
||||
mtu=$(getarg mtu=)
|
||||
case "$dev" in
|
||||
# ignore fancy values for ksdevice=XXX
|
||||
link|bootif|BOOTIF|ibft|*:*:*:*:*:*) dev="" ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
parse_ifname_opts() {
|
||||
local IFS=:
|
||||
set $1
|
||||
|
||||
case $# in
|
||||
7)
|
||||
ifname_if=$1
|
||||
# udev requires MAC addresses to be lower case
|
||||
ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/')
|
||||
;;
|
||||
*)
|
||||
die "Invalid arguments for ifname="
|
||||
;;
|
||||
esac
|
||||
|
||||
case $ifname_if in
|
||||
eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]|eth[0-9][0-9][0-9][0-9])
|
||||
warn "ifname=$ifname_if uses the kernel name space for interfaces"
|
||||
warn "This can fail for multiple network interfaces and is discouraged!"
|
||||
warn "Please use a custom name like \"netboot\" or \"bluesocket\""
|
||||
warn "or use biosdevname and no ifname= at all."
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
@@ -13,24 +13,13 @@ command -v setup_net >/dev/null || . /lib/net-lib.sh
|
||||
# instead of real netroot; If It's called without $2, then there's
|
||||
# no sense in doing something if no (net)root info is available
|
||||
# or root is already there
|
||||
if [ -z "$2" ]; then
|
||||
[ -d $NEWROOT/proc ] && exit 0
|
||||
[ -z "$netroot" ] && exit 1
|
||||
fi
|
||||
|
||||
# Let's see if we have to wait for other interfaces
|
||||
# Note: exit works just fine, since the last interface to be
|
||||
# online'd should see all files
|
||||
all_ifaces_up || exit 1
|
||||
[ -d $NEWROOT/proc ] && exit 0
|
||||
[ -z "$netroot" ] && exit 1
|
||||
|
||||
# Set or override primary interface
|
||||
netif=$1
|
||||
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
|
||||
|
||||
if [ -e /tmp/net.$netif.manualup ]; then
|
||||
rm -f /tmp/net.$netif.manualup
|
||||
fi
|
||||
|
||||
# Figure out the handler for root=dhcp by recalling all netroot cmdline
|
||||
# handlers when this is not called from manually network bringing up.
|
||||
if [ -z "$2" ]; then
|
||||
@@ -72,29 +61,13 @@ if [ -z "$2" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# We're here, so we can assume that upping interfaces is now ok
|
||||
setup_net $netif
|
||||
|
||||
# exit in case manually bring up network
|
||||
[ -n "$2" ] && exit 0
|
||||
|
||||
# Source netroot hooks before we start the handler
|
||||
source_hook netroot
|
||||
source_hook netroot $netif
|
||||
|
||||
# Run the handler; don't store the root, it may change from device to device
|
||||
# XXX other variables to export?
|
||||
if $handler $netif $netroot $NEWROOT; then
|
||||
# Network rootfs mount successful
|
||||
for iface in $IFACES ; do
|
||||
[ -f /tmp/dhclient.$iface.lease ] && cp /tmp/dhclient.$iface.lease /tmp/net.$iface.lease
|
||||
[ -f /tmp/dhclient.$iface.dhcpopts ] && cp /tmp/dhclient.$iface.dhcpopts /tmp/net.$iface.dhcpopts
|
||||
done
|
||||
|
||||
# Save used netif for later use
|
||||
[ ! -f /tmp/net.ifaces ] && echo $netif > /tmp/net.ifaces
|
||||
else
|
||||
warn "Mounting root via '$netif' failed"
|
||||
# If we're trying with multiple interfaces, put that one down.
|
||||
[ -z "$BOOTDEV" ] && ifdown $netif
|
||||
# Network rootfs mount successful - save interface info for ifcfg etc.
|
||||
save_netinfo $netif
|
||||
fi
|
||||
exit 0
|
||||
|
@@ -15,10 +15,7 @@
|
||||
|
||||
# Check if bond parameter is valid
|
||||
if getarg bond= >/dev/null ; then
|
||||
if [ -z "$netroot" ] ; then
|
||||
die "No netboot configured, bond is invalid"
|
||||
fi
|
||||
command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
|
||||
:
|
||||
fi
|
||||
|
||||
# We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup
|
||||
@@ -35,8 +32,8 @@ parsebond() {
|
||||
case $# in
|
||||
0) bondname=bond0; bondslaves="eth0 eth1" ;;
|
||||
1) bondname=$1; bondslaves="eth0 eth1" ;;
|
||||
2) bondname=$1; bondslaves=$(echo $2|tr "," " ") ;;
|
||||
3) bondname=$1; bondslaves=$(echo $2|tr "," " "); bondoptions=$(echo $3|tr "," " ") ;;
|
||||
2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
|
||||
3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
|
||||
*) die "bond= requires zero to four parameters" ;;
|
||||
esac
|
||||
}
|
||||
@@ -56,7 +53,7 @@ if getarg bond >/dev/null; then
|
||||
bondslaves="eth0 eth1"
|
||||
fi
|
||||
# Make it suitable for initscripts export
|
||||
bondoptions=$(echo $bondoptions|tr ";" ",")
|
||||
bondoptions=$(str_replace "$bondoptions" ";" ",")
|
||||
echo "bondname=$bondname" > /tmp/bond.info
|
||||
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info
|
||||
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info
|
||||
|
@@ -3,8 +3,9 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
#
|
||||
# Format:
|
||||
# bridge=<bridgename>:<ethname>
|
||||
# bridge=<bridgename>:<ethnames>
|
||||
#
|
||||
# <ethnames> is a comma-separated list of physical (ethernet) interfaces
|
||||
# bridge without parameters assumes bridge=br0:eth0
|
||||
#
|
||||
|
||||
@@ -13,9 +14,6 @@
|
||||
|
||||
# Check if bridge parameter is valid
|
||||
if getarg bridge= >/dev/null ; then
|
||||
if [ -z "$netroot" ] ; then
|
||||
die "No netboot configured, bridge is invalid"
|
||||
fi
|
||||
command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
|
||||
fi
|
||||
|
||||
@@ -27,16 +25,16 @@ parsebridge() {
|
||||
v=${v#*:}
|
||||
done
|
||||
|
||||
unset bridgename ethname
|
||||
unset bridgename ethnames
|
||||
case $# in
|
||||
0) bridgename=br0; ethname=$iface ;;
|
||||
0) bridgename=br0; ethnames=$iface ;;
|
||||
1) die "bridge= requires two parameters" ;;
|
||||
2) bridgename=$1; ethname=$2 ;;
|
||||
2) bridgename=$1; ethnames=$(str_replace "$2" "," " ") ;;
|
||||
*) die "bridge= requires two parameters" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
unset bridgename ethname
|
||||
unset bridgename ethnames
|
||||
|
||||
iface=eth0
|
||||
if [ -e /tmp/bond.info ]; then
|
||||
@@ -46,7 +44,7 @@ if [ -e /tmp/bond.info ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Parse bridge for bridgename and ethname
|
||||
# Parse bridge for bridgename and ethnames
|
||||
if bridge="$(getarg bridge)"; then
|
||||
# Read bridge= parameters if they exist
|
||||
if [ -n "$bridge" ]; then
|
||||
@@ -55,9 +53,9 @@ if bridge="$(getarg bridge)"; then
|
||||
# Simple default bridge
|
||||
if [ -z "$bridgename" ]; then
|
||||
bridgename=br0
|
||||
ethname=$iface
|
||||
ethnames=$iface
|
||||
fi
|
||||
echo "bridgename=$bridgename" > /tmp/bridge.info
|
||||
echo "ethname=$ethname" >> /tmp/bridge.info
|
||||
echo "ethnames=\"$ethnames\"" >> /tmp/bridge.info
|
||||
return
|
||||
fi
|
||||
|
@@ -18,21 +18,7 @@ if ! getarg ifname= >/dev/null ; then
|
||||
return
|
||||
fi
|
||||
|
||||
parse_ifname_opts() {
|
||||
local IFS=:
|
||||
set $1
|
||||
|
||||
case $# in
|
||||
7)
|
||||
ifname_if=$1
|
||||
# udev requires MAC addresses to be lower case
|
||||
ifname_mac=`echo $2:$3:$4:$5:$6:$7 | tr '[:upper:]' '[:lower:]'`
|
||||
;;
|
||||
*)
|
||||
die "Invalid arguments for ifname="
|
||||
;;
|
||||
esac
|
||||
}
|
||||
command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
|
||||
|
||||
# Check ifname= lines
|
||||
for p in $(getargs ifname=); do
|
||||
|
@@ -17,14 +17,6 @@
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v ibft_to_cmdline >/dev/null || . /lib/net-lib.sh
|
||||
|
||||
# Check if ip= lines should be used
|
||||
if getarg ip= >/dev/null ; then
|
||||
if [ -z "$netroot" ] ; then
|
||||
echo "Warning: No netboot configured, ignoring ip= lines"
|
||||
return;
|
||||
fi
|
||||
fi
|
||||
|
||||
# Don't mix BOOTIF=macaddr from pxelinux and ip= lines
|
||||
getarg ip= >/dev/null && getarg BOOTIF= >/dev/null && \
|
||||
die "Mixing BOOTIF and ip= lines is dangerous"
|
||||
|
42
modules.d/40network/parse-vlan.sh
Normal file
42
modules.d/40network/parse-vlan.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Format:
|
||||
# vlan=<vlanname>:<phydevice>
|
||||
#
|
||||
|
||||
# return if vlan already parsed
|
||||
[ -n "$vlanname" ] && return
|
||||
|
||||
# Check if vlan parameter is valid
|
||||
if getarg vlan= >/dev/null ; then
|
||||
:
|
||||
fi
|
||||
|
||||
parsevlan() {
|
||||
local v=${1}:
|
||||
set --
|
||||
while [ -n "$v" ]; do
|
||||
set -- "$@" "${v%%:*}"
|
||||
v=${v#*:}
|
||||
done
|
||||
|
||||
unset vlanname phydevice
|
||||
case $# in
|
||||
2) vlanname=$1; phydevice=$2 ;;
|
||||
*) die "vlan= requires two parameters" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
unset vlanname phydevice
|
||||
|
||||
if getarg vlan >/dev/null; then
|
||||
# Read vlan= parameters if they exist
|
||||
vlan="$(getarg vlan=)"
|
||||
if [ ! "$vlan" = "vlan" ]; then
|
||||
parsevlan "$(getarg vlan=)"
|
||||
fi
|
||||
|
||||
echo "vlanname=\"$vlanname\"" > /tmp/vlan.info
|
||||
echo "phydevice=\"$phydevice\"" >> /tmp/vlan.info
|
||||
return
|
||||
fi
|
@@ -20,6 +20,70 @@ fi
|
||||
mkdir -m 0755 -p /tmp/ifcfg/
|
||||
mkdir -m 0755 -p /tmp/ifcfg-leases/
|
||||
|
||||
get_config_line_by_subchannel()
|
||||
{
|
||||
local CHANNEL
|
||||
local line
|
||||
|
||||
CHANNELS="$1"
|
||||
while read line; do
|
||||
if strstr "$line" "$CHANNELS"; then
|
||||
echo $line
|
||||
return 0
|
||||
fi
|
||||
done < /etc/ccw.conf
|
||||
return 1
|
||||
}
|
||||
|
||||
print_s390() {
|
||||
local _netif
|
||||
local SUBCHANNELS
|
||||
local OPTIONS
|
||||
local NETTYPE
|
||||
local CONFIG_LINE
|
||||
local i
|
||||
local channel
|
||||
local OLD_IFS
|
||||
|
||||
_netif="$1"
|
||||
# if we find ccw channel, then use those, instead of
|
||||
# of the MAC
|
||||
SUBCHANNELS=$({
|
||||
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
|
||||
[ -e $i ] || continue
|
||||
channel=$(readlink -f $i)
|
||||
echo -n "${channel##*/},"
|
||||
done
|
||||
})
|
||||
[ -n "$SUBCHANNELS" ] || return 1
|
||||
|
||||
SUBCHANNELS=${SUBCHANNELS%,}
|
||||
echo "SUBCHANNELS=\"${SUBCHANNELS}\""
|
||||
CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
|
||||
|
||||
[ $? -ne 0 -o -z "$CONFIG_LINE" ] && return
|
||||
|
||||
OLD_IFS=$IFS
|
||||
IFS=","
|
||||
set -- $CONFIG_LINE
|
||||
IFS=$OLD_IFS
|
||||
NETTYPE=$1
|
||||
shift
|
||||
SUBCHANNELS="$1"
|
||||
OPTIONS=""
|
||||
shift
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
*=*) OPTIONS="$OPTIONS $1";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
OPTIONS=${OPTIONS## }
|
||||
echo "NETTYPE=\"${NETTYPE}\""
|
||||
echo "OPTIONS=\"${OPTIONS}\""
|
||||
}
|
||||
|
||||
|
||||
for netif in $IFACES ; do
|
||||
# bridge?
|
||||
unset bridge
|
||||
@@ -38,7 +102,6 @@ for netif in $IFACES ; do
|
||||
echo "ONBOOT=yes"
|
||||
echo "NETBOOT=yes"
|
||||
echo "UUID=$uuid"
|
||||
[ -n "$macaddr" ] && echo "MACADDR=$macaddr"
|
||||
[ -n "$mtu" ] && echo "MTU=$mtu"
|
||||
if [ -f /tmp/net.$netif.lease ]; then
|
||||
strstr "$ip" '*:*:*' &&
|
||||
@@ -46,12 +109,25 @@ for netif in $IFACES ; do
|
||||
echo "BOOTPROTO=dhcp"
|
||||
cp /tmp/net.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
|
||||
else
|
||||
echo "BOOTPROTO=none"
|
||||
# If we've booted with static ip= lines, the override file is there
|
||||
# If we've booted with static ip= lines, the override file is there
|
||||
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
|
||||
echo "IPADDR=$ip"
|
||||
echo "NETMASK=$mask"
|
||||
[ -n "$gw" ] && echo "GATEWAY=$gw"
|
||||
if strstr "$ip" '*:*:*'; then
|
||||
echo "IPV6_AUTOCONF=no"
|
||||
echo "IPV6ADDR=$ip/$mask"
|
||||
else
|
||||
echo "BOOTPROTO=none"
|
||||
echo "IPADDR=$ip"
|
||||
if strstr "$mask" "."; then
|
||||
echo "NETMASK=$mask"
|
||||
else
|
||||
echo "PREFIX=$mask"
|
||||
fi
|
||||
fi
|
||||
if strstr "$gw" '*:*:*'; then
|
||||
echo "IPV6_DEFAULTGW=$gw"
|
||||
elif [ -n "$gw" ]; then
|
||||
echo "GATEWAY=$gw"
|
||||
fi
|
||||
fi
|
||||
} > /tmp/ifcfg/ifcfg-$netif
|
||||
|
||||
@@ -59,7 +135,12 @@ for netif in $IFACES ; do
|
||||
if [ -z "$bridge" ] && [ -z "$bond" ]; then
|
||||
# standard interface
|
||||
{
|
||||
echo "HWADDR=$(cat /sys/class/net/$netif/address)"
|
||||
if [ -n "$macaddr" ]; then
|
||||
echo "MACADDR=$macaddr"
|
||||
else
|
||||
echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
|
||||
fi
|
||||
print_s390 $netif
|
||||
echo "TYPE=Ethernet"
|
||||
echo "NAME=\"Boot Disk\""
|
||||
[ -n "$mtu" ] && echo "MTU=$mtu"
|
||||
@@ -138,6 +219,11 @@ for netif in $IFACES ; do
|
||||
} >> /tmp/ifcfg/ifcfg-$ethname
|
||||
fi
|
||||
fi
|
||||
i=1
|
||||
for ns in $(getargs nameserver); do
|
||||
echo "DNS${i}=${ns}" >> /tmp/ifcfg/ifcfg-$netif
|
||||
i=$((i+1))
|
||||
done
|
||||
done
|
||||
|
||||
# Pass network opts
|
||||
@@ -147,7 +233,7 @@ echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
|
||||
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
|
||||
{
|
||||
cp /tmp/net.* /run/initramfs/
|
||||
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/
|
||||
cp -a -t /run/initramfs/state/etc/sysconfig/network-scripts/ /tmp/ifcfg/*
|
||||
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
|
||||
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
|
||||
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
|
||||
} > /dev/null 2>&1
|
||||
|
@@ -12,7 +12,7 @@ depends() {
|
||||
}
|
||||
|
||||
install() {
|
||||
inst "$moddir/url-lib.sh" "/lib/url-lib.sh"
|
||||
inst_simple "$moddir/url-lib.sh" "/lib/url-lib.sh"
|
||||
dracut_install curl
|
||||
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
|
||||
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
|
||||
|
@@ -43,6 +43,7 @@ add_url_handler() {
|
||||
local schemes="$@" scheme=""
|
||||
set --
|
||||
for scheme in $schemes; do
|
||||
[ "$(get_url_handler $scheme)" = "$handler" ] && continue
|
||||
set -- "$@" "$scheme:$handler"
|
||||
done
|
||||
set -- $@ $url_handler_map # add new items to *front* of list
|
||||
@@ -53,7 +54,8 @@ add_url_handler() {
|
||||
|
||||
export CURL_HOME="/run/initramfs/url-lib"
|
||||
mkdir -p $CURL_HOME
|
||||
curl_args="--location --retry 3 --fail --show-error --progress-bar"
|
||||
curl_args="--location --retry 3 --fail --show-error"
|
||||
|
||||
curl_fetch_url() {
|
||||
local url="$1" outloc="$2"
|
||||
echo "$url" > /proc/self/fd/0
|
||||
|
@@ -2,11 +2,7 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if getargbool 1 rd.splash -n rd_NO_SPLASH; then
|
||||
[ -c /dev/null ] || mknod /dev/null c 1 3
|
||||
[ -c /dev/console ] || mknod /dev/console c 5 1
|
||||
[ -c /dev/tty0 ] || mknod /dev/tty0 c 4 0
|
||||
|
||||
if getargbool 1 rd.splash -d -n rd_NO_SPLASH; then
|
||||
info "Starting Gentoo Splash"
|
||||
|
||||
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
|
||||
|
@@ -14,29 +14,57 @@ depends() {
|
||||
installkernel() {
|
||||
local _modname
|
||||
# Include KMS capable drm drivers
|
||||
for _modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" \( -name '*.ko' -o -name '*.ko.gz' -o -name '*.ko.xz' \) 2>/dev/null); do
|
||||
case $_modname in
|
||||
*.ko) grep -q drm_crtc_init $_modname ;;
|
||||
*.ko.gz) zgrep -q drm_crtc_init $_modname ;;
|
||||
*.ko.xz) xzgrep -q drm_crtc_init $_modname ;;
|
||||
esac
|
||||
if test $? -eq 0; then
|
||||
# if the hardware is present, include module even if it is not currently loaded,
|
||||
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
|
||||
# loading of the driver if needed
|
||||
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
|
||||
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
|
||||
hostonly='' instmods $_modname
|
||||
continue
|
||||
fi
|
||||
instmods $_modname
|
||||
|
||||
drm_module_filter() {
|
||||
local _drm_drivers='drm_crtc_init'
|
||||
local _ret
|
||||
# subfunctions inherit following FDs
|
||||
local _merge=8 _side2=9
|
||||
function nmf1() {
|
||||
local _fname _fcont
|
||||
while read _fname; do
|
||||
case "$_fname" in
|
||||
*.ko) _fcont="$(< $_fname)" ;;
|
||||
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
|
||||
*.ko.xz) _fcont="$(xz -dc $_fname)" ;;
|
||||
esac
|
||||
[[ $_fcont =~ $_drm_drivers
|
||||
&& ! $_fcont =~ iw_handler_get_spy ]] \
|
||||
&& echo "$_fname"
|
||||
done
|
||||
}
|
||||
function rotor() {
|
||||
local _f1 _f2
|
||||
while read _f1; do
|
||||
echo "$_f1"
|
||||
if read _f2; then
|
||||
echo "$_f2" 1>&${_side2}
|
||||
fi
|
||||
done | nmf1 1>&${_merge}
|
||||
}
|
||||
# Use two parallel streams to filter alternating modules.
|
||||
set +x
|
||||
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
|
||||
[[ $debug ]] && set -x
|
||||
return 0
|
||||
}
|
||||
|
||||
for _modname in $(find_kernel_modules_by_path drivers/gpu/drm \
|
||||
| drm_module_filter) ; do
|
||||
# if the hardware is present, include module even if it is not currently loaded,
|
||||
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
|
||||
# loading of the driver if needed
|
||||
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
|
||||
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
|
||||
hostonly='' instmods $_modname
|
||||
continue
|
||||
fi
|
||||
instmods $_modname
|
||||
done
|
||||
}
|
||||
|
||||
install() {
|
||||
if grep -q nash /usr/libexec/plymouth/plymouth-populate-initrd \
|
||||
|| ! grep -q PLYMOUTH_POPULATE_SOURCE_FUNCTIONS /usr/libexec/plymouth/plymouth-populate-initrd \
|
||||
|| [ ! -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
|
||||
. "$moddir"/plymouth-populate-initrd.sh
|
||||
else
|
||||
@@ -47,6 +75,6 @@ install() {
|
||||
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
|
||||
inst_hook pre-trigger 10 "$moddir"/plymouth-pretrigger.sh
|
||||
inst_hook emergency 50 "$moddir"/plymouth-emergency.sh
|
||||
inst readlink
|
||||
dracut_install readlink
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,6 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if [ -x /bin/plymouth ]; then
|
||||
if [ -x /bin/plymouth -a -z "$DRACUT_SYSTEMD" ]; then
|
||||
/bin/plymouth --newroot=$NEWROOT
|
||||
fi
|
||||
|
@@ -11,9 +11,10 @@ dracut_install /bin/plymouth \
|
||||
|
||||
mkdir -m 0755 -p "${initdir}/usr/share/plymouth"
|
||||
|
||||
inst_libdir_file "plymouth/text.so" "plymouth/details.so"
|
||||
|
||||
if [[ $hostonly ]]; then
|
||||
dracut_install "${usrlibdir}/plymouth/text.so" \
|
||||
"${usrlibdir}/plymouth/details.so" \
|
||||
dracut_install \
|
||||
"/usr/share/plymouth/themes/details/details.plymouth" \
|
||||
"/usr/share/plymouth/themes/text/text.plymouth" \
|
||||
|
||||
@@ -28,7 +29,7 @@ if [[ $hostonly ]]; then
|
||||
inst /usr/share/plymouth/themes/default.plymouth
|
||||
# Install plugin for this theme
|
||||
PLYMOUTH_PLUGIN=$(grep "^ModuleName=" /usr/share/plymouth/themes/default.plymouth | while read a b c; do echo $b; done;)
|
||||
inst "${usrlibdir}/plymouth/${PLYMOUTH_PLUGIN}.so"
|
||||
inst_libdir_file "plymouth/${PLYMOUTH_PLUGIN}.so"
|
||||
fi
|
||||
else
|
||||
for x in /usr/share/plymouth/themes/{text,details}/* ; do
|
||||
@@ -37,11 +38,6 @@ else
|
||||
mkdir -m 0755 -p "${initdir}/$THEME_DIR"
|
||||
dracut_install "$x"
|
||||
done
|
||||
for x in "${usrlibdir}"/plymouth/{text,details}.so ; do
|
||||
[[ -f "$x" ]] || continue
|
||||
[[ "$x" != "${x%%/label.so}" ]] && continue
|
||||
dracut_install "$x"
|
||||
done
|
||||
(
|
||||
cd ${initdir}/usr/share/plymouth/themes;
|
||||
ln -s text/text.plymouth default.plymouth 2>&1;
|
||||
|
@@ -2,27 +2,23 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
|
||||
[ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
|
||||
# first trigger graphics subsystem
|
||||
udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
|
||||
# first trigger graphics and tty subsystem
|
||||
udevadm trigger --action=add --subsystem-match=graphics --subsystem-match=drm --subsystem-match=tty >/dev/null 2>&1
|
||||
if [ -x /bin/plymouthd -a -z "$DRACUT_SYSTEMD" ]; then
|
||||
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -d -n rd_NO_PLYMOUTH; then
|
||||
# first trigger graphics subsystem
|
||||
udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
|
||||
# first trigger graphics and tty subsystem
|
||||
udevadm trigger --action=add --subsystem-match=graphics --subsystem-match=drm --subsystem-match=tty >/dev/null 2>&1
|
||||
|
||||
udevadm settle --timeout=30 2>&1 | vinfo
|
||||
[ -c /dev/zero ] || mknod -m 0666 /dev/zero c 1 5
|
||||
[ -c /dev/tty0 ] || mknod -m 0620 /dev/tty0 c 4 0
|
||||
[ -e /dev/systty ] || ln -s tty0 /dev/systty
|
||||
[ -c /dev/fb0 ] || mknod -m 0660 /dev/fb0 c 29 0
|
||||
[ -e /dev/fb ] || ln -s fb0 /dev/fb
|
||||
udevadm settle --timeout=30 2>&1 | vinfo
|
||||
|
||||
info "Starting plymouth daemon"
|
||||
mkdir -m 0755 /run/plymouth
|
||||
consoledev=$(getarg console= | sed -e 's/,.*//')
|
||||
consoledev=${consoledev:-tty0}
|
||||
[ -x /lib/udev/console_init ] && /lib/udev/console_init "/dev/$consoledev"
|
||||
[ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid
|
||||
/bin/plymouth --show-splash 2>&1 | vinfo
|
||||
# reset tty after plymouth messed with it
|
||||
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
|
||||
info "Starting plymouth daemon"
|
||||
mkdir -m 0755 /run/plymouth
|
||||
read consoledev rest < /sys/class/tty/console/active
|
||||
consoledev=${consoledev:-tty0}
|
||||
[ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
|
||||
[ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid
|
||||
/bin/plymouth --show-splash 2>&1 | vinfo
|
||||
# reset tty after plymouth messed with it
|
||||
[ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
|
||||
fi
|
||||
fi
|
||||
|
@@ -89,7 +89,7 @@ EOF
|
||||
for option in LAYER2 PORTNO; do
|
||||
[ -z "${!option}" ] && continue
|
||||
[ -n "$optstr" ] && optstr=${optstr}" "
|
||||
optstr=${optstr}$(echo ${option} | tr [[:upper:]] [[:lower:]])"="${!option}
|
||||
optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option}
|
||||
done
|
||||
# write single quotes since network.py removes double quotes but we need quotes
|
||||
echo "OPTIONS='$optstr'" >> $IFCFGFILE
|
||||
|
@@ -5,7 +5,7 @@
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
function sysecho () {
|
||||
file=$1
|
||||
file="$1"
|
||||
shift
|
||||
local i=1
|
||||
while [ $i -le 10 ] ; do
|
||||
@@ -16,7 +16,11 @@ function sysecho () {
|
||||
break
|
||||
fi
|
||||
done
|
||||
[ -f "$file" ] && echo $* > $file
|
||||
local status
|
||||
read status < "$file"
|
||||
if [[ ! $status == $* ]]; then
|
||||
[ -f "$file" ] && echo $* > "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
function dasd_settle() {
|
||||
@@ -162,6 +166,8 @@ processcmsfile()
|
||||
fi
|
||||
|
||||
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$env{INTERFACE} /sbin/cmsifup $env{INTERFACE}"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules
|
||||
# remove the default net rules
|
||||
rm -f /etc/udev/rules.d/61-default-net.rules
|
||||
[[ -f /etc/udev/rules.d/60-net.rules ]] \
|
||||
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules
|
||||
|
||||
@@ -169,8 +175,8 @@ processcmsfile()
|
||||
fi
|
||||
|
||||
if [[ $DASD ]]; then
|
||||
echo $DASD >> /etc/dasd.conf
|
||||
echo "options dasd_mod dasd=$DASD" >> /etc/modprobe.d/dasd_mod.conf
|
||||
echo $DASD | normalize_dasd_arg > /etc/dasd.conf
|
||||
echo "options dasd_mod dasd=$DASD" > /etc/modprobe.d/dasd_mod.conf
|
||||
dasd_cio_free
|
||||
fi
|
||||
|
||||
|
@@ -22,19 +22,11 @@ installkernel() {
|
||||
install() {
|
||||
inst_hook pre-trigger 30 "$moddir/cmssetup.sh"
|
||||
inst_hook pre-pivot 95 "$moddir/cms-write-ifcfg.sh"
|
||||
inst "$moddir/cmsifup.sh" /sbin/cmsifup
|
||||
inst /etc/cmsfs-fuse/filetypes.conf
|
||||
inst /etc/udev/rules.d/99-fuse.rules
|
||||
inst /etc/fuse.conf
|
||||
inst_script "$moddir/cmsifup.sh" /sbin/cmsifup
|
||||
dracut_install /etc/cmsfs-fuse/filetypes.conf /etc/udev/rules.d/99-fuse.rules /etc/fuse.conf \
|
||||
cmsfs-fuse fusermount ulockmgr_server bash insmod rmmod cat normalize_dasd_arg sed \
|
||||
$(rpm -ql s390utils-base)
|
||||
|
||||
for file in $(rpm -ql s390utils-base); do
|
||||
[[ -f $file ]] && inst $file
|
||||
done
|
||||
|
||||
for file in {"$usrlibdir","$libdir"}/gconv/*; do
|
||||
[[ -f $file ]] && inst $file
|
||||
done
|
||||
#inst /usr/lib/locale/locale-archive
|
||||
|
||||
dracut_install cmsfs-fuse fusermount ulockmgr_server bash tr insmod rmmod cat
|
||||
inst_libdir_file "gconv/*"
|
||||
#inst /usr/lib/locale/locale-archive
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
|
@@ -8,9 +8,6 @@ check() {
|
||||
# no point in trying to support it in the initramfs.
|
||||
type -P btrfs >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
[[ $debug ]] && set -x
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
local _found
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
@@ -34,8 +31,9 @@ installkernel() {
|
||||
|
||||
install() {
|
||||
inst_rules "$moddir/80-btrfs.rules"
|
||||
inst "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
|
||||
inst "$moddir/btrfs_timeout.sh" /sbin/btrfs_timeout
|
||||
dracut_install btrfs btrfsck
|
||||
inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
|
||||
inst_script "$moddir/btrfs_timeout.sh" /sbin/btrfs_timeout
|
||||
dracut_install btrfsck
|
||||
inst $(command -v btrfs) /sbin/btrfs
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
# close everything which is not busy
|
||||
rm -f /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1
|
||||
|
||||
if ! getarg rd.luks.uuid rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -n rd_NO_LUKS >/dev/null 2>&1; then
|
||||
if ! getarg rd.luks.uuid -d rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS >/dev/null 2>&1; then
|
||||
while true; do
|
||||
local do_break="y"
|
||||
for i in /dev/mapper/luks-*; do
|
||||
|
@@ -165,8 +165,15 @@ readkey() {
|
||||
local keydev="$2"
|
||||
local device="$3"
|
||||
|
||||
local mntp=$(mkuniqdir /mnt keydev)
|
||||
mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!'
|
||||
# This creates a unique single mountpoint for *, or several for explicitly
|
||||
# given LUKS devices. It accomplishes unlocking multiple LUKS devices with
|
||||
# a single password entry.
|
||||
local mntp="/mnt/$(str_replace "keydev-$keydev-$keypath" '/' '-')"
|
||||
|
||||
if [ ! -d "$mntp" ]; then
|
||||
mkdir "$mntp"
|
||||
mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!'
|
||||
fi
|
||||
|
||||
case "${keypath##*.}" in
|
||||
gpg)
|
||||
@@ -177,9 +184,22 @@ readkey() {
|
||||
die "No GPG support to decrypt '$keypath' on '$keydev'."
|
||||
fi
|
||||
;;
|
||||
img)
|
||||
if [ -f /lib/dracut-crypt-loop-lib.sh ]; then
|
||||
. /lib/dracut-crypt-loop-lib.sh
|
||||
loop_decrypt "$mntp" "$keypath" "$keydev" "$device"
|
||||
initqueue --onetime --finished --unique --name "crypt-loop-cleanup-99-${mntp##*/}" \
|
||||
$(command -v umount) "$mntp; " $(command -v rmdir) "$mntp"
|
||||
return 0
|
||||
else
|
||||
die "No loop file support to decrypt '$keypath' on '$keydev'."
|
||||
fi
|
||||
;;
|
||||
*) cat "$mntp/$keypath" ;;
|
||||
esac
|
||||
|
||||
# General unmounting mechanism, modules doing custom cleanup should return earlier
|
||||
# and install a pre-pivot cleanup hook
|
||||
umount "$mntp"
|
||||
rmdir "$mntp"
|
||||
}
|
||||
|
18
modules.d/90crypt/crypt-run-generator.sh
Executable file
18
modules.d/90crypt/crypt-run-generator.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
|
||||
dev=$1
|
||||
luks=$2
|
||||
|
||||
if [ -f /etc/crypttab ]; then
|
||||
while read l rest; do
|
||||
strstr "${l##luks-}" "${luks##luks-}" && exit 0
|
||||
done < /etc/crypttab
|
||||
fi
|
||||
|
||||
echo "$luks $dev" >> /etc/crypttab
|
||||
/lib/systemd/system-generators/systemd-cryptsetup-generator
|
||||
systemctl daemon-reload
|
||||
systemctl start cryptsetup.target
|
||||
exit 0
|
@@ -32,9 +32,12 @@ else
|
||||
device="$1"
|
||||
fi
|
||||
|
||||
# number of tries
|
||||
numtries=${3:-10}
|
||||
|
||||
# TODO: improve to support what cmdline does
|
||||
if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -n rd_NO_CRYPTTAB; then
|
||||
while read name dev luksfile rest; do
|
||||
if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -d -n rd_NO_CRYPTTAB; then
|
||||
while read name dev luksfile luksoptions; do
|
||||
# ignore blank lines and comments
|
||||
if [ -z "$name" -o "${name#\#}" != "$name" ]; then
|
||||
continue
|
||||
@@ -57,17 +60,59 @@ if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -n rd_NO_CRYPTTAB; then
|
||||
fi
|
||||
fi
|
||||
done < /etc/crypttab
|
||||
unset name dev rest
|
||||
unset name dev
|
||||
fi
|
||||
|
||||
#
|
||||
# Open LUKS device
|
||||
#
|
||||
|
||||
info "luksOpen $device $luksname $luksfile"
|
||||
info "luksOpen $device $luksname $luksfile $luksoptions"
|
||||
|
||||
OLD_IFS="$IFS"
|
||||
IFS=,
|
||||
set -- $luksoptions
|
||||
IFS="$OLD_IFS"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
noauto)
|
||||
# skip this
|
||||
exit 0
|
||||
;;
|
||||
swap)
|
||||
# skip this
|
||||
exit 0
|
||||
;;
|
||||
tmp)
|
||||
# skip this
|
||||
exit 0
|
||||
;;
|
||||
allow-discards)
|
||||
allowdiscards="--allow-discards"
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# parse for allow-discards
|
||||
if strstr "$(cryptsetup --help)" "allow-discards"; then
|
||||
if discarduuids=$(getargs "rd.luks.allow-discards"); then
|
||||
if strstr " $discarduuids " " ${luksdev##luks-}"; then
|
||||
allowdiscards="--allow-discards"
|
||||
fi
|
||||
elif getargbool rd.luks.allow-discards; then
|
||||
allowdiscards="--allow-discards"
|
||||
fi
|
||||
fi
|
||||
|
||||
if strstr "$(cryptsetup --help)" "allow-discards"; then
|
||||
cryptsetupopts="$cryptsetupopts $allowdiscards"
|
||||
fi
|
||||
|
||||
unset allowdiscards
|
||||
|
||||
if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then
|
||||
if cryptsetup --key-file "$luksfile" luksOpen "$device" "$luksname"; then
|
||||
if cryptsetup --key-file "$luksfile" $cryptsetupopts luksOpen "$device" "$luksname"; then
|
||||
ask_passphrase=0
|
||||
fi
|
||||
else
|
||||
@@ -76,26 +121,22 @@ else
|
||||
keydev="${tmp%%:*}"
|
||||
keypath="${tmp#*:}"
|
||||
else
|
||||
if [ $# -eq 3 ]; then
|
||||
if [ $3 -eq 0 ]; then
|
||||
info "No key found for $device. Fallback to passphrase mode."
|
||||
break
|
||||
fi
|
||||
info "No key found for $device. Will try $3 time(s) more later."
|
||||
set -- "$1" "$2" "$(($3 - 1))"
|
||||
else
|
||||
info "No key found for $device. Will try later."
|
||||
if [ $numtries -eq 0 ]; then
|
||||
warn "No key found for $device. Fallback to passphrase mode."
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
info "No key found for $device. Will try $numtries time(s) more later."
|
||||
initqueue --unique --onetime --settled \
|
||||
--name cryptroot-ask-$luksname \
|
||||
$(command -v cryptroot-ask) "$@"
|
||||
$(command -v cryptroot-ask) "$device" "$luksname" "$(($numtries-1))"
|
||||
exit 0
|
||||
fi
|
||||
unset tmp
|
||||
|
||||
info "Using '$keypath' on '$keydev'"
|
||||
readkey "$keypath" "$keydev" "$device" \
|
||||
| cryptsetup -d - luksOpen "$device" "$luksname"
|
||||
| cryptsetup -d - $cryptsetupopts luksOpen "$device" "$luksname"
|
||||
unset keypath keydev
|
||||
ask_passphrase=0
|
||||
break
|
||||
@@ -103,7 +144,7 @@ else
|
||||
fi
|
||||
|
||||
if [ $ask_passphrase -ne 0 ]; then
|
||||
luks_open="$(command -v cryptsetup) luksOpen"
|
||||
luks_open="$(command -v cryptsetup) $cryptsetupopts luksOpen"
|
||||
ask_for_password --ply-tries 5 \
|
||||
--ply-cmd "$luks_open -T1 $device $luksname" \
|
||||
--ply-prompt "Password ($device)" \
|
||||
|
@@ -7,8 +7,6 @@ check() {
|
||||
# if cryptsetup is not installed, then we cannot support encrypted devices.
|
||||
type -P cryptsetup >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
|
||||
check_crypt() {
|
||||
local dev=$1 fs=$2
|
||||
[[ $fs = "crypto_LUKS" ]] || return 1
|
||||
@@ -44,12 +42,22 @@ installkernel() {
|
||||
|
||||
install() {
|
||||
dracut_install cryptsetup rmdir readlink umount
|
||||
inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
|
||||
inst "$moddir"/probe-keydev.sh /sbin/probe-keydev
|
||||
inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
|
||||
inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
|
||||
inst_hook cmdline 10 "$moddir/parse-keydev.sh"
|
||||
inst_hook cmdline 30 "$moddir/parse-crypt.sh"
|
||||
inst_hook pre-pivot 30 "$moddir/crypt-cleanup.sh"
|
||||
inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
|
||||
inst_simple /etc/crypttab
|
||||
inst "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
|
||||
}
|
||||
inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
|
||||
|
||||
dracut_install -o \
|
||||
$systemdutildir/system-generators/systemd-cryptsetup-generator \
|
||||
$systemdutildir/system-generators/systemd-cryptsetup-generator \
|
||||
$systemdutildir/systemd-cryptsetup \
|
||||
$systemdsystemunitdir/systemd-ask-password-console.path \
|
||||
$systemdsystemunitdir/systemd-ask-password-console.service \
|
||||
$systemdsystemunitdir/cryptsetup.target \
|
||||
$systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
|
||||
systemd-ask-password systemd-tty-ask-password-agent
|
||||
inst_script "$moddir"/crypt-run-generator.sh /sbin/crypt-run-generator
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
if ! getargbool 1 rd.luks -n rd_NO_LUKS; then
|
||||
|
||||
if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then
|
||||
info "rd.luks=0: removing cryptoluks activation"
|
||||
rm -f /etc/udev/rules.d/70-luks.rules
|
||||
else
|
||||
@@ -10,19 +11,31 @@ else
|
||||
echo 'ACTION!="add|change", GOTO="luks_end"'
|
||||
} > /etc/udev/rules.d/70-luks.rules.new
|
||||
|
||||
LUKS=$(getargs rd.luks.uuid rd_LUKS_UUID)
|
||||
LUKS=$(getargs rd.luks.uuid -d rd_LUKS_UUID)
|
||||
tout=$(getarg rd.luks.key.tout)
|
||||
|
||||
if [ -n "$LUKS" ]; then
|
||||
for luksid in $LUKS; do
|
||||
|
||||
luksid=${luksid##luks-}
|
||||
{
|
||||
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
|
||||
printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
|
||||
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
|
||||
printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask)
|
||||
printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $tout
|
||||
} >> /etc/udev/rules.d/70-luks.rules.new
|
||||
|
||||
if [ -z "$DRACUT_SYSTEMD" ]; then
|
||||
{
|
||||
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
|
||||
printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
|
||||
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
|
||||
printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask)
|
||||
printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $tout
|
||||
} >> /etc/udev/rules.d/70-luks.rules.new
|
||||
else
|
||||
{
|
||||
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
|
||||
printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
|
||||
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
|
||||
printf -- '--name crypt-run-generator-%%k %s ' $(command -v crypt-run-generator)
|
||||
printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n'
|
||||
} >> /etc/udev/rules.d/70-luks.rules.new
|
||||
fi
|
||||
|
||||
uuid=$luksid
|
||||
while [ "$uuid" != "${uuid#*-}" ]; do uuid=${uuid%%-*}${uuid#*-}; done
|
||||
@@ -35,11 +48,19 @@ else
|
||||
} >> $hookdir/emergency/90-crypt.sh
|
||||
done
|
||||
else
|
||||
{
|
||||
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue)
|
||||
printf -- '--unique --onetime --name cryptroot-ask-%%k '
|
||||
printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $(command -v cryptroot-ask) $tout
|
||||
} >> /etc/udev/rules.d/70-luks.rules.new
|
||||
if [ -z "$DRACUT_SYSTEMD" ]; then
|
||||
{
|
||||
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue)
|
||||
printf -- '--unique --onetime --name cryptroot-ask-%%k '
|
||||
printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $(command -v cryptroot-ask) $tout
|
||||
} >> /etc/udev/rules.d/70-luks.rules.new
|
||||
else
|
||||
{
|
||||
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue)
|
||||
printf -- '--unique --onetime --name crypt-run-generator-%%k '
|
||||
printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' $(command -v crypt-run-generator)
|
||||
} >> /etc/udev/rules.d/70-luks.rules.new
|
||||
fi
|
||||
fi
|
||||
|
||||
echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules.new
|
||||
|
@@ -13,4 +13,9 @@ _do_dm_shutdown() {
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
_do_dm_shutdown $1
|
||||
|
||||
if command -v dmsetup >/dev/null; then
|
||||
_do_dm_shutdown $1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
@@ -3,6 +3,7 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
type -P dmsetup >/dev/null || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
@@ -18,13 +19,10 @@ install() {
|
||||
modinfo -k $kernel dm_mod >/dev/null 2>&1 && \
|
||||
inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh"
|
||||
|
||||
inst dmsetup
|
||||
dracut_install dmsetup
|
||||
dracut_install -o dmeventd
|
||||
|
||||
type -P dmeventd >/dev/null && dracut_install dmeventd
|
||||
|
||||
for _i in {"$libdir","$usrlibdir"}/libdevmapper-event.so*; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
inst_libdir_file "libdevmapper-event.so*"
|
||||
|
||||
inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
|
||||
# Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules
|
||||
|
@@ -4,6 +4,8 @@
|
||||
|
||||
SUBSYSTEM!="block", GOTO="dm_end"
|
||||
ACTION!="add|change", GOTO="dm_end"
|
||||
# Also don't process disks that are slated to be a multipath device
|
||||
ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="dm_end"
|
||||
|
||||
ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
DM_RAIDS=$(getargs rd.dm.uuid rd_DM_UUID=)
|
||||
DM_RAIDS=$(getargs rd.dm.uuid -d rd_DM_UUID=)
|
||||
|
||||
DM_CLEANUP="no"
|
||||
|
||||
|
@@ -8,9 +8,6 @@ check() {
|
||||
# in trying to support it in the initramfs.
|
||||
type -P dmraid >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
[[ $debug ]] && set -x
|
||||
|
||||
check_dmraid() {
|
||||
local dev=$1 fs=$2 holder DEVPATH DM_NAME
|
||||
[[ "$fs" = "${fs%%_raid_member}" ]] && return 1
|
||||
@@ -54,17 +51,15 @@ depends() {
|
||||
|
||||
install() {
|
||||
local _i
|
||||
dracut_install dmraid partx kpartx
|
||||
dracut_install dmraid
|
||||
dracut_install -o kpartx
|
||||
inst $(command -v partx) /sbin/partx
|
||||
|
||||
inst "$moddir/dmraid.sh" /sbin/dmraid_scan
|
||||
|
||||
if [ ! -x /lib/udev/vol_id ]; then
|
||||
inst_rules 64-md-raid.rules
|
||||
fi
|
||||
inst_rules 64-md-raid.rules
|
||||
|
||||
for _i in {"$libdir","$usrlibdir"}/libdmraid-events*.so*; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
inst_libdir_file "libdmraid-events*.so*"
|
||||
|
||||
inst_rules "$moddir/61-dmraid-imsm.rules"
|
||||
#inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup
|
||||
|
@@ -2,17 +2,17 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
# nodmraid for anaconda / rc.sysinit compatibility
|
||||
if ! getargbool 1 rd.dm -n rd_NO_DM || getarg nodmraid; then
|
||||
if ! getargbool 1 rd.dm -d -n rd_NO_DM || getarg "rd.dm=0" -d nodmraid; then
|
||||
info "rd.dm=0: removing DM RAID activation"
|
||||
udevproperty rd_NO_DM=1
|
||||
fi
|
||||
|
||||
if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd; then
|
||||
if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.imsm -d -n rd_NO_MDIMSM -n noiswmd; then
|
||||
info "rd.md.imsm=0: no MD RAID for imsm/isw raids"
|
||||
udevproperty rd_NO_MDIMSM=1
|
||||
fi
|
||||
|
||||
if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF || getarg noddfmd; then
|
||||
if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF -n noddfmd; then
|
||||
info "rd.md.ddf=0: no MD RAID for SNIA ddf raids"
|
||||
udevproperty rd_NO_MDDDF=1
|
||||
fi
|
||||
|
@@ -3,11 +3,10 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
if getargbool 0 rd.live.debug -y rdlivedebug; then
|
||||
if getargbool 0 rd.live.debug -n -y rdlivedebug; then
|
||||
exec > /tmp/liveroot.$$.out
|
||||
exec 2>> /tmp/liveroot.$$.out
|
||||
set -x
|
||||
@@ -18,22 +17,22 @@ livedev="$1"
|
||||
|
||||
# parse various live image specific options that make sense to be
|
||||
# specified as their own things
|
||||
live_dir=$(getarg rd.live.dir live_dir)
|
||||
live_dir=$(getarg rd.live.dir -d live_dir)
|
||||
[ -z "$live_dir" ] && live_dir="LiveOS"
|
||||
getargbool 0 rd.live.ram -y live_ram && live_ram="yes"
|
||||
getargbool 0 rd.live.overlay.reset -y reset_overlay && reset_overlay="yes"
|
||||
getargbool 0 rd.live.overlay.readonly -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
|
||||
overlay=$(getarg rd.live.overlay overlay)
|
||||
getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
|
||||
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
|
||||
getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
|
||||
overlay=$(getarg rd.live.overlay -d overlay)
|
||||
|
||||
# CD/DVD media check
|
||||
[ -b $livedev ] && fs=$(blkid -s TYPE -o value $livedev)
|
||||
if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
|
||||
check="yes"
|
||||
fi
|
||||
getarg rd.live.check check || check=""
|
||||
getarg rd.live.check -d check || check=""
|
||||
if [ -n "$check" ]; then
|
||||
[ -x /bin/plymouth ] && /bin/plymouth --hide-splash
|
||||
checkisomd5 --verbose $livedev || :
|
||||
checkisomd5 --verbose $livedev
|
||||
if [ $? -ne 0 ]; then
|
||||
die "CD check failed!"
|
||||
exit 1
|
||||
@@ -168,7 +167,6 @@ if [ -e "$SQUASHED" ] ; then
|
||||
dd if=$SQUASHED of=/squashed.img bs=512 2> /dev/null
|
||||
umount -n /run/initramfs/live
|
||||
echo "Done copying live image to RAM."
|
||||
eject -p $livedev || :
|
||||
SQUASHED="/squashed.img"
|
||||
fi
|
||||
|
||||
@@ -204,7 +202,7 @@ if [ -b "$BASE_LOOPDEV" ]; then
|
||||
ln -s $BASE_LOOPDEV /run/initramfs/live-baseloop
|
||||
fi
|
||||
ln -s /dev/mapper/live-rw /dev/root
|
||||
printf '/bin/mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
|
||||
printf 'mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
|
||||
|
||||
need_shutdown
|
||||
|
||||
|
@@ -20,22 +20,13 @@ installkernel() {
|
||||
}
|
||||
|
||||
install() {
|
||||
dracut_install umount
|
||||
inst dmsetup
|
||||
inst blkid
|
||||
inst dd
|
||||
inst losetup
|
||||
inst grep
|
||||
|
||||
dracut_install -o eject
|
||||
|
||||
inst blockdev
|
||||
type -P checkisomd5 >/dev/null && inst checkisomd5
|
||||
dracut_install umount dmsetup blkid dd losetup grep blockdev
|
||||
dracut_install -o checkisomd5
|
||||
inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh"
|
||||
inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh"
|
||||
inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh"
|
||||
inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
|
||||
inst "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
|
||||
inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
|
||||
# should probably just be generally included
|
||||
inst_rules 60-cdrom_id.rules
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
[ -z "$root" ] && root=$(getarg root=)
|
||||
|
||||
# support legacy syntax of passing liveimg and then just the base root
|
||||
if getargbool 0 rd.live.image -y liveimg; then
|
||||
if getargbool 0 rd.live.image -d -y liveimg; then
|
||||
liveroot="live:$root"
|
||||
fi
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
|
||||
for modlist in $(getargs rd.driver.post rdinsmodpost=); do
|
||||
for modlist in $(getargs rd.driver.post -d rdinsmodpost=); do
|
||||
(
|
||||
IFS=,
|
||||
for m in $modlist; do
|
||||
|
@@ -16,6 +16,7 @@ installkernel() {
|
||||
*.ko.xz) [[ $(xz -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
|
||||
esac
|
||||
done
|
||||
return 0
|
||||
}
|
||||
function rotor() {
|
||||
local _f1 _f2
|
||||
@@ -25,18 +26,24 @@ installkernel() {
|
||||
echo "$_f2" 1>&${_side2}
|
||||
fi
|
||||
done | bmf1 1>&${_merge}
|
||||
return 0
|
||||
}
|
||||
# Use two parallel streams to filter alternating modules.
|
||||
set +x
|
||||
eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
|
||||
[[ $debug ]] && set -x
|
||||
return 0
|
||||
}
|
||||
|
||||
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc ata_piix
|
||||
hostonly='' instmods pcmcia firewire-ohci
|
||||
hostonly='' instmods usb_storage sdhci sdhci-pci
|
||||
|
||||
# arm specific modules
|
||||
hostonly='' instmods sdhci_esdhc_imx mmci sdhci_tegra mvsdio omap omapdrm sdhci_dove ahci_platform pata_imx sata_mv
|
||||
|
||||
# install keyboard support
|
||||
hostonly='' instmods atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech hid-logitech-dj hid-microsoft ehci-hcd ohci-hcd uhci-hcd
|
||||
hostonly='' instmods atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech hid-logitech-dj hid-microsoft ehci-hcd ohci-hcd uhci-hcd xhci-hcd hid_generic
|
||||
# install unix socket support
|
||||
hostonly='' instmods unix
|
||||
instmods "=drivers/pcmcia" =ide "=drivers/usb/storage"
|
||||
@@ -54,35 +61,12 @@ installkernel() {
|
||||
}
|
||||
for_each_host_dev_fs inst_fs
|
||||
fi
|
||||
else
|
||||
hostonly='' instmods $drivers
|
||||
fi
|
||||
|
||||
[[ $add_drivers ]] && hostonly='' instmods $add_drivers
|
||||
[[ $filesystems ]] && hostonly='' instmods $filesystems
|
||||
|
||||
# force install of scsi_wait_scan
|
||||
hostonly='' instmods scsi_wait_scan
|
||||
|
||||
for _f in modules.builtin.bin modules.builtin; do
|
||||
[[ $srcmods/$_f ]] && break
|
||||
done || {
|
||||
dfatal "No modules.builtin.bin and modules.builtin found!"
|
||||
return 1
|
||||
}
|
||||
|
||||
for _f in modules.builtin.bin modules.builtin modules.order; do
|
||||
[[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
install() {
|
||||
local _f i
|
||||
[ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf
|
||||
for i in $(find -L /etc/modprobe.d/ -maxdepth 1 -type f -name '*.conf'); do
|
||||
inst_simple "$i"
|
||||
done
|
||||
dracut_install -o /{etc,lib}/modprobe.d/*.conf
|
||||
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
|
||||
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
for i in $(getargs rd.driver.pre rdloaddriver=); do
|
||||
for i in $(getargs rd.driver.pre -d rdloaddriver=); do
|
||||
(
|
||||
IFS=,
|
||||
for p in $i; do
|
||||
@@ -11,7 +11,7 @@ for i in $(getargs rd.driver.pre rdloaddriver=); do
|
||||
)
|
||||
done
|
||||
|
||||
for i in $(getargs rd.driver.blacklist rdblacklist=); do
|
||||
for i in $(getargs rd.driver.blacklist -d rdblacklist=); do
|
||||
(
|
||||
IFS=,
|
||||
for p in $i; do
|
||||
@@ -20,7 +20,7 @@ for i in $(getargs rd.driver.blacklist rdblacklist=); do
|
||||
)
|
||||
done
|
||||
|
||||
for p in $(getargs rd.driver.post rdinsmodpost=); do
|
||||
for p in $(getargs rd.driver.post -d rdinsmodpost=); do
|
||||
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
|
||||
_do_insmodpost=1
|
||||
done
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# fetch-liveupdate - fetch an update image for dmsquash-live media.
|
||||
# this gets called by the "initqueue/online" hook for each network interface
|
||||
# that comes online.
|
||||
@@ -27,6 +27,5 @@ if [ $? != 0 ]; then
|
||||
warn "url: $url"
|
||||
return 1
|
||||
fi
|
||||
rm -rf /updates
|
||||
mv -f /updates.tmp.$$ /updates
|
||||
copytree /updates.tmp.$$ /updates
|
||||
mv /tmp/liveupdates.info /tmp/liveupdates.done
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# livenetroot - fetch a live image from the network and run it
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
@@ -6,13 +6,13 @@ check() {
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo network url-lib dmsquash-live
|
||||
echo network url-lib dmsquash-live img-lib
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_hook cmdline 29 "$moddir/parse-livenet.sh"
|
||||
inst_hook initqueue/online 95 "$moddir/fetch-liveupdate.sh"
|
||||
inst "$moddir/livenetroot.sh" "/sbin/livenetroot"
|
||||
inst_script "$moddir/livenetroot.sh" "/sbin/livenetroot"
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@ updates=$(getarg live.updates=)
|
||||
if [ -n "$updates" ]; then
|
||||
# make sure network comes up even if we're doing a local live device
|
||||
if [ -z "$netroot" ]; then
|
||||
echo "rd.neednet=1" > /etc/cmdline.d/90livenet.conf
|
||||
echo > /tmp/net.ifaces
|
||||
unset CMDLINE
|
||||
fi
|
||||
echo "$updates" > /tmp/liveupdates.info
|
||||
|
@@ -6,6 +6,8 @@
|
||||
|
||||
SUBSYSTEM!="block", GOTO="lvm_end"
|
||||
ACTION!="add|change", GOTO="lvm_end"
|
||||
# Also don't process disks that are slated to be a multipath device
|
||||
ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="lvm_end"
|
||||
KERNEL=="dm-[0-9]*", ACTION=="add", GOTO="lvm_end"
|
||||
ENV{ID_FS_TYPE}!="LVM?_member", GOTO="lvm_end"
|
||||
|
||||
|
@@ -7,10 +7,10 @@
|
||||
extraargs="$@"
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
VGS=$(getargs rd.lvm.vg rd_LVM_VG=)
|
||||
LVS=$(getargs rd.lvm.lv rd_LVM_LV=)
|
||||
SNAPSHOT=$(getargs rd.lvm.snapshot rd_LVM_SNAPSHOT=)
|
||||
SNAPSIZE=$(getargs rd.lvm.snapsize rd_LVM_SNAPSIZE=)
|
||||
VGS=$(getargs rd.lvm.vg -d rd_LVM_VG=)
|
||||
LVS=$(getargs rd.lvm.lv -d rd_LVM_LV=)
|
||||
SNAPSHOT=$(getargs rd.lvm.snapshot -d rd_LVM_SNAPSHOT=)
|
||||
SNAPSIZE=$(getargs rd.lvm.snapsize -d rd_LVM_SNAPSIZE=)
|
||||
|
||||
[ -d /etc/lvm ] || mkdir -m 0755 -p /etc/lvm
|
||||
# build a list of devices to scan
|
||||
@@ -35,10 +35,12 @@ if [ ! -e /etc/lvm/lvm.conf ]; then
|
||||
if [ -n $SNAPSHOT ]; then
|
||||
echo 'global {';
|
||||
echo ' locking_type = 1';
|
||||
echo ' use_lvmetad = 0';
|
||||
echo '}';
|
||||
else
|
||||
echo 'global {';
|
||||
echo ' locking_type = 4';
|
||||
echo ' use_lvmetad = 0';
|
||||
echo '}';
|
||||
fi
|
||||
} > /etc/lvm/lvm.conf
|
||||
@@ -127,4 +129,6 @@ if [ "$lvmwritten" ]; then
|
||||
fi
|
||||
unset lvmwritten
|
||||
|
||||
udevadm settle
|
||||
|
||||
need_shutdown
|
||||
|
@@ -7,9 +7,6 @@ check() {
|
||||
# No point trying to support lvm if the binaries are missing
|
||||
type -P lvm >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
[[ $debug ]] && set -x
|
||||
|
||||
check_lvm() {
|
||||
local DM_VG_NAME DM_LV_NAME DM_UDEV_DISABLE_DISK_RULES_FLAG
|
||||
eval $(udevadm info --query=property --name=$1|egrep '(DM_VG_NAME|DM_LV_NAME|DM_UDEV_DISABLE_DISK_RULES_FLAG)=')
|
||||
@@ -49,6 +46,7 @@ install() {
|
||||
# FIXME: near-term hack to establish read-only locking;
|
||||
# use command-line lvm.conf editor once it is available
|
||||
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' ${initdir}/etc/lvm/lvm.conf
|
||||
sed -i -e 's/\(^[[:space:]]*\)use_lvmetad[[:space:]]*=[[:space:]]*[[:digit:]]/\1use_lvmetad = 0/' ${initdir}/etc/lvm/lvm.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -57,11 +55,9 @@ install() {
|
||||
# files, but provides the one below:
|
||||
inst_rules 64-device-mapper.rules
|
||||
|
||||
inst "$moddir/lvm_scan.sh" /sbin/lvm_scan
|
||||
inst_script "$moddir/lvm_scan.sh" /sbin/lvm_scan
|
||||
inst_hook cmdline 30 "$moddir/parse-lvm.sh"
|
||||
|
||||
for _i in {"$libdir","$usrlibdir"}/libdevmapper-event-lvm*.so; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
inst_libdir_file "libdevmapper-event-lvm*.so"
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,15 @@
|
||||
#!/bin/sh
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
if [ -e /etc/lvm/lvm.conf ] && ! getargbool 1 rd.lvm.conf -n rd_NO_LVMCONF; then
|
||||
if [ -e /etc/lvm/lvm.conf ] && ! getargbool 1 rd.lvm.conf -d -n rd_NO_LVMCONF; then
|
||||
rm -f /etc/lvm/lvm.conf
|
||||
fi
|
||||
|
||||
if ! getargbool 1 rd.lvm -n rd_NO_LVM; then
|
||||
if ! getargbool 1 rd.lvm -d -n rd_NO_LVM; then
|
||||
info "rd.lvm=0: removing LVM activation"
|
||||
rm -f /etc/udev/rules.d/64-lvm*.rules
|
||||
else
|
||||
for dev in $(getargs rd.lvm.vg rd_LVM_VG=) $(getargs rd.lvm.lv rd_LVM_LV=); do
|
||||
for dev in $(getargs rd.lvm.vg -d rd_LVM_VG=) $(getargs rd.lvm.lv -d rd_LVM_LV=); do
|
||||
wait_for_dev "/dev/$dev"
|
||||
done
|
||||
fi
|
||||
|
@@ -6,6 +6,8 @@ ACTION!="add|change", GOTO="md_end"
|
||||
SUBSYSTEM!="block", GOTO="md_end"
|
||||
ENV{rd_NO_MD}=="?*", GOTO="md_end"
|
||||
KERNEL=="md*", GOTO="md_end"
|
||||
# Also don't process disks that are slated to be a multipath device
|
||||
ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="md_end"
|
||||
|
||||
ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_try"
|
||||
GOTO="md_end"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user