308 Commits
1.4.0 ... 2.9.1

Author SHA1 Message Date
Enis
ce7fcae4a4 Some changes to README.md 2024-10-23 22:28:09 +03:00
dcd167b9bb pmt: f*** 2024-10-03 22:51:49 +03:00
2501f2abd1 pmt: edit readme (fix links) 2024-10-03 22:21:43 +03:00
bd03af35c5 pmt: e2fsprogs: cleanup makefile 2024-10-03 22:17:42 +03:00
b85b3178c3 pmt: disable debugging 2024-10-03 22:13:21 +03:00
dfa55a7ea0 pmt: migrate compiler version information completely to NDK base 2024-10-03 22:05:03 +03:00
f88e9b013e pmt: fix all build issues etc (ndk) 2024-10-03 22:00:12 +03:00
ee7b44b484 pmt: Android.mk: remove 'devname.c' on libext2fs 2024-10-02 23:16:42 +03:00
bc48cda2ec pmt: e2fsprogs: edit blkid header 2024-10-02 23:11:46 +03:00
2472e74dd9 pmt: e2fsprogs: add missing headers 2024-10-02 23:07:31 +03:00
5c97d68677 pmt: e2fsprogs: cleanup 2024-10-02 23:01:00 +03:00
e7c51ced1b pmt: e2fsprogs: cleanup 2024-10-02 22:59:34 +03:00
5cbd362d72 pmt: Android.mk: fix cflags 2024-10-02 22:54:02 +03:00
b55f82cdd3 pmt: Android.mk: try fix missing includes 2024-10-02 22:48:08 +03:00
8d7d43507a pmt: Application.mk: enable APP_ALLOW_MISSING_DEPS 2024-10-02 22:29:46 +03:00
6c774197d8 pmt: Android.mk: fix typo 2024-10-02 22:21:57 +03:00
577ac48908 pmt: workflow: f*** (3) 2024-10-02 22:14:16 +03:00
cb532d8389 pmt: workflow: f*** (2) 2024-10-02 22:07:54 +03:00
87f294e019 pmt: workflow: f*** 2024-10-02 22:04:52 +03:00
1b4080d744 pmt: installer script: add missing values 2024-10-02 22:02:11 +03:00
858a605753 pmt: workflow: add missing environment value 2024-10-02 21:56:20 +03:00
fb50e0fe8e pmt: add missing bash script 2024-10-02 21:52:36 +03:00
8a152d623f pmt: README: correct incorrect build configs [placeholder: initial] 2024-10-02 21:47:31 +03:00
84961924f7 pmt: README: correct incorrect content 2024-10-02 21:46:11 +03:00
7259d451c4 pmt: initial 2.9.1 update 2024-10-02 21:37:57 +03:00
82bd2939cd nevermind 2024-09-11 19:24:40 +03:00
82fa4bffbb pmt: use static libc++_shared 2024-09-11 19:14:55 +03:00
cf7a095dac pmt: deb maker: fix typo 2024-09-11 18:39:58 +03:00
29d11d5259 pmt: script: switch wrong name 2024-09-11 18:31:10 +03:00
742b946935 pmt: script: some fixes 2024-09-11 18:30:47 +03:00
e145dea230 pmt: script, deb: some fixes 2024-09-11 18:30:03 +03:00
fcf61f3348 pmt: termux script: some minor additions 2024-09-11 18:13:48 +03:00
5701862621 pmt: releases: fix body on releases 2024-09-11 17:50:35 +03:00
7daf21df00 pmt: workflow: fix making deb package 2024-09-11 17:41:26 +03:00
affbdbcf20 pmt: workflow: fix typo 2024-09-11 17:34:20 +03:00
87ab05b4c6 pmt: update changelog 2024-09-11 17:24:03 +03:00
cf98bb9c9e pmt: try fix workflow, The script was explained 2024-09-11 17:20:41 +03:00
7bd057156f pmt: workflow try fix build issues with NDK 2024-09-11 16:52:00 +03:00
e39769460f pmt: f*** 2024-09-11 07:46:43 +03:00
3d246fe653 pmt: use LOCAL_STL for linking libc++_shared 2024-09-11 07:16:49 +03:00
c5f0498eef pmt: f*** C++ 2024-09-11 07:06:08 +03:00
0b15005dbd pmt: Link libc++_shared to binary 2024-09-11 06:59:26 +03:00
9ed45938e6 pmt: disable debugging 2024-09-11 06:52:54 +03:00
a4491447cb pmt: Android.mk: switch std to C++ 14 2024-09-11 06:52:21 +03:00
7abc4318cf pmt: fixup generator bash script 2024-09-11 06:46:01 +03:00
e1801d5789 pmt: workflow: try fix build issues 2024-09-11 06:33:59 +03:00
f6c9ac66f5 pmt: cleanup dummy files 2024-09-11 06:25:36 +03:00
542330f63b pmt: fix NDK issues [placeholder: initial] 2024-09-11 06:25:03 +03:00
001887fd8b pmt: f*** NDK 2024-09-10 06:48:45 +03:00
39ac8b2797 pmt: fixup main.mk 2024-09-10 06:39:51 +03:00
34b4c1beb2 pmt: fixup workflow [place-holder: initial] 2024-09-10 06:31:57 +03:00
595f3b00b3 pmt: initial 2.8.0 update 2024-09-10 06:17:41 +03:00
ec5a2b97b9 pmt: header: add license text per generated header for automatic clang version detection 2024-08-03 12:28:33 +03:00
95c100453f pmt: fix wrong source paths (said) 2024-08-02 18:25:06 +03:00
157e99a08e pmt: utils: run commands silently 2024-08-02 18:05:47 +03:00
b1f9e491b3 pmt: fix wrong include 2024-08-02 18:04:41 +03:00
9313a8ec4a pmt: fix problem in makefile build system 2024-08-02 17:54:52 +03:00
512d35737b pmt: transfer documents to 2.7.0 branch 2024-08-02 17:53:27 +03:00
9bcde145a5 pmt: 2.7.0 changelog update 2024-08-02 17:52:24 +03:00
5d51e44a2c pmt: initial 2.7.0 update 2024-08-02 17:44:31 +03:00
ed745369fa pmt: Fixes the deficiencies in the update in the compilation system 2024-08-02 09:02:39 +03:00
851f0aaeb2 pmt: enable NDK build type in builds for deb packages (version targeted) 2024-07-31 13:38:36 +03:00
00990ea242 pmt: update mandoc 2024-07-29 21:41:29 +03:00
356e8683a5 pmt: fixup builder workflow problem 2024-07-29 21:25:26 +03:00
9c72226498 pmt: README: fix wrong links 2024-07-29 21:17:42 +03:00
2f87fd57c0 pmt: header: add missing include (fcntl) 2024-07-29 21:16:15 +03:00
5b00b0bfe3 pmt: initial 2.6.0 update 2024-07-28 23:01:21 +03:00
36efab6eb3 forget it 2024-07-22 23:25:14 +03:00
74ca2de92e pmt: cleanup release notes 2024-07-22 22:22:51 +03:00
3640331184 pmt: add more information about compilation 2024-07-22 16:29:06 +03:00
0fc709f34f pmt: Add documentation about adding languages 2024-07-22 11:59:44 +03:00
36c49131be pmt: Update disclaimer 2024-07-22 11:51:35 +03:00
14788d1aaf pmt: ad badge 2024-07-22 11:38:09 +03:00
9c61fcfaae pmt: delete accidentally loaded build specific files 2024-07-22 11:35:04 +03:00
b834134221 pmt: Use timestamp instead of architecture in xz package name and use sudo when creating deb package 2024-07-22 08:52:42 +03:00
7eb6289726 pmt: fix wrong help message in source 2024-07-22 08:27:21 +03:00
3b612d1df4 pmt: fix wrong help message 2024-07-22 08:26:38 +03:00
fb6b7dca06 pmt: update man page [automake: initial] 2024-07-22 08:23:20 +03:00
41cb1801c0 pmt: Make builder workflow only manually executable 2024-07-21 22:30:44 +03:00
d2e4b58ab6 pmt: Create separate workflow for automatic commit review 2024-07-21 22:27:43 +03:00
b4b9f1d1df pmt: change title 2024-07-21 22:15:37 +03:00
8c8d9edbd4 pmt: fix wrong erase path 2024-07-21 22:03:59 +03:00
2dcf2c124f pmt: Add text about deb installation to Termux automatically in posts 2024-07-21 22:01:14 +03:00
04d7121eb6 pmt: Create guide for installing deb in Termux 2024-07-21 21:59:40 +03:00
ad8756a05c pmt: Use code font in clang version information in release descriptions 2024-07-21 21:47:20 +03:00
26cc9740b7 pmt: switch check-out version 4 2024-07-21 21:39:13 +03:00
0519bc3a66 pmt: workflow: change token name 2024-07-21 21:07:48 +03:00
484fa8dcca pmt: add missing explantions 2024-07-21 20:23:49 +03:00
91713b86be pmt: initial 2.5.0 update 2024-07-21 20:20:17 +03:00
4f8e15935a pmt: copy commit
pmt: fix wrong translations
2024-07-14 08:19:53 +03:00
19b8d74498 pmt: fix wrong translations 2024-07-14 08:18:19 +03:00
da15903881 pmt: solve serious working problem 2024-07-13 21:55:51 +03:00
57403a0196 pmt: generate build config for workflows (soon) 2024-07-11 17:46:18 +03:00
d591c760e1 pmt: Create comments and text appropriate for the ShawkTeam repository 2024-07-11 16:07:07 +03:00
ec6148b0d9 f*** C 2024-07-10 14:35:30 +03:00
f7bbe2ba15 pmt: languages: en: fix typos 2024-07-10 14:33:48 +03:00
c9453ef968 Merge pull request #1 from r0manas-dev/patch-1
pmt: fix bad English translations
2024-07-10 01:47:07 +03:00
7943fa312c pmt: fix broken syntax 2024-07-10 01:45:30 +03:00
3fb873199b Update ADD-LANGUAGES.md 2024-07-10 01:40:14 +03:00
chakra
c6163bc752 Update languages.c 2024-07-09 15:26:38 -07:00
chakra
30f1a84f13 Update languages.c 2024-07-09 15:22:11 -07:00
4607f565af Update README.md 2024-07-09 21:27:56 +03:00
2edc502bbf pmt: ADD-LANGUAGES 2024-07-09 21:26:40 +03:00
fd15d460f6 pmt.c: cleanup unnecessary code and fix wrong log text
pmt: cleanup

pmt: cleanup
2024-07-09 20:38:17 +03:00
fe752d7505 pmt: First statement about supported languages 2024-07-09 19:38:45 +03:00
464027fd1c Create CHANGELOG.md 2024-07-09 19:33:29 +03:00
99b45da4a7 pmt: README: add new comments as needed 2024-07-09 19:30:52 +03:00
284bb42faa pmt: README: fix wrong text 2024-07-09 19:28:41 +03:00
964d9b5426 pmt: initial 2.4.0 update 2024-07-09 19:26:18 +03:00
4dd49c2509 pmt: fix some 2.3.0 missing: makefile 2024-07-04 14:58:08 +03:00
934d1b0112 pmt: fix some 2.3.0 missings 2024-07-04 14:57:06 +03:00
32ac3a3dd6 pmt: initial 2.3.0 update
Delete jni/Makefile
2024-06-28 00:44:34 +03:00
fc02df6583 pmt: Fix FORTIFY problems 2024-06-17 11:41:55 +03:00
deb42c9ff5 Update README.md 2024-06-17 10:57:12 +03:00
60904a4b2f Update install-termux.sh 2024-06-17 00:37:35 +03:00
ad6115f51b Update install-termux.sh 2024-06-17 00:30:59 +03:00
6cc59d92f8 Update install-termux.sh 2024-06-17 00:28:42 +03:00
fe69408eb5 Update install-termux.sh 2024-06-17 00:26:37 +03:00
cd386ac6f9 Update install-termux.sh 2024-06-17 00:22:37 +03:00
268aa8ac77 Update install-termux.sh 2024-06-17 00:21:57 +03:00
c5746fe14b Update install-termux.sh 2024-06-17 00:17:11 +03:00
d2cb68df5e Update install-termux.sh 2024-06-17 00:13:30 +03:00
3976e0fb39 Update install-termux.sh 2024-06-17 00:08:01 +03:00
0a9e164b9c Update install-termux.sh 2024-06-17 00:07:00 +03:00
ecada5f076 Update install-termux.sh 2024-06-17 00:06:28 +03:00
ca09bb94e1 Update install-termux.sh 2024-06-17 00:03:18 +03:00
52ffe99d4b Update install-termux.sh 2024-06-17 00:00:54 +03:00
416939634a pmt: fix syntax 2024-06-17 00:00:24 +03:00
cbbd36899e Update README.md 2024-06-16 23:58:10 +03:00
9dc79ae923 Update install-termux.sh 2024-06-16 23:57:15 +03:00
b522dcc62b Update install-termux.sh 2024-06-16 23:56:35 +03:00
7aeea39e41 Update README.md 2024-06-16 23:56:01 +03:00
974774eb3e pmt: add quick installer 2024-06-16 23:51:02 +03:00
70ce307e50 readme: create a general file alignment table 2024-06-16 08:44:01 +03:00
99ecb9daf3 Make some corrections. 2024-06-10 06:28:01 +03:00
d0a7b2d16f Update CHANGELOG.md 2024-06-04 18:07:35 +03:00
96336bcd0b Update README.md 2024-06-04 17:59:20 +03:00
545376afb2 Initial 2.1.0 update 2024-06-04 17:55:15 +03:00
62b24d5705 Update docs.c 2024-05-26 17:08:18 +03:00
0fca319b29 Update README.md 2024-05-26 17:07:56 +03:00
929150e034 pmt: delete unnecessary files 2024-05-26 11:31:46 +03:00
93843a511d fix typo 2024-05-26 11:30:57 +03:00
0981e70268 pmt: edit changelog 2024-05-26 11:30:03 +03:00
b214da3cd6 pmt: fix missing explanation 2024-05-26 11:24:41 +03:00
464bfe6e56 pmt: Update build guide 2024-05-26 11:23:54 +03:00
f5531fde32 pmt: initial 2.0.0 update 2024-05-26 10:49:33 +03:00
f771fb7c68 Update env.mk 2024-05-14 00:07:19 +03:00
4bc5235952 Update vars.mk 2024-05-14 00:04:29 +03:00
d4b4c91ff4 pmt; use target arch macro 2024-05-14 00:00:15 +03:00
6fc38eb01d Update vars.mk 2024-05-13 23:58:04 +03:00
42e5d132e7 Update vars.mk 2024-05-13 23:52:55 +03:00
39d1411b11 pmt; include stdint lib 2024-05-13 23:47:16 +03:00
04d6471c86 Update tools.c 2024-05-13 23:46:54 +03:00
f7d2f313de Update pmt.c 2024-05-13 23:46:37 +03:00
49a87b0387 pmt; include stdint lib 2024-05-13 23:46:15 +03:00
5a104e5b22 pmt; include stdint lib 2024-05-13 23:45:56 +03:00
055213f2f6 pmt; include stdint lib 2024-05-13 23:45:37 +03:00
7f270e319c pmt; include stdint lib 2024-05-13 23:45:17 +03:00
6a035f8f41 Update pmt.h 2024-05-13 23:43:35 +03:00
1b2dda655a Update vars.mk 2024-05-13 23:43:11 +03:00
07d63944c1 Update pmt.h 2024-05-13 23:36:54 +03:00
36b7bcf246 Update pmt.h 2024-05-13 23:35:30 +03:00
cd3f65a145 Update pmt.h 2024-05-13 23:34:56 +03:00
9dd29f96b8 Update pmt.h 2024-05-13 23:31:41 +03:00
7254637caf Update pmt.h 2024-05-13 23:30:54 +03:00
2af00a8028 Update pmt.h 2024-05-13 23:26:39 +03:00
b5790af803 pmt: change macro name 2024-05-13 23:23:02 +03:00
8fe1548796 Update vars.mk 2024-05-13 23:20:12 +03:00
04d8ccdd81 Update vars.mk 2024-05-13 23:14:59 +03:00
1a790d1d89 Update vars.mk 2024-05-13 23:13:43 +03:00
1296e488f1 Update vars.mk 2024-05-13 23:09:35 +03:00
3fea6c73cc Update vars.mk 2024-05-13 23:06:56 +03:00
cf4b590130 Update vars.mk 2024-05-13 23:05:28 +03:00
352ef6e68a Update vars.mk 2024-05-13 23:04:36 +03:00
754ebaade2 Update vars.mk 2024-05-13 23:03:37 +03:00
8a28a8f1ef Update ndk.sh 2024-05-13 23:01:43 +03:00
086a2dd93d Update vars.mk 2024-05-13 23:00:17 +03:00
383a1efe55 Create ndk.sh 2024-05-13 22:59:21 +03:00
b96977a5fc Update vars.mk 2024-05-13 22:58:17 +03:00
976c10593c Update vars.mk 2024-05-13 22:53:23 +03:00
d45dd67cbe Update vars.mk 2024-05-13 22:46:55 +03:00
0fa5a546aa Update vars.mk 2024-05-13 22:44:59 +03:00
0c487c62fe pmt: fix syntax 2024-05-13 22:43:15 +03:00
105d92e0ca Update vars.mk 2024-05-13 22:40:15 +03:00
850d104a1a Update README.md 2024-05-13 22:28:51 +03:00
6d24fb9eae pmt: adapt NDK 2024-05-13 22:28:10 +03:00
ae8c73c4f5 pmt: adapt NDK 2024-05-13 22:26:46 +03:00
890d93131c pmt: include env first 2024-05-13 22:24:57 +03:00
a33d4e3f16 Update README.md 2024-05-13 22:12:29 +03:00
f344d62d4c Update README.md 2024-05-13 22:10:44 +03:00
40c5b155dc Update README.md 2024-05-13 22:08:51 +03:00
0547e18639 Update README.md 2024-05-13 22:05:57 +03:00
f34a47889e Update README.md 2024-05-13 22:00:47 +03:00
a9fac9e661 pmt: just report compiling with android NDK 2024-05-13 21:57:15 +03:00
e8040de436 pmt: header: make compatible with android NDK 2024-05-13 21:53:54 +03:00
ff6e82c556 pmt: versioner: add 32-bit or 64-bit build information to version information 2024-05-13 21:51:20 +03:00
0c7da875b2 pmt: listpart: include string library 2024-05-13 21:43:21 +03:00
41565d221f pmt: update version 2024-05-08 06:58:40 +03:00
5ba78d860e pmt: update version 2024-05-07 20:58:37 +03:00
181125dfca pmt: initial 1.9.0 update 2024-05-05 21:06:14 +03:00
4464c203fd pmt: initial 1.9.0 update 2024-05-05 21:05:21 +03:00
b9e58df98f pmt: initial 1.9.0 update 2024-05-05 21:04:48 +03:00
e2f8cf4ca3 pmt: initial 1.9.0 update 2024-05-05 21:03:51 +03:00
07e2249ef1 pmt: initial 1.9.0 update 2024-05-05 21:03:01 +03:00
fd970be822 pmt: initial 1.9.0 update 2024-05-05 21:02:26 +03:00
45c964997c Delete src/format.c 2024-05-05 21:02:15 +03:00
31b7f16a29 pmt: initial 1.9.0 update 2024-05-05 21:02:04 +03:00
5f83a4476f pmt: initial 1.9.0 update 2024-05-05 21:01:43 +03:00
5438f5210f pmt: initial 1.9.0 update 2024-05-05 21:00:53 +03:00
cb7904cd5a pmt: initial 1.9.0 update 2024-05-05 20:57:20 +03:00
9c570d5b02 pmt: initial 1.9.0 update 2024-05-05 20:56:34 +03:00
c9736863fe pmt: initial 1.9.0 update 2024-05-05 20:55:59 +03:00
d5ce065e8b pmt: initial 1.9.0 update 2024-05-05 20:55:19 +03:00
a4bc9e3834 pmt: initial 1.9.0 update 2024-05-05 20:54:15 +03:00
ce017e2cbc pmt: move source in to src 2024-04-25 22:35:32 +03:00
b5daf8a44c pmt: move source in to src 2024-04-25 22:35:01 +03:00
f125ae760c pmt: move source in to src 2024-04-25 22:34:31 +03:00
f68f92ade1 pmt: move source in to src 2024-04-25 22:34:04 +03:00
3a723446cc pmt: move source in to src 2024-04-25 22:33:40 +03:00
1d66a3c21f pmt: move source in to src 2024-04-25 22:32:34 +03:00
13e31df7c6 pmt: move source in to src 2024-04-25 22:31:52 +03:00
4922ed5a35 pmt: move source in to src 2024-04-25 22:31:12 +03:00
3220aace91 pmt: move source in to src 2024-04-25 22:30:40 +03:00
7f85d63088 pmt: initial 1.8.0 update 2024-04-25 22:09:03 +03:00
412b697b9c pmt: initial 1.8.0 update 2024-04-25 22:08:30 +03:00
afc958aeb4 pmt: initial 1.8.0 update 2024-04-25 22:07:45 +03:00
fbd45e0936 pmt: initial 1.8.0 update 2024-04-25 22:07:05 +03:00
0ef8767eb5 pmt: initial 1.8.0 update 2024-04-25 22:06:31 +03:00
9bc871573e pmt: initial 1.8.0 update 2024-04-25 22:05:58 +03:00
adad63bbbd pmt: initial 1.8.0 update 2024-04-25 22:05:12 +03:00
0157c886ae pmt: initial 1.8.0 update 2024-04-25 22:04:33 +03:00
076774d9f4 pmt: initial 1.8.0 update 2024-04-25 22:04:00 +03:00
25642cc6f2 pmt: initial 1.8.0 update 2024-04-25 22:02:58 +03:00
16c8654fa2 pmt: initial 1.8.0 update 2024-04-25 22:02:04 +03:00
1fb592a94f pmt: initial 1.8.0 update 2024-04-25 22:01:14 +03:00
5bb26c9eea pmt: initial 1.8.0 update 2024-04-25 21:59:54 +03:00
540dd4fe35 pmt: initial 1.8.0 update 2024-04-25 21:59:06 +03:00
22ef985925 pmt: initial 1.8.0 update 2024-04-25 21:58:42 +03:00
2e81ab9541 pmt: initial 1.8.0 update 2024-04-25 21:57:50 +03:00
112a2986b5 pmt: initial 1.8.0 update 2024-04-25 21:56:59 +03:00
65fd480ba2 pmt: initial 1.8.0 update 2024-04-25 21:56:37 +03:00
d31bccd8f6 pmt: initial 1.8.0 update 2024-04-25 21:56:05 +03:00
6c574e9536 pmt: initial 1.8.0 update 2024-04-25 21:55:09 +03:00
a4838b24e1 pmt: initial 1.8.0 update 2024-04-25 21:54:10 +03:00
908060219e pmt: initial 1.8.0 update 2024-04-25 21:50:04 +03:00
ac06203a2c pmt: initial 1.8.0 update 2024-04-25 21:49:07 +03:00
56976b2bd0 pmt: initial 1.8.0 update 2024-04-25 21:48:43 +03:00
b7ebb92fcd Update CHANGELOG.md 2024-04-25 21:44:08 +03:00
3b36e1309d pmt: Specify that bugs should be reported by email 2024-04-17 17:59:31 +03:00
8dbc54f9fc pmt: build system: update help message 2024-04-13 22:30:29 +03:00
4b4b53a080 pmt: update explanation 2024-04-13 22:29:36 +03:00
09d9aa1ee6 pmt: exclude unnecessary library 2024-04-13 22:26:21 +03:00
171de34710 pmt: exclude unnecessary library 2024-04-13 22:25:54 +03:00
5e39fdcdc9 pmt: add arm defination controller 2024-04-10 01:02:06 +03:00
fbb4822872 Update pmt.h 2024-04-10 00:53:45 +03:00
711319cce0 Update pmt.h 2024-04-10 00:51:39 +03:00
6dbf7acf3c Update pmt.h 2024-04-10 00:48:11 +03:00
287c75aa67 Rename env.mk to env.mk 2024-04-10 00:41:29 +03:00
1835ecc1e0 pmt: apply version 1.7.0 changes 2024-04-09 23:55:55 +03:00
8afbb2314c pmt: apply version 1.7.0 changes 2024-04-09 23:54:53 +03:00
283346f522 Delete binary/include/documentation.h 2024-04-09 23:54:15 +03:00
c46a65607b pmt: apply version 1.7.0 changes 2024-04-09 23:54:01 +03:00
dd6c1c9faf pmt: apply version 1.7.0 changes 2024-04-09 23:53:27 +03:00
6ab211c1b3 pmt: apply version 1.7.0 changes 2024-04-09 23:47:19 +03:00
372563fceb pmt: apply version 1.7.0 changes 2024-04-09 23:46:45 +03:00
0b34fdbfd9 pmt: apply version 1.7.0 changes 2024-04-09 23:46:15 +03:00
a2aee5c5e8 pmt: apply version 1.7.0 changes 2024-04-09 23:45:38 +03:00
d3d6bfd244 pmt: apply version 1.7.0 changes 2024-04-09 23:32:06 +03:00
97edfbc133 pmt: apply version 1.7.0 changes 2024-04-09 23:31:14 +03:00
b5d4c76b2d pmt: apply version 1.7.0 changes 2024-04-09 23:30:35 +03:00
39b1e67f8e Delete mka/apply-config.mk 2024-04-09 23:29:28 +03:00
1ffd0f90be pmt: apply version 1.7.0 changes 2024-04-09 23:28:21 +03:00
b8a8b7ff8f pmt: apply version 1.7.0 changes 2024-04-09 23:26:20 +03:00
848412e1cd pmt: apply version 1.7.0 changes 2024-04-09 23:24:53 +03:00
8034ed897c Fix changelog link 2024-03-12 20:03:43 +03:00
c8c0687519 pmt: improve build system 2024-03-11 22:34:21 +03:00
c82a127e43 pmt: update err message 2024-03-06 22:50:42 +03:00
6378f8300b Update README.md 2024-03-06 20:47:07 +03:00
80b22ee9c7 pmt: initial 1.5.0 update 2024-03-06 20:39:48 +03:00
e770a80d2a pmt: initial 1.5.0 update 2024-03-06 20:39:18 +03:00
9cd749708d pmt: initial 1.5.0 update 2024-03-06 20:31:17 +03:00
39a5098f71 pmt: initial 1.5.0 update 2024-03-06 20:30:50 +03:00
d7c4ec5236 pmt: initial 1.5.0 update 2024-03-06 20:29:49 +03:00
651c49c3d9 pmt: initial 1.5.0 update 2024-03-06 20:29:15 +03:00
c88c529d2c pmt: initial 1.5.0 update 2024-03-06 20:28:11 +03:00
2d23f45387 pmt: initial 1.5.0 update 2024-03-06 20:26:56 +03:00
67d4c86dfd pmt: initial 1.5.0 update 2024-03-06 20:26:25 +03:00
682e7657fd pmt: initial 1.5.0 update 2024-03-06 20:26:05 +03:00
c91cb25c65 pmt: initial 1.5.0 update 2024-03-06 20:25:30 +03:00
d91f9279cc pmt: initial 1.5.0 update 2024-03-06 20:23:44 +03:00
099e9d2ba6 pmt: initial 1.5.0 update 2024-03-06 20:23:09 +03:00
56638ab00e pmt: initial 1.5.0 update 2024-03-06 20:22:35 +03:00
7fd5e1768e pmt: initial 1.5.0 update 2024-03-06 20:21:50 +03:00
b045bf9b87 Add headers 2024-03-04 23:57:56 +03:00
a5ded6a26e pbt: upgrade to 1.5.0 2024-03-04 23:54:36 +03:00
48bc47c1e2 Clean 2024-03-04 23:36:27 +03:00
bbf4ff76cb pbt: add some funcs 2024-03-04 23:32:02 +03:00
9260b35ae6 Update common.h 2024-03-04 23:28:25 +03:00
6064ba2ee1 pbt: update binary 2024-03-04 23:23:27 +03:00
21e7daac0f pbt: add global variables, macros 2024-03-04 23:17:13 +03:00
ddbbffff6b pbt: Let's make a change... 2024-03-04 23:01:50 +03:00
aaf0bc6660 pbt: add banner 2024-03-04 22:51:31 +03:00
d536844f1c pbt: add banner 2024-03-04 22:51:13 +03:00
7dd8694da1 pbt: add banner 2024-03-04 22:49:40 +03:00
ac6d22e58d tb8765ap1_bsp: add banner 2024-03-04 22:49:06 +03:00
189f3078ae tb8765ap1_bsp: change syntax and add banner 2024-03-04 22:48:26 +03:00
9acb17bd10 pbt: update the version and add a new feature 2024-03-04 22:43:54 +03:00
a7da00190f pbt: upgrade version info 2024-03-04 22:41:54 +03:00
287 changed files with 89290 additions and 593 deletions

97
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,97 @@
name: Build and release
on: [workflow_dispatch]
jobs:
build-and-rel-pmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Cleanup
id: cleanup
uses: rokibhasansagar/slimhub_actions@main
- name: Update and setup packages
id: general-packages-progress
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt upgrade -y \
&& sudo apt install make xz-utils aria2 gawk gh -y
- name: Save spefic version variables
id: save-vars
run: |
. build/workflow/build.config
echo "PMT_VERSION=${PMT_VERSION}" >> $GITHUB_ENV
echo "PMT_VERSION_CODE=${PMT_VERSION_CODE}" >> $GITHUB_ENV
echo "NDK_VERSION=${NDK_VERSION}" >> $GITHUB_ENV
echo "NDK_LINK=${NDK_LINK}" >> $GITHUB_ENV
echo "NDK_IS=${NDK_IS}" >> $GITHUB_ENV
cd /home
sudo git clone https://github.com/ShawkTeam/pmt -b ${PMT_VERSION}
sudo chmod -R 777 pmt
echo "PMT_SRCDIR=/home/pmt" >> $GITHUB_ENV
echo "NDK_DIR=/home/ndk/android-ndk" >> $GITHUB_ENV
echo "NDK_IN_DIR=/home/ndk" >> $GITHUB_ENV
sudo mkdir -p "/home/ndk" && cd "/home/ndk" && sudo chmod 777 "/home/ndk"
- name: Setup Android NDK
id: setup-ndk
run: |
echo "Downloading NDK ${{ env.NDK_VERSION }}..."
aria2c "${{ env.NDK_LINK }}"
echo "Extracting..."
unzip -q *.zip && rm *.zip
mv * "${{ env.NDK_IS }}"
sudo chmod -R 777 *
working-directory: ${{ env.NDK_IN_DIR }}
- name: Build pmt
id: build-pmt
run: |
export NDK_PROJECT_PATH=${PWD}
export NDK_ROOT_DIR=${{ env.NDK_DIR }}
. build/bash/gen-header
cd ${{ env.NDK_DIR }}
./ndk-build
working-directory: ${{ env.PMT_SRCDIR }}
- name: Last small transactions
id: small-transactions
run: |
export CXX_64="${PWD}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++"
export CXX_VERSION=$(${CXX_64} --version | head -n 1)
echo "CXX_VERSION=${CXX_VERSION}" >> $GITHUB_ENV
. ${{ env.PMT_SRCDIR }}/build/workflow/build.config
. ${{ env.PMT_SRCDIR }}/build/workflow/relnotes > /home/pmt/release_body.txt
cd ${{ env.PMT_SRCDIR }}
zip -rq pmt-objs-local.zip obj/local/arm64-v8a obj/local/armeabi-v7a
xz libs/arm64-v8a/pmt
xz libs/armeabi-v7a/pmt
mv libs/arm64-v8a/pmt.xz ${PWD}/pmt-arm64-v8a-$(date +%Y%m%d).xz
mv libs/armeabi-v7a/pmt.xz ${PWD}/pmt-armeabi-v7a-$(date +%Y%m%d).xz
cp build/mandoc/mandoc pmt.8
gzip -c pmt.8 > mandoc.gz
working-directory: ${{ env.NDK_DIR }}
- name: Upload to release
id: upload-to-rels
uses: softprops/action-gh-release@v2
with:
files: |
/home/pmt/pmt*.xz
/home/pmt/pmt-objs-local.zip
/home/pmt/mandoc.gz
name: Partition Manager ${{ env.PMT_VERSION }} Release
tag_name: ${{ env.PMT_VERSION }}
body_path: /home/pmt/release_body.txt
env:
GITHUB_TOKEN: ${{ secrets.PMT_WORKFLOW_GTOKEN }}

35
.github/workflows/check_commits.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Check commit
on: [push]
jobs:
check-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect commit type
id: check-commit-type
run: |
echo "BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
readonly COMM_MSG=$(git log -1 --pretty=%B)
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
if [[ "${COMM_MSG}" == *"initial"* ]]; then
echo "run_builder=true" >> $GITHUB_ENV
else
echo "run_builder=false" >> $GITHUB_ENV
fi
elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then
echo "run_builder=true" >> $GITHUB_ENV
fi
- name: Run release workflow
id: run-rel-workflow
if: env.run_builder == 'true'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: 'build.yml'
token: ${{ secrets.PMT_WORKFLOW_GTOKEN }}
ref: ${{ env.BRANCH }}

147
ADD-LANGUAGES.md Executable file
View File

@@ -0,0 +1,147 @@
### Add a new language to pmt (guide)
On this page, I will tell you how to add languages to pmt. This is not a difficult thing :)
##### Send ready stuff
- Send ready translations via pull requests. After making the necessary checks, if there is no problem, I will accept it.
- Proper commit messages are required.
- If there is an error, I will mention it in the pull request comments.
- Once you accept it, I (YZBruh) will implement the rest of the necessary things.
- It may take 5 days for me to notice :P
##### Little important notes
- You don't have to be a professional to do this thing.
- There will be only one place you need to pay attention to, I will explain it.
- There is no need to know C/C++.
- You can edit existing translations.
- You may need ready pmt to understand some things.
- If you are on an x86 PC, you can compile and use it, but the functions will never work.
##### Understanding general logic
All the texts (strings) in pmt are like variables in bash. I mean:
```
Bash
export missing_operand="missing operand."
APPLYING:
~ $ echo -n "$missing_operand\n" # for more detail I used the -n argument
missing operand
~ $
C / C++
const char* _Nonnull missing_operand = "missing operand.";
const std::string missing_operand = "missing operand.";
APPLYING (C / C++):
printf("%s\n", missing_operand); // Move to new line with '\n' character
std::cout << missing_operand << std::endl; // Move to new line with std::endl
```
For example, let's take the output directly in pmt without any arguments and process the variables and structures behind the work.
```
Shell
~ $ pmt
pmt: missing operand
Try `pmt --help' for more information.
~ $
Code pieces (C++)
struct pmt_langdb_general en = {
// other translations
.missing_operand = "missing operand",
.try_h = "Try",
.for_more = "for more information",
// other translations
}
// pmt code functions [ logging ]
LOGE("%s\n%s `%s --help' %s.\n, missing_operand, try_h, args[0], for_more); // LOGE is error logger (pmt). args[0] = execution name
```
In short, there are variables for texts. And I made these dynamic by using [struct](https://chatgpt.com/share/a798b57c-7e29-4b17-8887-f230414e57bd) method in C (but C++ is being used. And, it didn't change much about that). You just need to add translation :)
##### Translating main program texts (relevant part)
- Let's open our jni/Languages.cpp source file.
- Now, let's create the translation with the ready-made struct structure (see include/pmt/StringKeys.h for the structure).
```
// Main
struct langdb_general Lang<LANGUAGE_PREFIX> = { // LANGUAGE_PREFIX must be the corresponding abbreviation of the language in English. For example, it's like En in English.
// translations
}
// Example
struct langdb_general LangEn = {
// translation
}
```
- We need to add some information about the language.
```
VERY IMPORTANT NOTE: You should do your translations from within the function called WCHAR_T!
struct langdb_general Lang<LANGUAGE_PREFIX> = {
.lang_by_s = // Names of those who made the translation. It's up to you. Do you use & between more than one person?
.language = // Language name. For example English
.lang_prefix = // Language prefix. For example en
// other translations
}
// Example
struct langdb_general LangEn = {
.lang_by_s = WCHAR_T("YZBruh & r0manas"),
.language = WCHAR_T("English"),
.lang_prefix = WCHAR_T("en"),
// other translations
.by_str = WCHAR_T("By") // Example for end translate
}
// CRITIC WARNING: Do not add ',' to the end of the last translation text. But others always...
```
- Now do the others :)
- Now let me explain the documentation...
##### Document texts translation (relevant part)
- Let's open our jni/Languages.cpp source file.
- Now, let's create the translation with the ready-made struct structure (see include/pmt/StringKeys.h for the structure).
```
struct langdb_docs LangDoc<LANGUAGE_PREFIX> = {
// translations
}
// Example
struct pmt_langdb_docs LangDocEn = {
// translations
}
// CRITIC WARNING: Do not add ',' to the end of the last translation text. But others always...
```
- Make translations by taking examples from existing ones. And definitely do it regularly by getting help message from pmt :D
##### General things to do in translation
- Open jni/LanguageTools.cpp
```
string supp_langs[] = {
"en",
"tr",
// language prefix. "<LANGUAGE_PREFIX>",
"" // PLEASE DO NOT ADD IT UNDER `""`!
};
// Example
string supp_langs[] = {
"en",
"tr",
"az",
""
};
// Add the language you are translating into these existing language prefixes. I will fix the errors here (if there is an error)
```
##### Notes
- Apologies for the crappy current language control structure :(
- You can ask your questions: <t.me / ShawkTeam | Topics | pmt>

11
CHANGELOG.md Executable file
View File

@@ -0,0 +1,11 @@
### Version 2.9.1 Changelog
- All dependencies related to e2fsprogs were added into pmt for built-in mke2fs
- Partition size displaying feature added
- Make compilation system deprecated, only Android NDK can be used
- Some small fixes
- Some minor changes on compilation system
```
END OF 2.9.1 UPDATE CHANGELOG
```

17
DISCLAIMER Normal file → Executable file
View File

@@ -1,6 +1,11 @@
WARNING:
Disclaimer of Liability Regarding the Use of the C Library
- This library is intended for the user to backup the C android partitions. However, we do not accept responsibility for any problems or losses that may arise during its use.
- Users should carefully test the library functions and, if necessary, implement their own error management mechanisms.
- The authors reserve the right to make any changes or updates related to the library.
- This library is intended for backing up android partitions and its suitability for any specific project or application is not guaranteed. It is important for users to evaluate the suitability of their own projects.
Disclaimer regarding problems caused by PMT
1. This program is provided as is, without warranty.
2. Not for commercial purposes.
3. The developer is NOT responsible for any damages, losses or similar problems that may occur as a result of the use of the program.
4. THE USER IS RESPONSIBLE FOR ANY PROBLEMS THAT MAY COME FROM WRONG OR FAILURE USING THE PROGRAM.
5. Developers do NOT have to keep the program always updated.
6. There is NO guarantee that updates will be provided in the future.
7. The user must use the program IN ACCORDANCE with the license.
8. The developer has ALL rights to the development and distribution of the program.
9. The developer will only be interested in solving users' queries etc. AND THE UPDATE MAY NOT DO THIS AFTER THE INTERRUPTION.

0
LICENSE Normal file → Executable file
View File

113
Makefile
View File

@@ -1,113 +0,0 @@
include mka/config.mk
# By YZBruh
# Copyright 2024 YZBruh - Partition Backupper
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# speficy
VERSION := 1.4.0
VERSION_CODE := 140
SOURCE_DIR := binary
TARGET := pbt
ARCH := $(shell uname -m)
# code list
OBJS= $(SOURCE_DIR)/pbt.o
SRCS := $(SOURCE_DIR)/pbt.c
# gcc flags
LDFLAGS :=
LDLIBS := -lm
# display
all:
@printf " --- Building Partition Backupper --- \n"; \
printf "Version: $(VERSION)\n"; \
printf "Version code: $(VERSION_CODE)\n"; \
printf " \n"; \
printf " ------------------------------------- \n"; \
printf " \n"; \
printf "Starting build... Please waith.\n"; \
sleep 2; \
printf "Make running with silent mode...\n"; \
make -s pbt;
# build progress
.PHONY: $(TARGET)
$(TARGET): $(OBJS)
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
@mkdir -p out; \
mkdir -p out/binary; \
mkdir -p out/package; \
mv pbt out/binary; \
printf "Generating gzip package...\n"; \
cp out/binary/pbt out/package; \
gzip -f out/package/pbt; \
mv out/package/pbt.gz out/package/pbt_$(ARCH).gz; \
printf " \n"; \
printf " ------------------------------------- \n";
# cleaner functions
.PHONY: clean
clean:
@printf "Cleaning (builded files [.o extended])...\n"; \
sleep 2; \
rm -rf $(OBJS); \
printf "Success\n";
.PHONY: clean-all
clean-all:
@printf "Cleaning (builded files [.o extended] and binary)...\n"; \
sleep 2; \
rm -rf $(OBJS) out; \
printf "Success\n";
# helper function
.PHONY: help
help:
@printf " --------- Partition Backupper help ---------\n"; \
printf " \n"; \
printf " Commands;\n"; \
printf " make ==> Build Partition Backupper\n"; \
printf " make clean ==> Clear files (Builded binaries are not deleted)\n"; \
printf " make clean-all ==> Clear files (Builded binaries are deleted)\n"; \
printf " make install-termux ==> If you are using termux, it installs the compiled pbt into termux. So it allows you to use it like a normal command.\n"; \
printf " make help ==> Display help message\n"; \
printf " \n";
.PHONY: install-termux
install-termux:
@arch=$$(uname -m); \
if [ "$$arch" = "aarch64" ]; then \
printf " ------------------------------------- \n"; \
printf " pbt installer \n"; \
printf " ------------------------------------- \n"; \
cp out/binary/pbt /data/data/com.termux/files/usr/bin/pbt; \
chmod 777 /data/data/com.termux/files/usr/bin/pbt; \
printf " \n"; \
printf "Success.\n"; \
printf " \n"; \
elif [ "$$arch" = "armv7l" ]; then \
printf " ------------------------------------- \n"; \
printf " ptb installer \n"; \
printf " ------------------------------------- \n"; \
cp out/pbt /data/data/com.termux/files/usr/bin/pbt; \
chmod 777 /data/data/com.termux/files/usr/bin/pbt; \
printf " \n"; \
printf "Success.\n"; \
printf " \n"; \
else \
printf "This function is only available on Termux Android devices using aarch64 (64-bit) and armv7l (32-bit)\n"; \
fi

2
NOTICE Normal file → Executable file
View File

@@ -1,4 +1,4 @@
Copyright 2024 YZBruh - Partition Backupper
Copyright 2024 Partition Manager
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

177
README.md Normal file → Executable file
View File

@@ -1,68 +1,131 @@
## Partition Backupper (pbt)
## Partition Manager (pmt)
This binary static C library is for backing up partitions of android devices.
It offers a lot of options. I will place these below. But first let me talk about the operation...
[![Commit reviewed](https://github.com/ShawkTeam/pmt/actions/workflows/check_commits.yml/badge.svg)](https://github.com/ShawkTeam/pmt/actions/workflows/check_commits.yml)
This is a binary written with C++ and it is for writing/reading, formatting and getting size on Android partitions.
```
1. The partition name is obtained (with the -p or --partition argument)
2. Other arguments (if used) are processed.
3. It is backed up using DD. If the progress is not a problem, it is not given (DD)
Usage: pmt [OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...
or: pmt [OPTIONS] flash PARTITION FILE [OPTIONS]...
or: pmt [OPTIONS] format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...
or: pmt [OPTIONS] partition-size PARTITION [OPTIONS]...
Options:
-l, --logical It is meant to determine whether the target partition is logical.
-P, --search-path It is meant to specify a custom partition search path. Only classic partitions (default: /dev/block/by-name).
-p, --list List partitions.
-s, --silent Information and warning messages are silenced in normal work.
-f, --force Force mode. Some things are ignored.
-V, --verbose Verbose mode. Print detailed informations etc.
-S, --set-lang Set current language.
-v, --version See version.
--help See this help message.
partition-size flags:
--only-size Only the size is displayed, the partition name etc is not displayed.
--as-byte Display size as byte.
--as-kilobyte Display size as kilobyte.
--as-megabyte Display size as megabyte.
--as-gigabyte Display size as gigabyte.
Examples:
pmt backup boot_a -P /dev/block/platform/bootdevice/by-name
pmt flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name
pmt format system_a ext4 --logical
pmt -P /dev/block/platform/bootdevice/by-name --list
pmt partition-size boot --as-byte
pmt partition-size system --only-size --as-gigabyte --logical
Report bugs and suggestions to <t.me/ShawkTeam | Topics | pmt>
```
#### Presented arguments (options)
```
Usage (arguments):
-p, --partition name of the partition to be backed up
-l, --logical know that the partition that will be backed up is logical
-o, --out the output name of the backed-up partition (default: partition name)
-d, --outdir directory where the backup partition will be saved (default: /storage/emulated/0)
-c, --context it is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)
-D, --list list partitions
-v, --version see version
-h, --help see help message
-L, --license see license
Example 1:
-p boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name
Example 2:
-c /dev/block/platform/bootdevice/by-name --list
Report bugs to <xda-@YZBruh>
```
For example, if we want to back up the `boot_a` partition: `pbt -p boot_a` (edit the command if it has a different name).
#### Some notes
### Notes
- pmt now supports multiple languages. [See languages.](https://github.com/ShawkTeam/pmt/blob/2.9.1/LANGUAGES.md)
- [Add a language.](https://github.com/ShawkTeam/pmt/blob/2.9.1/ADD-LANGUAGES.md)
- Feel free to ask any questions you want.
- Packages are available in publications.
- it is mandatory to use the `-p` | `--partition` argument. After all, a partition name is required to be backed up.
- If the logical partition flag is not used, a classic partition is tried to be backed up by default.
- Let me know your suggestions!
- If the logical partition flag is not used, a classic partition is tried to be processing by default.
- [Click to see special version changes.](https://github.com/ShawkTeam/pmt/blob/2.9.1/CHANGELOG.md)
- We are always open to your suggestions and support _(developing)_!
### How is it built?
Even termux is enough to build the pbt. Or you can compile it with linux if you want. NOTE: Use a custom gcc according to the architecture you want to compile.
## How to build?
Partition Manager only buildable with Android NDK (make compilation system deprecated).
- [Download Android NDK](https://developer.android.com/ndk/downloads) and extract the NDK package.
- Clone this repository. And get access to it.
```
git clone https://github.com/ShawkTeam/pmt -b 2.9.1
cd pmt
```
- Set the NDK working directory variable.
```
export NDK_PROJECT_PATH="${PWD}" # or where the source directory is everywhere
export NDK_ROOT_DIR=<PATH> # Note that if the NDK is in the directory
# Generate clang version header
bash build/bash/gen-header
```
- Go to the NDK directory and start the build
```
./ndk-build
# Permission denied? Change mode and retry
(sudo) chmod +x ndk-build
# OR
(sudo) chmod 755 ndk-build
```
- The output files will be inside the `pmt` folder. Binaries are available in two architectures within the `libs` folder. `arm64-v8a` (64-bit) and `armeabi-v7a` (32-bit).
```
pmt/
|
________________|________________
| | | |
jni/ build/ obj/ libs/
|
__________|__________
| |
arm64-v8a/ armeabi-v7a/
| |
pmt pmt
```
### Manage pmt with termux script
- Download script.
```
curl -LSs https://github.com/ShawkTeam/pmt/raw/2.9.1/pmt-termux.sh > pmt-termux.sh
```
- Some informations...
```
## View script help
bash pmt-termux.sh # --help (optional)
## The commands will be told to you anyway. Ask your questions from the telegram group.
```
### How to use
```
# Directly access root shell
/system/bin/su
# If you are using termux, use with
# tsu (sudo) will be a better choice
pkg install -y tsu # install tsu (sudo)
sudo <COMMAND(S)>
```
- If you have installed the deb package of pmt, installed it with a makefile, or installed it to `$PATH` using any path, just the name of the pmt is enough (or the file name if you did it manually)
```
(sudo) pmt <ARGUMENT(S)>
```
- If you have not done this type of institution, pmt is in the directory where you are present you can run with `(sudo) ./`.
```
(sudo) ./pmt <ARGUMENT(S)> # or whatever the file name is
```
### Notes
If you want to change something, take a look at the configuration. You can change him.
it is located in the `mka` folder. His name is `config.mk`. I gave the information in the file. You can ask more.
To build;
```
make
```
Special `make` commands (pbt offers :) ;
```
--------- Partition Backupper help ---------
Commands;
make ==> Build Partition Backupper
make clean ==> Clear files (Builded binaries are not deleted)
make clean-all ==> Clear files (Builded binaries are deleted)
make install-termux ==> If you are using termux, it installs the compiled pbt into termux. So it allows you to use it like a normal command.
make help ==> Display help message
```
I compiled it with termux :D. Why should I bother... I compiled it with `GCC 17.0.6`. You can look at the version with the viewing option :)
it is located in the `build/config` folder. His name is `env.mk`. I gave the information in the file. You can ask more.

View File

@@ -1,54 +0,0 @@
#ifndef _DOCUMENTATION_H_
#define _DOCUMENTATION_H_
/* By YZBruh */
/*
* Copyright 2024 YZBruh - Partition Backupper
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
void licenses() {
printf("Copyright 2024 YZBruh - Partition Backupper\n");
printf("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
printf("you may not use this file except in compliance with the License.\n");
printf("You may obtain a copy of the License at\n\n");
printf(" http://www.apache.org/licenses/LICENSE-2.0\n\n");
printf("Unless required by applicable law or agreed to in writing, software\n");
printf("distributed under the License is distributed on an \"AS IS\" BASIS,\n");
printf("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
printf("See the License for the specific language governing permissions and limitations under the License.\n");
}
void help() {
printf("Usage (arguments): \n");
printf(" -p, --partition name of the partition to be backed up\n");
printf(" -l, --logical know that the partition that will be backed up is logical\n");
printf(" -o, --out the output name of the backed-up partition (default: partition name)\n");
printf(" -d, --outdir directory where the backup partition will be saved (default: /storage/emulated/0)\n");
printf(" -c, --context it is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)\n");
printf(" -D, --list list partitions\n");
printf(" -v, --version see version\n");
printf(" -h, --help see help message\n");
printf(" -L, --license see license\n\n");
printf("Example 1:\n");
printf(" -p boot_a -o boot_slot_a_image -d /sdcard/backup -c /dev/block/platform/bootdevice/by-name\n\n");
printf("Example 2:\n");
printf(" -c /dev/block/platform/bootdevice/by-name --list\n\n");
printf("Report bugs to <xda-@YZBruh>\n");
}
/* end of code */
#endif

View File

@@ -1,166 +0,0 @@
#ifndef _PBT_H_
#define _PBT_H_
/* By YZBruh */
/*
* Copyright 2024 YZBruh - Partition Packupper
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* add pre-function important */
char *out;
char *outdir;
char *my_out;
char *cust_cxt;
bool use_cust_cxt = false;
bool pbt_ab = false;
bool pbt_logical = false;
/* shorter error messages will be functional xd */
void error(const char *err_msg) {
fprintf(stderr, ANSI_RED "%s" ANSI_RESET, err_msg);
exit(EXIT_FAILURE);
}
/* check if the device is ab partitioned */
void check_psf() {
/* true = ab | false = a */
if (use_cust_cxt) {
char cust_cxt_ckpath[150];
sprintf(cust_cxt_ckpath, "%s/boot_a", cust_cxt);
if (access(cust_cxt_ckpath, F_OK) != 0) {
pbt_ab = false;
} else {
pbt_ab = true;
}
} else {
if (access("/dev/block/by-name/boot_a", F_OK) != 0) {
pbt_ab = false;
} else {
pbt_ab = true;
}
}
/* true = logical | false = classic */
if (use_cust_cxt) {
char cust_cxt_cklpath[150];
sprintf(cust_cxt_cklpath, "%s/super", cust_cxt);
if (access(cust_cxt_cklpath, F_OK) != 0) {
pbt_logical = false;
} else {
pbt_logical = true;
}
} else {
if (access("/dev/block/by-name/super", F_OK) != 0) {
pbt_logical = false;
} else {
pbt_logical = true;
}
}
}
/* list existing partitions */
void listpart() {
if (use_cust_cxt) {
printf("List of classic partitions (%s): \n", cust_cxt);
char cust_cxt_path[150];
sprintf(cust_cxt_path, "ls %s", cust_cxt);
if (system(cust_cxt_path) != 0) {
error("An error occurred when the partition list appears!\n");
}
} else {
printf("List of classic partitions (/dev/block/by-name): \n");
if (system("ls /dev/block/by-name") != 0) {
error("An error occurred when the classic partition list appears!\n");
}
}
if (pbt_logical) {
printf("List of logical partitions (/dev/block/mapper): \n");
if (system("ls /dev/block/mapper") != 0) {
error("An error occurred when the logical partition list appears!\n");
}
}
if (pbt_ab) {
printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
}
if (pbt_logical) {
printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
}
}
/* additional function to perform backup */
void backup(char *target_pt, char *pst) {
char path[200];
if (strstr(pst, "classic") != NULL) {
if (use_cust_cxt) {
sprintf(path, "%s/%s", cust_cxt, target_pt);
} else {
sprintf(path, "/dev/block/by-name/%s", target_pt);
}
} else if (strstr(pst, "logical") != NULL) {
sprintf(path, "/dev/block/mapper/%s", target_pt);
} else {
error("İnvalid partition type!\n");
}
if (access(path, F_OK) == -1) {
error("Partition not found!\n");
} else {
printf("Target partition: %s\nBackupping...\n", target_pt);
}
char cmd[256];
if (my_out != NULL) {
if (out != NULL) {
sprintf(cmd, "dd if=%s of=%s/%s.img status=none", path, my_out, out);
} else {
sprintf(cmd, "dd if=%s of=%s/%s.img status=none", path, my_out, target_pt);
}
} else {
if (out != NULL) {
sprintf(cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", path, out);
} else {
sprintf(cmd, "dd if=%s of=/storage/emulated/0/%s.img status=none", path, target_pt);
}
}
if (system(cmd) != 0) {
error("Failed!\n");
} else {
if (my_out != NULL) {
if (out != NULL) {
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, my_out, out, ANSI_RESET);
} else {
printf("%sSuccess. Output: %s/%s.img%s\n", ANSI_GREEN, my_out, target_pt, ANSI_RESET);
}
} else {
if (out != NULL) {
printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, out, ANSI_RESET);
} else {
printf("%sSuccess. Output: /storage/emulated/0/%s.img%s\n", ANSI_GREEN, target_pt, ANSI_RESET);
}
}
}
}
/* root checker function */
void verify_root() {
// a quick, easy method to verify root :D
if (chdir("/dev/block") != 0) {
error("Root privileges could not be detected! Please run this binary with root.\n");
}
}
/* end of code */
#endif

View File

@@ -1,173 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <stdbool.h>
#include <getopt.h>
#include <stdint.h>
#include <stddef.h>
#define ANSI_RED "\033[31m"
#define ANSI_YELLOW "\033[33m"
#define ANSI_GREEN "\033[32m"
#define ANSI_RESET "\033[0m"
#define PACK_VER "1.4.0"
#define PACK_VER_CODE "140"
#define PACK_NAME "Partition Backupper"
#define PACK_LANG "en"
#include "include/pbt.h"
#include "include/documentation.h"
/* By YZBruh */
/*
* Copyright 2024 YZBruh - Partition Backupper
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* classic main function (C binary here xd) */
int main(int argc, char *argv[]) {
# ifdef __aarch64__
/* empty */
# elif __armv8l__
/* empty */
# elif __aarch32__
/* empty */
# elif __armv7l__
/* empty */
# else
error("Incompatible architecture was detected. This binary works with only arm (32-bit or 64-bit).\n");
# endif
/* a structure for long arguments... */
struct option long_options[] = {
{"partition", required_argument, 0, 'p'},
{"logical", no_argument, 0, 'l'},
{"out", required_argument, 0, 'o'},
{"outdir", required_argument, 0, 'd'},
{"context", required_argument, 0, 'c'},
{"list", no_argument, 0, 'D'},
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"license", no_argument, 0, 'L'},
{0, 0, 0, 0}
};
char *argx_target_p;
bool use_argx_p = false;
bool use_logical = false;
int opt;
/* control for each argument */
while ((opt = getopt_long(argc, argv, "p:lo:d:c:DvhL", long_options, NULL)) != -1) {
/* process arguments */
switch (opt) {
case 'p':
argx_target_p = strdup(optarg);
use_argx_p = true;
break;
case 'l':
verify_root();
check_psf();
if (pbt_logical) {
use_logical = true;
} else {
error("This device does not have logical partitions!\n");
}
break;
case 'o':
out = strdup(optarg);
break;
case 'd':
verify_root();
check_psf();
outdir = strdup(optarg);
struct stat out_info;
if (stat(outdir, &out_info) != 0) {
fprintf(stderr, "%s: %s: no such file or directory.\n", argv[0], outdir);
exit(EXIT_FAILURE);
} else {
if (S_ISDIR(out_info.st_mode)) {
my_out = outdir;
} else {
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], outdir);
exit(EXIT_FAILURE);
}
}
break;
case 'c':
use_cust_cxt = true;
cust_cxt = strdup(optarg);
break;
case 'D':
listpart();
exit(EXIT_SUCCESS);
break;
case 'v':
printf("Version: %s (code %s)\n", PACK_VER, PACK_VER_CODE);
# ifdef __clang__
printf("Compiled by clang version %s\n", __clang_version__);
# endif
printf("See licenses with -L argument.\n");
exit(EXIT_SUCCESS);
break;
case 'h':
help();
exit(EXIT_SUCCESS);
break;
case 'L':
licenses();
exit(EXIT_SUCCESS);
break;
case '?':
printf("Try `%s --help' for more information.\n", argv[0]);
exit(EXIT_FAILURE);
break;
default:
printf("Usage: %s -p, --partition PARTITION [-l, --logical] [-o, --out] [-d, --outdir] [-D, --list] [-v, --version] [-h, --help] [-L, --license]\n", argv[0]);
}
}
verify_root();
check_psf();
/* custom context checker */
if (use_cust_cxt) {
struct stat cxtinfo;
printf("Checking custom context path...\n");
if (stat(cust_cxt, &cxtinfo) == 0) {
if (S_ISDIR(cxtinfo.st_mode)) {
/* empty */
} else {
fprintf(stderr, "%s: %s: is a not directory.\n", argv[0], cust_cxt);
exit(EXIT_FAILURE);
}
} else {
error("The specified context was not found!\n");
}
if (strstr(cust_cxt, "/dev") != 0) {
printf("%sThis custom context is strange...%s", ANSI_YELLOW, ANSI_RESET);
}
}
if (use_argx_p) {
if (use_logical) {
backup(argx_target_p, "logical");
} else {
backup(argx_target_p, "classic");
}
} else {
fprintf(stderr, "%s: required partition name.\nTry `%s --help' for more information.\n", argv[0], argv[0]);
exit(EXIT_FAILURE);
}
}
/* end of code */

24
mka/apply-config.mk → build/bash/gen-header Normal file → Executable file
View File

@@ -1,6 +1,6 @@
# By YZBruh
# Copyright 2024 YZBruh - Partition Backupper
# Copyright 2024 Partition Manager
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,16 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# gcc setting
ifeq ($(USE_CUST_GCC), true)
CC := $(CUST_GCC)
LD := $(CUST_GCC)
else
CC := gcc
LD := gcc
endif
[ -z ${NDK_ROOT_DIR} ] \
&& echo "Please set NDK_ROOT_DIR variable!" \
&& exit 1
# gcc flag settings
CFLAGS := -O3 -g -Wno-unused-parameter -Wall -Wextra -static $(EXTRA_GCC_FLAGS)
[ -z ${NDK_PROJECT_PATH} ] \
&& echo "Please set NDK_PROJECT_PATH variable!" \
&& exit 1
# end of code
CXX_IS="${NDK_ROOT_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++"
CXX_VERS=$(${CXX_IS} --version | head -n 1)
mkdir -p ${NDK_PROJECT_PATH}/include/PartitionManager/generated
echo -e "#define __NDK_CXX_VERSION__ \"${CXX_VERS}\"" > ${NDK_PROJECT_PATH}/include/PartitionManager/generated/clang-version.h

32
build/config/env.mk Executable file
View File

@@ -0,0 +1,32 @@
# By YZBruh
# Copyright 2024 Partition Manager
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#########################################
# #
# Configuration Flags #
# #
# you can edit #
# #
#########################################
# addionital compiler flags
PMT_EXTRA_CXXFLAGS ?=
# debugging mode (binary). it's enabling address sanitizer and source level debug information with dwarf version 5
PMT_ENABLE_DEBUG ?=
#########################################
#########################################

154
build/mandoc/mandoc Executable file
View File

@@ -0,0 +1,154 @@
.\" By YZBruh
.\" Copyright 2024 Partition Manager
.\"
.\" Licensed under the Apache License, Version 2.0 (the "License");
.\" you may not use this file except in compliance with the License.
.\" You may obtain a copy of the License at
.\"
.\" http://www.apache.org/licenses/LICENSE-2.0
.\"
.\" Unless required by applicable law or agreed to in writing, software
.\" distributed under the License is distributed on an "AS IS" BASIS,
.\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.\" See the License for the specific language governing permissions and
.\" limitations under the License.
.\"
.TH "PMT" "8" "September 2024" "PMT 2.9.0" "Partition Manager"
.SH NAME
.B pmt
\- Android Partition Manager Tool
.SH SYNOSIS
.B pmt
[
.I {OPTIONS}
.B backup
.I PARTITION {OUTPUT} {OPTIONS}...
]
[
.I {OPTIONS}
.B flash
.I PARTITION FILE {OPTIONS}...
]
[
.I {OPTIONS}
.B format
.I PARTITION FILE_SYSTEM{ext/2/3/4} {OPTIONS}...
]
[
.I {OPTIONS}
.B partition-size
.I PARTITION {OPTIONS}...
]
[
.B \-l
|
.B \-\-logical
]
[
.B \-P
|
.B \-\-search\-path
.I search\-path
]
[
.B \-p
|
.B \-\-list
]
[
.B \-s
|
.B \-\-silent
]
[
.B \-V
|
.B \-\-verbose
]
[
.B \-f
|
.B \-\-force
]
[
.B \-S
|
.B \-\-set\-language
]
[
.B \-v
|
.B \-\-version
]
[
.B \-\-help
]
.SH DESCRIPTION
.B pmt
is a tool made to read android parts, make flash and format. Written with C++ language. It was first created as only a hobby but subsequently serialized
.PP
.SH OPTIONS
.sp
\fB\-l\fP, \fB\-\-logical\fP
.RS 4
It is meant to determine whether the target partition is logical.
.RE
.sp
\fB\-c\fP, \fB\-\-context\fP
.RS 4
It is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name)
.RE
.sp
\fB\-p\fP, \fB\-\-list\fP
.RS 4
List partitions.
.RE
.sp
\fB\-s\fP, \fB\-\-silent\fP
.RS 4
Information and warning messages are silenced in normal work.
.RE
.sp
\fB\-V\fP, \fB\-\-verbose
.RS 4
Verbose mode. Print detailed informations etc.
.RE
.sp
\fB\-f\fP, \fB\-\-force\fP
.RS 4
Force mode. Some things are ignored.
.RE
.sp
\fB\-S\fP, \fB\-\-set\-language\fP
.RS 4
Set current language.
.RE
.sp
\fB\-v\fP, \fB\-\-version\fP
.RS 4
See version info.
.RE
.sp
\fB\-\-help\fP
.RS 4
See help message.
.SH EXAMPLES
.B pmt
backup boot_a -c /dev/block/platform/bootdevice/by-name
.sp
.B pmt
flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name
.sp
.B pmt
format system_a ext4 --logical
.sp
.B pmt
-c /dev/block/platform/bootdevice/by-name --list
.SH AUTHOR
This version of
.B pmt
has been written by YZBruh <github.com/YZBruh>
.SH BUGS
Report bugs to <t.me/ShawkTeam | Topics | pmt>
.PP

5
build/workflow/build.config Executable file
View File

@@ -0,0 +1,5 @@
export PMT_VERSION="2.9.1"
export PMT_VERSION_CODE=291
export NDK_VERSION="r27"
export NDK_IS="android-ndk"
export NDK_LINK="https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip"

10
build/workflow/relnotes Executable file
View File

@@ -0,0 +1,10 @@
echo -e "\`${CC_VERSION}\`
Version and code: \`${PMT_VERSION}\`/\`${PMT_VERSION_CODE}\`
Supported architectures: \`arm64-v8a\` (64-bit), \`armeabi-v7a\` (32-bit)
Notes:
- Builded with Android NDK \`${NDK_VERSION}\`
- Packages are compressed with \`xz\`.
- Report bugs and suggestions.
- [Click](https://github.com/ShawkTeam/pmt/blob/${PMT_VERSION}/CHANGELOG.md) for viewing version \`${PMT_VERSION}\` changelog."

View File

@@ -0,0 +1,101 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#define deprecated_opt 1
#define changed_opt 2
#define end_depr_pointer 0
#define not_changed 0
#define not_changed_long nullptr
/* versions */
#define v150 "1.5.0"
#define v160 "1.6.0"
#define v170 "1.7.0"
#define v180 "1.8.0"
#define v190 "1.9.0"
#define v200 "2.0.0"
#define v210 "2.1.0"
#define v220 "2.2.0"
#define v230 "2.3.0"
#define v240 "2.4.0"
#define v250 "2.5.0"
#define v260 "2.6.0"
#define v270 "2.7.0"
#define v280 "2.8.0"
#define v290 "2.9.0"
#define vUNK nullptr
struct pmt_deprecates {
int depr_type;
int option;
int option_new;
const char* option_long;
const char* option_long_new;
const char* depr_version;
};
static struct pmt_deprecates depr_table[] = {
{deprecated_opt, 'b', not_changed, "backup", not_changed_long, v210},
{deprecated_opt, 'F', not_changed, "flash", not_changed_long, v210},
{deprecated_opt, 'r', not_changed, "format", not_changed_long, v210},
{deprecated_opt, 'L', not_changed, "license", not_changed_long, v250},
{changed_opt, 'D', 'p', "list", not_changed_long, v210},
{changed_opt, 'c', 'P', "context", "search-path", v290},
{end_depr_pointer, not_changed, not_changed, not_changed_long, not_changed_long, vUNK}
};
static void
__process_deprecated_opts(int opt, const string& opt_long, const char* depr_msg)
{
static string long_e_msg;
if (opt_long.empty())
long_e_msg = PartitionManager::Display::UsingDispString->not_changed_opt;
else
long_e_msg = opt_long;
for (int optctrl = 0; depr_table[optctrl].depr_type != 0; optctrl++)
{
if (depr_table[optctrl].depr_type == 1)
{
if (opt == depr_table[optctrl].option || strcmp(opt_long.c_str(), depr_table[optctrl].option_long) == 0)
{
LOGD("%s [%s]: -%c (%s): %s\n", PartitionManager::Display::UsingDispString->depr_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, depr_table[optctrl].option_long, depr_msg);
exit(1);
}
}
else if (depr_table[optctrl].depr_type == 2)
{
if (opt == depr_table[optctrl].option || strcmp(opt_long.c_str(), depr_table[optctrl].option_long) == 0)
{
LOGD("%s [%s]: -%c (%s): %s\n", PartitionManager::Display::UsingDispString->switched_opt_str, depr_table[optctrl].depr_version, (char)depr_table[optctrl].option, long_e_msg.c_str(), depr_msg);
exit(1);
}
}
}
}
#define DEPR_HANDLE(x, y, z) \
__process_deprecated_opts(x, y, z)
/* end of code */

View File

@@ -0,0 +1,25 @@
/* By YZBruh */
/*
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
extern "C" {
int mke2fs_main(int argc, char* argv[]);
}
/* end of code */

View File

@@ -0,0 +1,27 @@
/* By YZBruh */
/*
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
namespace PartitionManager {
namespace Functions {
void DisplayHelp(void);
}
}
/* end */

View File

@@ -0,0 +1,26 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#define VIEW_AS_BYTE 1
#define VIEW_AS_KIB 2
#define VIEW_AS_MIB 3
#define VIEW_AS_GIB 4
/* end of code */

View File

@@ -0,0 +1,157 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#if !defined(__clang__) && !defined(__NDK_BUILD)
#error "Your compiler is NOT clang. Please build with (LLVM) clang."
#endif
#ifdef INC_MAIN_LIBS
#include <iostream>
#include <stdbool.h>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdarg>
#ifdef IS_MAIN
#include <clocale>
#endif
#if !defined(HELP) || !defined(VERSIONING)
#include <cstdlib>
#include <unistd.h>
#include <fcntl.h>
#include <fstream>
#endif
#endif
#ifdef INC_STRINGKEYS
#include <PartitionManager/StringKeys.h>
#endif
#ifdef INC_DIRENT
#include <dirent.h>
#endif
#ifdef INC_STAT
#include <sys/stat.h>
#endif
#ifdef INC_DEBUGERS
#include <cerrno>
#endif
#ifdef INC_TOOLS_REQS
#include <sys/vfs.h>
typedef unsigned short ushort_t;
#endif
#ifdef INC_LIBGEN
#include <libgen.h>
#endif
using namespace std;
/* logging levels */
typedef enum {
LOG_LEVEL_FATAL,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARN,
LOG_LEVEL_DEBUG
} LogLevel;
/**
* Fast error processing without errno entry
* but errno can be given in the entrance
*/
extern "C" char* strqerror(int errno_macro = errno);
/* create a special namespace */
namespace PartitionManager {
namespace Strings {
extern string OutputName;
extern string CustomSearchPath;
extern string TargetPartition;
extern string TargetFlashFile;
extern string TargetFormatFS;
extern string PartitionType;
extern string ExecutingName;
extern string CurrentLanguage;
} /* namespace Strings */
namespace Integers {
extern int PartSizeViewType;
} /* namespace Integers */
namespace Booleans {
extern bool UseLogical;
extern bool UseCustomSearchPath;
extern bool UsesSlots;
extern bool UsesLogical;
extern bool OnlyViewSize;
extern bool SilentEnabled;
extern bool FlashMode;
extern bool BackupMode;
extern bool FormatMode;
extern bool PartSizeViewMode;
extern bool ForceMode;
extern bool VerboseMode;
extern bool InstalledOnTermux;
} /* namespace Booleans */
namespace Display {
extern struct langdb_general* UsingDispString;
extern struct langdb_docs* UsingDocDispString;
extern struct langdb_general LangEn;
extern struct langdb_general LangTr;
extern struct langdb_docs LangDocEn;
extern struct langdb_docs LangDocTr;
} /* namespace Display */
namespace Functions {
int ListPartitions(void);
int GetState(const string& filepath, const string& stype = "file");
int Start(unsigned short progress_code);
void SetLanguage(const string& lang, unsigned short null_conf_stat);
void DisplayLog(LogLevel status, const char* fmt, ...);
void DisplayVerboseLog(LogLevel status, const char* fmt, ...);
void CheckDevPoint(void);
void CheckRoot(void);
bool CleanSWPoint(void);
bool LoadLanguage(void);
} /* namespace Functions */
} /* namespace PartitionManager */
/* logging macros */
#define LOGF(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
#define LOGE(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
#define LOGD(fmt, ...) \
PartitionManager::Functions::DisplayLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
/* verbose logging macros */
#define VLOGF(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
#define VLOGE(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
#define VLOGW(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
#define VLOGD(fmt, ...) \
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
/* end of code */

View File

@@ -0,0 +1,132 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
/* The struct is a very good option for setting the languages of texts etc. */
struct langdb_general {
const char* _Nonnull lang_by_s;
const char* _Nonnull language;
const char* _Nonnull lang_prefix;
const char* _Nonnull not_logical;
const char* _Nonnull not_file;
const char* _Nonnull not_dir;
const char* _Nonnull not_in_dev;
const char* _Nonnull not_open;
const char* _Nonnull not_block;
const char* _Nonnull not_read;
const char* _Nonnull not_readdir;
const char* _Nonnull not_write;
const char* _Nonnull not_gen;
const char* _Nonnull no_root;
const char* _Nonnull expected_backup_arg;
const char* _Nonnull expected_flash_arg;
const char* _Nonnull expected_format_arg;
const char* _Nonnull expected_partsz_arg;
const char* _Nonnull missing_operand;
const char* _Nonnull multiple_wiewers;
const char* _Nonnull symbol_rule;
const char* _Nonnull req_part_name;
const char* _Nonnull part_not_found;
const char* _Nonnull unsupported_fs;
const char* _Nonnull cannot_stat;
const char* _Nonnull ffile_more_part;
const char* _Nonnull cannot_get_bsz;
const char* _Nonnull format_fail;
const char* _Nonnull fail_get_psize;
const char* _Nonnull depr_backup_opt;
const char* _Nonnull depr_flash_opt;
const char* _Nonnull depr_format_opt;
const char* _Nonnull depr_Vlicense_opt;
const char* _Nonnull depr_ch_list_opt;
const char* _Nonnull depr_ch_sp_opt;
const char* _Nonnull not_spec_opt;
const char* _Nonnull some_spec;
const char* _Nonnull logical_warn;
const char* _Nonnull ab_warn;
const char* _Nonnull out_not_spec;
const char* _Nonnull no_found_on_process;
const char* _Nonnull please_rerun;
const char* _Nonnull part_disk_sz;
const char* _Nonnull flash_file_sz;
const char* _Nonnull part_disk_sz_fail;
const char* _Nonnull flash_file_sz_fail;
const char* _Nonnull unknown_opr;
const char* _Nonnull req_an_arg;
const char* _Nonnull list_of_general;
const char* _Nonnull list_of_logc;
const char* _Nonnull success_backup;
const char* _Nonnull success_flash;
const char* _Nonnull success_format;
const char* _Nonnull formatting;
const char* _Nonnull warn;
const char* _Nonnull fatal;
const char* _Nonnull is_requires_arg;
const char* _Nonnull only_partsz_args;
const char* _Nonnull unknw_arg;
const char* _Nonnull switching_lang;
const char* _Nonnull welcome;
const char* _Nullable welcome_;
const char* _Nonnull for_more;
const char* _Nonnull s_and_v;
const char* _Nonnull try_h;
const char* _Nonnull usage_head;
const char* _Nonnull depr_opt_str;
const char* _Nonnull switched_opt_str;
const char* _Nonnull not_changed_opt;
const char* _Nonnull compiler_str;
const char* _Nonnull version_str;
const char* _Nonnull bin_str;
const char* _Nonnull part_name;
const char* _Nonnull part_type;
const char* _Nonnull fs_str;
const char* _Nonnull unknw_str;
const char* _Nonnull by_str;
const char* _Nonnull yes;
const char* _Nonnull no;
};
/* docs etc. */
struct langdb_docs {
const char* _Nonnull docs_strs_l1;
const char* _Nonnull docs_strs_l2;
const char* _Nonnull docs_strs_l3;
const char* _Nonnull docs_strs_l4;
const char* _Nonnull docs_strs_l5;
const char* _Nonnull docs_strs_l6;
const char* _Nonnull docs_strs_l7;
const char* _Nonnull docs_strs_l8;
const char* _Nonnull docs_strs_l9;
const char* _Nonnull docs_strs_l10;
const char* _Nonnull docs_strs_l11;
const char* _Nonnull docs_strs_l12;
const char* _Nonnull docs_strs_l13;
const char* _Nonnull docs_strs_l14;
const char* _Nonnull docs_strs_l15;
const char* _Nonnull docs_strs_l16;
const char* _Nonnull docs_strs_l17;
const char* _Nonnull docs_strs_l18;
const char* _Nonnull docs_strs_l19;
const char* _Nonnull docs_strs_l20;
const char* _Nonnull docs_strs_l21;
const char* _Nonnull docs_strs_l22;
const char* _Nonnull or_str;
const char* _Nonnull usage_docstr;
};
/* end of code */

View File

@@ -0,0 +1,36 @@
/* By YZBruh */
/*
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <android/ndk-version.h>
#include <PartitionManager/generated/clang-version.h>
#include <e2fsprogs/version.h>
/* versioning */
#define PMT_MAJOR 2
#define PMT_MINOR 9
#define PMT_PATCHLEVEL 1
namespace PartitionManager {
namespace Functions {
void DisplayVersion(void);
}
}
/* end */

496
include/e2fsprogs/blkid/blkid.h Executable file
View File

@@ -0,0 +1,496 @@
/*
* blkid.h - Interface for libblkid, a library to identify block devices
*
* Copyright (C) 2001 Andreas Dilger
* Copyright (C) 2003 Theodore Ts'o
* Copyright (C) 2008 Karel Zak <kzak@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _BLKID_BLKID_H
#define _BLKID_BLKID_H
#include <stdint.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* blkid_dev:
*
* The device object keeps information about one device
*/
typedef struct blkid_struct_dev *blkid_dev;
/**
* blkid_cache:
*
* information about all system devices
*/
typedef struct blkid_struct_cache *blkid_cache;
/**
* blkid_probe:
*
* low-level probing setting
*/
typedef struct blkid_struct_probe *blkid_probe;
/**
* blkid_topology:
*
* device topology information
*/
typedef struct blkid_struct_topology *blkid_topology;
/**
* blkid_partlist
*
* list of all detected partitions and partitions tables
*/
typedef struct blkid_struct_partlist *blkid_partlist;
/**
* blkid_partition:
*
* information about a partition
*/
typedef struct blkid_struct_partition *blkid_partition;
/**
* blkid_parttable:
*
* information about a partition table
*/
typedef struct blkid_struct_parttable *blkid_parttable;
/**
* blkid_loff_t:
*
* 64-bit signed number for offsets and sizes
*/
typedef int64_t blkid_loff_t;
/**
* blkid_tag_iterate:
*
* tags iterator for high-level (blkid_cache) API
*/
typedef struct blkid_struct_tag_iterate *blkid_tag_iterate;
/**
* blkid_dev_iterate:
*
* devices iterator for high-level (blkid_cache) API
*/
typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
/*
* Flags for blkid_get_dev
*
* BLKID_DEV_CREATE Create an empty device structure if not found
* in the cache.
* BLKID_DEV_VERIFY Make sure the device structure corresponds
* with reality.
* BLKID_DEV_FIND Just look up a device entry, and return NULL
* if it is not found.
* BLKID_DEV_NORMAL Get a valid device structure, either from the
* cache or by probing the device.
*/
#define BLKID_DEV_FIND 0x0000
#define BLKID_DEV_CREATE 0x0001
#define BLKID_DEV_VERIFY 0x0002
#define BLKID_DEV_NORMAL (BLKID_DEV_CREATE | BLKID_DEV_VERIFY)
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
#ifndef __ul_attribute__
# if __GNUC_PREREQ (3, 4)
# define __ul_attribute__(_a_) __attribute__(_a_)
# else
# define __ul_attribute__(_a_)
# endif
#endif
/* init.c */
extern void blkid_init_debug(int mask);
/* cache.c */
extern void blkid_put_cache(blkid_cache cache);
extern int blkid_get_cache(blkid_cache *cache, const char *filename);
extern void blkid_gc_cache(blkid_cache cache);
/* dev.c */
extern const char *blkid_dev_devname(blkid_dev dev)
__ul_attribute__((warn_unused_result));
extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache);
extern int blkid_dev_set_search(blkid_dev_iterate iter,
const char *search_type, const char *search_value);
extern int blkid_dev_next(blkid_dev_iterate iterate, blkid_dev *dev);
extern void blkid_dev_iterate_end(blkid_dev_iterate iterate);
/* devno.c */
extern char *blkid_devno_to_devname(dev_t devno)
__ul_attribute__((warn_unused_result));
extern int blkid_devno_to_wholedisk(dev_t dev, char *diskname,
size_t len, dev_t *diskdevno)
__ul_attribute__((warn_unused_result));
/* devname.c */
extern int blkid_probe_all(blkid_cache cache);
extern int blkid_probe_all_new(blkid_cache cache);
extern int blkid_probe_all_removable(blkid_cache cache);
extern blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags);
/* getsize.c */
extern blkid_loff_t blkid_get_dev_size(int fd);
/* verify.c */
extern blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev);
/* read.c */
/* resolve.c */
extern char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
const char *devname)
__ul_attribute__((warn_unused_result));
extern char *blkid_get_devname(blkid_cache cache, const char *token,
const char *value)
__ul_attribute__((warn_unused_result));
/* tag.c */
extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev);
extern int blkid_tag_next(blkid_tag_iterate iterate,
const char **type, const char **value);
extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
extern int blkid_dev_has_tag(blkid_dev dev, const char *type, const char *value);
extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
const char *type,
const char *value);
extern int blkid_parse_tag_string(const char *token, char **ret_type, char **ret_val);
/* version.c */
extern int blkid_parse_version_string(const char *ver_string)
__ul_attribute__((nonnull));
extern int blkid_get_library_version(const char **ver_string,
const char **date_string);
/* encode.c */
extern int blkid_encode_string(const char *str, char *str_enc, size_t len);
extern int blkid_safe_string(const char *str, char *str_safe, size_t len);
/* evaluate.c */
extern int blkid_send_uevent(const char *devname, const char *action);
extern char *blkid_evaluate_tag(const char *token, const char *value,
blkid_cache *cache)
__ul_attribute__((warn_unused_result));
extern char *blkid_evaluate_spec(const char *spec, blkid_cache *cache)
__ul_attribute__((warn_unused_result));
/* probe.c */
extern blkid_probe blkid_new_probe(void)
__ul_attribute__((warn_unused_result));
extern blkid_probe blkid_new_probe_from_filename(const char *filename)
__ul_attribute__((warn_unused_result))
__ul_attribute__((nonnull));
extern void blkid_free_probe(blkid_probe pr);
extern void blkid_reset_probe(blkid_probe pr);
extern int blkid_probe_reset_buffers(blkid_probe pr);
extern int blkid_probe_hide_range(blkid_probe pr, uint64_t off, uint64_t len);
extern int blkid_probe_set_device(blkid_probe pr, int fd,
blkid_loff_t off, blkid_loff_t size)
__ul_attribute__((nonnull));
extern dev_t blkid_probe_get_devno(blkid_probe pr)
__ul_attribute__((nonnull));
extern dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_is_wholedisk(blkid_probe pr)
__ul_attribute__((nonnull));
extern blkid_loff_t blkid_probe_get_size(blkid_probe pr)
__ul_attribute__((nonnull));
extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr)
__ul_attribute__((nonnull));
extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_set_sectorsize(blkid_probe pr, unsigned int sz)
__ul_attribute__((nonnull));
extern blkid_loff_t blkid_probe_get_sectors(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_get_fd(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_set_hint(blkid_probe pr, const char *name, uint64_t value)
__ul_attribute__((nonnull));
extern void blkid_probe_reset_hints(blkid_probe pr)
__ul_attribute__((nonnull));
/*
* superblocks probing
*/
extern int blkid_known_fstype(const char *fstype)
__ul_attribute__((nonnull));
extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage);
extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
#define BLKID_SUBLKS_FSINFO (1 << 11) /* read and define fs properties from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
extern int blkid_probe_set_superblocks_flags(blkid_probe pr, int flags)
__ul_attribute__((nonnull));
extern int blkid_probe_reset_superblocks_filter(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_invert_superblocks_filter(blkid_probe pr)
__ul_attribute__((nonnull));
/**
* BLKID_FLTR_NOTIN
*/
#define BLKID_FLTR_NOTIN 1
/**
* BLKID_FLTR_ONLYIN
*/
#define BLKID_FLTR_ONLYIN 2
extern int blkid_probe_filter_superblocks_type(blkid_probe pr, int flag, char *names[])
__ul_attribute__((nonnull));
#define BLKID_USAGE_FILESYSTEM (1 << 1)
#define BLKID_USAGE_RAID (1 << 2)
#define BLKID_USAGE_CRYPTO (1 << 3)
#define BLKID_USAGE_OTHER (1 << 4)
extern int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage)
__ul_attribute__((nonnull));
/*
* topology probing
*/
extern int blkid_probe_enable_topology(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
/* binary interface */
extern blkid_topology blkid_probe_get_topology(blkid_probe pr)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_alignment_offset(blkid_topology tp)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_minimum_io_size(blkid_topology tp)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_optimal_io_size(blkid_topology tp)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_logical_sector_size(blkid_topology tp)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_dax(blkid_topology tp)
__ul_attribute__((nonnull));
extern uint64_t blkid_topology_get_diskseq(blkid_topology tp)
__ul_attribute__((nonnull));
/*
* partitions probing
*/
extern int blkid_known_pttype(const char *pttype);
extern int blkid_partitions_get_name(const size_t idx, const char **name);
extern int blkid_probe_enable_partitions(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
extern int blkid_probe_reset_partitions_filter(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_invert_partitions_filter(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *names[])
__ul_attribute__((nonnull));
/* partitions probing flags */
#define BLKID_PARTS_FORCE_GPT (1 << 1)
#define BLKID_PARTS_ENTRY_DETAILS (1 << 2)
#define BLKID_PARTS_MAGIC (1 << 3)
extern int blkid_probe_set_partitions_flags(blkid_probe pr, int flags)
__ul_attribute__((nonnull));
/* binary interface */
extern blkid_partlist blkid_probe_get_partitions(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_partlist_numof_partitions(blkid_partlist ls)
__ul_attribute__((nonnull));
extern blkid_parttable blkid_partlist_get_table(blkid_partlist ls)
__ul_attribute__((nonnull));
extern blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n)
__ul_attribute__((nonnull));
extern blkid_partition blkid_partlist_get_partition_by_partno(blkid_partlist ls, int n)
__ul_attribute__((nonnull));
extern blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno)
__ul_attribute__((nonnull));
extern blkid_parttable blkid_partition_get_table(blkid_partition par)
__ul_attribute__((nonnull));
extern const char *blkid_partition_get_name(blkid_partition par)
__ul_attribute__((nonnull));
extern const char *blkid_partition_get_uuid(blkid_partition par)
__ul_attribute__((nonnull));
extern int blkid_partition_get_partno(blkid_partition par)
__ul_attribute__((nonnull));
extern blkid_loff_t blkid_partition_get_start(blkid_partition par)
__ul_attribute__((nonnull));
extern blkid_loff_t blkid_partition_get_size(blkid_partition par)
__ul_attribute__((nonnull));
extern int blkid_partition_get_type(blkid_partition par)
__ul_attribute__((nonnull));
extern const char *blkid_partition_get_type_string(blkid_partition par)
__ul_attribute__((nonnull));
extern unsigned long long blkid_partition_get_flags(blkid_partition par)
__ul_attribute__((nonnull));
extern int blkid_partition_is_logical(blkid_partition par)
__ul_attribute__((nonnull));
extern int blkid_partition_is_extended(blkid_partition par)
__ul_attribute__((nonnull));
extern int blkid_partition_is_primary(blkid_partition par)
__ul_attribute__((nonnull));
extern const char *blkid_parttable_get_type(blkid_parttable tab)
__ul_attribute__((nonnull));
extern const char *blkid_parttable_get_id(blkid_parttable tab)
__ul_attribute__((nonnull));
extern blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
__ul_attribute__((nonnull));
extern blkid_partition blkid_parttable_get_parent(blkid_parttable tab)
__ul_attribute__((nonnull));
/*
* NAME=value low-level interface
*/
extern int blkid_do_probe(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_do_safeprobe(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_do_fullprobe(blkid_probe pr)
__ul_attribute__((nonnull));
/**
* BLKID_PROBE_OK:
*
* probing return value; superblock (RAID, partiton table, ...) succesfully detected
*/
#define BLKID_PROBE_OK 0
/**
* BLKID_PROBE_NONE:
*
* probing return value; found nothing
*/
#define BLKID_PROBE_NONE 1
/**
* BLKID_PROBE_ERROR:
*
* probing return value; probing ends with en error (see errno for more details)
*/
#define BLKID_PROBE_ERROR -1
/**
* BLKID_PROBE_AMBIGUOUS:
*
* probing return value; more than one probing result, in this case, it's not
* safe to use the device automaticaly and user intervention is recommended
*/
#define BLKID_PROBE_AMBIGUOUS -2
extern int blkid_probe_numof_values(blkid_probe pr)
__ul_attribute__((nonnull));
extern int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
const char **data, size_t *len)
__ul_attribute__((nonnull(1)));
extern int blkid_probe_lookup_value(blkid_probe pr, const char *name,
const char **data, size_t *len)
__ul_attribute__((nonnull(1, 2)));
extern int blkid_probe_has_value(blkid_probe pr, const char *name)
__ul_attribute__((nonnull));
extern int blkid_do_wipe(blkid_probe pr, int dryrun)
__ul_attribute__((nonnull));
extern int blkid_probe_step_back(blkid_probe pr)
__ul_attribute__((nonnull));
/*
* Deprecated functions/macros
*/
#ifndef BLKID_DISABLE_DEPRECATED
#define BLKID_PROBREQ_LABEL BLKID_SUBLKS_LABEL
#define BLKID_PROBREQ_LABELRAW BLKID_SUBLKS_LABELRAW
#define BLKID_PROBREQ_UUID BLKID_SUBLKS_UUID
#define BLKID_PROBREQ_UUIDRAW BLKID_SUBLKS_UUIDRAW
#define BLKID_PROBREQ_TYPE BLKID_SUBLKS_TYPE
#define BLKID_PROBREQ_SECTYPE BLKID_SUBLKS_SECTYPE
#define BLKID_PROBREQ_USAGE BLKID_SUBLKS_USAGE
#define BLKID_PROBREQ_VERSION BLKID_SUBLKS_VERSION
extern int blkid_probe_set_request(blkid_probe pr, int flags)
__ul_attribute__((deprecated));
extern int blkid_probe_filter_usage(blkid_probe pr, int flag, int usage)
__ul_attribute__((deprecated));
extern int blkid_probe_filter_types(blkid_probe pr, int flag, char *names[])
__ul_attribute__((deprecated));
extern int blkid_probe_invert_filter(blkid_probe pr)
__ul_attribute__((deprecated));
extern int blkid_probe_reset_filter(blkid_probe pr)
__ul_attribute__((deprecated));
#endif /* BLKID_DISABLE_DEPRECATED */
#ifdef __cplusplus
}
#endif
#endif /* _BLKID_BLKID_H */

204
include/e2fsprogs/blkid/blkidP.h Executable file
View File

@@ -0,0 +1,204 @@
/*
* blkidP.h - Internal interfaces for libblkid
*
* Copyright (C) 2001 Andreas Dilger
* Copyright (C) 2003 Theodore Ts'o
*
* %Begin-Header%
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
* %End-Header%
*/
#ifndef _BLKID_BLKIDP_H
#define _BLKID_BLKIDP_H
#include <sys/types.h>
#include <stdio.h>
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include <blkid/blkid_local.h>
#include <blkid/list.h>
#ifdef __GNUC__
#define __BLKID_ATTR(x) __attribute__(x)
#else
#define __BLKID_ATTR(x)
#endif
/*
* This describes the attributes of a specific device.
* We can traverse all of the tags by bid_tags (linking to the tag bit_names).
* The bid_label and bid_uuid fields are shortcuts to the LABEL and UUID tag
* values, if they exist.
*/
struct blkid_struct_dev
{
struct list_head bid_devs; /* All devices in the cache */
struct list_head bid_tags; /* All tags for this device */
blkid_cache bid_cache; /* Dev belongs to this cache */
char *bid_name; /* Device inode pathname */
char *bid_type; /* Preferred device TYPE */
int bid_pri; /* Device priority */
dev_t bid_devno; /* Device major/minor number */
time_t bid_time; /* Last update time of device */
unsigned int bid_flags; /* Device status bitflags */
char *bid_label; /* Shortcut to device LABEL */
char *bid_uuid; /* Shortcut to binary UUID */
};
#define BLKID_BID_FL_VERIFIED 0x0001 /* Device data validated from disk */
#define BLKID_BID_FL_INVALID 0x0004 /* Device is invalid */
/*
* Each tag defines a NAME=value pair for a particular device. The tags
* are linked via bit_names for a single device, so that traversing the
* names list will get you a list of all tags associated with a device.
* They are also linked via bit_values for all devices, so one can easily
* search all tags with a given NAME for a specific value.
*/
struct blkid_struct_tag
{
struct list_head bit_tags; /* All tags for this device */
struct list_head bit_names; /* All tags with given NAME */
char *bit_name; /* NAME of tag (shared) */
char *bit_val; /* value of tag */
blkid_dev bit_dev; /* pointer to device */
};
typedef struct blkid_struct_tag *blkid_tag;
/*
* Minimum number of seconds between device probes, even when reading
* from the cache. This is to avoid re-probing all devices which were
* just probed by another program that does not share the cache.
*/
#define BLKID_PROBE_MIN 2
/*
* Time in seconds an entry remains verified in the in-memory cache
* before being reverified (in case of long-running processes that
* keep a cache in memory and continue to use it for a long time).
*/
#define BLKID_PROBE_INTERVAL 200
/* This describes an entire blkid cache file and probed devices.
* We can traverse all of the found devices via bic_list.
* We can traverse all of the tag types by bic_tags, which hold empty tags
* for each tag type. Those tags can be used as list_heads for iterating
* through all devices with a specific tag type (e.g. LABEL).
*/
struct blkid_struct_cache
{
struct list_head bic_devs; /* List head of all devices */
struct list_head bic_tags; /* List head of all tag types */
time_t bic_time; /* Last probe time */
time_t bic_ftime; /* Mod time of the cachefile */
unsigned int bic_flags; /* Status flags of the cache */
char *bic_filename; /* filename of cache */
};
#define BLKID_BIC_FL_PROBED 0x0002 /* We probed /proc/partition devices */
#define BLKID_BIC_FL_CHANGED 0x0004 /* Cache has changed from disk */
extern char *blkid_strdup(const char *s);
extern char *blkid_strndup(const char *s, const int length);
#define BLKID_CACHE_FILE "/etc/blkid.tab"
#define BLKID_ERR_IO 5
#define BLKID_ERR_PROC 9
#define BLKID_ERR_MEM 12
#define BLKID_ERR_CACHE 14
#define BLKID_ERR_DEV 19
#define BLKID_ERR_PARAM 22
#define BLKID_ERR_BIG 27
/*
* Priority settings for different types of devices
*/
#define BLKID_PRI_DM 40
#define BLKID_PRI_EVMS 30
#define BLKID_PRI_LVM 20
#define BLKID_PRI_MD 10
#if defined(TEST_PROGRAM) && !defined(CONFIG_BLKID_DEBUG)
#define CONFIG_BLKID_DEBUG
#endif
#define DEBUG_CACHE 0x0001
#define DEBUG_DUMP 0x0002
#define DEBUG_DEV 0x0004
#define DEBUG_DEVNAME 0x0008
#define DEBUG_DEVNO 0x0010
#define DEBUG_PROBE 0x0020
#define DEBUG_READ 0x0040
#define DEBUG_RESOLVE 0x0080
#define DEBUG_SAVE 0x0100
#define DEBUG_TAG 0x0200
#define DEBUG_INIT 0x8000
#define DEBUG_ALL 0xFFFF
#ifdef CONFIG_BLKID_DEBUG
#include <stdio.h>
extern int blkid_debug_mask;
#define DBG(m,x) if ((m) & blkid_debug_mask) x;
#else
#define DBG(m,x)
#endif
#ifdef CONFIG_BLKID_DEBUG
extern void blkid_debug_dump_dev(blkid_dev dev);
extern void blkid_debug_dump_tag(blkid_tag tag);
#endif
static inline int blkidP_is_disk_device(mode_t mode)
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
return S_ISBLK(mode) || S_ISCHR(mode);
#else
return S_ISBLK(mode);
#endif
}
/* devno.c */
struct dir_list {
char *name;
struct dir_list *next;
};
extern void blkid__scan_dir(const char *, dev_t, struct dir_list **, char **);
/* lseek.c */
extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence);
/* read.c */
extern void blkid_read_cache(blkid_cache cache);
/* save.c */
extern int blkid_flush_cache(blkid_cache cache);
/*
* Functions to create and find a specific tag type: tag.c
*/
extern void blkid_free_tag(blkid_tag tag);
extern blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type);
extern int blkid_set_tag(blkid_dev dev, const char *name,
const char *value, const int vlength);
/*
* Functions to create and find a specific tag type: dev.c
*/
extern blkid_dev blkid_new_dev(void);
extern void blkid_free_dev(blkid_dev dev);
#ifdef __cplusplus
}
#endif
#endif /* _BLKID_BLKIDP_H */

View File

@@ -0,0 +1,110 @@
/*
* blkid.h - Interface for libblkid, a library to identify block devices
*
* Copyright (C) 2001 Andreas Dilger
* Copyright (C) 2003 Theodore Ts'o
*
* %Begin-Header%
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
* %End-Header%
*/
#ifndef _BLKID_BLKID_H
#define _BLKID_BLKID_H
#include <sys/types.h>
#include <blkid/blkid_types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BLKID_VERSION "2.40.2"
#define BLKID_DATE "04-Jul-2024"
typedef struct blkid_struct_dev *blkid_dev;
typedef struct blkid_struct_cache *blkid_cache;
typedef __s64 blkid_loff_t;
typedef struct blkid_struct_tag_iterate *blkid_tag_iterate;
typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
/*
* Flags for blkid_get_dev
*
* BLKID_DEV_CREATE Create an empty device structure if not found
* in the cache.
* BLKID_DEV_VERIFY Make sure the device structure corresponds
* with reality.
* BLKID_DEV_FIND Just look up a device entry, and return NULL
* if it is not found.
* BLKID_DEV_NORMAL Get a valid device structure, either from the
* cache or by probing the device.
*/
#define BLKID_DEV_FIND 0x0000
#define BLKID_DEV_CREATE 0x0001
#define BLKID_DEV_VERIFY 0x0002
#define BLKID_DEV_NORMAL (BLKID_DEV_CREATE | BLKID_DEV_VERIFY)
/* cache.c */
extern void blkid_put_cache(blkid_cache cache);
extern int blkid_get_cache(blkid_cache *cache, const char *filename);
extern void blkid_gc_cache(blkid_cache cache);
/* dev.c */
extern const char *blkid_dev_devname(blkid_dev dev);
extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache);
extern int blkid_dev_set_search(blkid_dev_iterate iter,
char *search_type, char *search_value);
extern int blkid_dev_next(blkid_dev_iterate iterate, blkid_dev *dev);
extern void blkid_dev_iterate_end(blkid_dev_iterate iterate);
/* devno.c */
extern char *blkid_devno_to_devname(dev_t devno);
/* devname.c */
extern int blkid_probe_all(blkid_cache cache);
extern int blkid_probe_all_new(blkid_cache cache);
extern blkid_dev blkid_get_dev(blkid_cache cache, const char *devname,
int flags);
/* getsize.c */
extern blkid_loff_t blkid_get_dev_size(int fd);
/* probe.c */
int blkid_known_fstype(const char *fstype);
extern blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev);
/* read.c */
/* resolve.c */
extern char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
const char *devname);
extern char *blkid_get_devname(blkid_cache cache, const char *token,
const char *value);
/* tag.c */
extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev);
extern int blkid_tag_next(blkid_tag_iterate iterate,
const char **type, const char **value);
extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
const char *value);
extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
const char *type,
const char *value);
extern int blkid_parse_tag_string(const char *token, char **ret_type,
char **ret_val);
/* version.c */
extern int blkid_parse_version_string(const char *ver_string);
extern int blkid_get_library_version(const char **ver_string,
const char **date_string);
#ifdef __cplusplus
}
#endif
#endif /* _BLKID_BLKID_H */

View File

@@ -0,0 +1,45 @@
/*
* If linux/types.h is already been included, assume it has defined
* everything we need. (cross fingers) Other header files may have
* also defined the types that we need.
*/
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
!defined(_EXT2_TYPES_H) && !defined(_UUID_TYPES_H))
#define _BLKID_TYPES_H
typedef unsigned char __u8;
typedef __signed__ char __s8;
typedef unsigned short __u16;
typedef __signed__ short __s16;
typedef unsigned int __u32;
typedef __signed__ int __s32;
typedef unsigned long long __u64;
typedef __signed__ long long __s64;
#endif
#include <stdint.h> //uintptr_t
/* endian checking stuff */
#ifndef EXT2_ENDIAN_H_
#define EXT2_ENDIAN_H_
#ifdef __CHECKER__
#ifndef __bitwise
#define __bitwise __attribute__((bitwise))
#endif
#define __force __attribute__((force))
#else
#ifndef __bitwise
#define __bitwise
#endif
#define __force
#endif
typedef __u16 __bitwise __le16;
typedef __u32 __bitwise __le32;
typedef __u64 __bitwise __le64;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __be64;
#endif /* EXT2_ENDIAN_H_ */

184
include/e2fsprogs/blkid/list.h Executable file
View File

@@ -0,0 +1,184 @@
#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD_INIT)
#define _BLKID_LIST_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#else
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#endif
#ifdef __GNUC__
#define _INLINE_ static __inline__
#else /* For Watcom C */
#define _INLINE_ static inline
#endif
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
_INLINE_ void __list_add(struct list_head * add,
struct list_head * prev,
struct list_head * next)
{
next->prev = add;
add->next = next;
add->prev = prev;
prev->next = add;
}
/**
* list_add - add a new entry
* @add: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
_INLINE_ void list_add(struct list_head *add, struct list_head *head)
{
__list_add(add, head, head->next);
}
/**
* list_add_tail - add a new entry
* @add: new entry to be added
* @head: list head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
_INLINE_ void list_add_tail(struct list_head *add, struct list_head *head)
{
__list_add(add, head->prev, head);
}
/*
* Delete a list entry by making the prev/next entries
* point to each other.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
_INLINE_ void __list_del(struct list_head * prev,
struct list_head * next)
{
next->prev = prev;
prev->next = next;
}
/**
* list_del - deletes entry from list.
* @entry: the element to delete from the list.
*
* list_empty() on @entry does not return true after this, @entry is
* in an undefined state.
*/
_INLINE_ void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
}
/**
* list_del_init - deletes entry from list and reinitialize it.
* @entry: the element to delete from the list.
*/
_INLINE_ void list_del_init(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
INIT_LIST_HEAD(entry);
}
/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
_INLINE_ int list_empty(struct list_head *head)
{
return head->next == head;
}
/**
* list_splice - join two lists
* @list: the new list to add.
* @head: the place to add it in the first list.
*/
_INLINE_ void list_splice(struct list_head *list, struct list_head *head)
{
struct list_head *first = list->next;
if (first != list) {
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
}
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(intptr_t)(&((type *)0)->member)))
/**
* list_for_each - iterate over elements in a list
* @pos: the &struct list_head to use as a loop counter.
* @head: the head for your list.
*/
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
/**
* list_for_each_safe - iterate over elements in a list, but don't dereference
* pos after the body is done (in case it is freed)
* @pos: the &struct list_head to use as a loop counter.
* @pnext: the &struct list_head to use as a pointer to the next item.
* @head: the head for your list (not included in iteration).
*/
#define list_for_each_safe(pos, pnext, head) \
for (pos = (head)->next, pnext = pos->next; pos != (head); \
pos = pnext, pnext = pos->next)
#undef _INLINE_
#ifdef __cplusplus
}
#endif
#endif /* _BLKID_LIST_H */

852
include/e2fsprogs/blkid/probe.h Executable file
View File

@@ -0,0 +1,852 @@
/*
* probe.h - constants and on-disk structures for extracting device data
*
* Copyright (C) 1999 by Andries Brouwer
* Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
* Copyright (C) 2001 by Andreas Dilger
*
* %Begin-Header%
* This file may be redistributed under the terms of the
* GNU Lesser General Public License.
* %End-Header%
*/
#ifndef _BLKID_PROBE_H
#define _BLKID_PROBE_H
#include <stdint.h>
#include <blkid/blkid_types.h>
struct blkid_magic;
#define SB_BUFFER_SIZE 0x11000
struct blkid_probe {
int fd;
blkid_cache cache;
blkid_dev dev;
unsigned char *sbbuf;
size_t sb_valid;
unsigned char *buf;
size_t buf_max;
};
typedef int (*blkid_probe_t)(struct blkid_probe *probe,
struct blkid_magic *id, unsigned char *buf);
struct blkid_magic {
const char *bim_type; /* type name for this magic */
long bim_kboff; /* kilobyte offset of superblock */
unsigned bim_sboff; /* byte offset within superblock */
unsigned bim_len; /* length of magic */
const char *bim_magic; /* magic string */
blkid_probe_t bim_probe; /* probe function */
};
/*
* Structures for each of the content types we want to extract information
* from. We do not necessarily need the magic field here, because we have
* already identified the content type before we get this far. It may still
* be useful if there are probe functions which handle multiple content types.
*/
struct ext2_super_block {
__u32 s_inodes_count;
__u32 s_blocks_count;
__u32 s_r_blocks_count;
__u32 s_free_blocks_count;
__u32 s_free_inodes_count;
__u32 s_first_data_block;
__u32 s_log_block_size;
__u32 s_dummy3[7];
unsigned char s_magic[2];
__u16 s_state;
__u32 s_dummy5[8];
__u32 s_feature_compat;
__u32 s_feature_incompat;
__u32 s_feature_ro_compat;
unsigned char s_uuid[16];
char s_volume_name[16];
char s_last_mounted[64];
__u32 s_algorithm_usage_bitmap;
__u8 s_prealloc_blocks;
__u8 s_prealloc_dir_blocks;
__u16 s_reserved_gdt_blocks;
__u8 s_journal_uuid[16];
__u32 s_journal_inum;
__u32 s_journal_dev;
__u32 s_last_orphan;
__u32 s_hash_seed[4];
__u8 s_def_hash_version;
__u8 s_jnl_backup_type;
__u16 s_reserved_word_pad;
__u32 s_default_mount_opts;
__u32 s_first_meta_bg;
__u32 s_mkfs_time;
__u32 s_jnl_blocks[17];
__u32 s_blocks_count_hi;
__u32 s_r_blocks_count_hi;
__u32 s_free_blocks_hi;
__u16 s_min_extra_isize;
__u16 s_want_extra_isize;
__u32 s_flags;
__u16 s_raid_stride;
__u16 s_mmp_interval;
__u64 s_mmp_block;
__u32 s_raid_stripe_width;
__u32 s_reserved[163];
};
/* for s_flags */
#define EXT2_FLAGS_TEST_FILESYS 0x0004
/* for s_feature_compat */
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
/* for s_feature_ro_compat */
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
/* for s_feature_incompat */
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
EXT2_FEATURE_INCOMPAT_META_BG)
#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
EXT3_FEATURE_INCOMPAT_RECOVER| \
EXT2_FEATURE_INCOMPAT_META_BG)
#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED ~EXT3_FEATURE_INCOMPAT_SUPP
#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT3_FEATURE_RO_COMPAT_SUPP
struct xfs_super_block {
unsigned char xs_magic[4];
__u32 xs_blocksize;
__u64 xs_dblocks;
__u64 xs_rblocks;
__u32 xs_dummy1[2];
unsigned char xs_uuid[16];
__u32 xs_dummy2[15];
char xs_fname[12];
__u32 xs_dummy3[2];
__u64 xs_icount;
__u64 xs_ifree;
__u64 xs_fdblocks;
};
struct reiserfs_super_block {
__u32 rs_blocks_count;
__u32 rs_free_blocks;
__u32 rs_root_block;
__u32 rs_journal_block;
__u32 rs_journal_dev;
__u32 rs_orig_journal_size;
__u32 rs_dummy2[5];
__u16 rs_blocksize;
__u16 rs_dummy3[3];
unsigned char rs_magic[12];
__u32 rs_dummy4[5];
unsigned char rs_uuid[16];
char rs_label[16];
};
struct reiser4_super_block {
unsigned char rs4_magic[16];
__u16 rs4_dummy[2];
unsigned char rs4_uuid[16];
unsigned char rs4_label[16];
__u64 rs4_dummy2;
};
struct jfs_super_block {
unsigned char js_magic[4];
__u32 js_version;
__u64 js_size;
__u32 js_bsize; /* 4: aggregate block size in bytes */
__u16 js_l2bsize; /* 2: log2 of s_bsize */
__u16 js_l2bfactor; /* 2: log2(s_bsize/hardware block size) */
__u32 js_pbsize; /* 4: hardware/LVM block size in bytes */
__u16 js_l2pbsize; /* 2: log2 of s_pbsize */
__u16 js_pad; /* 2: padding necessary for alignment */
__u32 js_dummy2[26];
unsigned char js_uuid[16];
unsigned char js_label[16];
unsigned char js_loguuid[16];
};
struct romfs_super_block {
unsigned char ros_magic[8];
__u32 ros_dummy1[2];
unsigned char ros_volume[16];
};
struct cramfs_super_block {
__u8 magic[4];
__u32 size;
__u32 flags;
__u32 future;
__u8 signature[16];
struct cramfs_info {
__u32 crc;
__u32 edition;
__u32 blocks;
__u32 files;
} info;
__u8 name[16];
};
struct swap_id_block {
/* unsigned char sws_boot[1024]; */
__u32 sws_version;
__u32 sws_lastpage;
__u32 sws_nrbad;
unsigned char sws_uuid[16];
char sws_volume[16];
unsigned char sws_pad[117];
__u32 sws_badpg;
};
/* Yucky misaligned values */
struct vfat_super_block {
/* 00*/ unsigned char vs_ignored[3];
/* 03*/ unsigned char vs_sysid[8];
/* 0b*/ unsigned char vs_sector_size[2];
/* 0d*/ __u8 vs_cluster_size;
/* 0e*/ __u16 vs_reserved;
/* 10*/ __u8 vs_fats;
/* 11*/ unsigned char vs_dir_entries[2];
/* 13*/ unsigned char vs_sectors[2];
/* 15*/ unsigned char vs_media;
/* 16*/ __u16 vs_fat_length;
/* 18*/ __u16 vs_secs_track;
/* 1a*/ __u16 vs_heads;
/* 1c*/ __u32 vs_hidden;
/* 20*/ __u32 vs_total_sect;
/* 24*/ __u32 vs_fat32_length;
/* 28*/ __u16 vs_flags;
/* 2a*/ __u8 vs_version[2];
/* 2c*/ __u32 vs_root_cluster;
/* 30*/ __u16 vs_insfo_sector;
/* 32*/ __u16 vs_backup_boot;
/* 34*/ __u16 vs_reserved2[6];
/* 40*/ unsigned char vs_unknown[3];
/* 43*/ unsigned char vs_serno[4];
/* 47*/ unsigned char vs_label[11];
/* 52*/ unsigned char vs_magic[8];
/* 5a*/ unsigned char vs_dummy2[164];
/*1fe*/ unsigned char vs_pmagic[2];
};
/* Yucky misaligned values */
struct msdos_super_block {
/* 00*/ unsigned char ms_ignored[3];
/* 03*/ unsigned char ms_sysid[8];
/* 0b*/ unsigned char ms_sector_size[2];
/* 0d*/ __u8 ms_cluster_size;
/* 0e*/ __u16 ms_reserved;
/* 10*/ __u8 ms_fats;
/* 11*/ unsigned char ms_dir_entries[2];
/* 13*/ unsigned char ms_sectors[2];
/* 15*/ unsigned char ms_media;
/* 16*/ __u16 ms_fat_length;
/* 18*/ __u16 ms_secs_track;
/* 1a*/ __u16 ms_heads;
/* 1c*/ __u32 ms_hidden;
/* 20*/ __u32 ms_total_sect;
/* 24*/ unsigned char ms_unknown[3];
/* 27*/ unsigned char ms_serno[4];
/* 2b*/ unsigned char ms_label[11];
/* 36*/ unsigned char ms_magic[8];
/* 3d*/ unsigned char ms_dummy2[192];
/*1fe*/ unsigned char ms_pmagic[2];
};
struct vfat_dir_entry {
__u8 name[11];
__u8 attr;
__u16 time_creat;
__u16 date_creat;
__u16 time_acc;
__u16 date_acc;
__u16 cluster_high;
__u16 time_write;
__u16 date_write;
__u16 cluster_low;
__u32 size;
};
/* maximum number of clusters */
#define FAT12_MAX 0xFF4
#define FAT16_MAX 0xFFF4
#define FAT32_MAX 0x0FFFFFF6
struct minix_super_block {
__u16 ms_ninodes;
__u16 ms_nzones;
__u16 ms_imap_blocks;
__u16 ms_zmap_blocks;
__u16 ms_firstdatazone;
__u16 ms_log_zone_size;
__u32 ms_max_size;
unsigned char ms_magic[2];
__u16 ms_state;
__u32 ms_zones;
};
struct mdp_superblock_s {
__u32 md_magic;
__u32 major_version;
__u32 minor_version;
__u32 patch_version;
__u32 gvalid_words;
__u32 set_uuid0;
__u32 ctime;
__u32 level;
__u32 size;
__u32 nr_disks;
__u32 raid_disks;
__u32 md_minor;
__u32 not_persistent;
__u32 set_uuid1;
__u32 set_uuid2;
__u32 set_uuid3;
};
struct hfs_super_block {
char h_magic[2];
char h_dummy[18];
__u32 h_blksize;
};
struct ocfs_volume_header {
unsigned char minor_version[4];
unsigned char major_version[4];
unsigned char signature[128];
char mount[128];
unsigned char mount_len[2];
};
struct ocfs_volume_label {
unsigned char disk_lock[48];
char label[64];
unsigned char label_len[2];
unsigned char vol_id[16];
unsigned char vol_id_len[2];
};
#define ocfsmajor(o) ((__u32)o.major_version[0] \
+ (((__u32) o.major_version[1]) << 8) \
+ (((__u32) o.major_version[2]) << 16) \
+ (((__u32) o.major_version[3]) << 24))
#define ocfslabellen(o) ((__u32)o.label_len[0] + (((__u32) o.label_len[1]) << 8))
#define ocfsmountlen(o) ((__u32)o.mount_len[0] + (((__u32) o.mount_len[1])<<8))
#define OCFS_MAGIC "OracleCFS"
struct ocfs2_super_block {
unsigned char signature[8];
unsigned char s_dummy1[184];
unsigned char s_dummy2[80];
char s_label[64];
unsigned char s_uuid[16];
};
#define OCFS2_MIN_BLOCKSIZE 512
#define OCFS2_MAX_BLOCKSIZE 4096
#define OCFS2_SUPER_BLOCK_BLKNO 2
#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
struct oracle_asm_disk_label {
char dummy[32];
char dl_tag[8];
char dl_id[24];
};
#define ORACLE_ASM_DISK_LABEL_MARKED "ORCLDISK"
#define ORACLE_ASM_DISK_LABEL_OFFSET 32
struct iso_volume_descriptor {
unsigned char vd_type;
unsigned char vd_id[5];
unsigned char vd_version;
unsigned char flags;
unsigned char system_id[32];
unsigned char volume_id[32];
unsigned char unused[8];
unsigned char space_size[8];
unsigned char escape_sequences[8];
};
/* Common gfs/gfs2 constants: */
#define GFS_MAGIC 0x01161970
#define GFS_DEFAULT_BSIZE 4096
#define GFS_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE)
#define GFS_METATYPE_SB 1
#define GFS_FORMAT_SB 100
#define GFS_LOCKNAME_LEN 64
/* gfs1 constants: */
#define GFS_FORMAT_FS 1309
#define GFS_FORMAT_MULTI 1401
/* gfs2 constants: */
#define GFS2_FORMAT_FS 1801
#define GFS2_FORMAT_MULTI 1900
struct gfs2_meta_header {
__u32 mh_magic;
__u32 mh_type;
__u64 __pad0; /* Was generation number in gfs1 */
__u32 mh_format;
__u32 __pad1; /* Was incarnation number in gfs1 */
};
struct gfs2_inum {
__u64 no_formal_ino;
__u64 no_addr;
};
struct gfs2_sb {
struct gfs2_meta_header sb_header;
__u32 sb_fs_format;
__u32 sb_multihost_format;
__u32 __pad0; /* Was superblock flags in gfs1 */
__u32 sb_bsize;
__u32 sb_bsize_shift;
__u32 __pad1; /* Was journal segment size in gfs1 */
struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
struct gfs2_inum sb_root_dir;
char sb_lockproto[GFS_LOCKNAME_LEN];
char sb_locktable[GFS_LOCKNAME_LEN];
/* In gfs1, quota and license dinodes followed */
};
struct ntfs_super_block {
__u8 jump[3];
__u8 oem_id[8];
__u8 bios_parameter_block[25];
__u16 unused[2];
__u64 number_of_sectors;
__u64 mft_cluster_location;
__u64 mft_mirror_cluster_location;
__s8 cluster_per_mft_record;
__u8 reserved1[3];
__s8 cluster_per_index_record;
__u8 reserved2[3];
__u64 volume_serial;
__u16 checksum;
};
struct master_file_table_record {
__u32 magic;
__u16 usa_ofs;
__u16 usa_count;
__u64 lsn;
__u16 sequence_number;
__u16 link_count;
__u16 attrs_offset;
__u16 flags;
__u32 bytes_in_use;
__u32 bytes_allocated;
} __attribute__((__packed__));
struct file_attribute {
__u32 type;
__u32 len;
__u8 non_resident;
__u8 name_len;
__u16 name_offset;
__u16 flags;
__u16 instance;
__u32 value_len;
__u16 value_offset;
} __attribute__((__packed__));
#define MFT_RECORD_VOLUME 3
#define MFT_RECORD_ATTR_VOLUME_NAME 0x60
#define MFT_RECORD_ATTR_VOLUME_INFO 0x70
#define MFT_RECORD_ATTR_OBJECT_ID 0x40
#define MFT_RECORD_ATTR_END 0xffffffffu
/* HFS / HFS+ */
struct hfs_finder_info {
__u32 boot_folder;
__u32 start_app;
__u32 open_folder;
__u32 os9_folder;
__u32 reserved;
__u32 osx_folder;
__u8 id[8];
} __attribute__((packed));
struct hfs_mdb {
__u8 signature[2];
__u32 cr_date;
__u32 ls_Mod;
__u16 atrb;
__u16 nm_fls;
__u16 vbm_st;
__u16 alloc_ptr;
__u16 nm_al_blks;
__u32 al_blk_size;
__u32 clp_size;
__u16 al_bl_st;
__u32 nxt_cnid;
__u16 free_bks;
__u8 label_len;
__u8 label[27];
__u32 vol_bkup;
__u16 vol_seq_num;
__u32 wr_cnt;
__u32 xt_clump_size;
__u32 ct_clump_size;
__u16 num_root_dirs;
__u32 file_count;
__u32 dir_count;
struct hfs_finder_info finder_info;
__u8 embed_sig[2];
__u16 embed_startblock;
__u16 embed_blockcount;
} __attribute__((packed));
#define HFS_NODE_LEAF 0xff
#define HFSPLUS_POR_CNID 1
struct hfsplus_bnode_descriptor {
__u32 next;
__u32 prev;
__u8 type;
__u8 height;
__u16 num_recs;
__u16 reserved;
} __attribute__((packed));
struct hfsplus_bheader_record {
__u16 depth;
__u32 root;
__u32 leaf_count;
__u32 leaf_head;
__u32 leaf_tail;
__u16 node_size;
} __attribute__((packed));
struct hfsplus_catalog_key {
__u16 key_len;
__u32 parent_id;
__u16 unicode_len;
__u8 unicode[255 * 2];
} __attribute__((packed));
struct hfsplus_extent {
__u32 start_block;
__u32 block_count;
} __attribute__((packed));
#define HFSPLUS_EXTENT_COUNT 8
struct hfsplus_fork {
__u64 total_size;
__u32 clump_size;
__u32 total_blocks;
struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
} __attribute__((packed));
struct hfsplus_vol_header {
__u8 signature[2];
__u16 version;
__u32 attributes;
__u32 last_mount_vers;
__u32 reserved;
__u32 create_date;
__u32 modify_date;
__u32 backup_date;
__u32 checked_date;
__u32 file_count;
__u32 folder_count;
__u32 blocksize;
__u32 total_blocks;
__u32 free_blocks;
__u32 next_alloc;
__u32 rsrc_clump_sz;
__u32 data_clump_sz;
__u32 next_cnid;
__u32 write_count;
__u64 encodings_bmp;
struct hfs_finder_info finder_info;
struct hfsplus_fork alloc_file;
struct hfsplus_fork ext_file;
struct hfsplus_fork cat_file;
struct hfsplus_fork attr_file;
struct hfsplus_fork start_file;
} __attribute__((packed));
/* this is lvm's label_header & pv_header combined. */
#define LVM2_ID_LEN 32
struct lvm2_pv_label_header {
/* label_header */
__u8 id[8]; /* LABELONE */
__u64 sector_xl; /* Sector number of this label */
__u32 crc_xl; /* From next field to end of sector */
__u32 offset_xl; /* Offset from start of struct to contents */
__u8 type[8]; /* LVM2 001 */
/* pv_header */
__u8 pv_uuid[LVM2_ID_LEN];
} __attribute__ ((packed));
/*
* this is a very generous portion of the super block, giving us
* room to translate 14 chunks with 3 stripes each.
*/
#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
#define BTRFS_LABEL_SIZE 256
#define BTRFS_UUID_SIZE 16
#define BTRFS_FSID_SIZE 16
#define BTRFS_CSUM_SIZE 32
struct btrfs_dev_item {
/* the internal btrfs device id */
__u64 devid;
/* size of the device */
__u64 total_bytes;
/* bytes used */
__u64 bytes_used;
/* optimal io alignment for this device */
__u32 io_align;
/* optimal io width for this device */
__u32 io_width;
/* minimal io size for this device */
__u32 sector_size;
/* type and info about this device */
__u64 type;
/* expected generation for this device */
__u64 generation;
/*
* starting byte of this partition on the device,
* to allow for stripe alignment in the future
*/
__u64 start_offset;
/* grouping information for allocation decisions */
__u32 dev_group;
/* seek speed 0-100 where 100 is fastest */
__u8 seek_speed;
/* bandwidth 0-100 where 100 is fastest */
__u8 bandwidth;
/* btrfs generated uuid for this device */
__u8 uuid[BTRFS_UUID_SIZE];
/* uuid of FS who owns this device */
__u8 fsid[BTRFS_UUID_SIZE];
} __attribute__ ((__packed__));
/*
* the super block basically lists the main trees of the FS
* it currently lacks any block count etc etc
*/
struct btrfs_super_block {
__u8 csum[BTRFS_CSUM_SIZE];
/* the first 3 fields must match struct btrfs_header */
__u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
__u64 bytenr; /* this block number */
__u64 flags;
/* allowed to be different from the btrfs_header from here own down */
__u64 magic;
__u64 generation;
__u64 root;
__u64 chunk_root;
__u64 log_root;
/* this will help find the new super based on the log root */
__u64 log_root_transid;
__u64 total_bytes;
__u64 bytes_used;
__u64 root_dir_objectid;
__u64 num_devices;
__u32 sectorsize;
__u32 nodesize;
__u32 leafsize;
__u32 stripesize;
__u32 sys_chunk_array_size;
__u64 chunk_root_generation;
__u64 compat_flags;
__u64 compat_ro_flags;
__u64 incompat_flags;
__u16 csum_type;
__u8 root_level;
__u8 chunk_root_level;
__u8 log_root_level;
struct btrfs_dev_item dev_item;
char label[BTRFS_LABEL_SIZE];
/* future expansion */
__u64 reserved[32];
__u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
} __attribute__ ((__packed__));
#define F2FS_MAX_EXTENSION 64 /* # of extension entries */
struct f2fs_super_block {
__u32 magic; /* Magic Number */
__u16 major_ver; /* Major Version */
__u16 minor_ver; /* Minor Version */
__u32 log_sectorsize; /* log2 sector size in bytes */
__u32 log_sectors_per_block; /* log2 # of sectors per block */
__u32 log_blocksize; /* log2 block size in bytes */
__u32 log_blocks_per_seg; /* log2 # of blocks per segment */
__u32 segs_per_sec; /* # of segments per section */
__u32 secs_per_zone; /* # of sections per zone */
__u32 checksum_offset; /* checksum offset inside super block */
__u64 block_count; /* total # of user blocks */
__u32 section_count; /* total # of sections */
__u32 segment_count; /* total # of segments */
__u32 segment_count_ckpt; /* # of segments for checkpoint */
__u32 segment_count_sit; /* # of segments for SIT */
__u32 segment_count_nat; /* # of segments for NAT */
__u32 segment_count_ssa; /* # of segments for SSA */
__u32 segment_count_main; /* # of segments for main area */
__u32 segment0_blkaddr; /* start block address of segment 0 */
__u32 cp_blkaddr; /* start block address of checkpoint */
__u32 sit_blkaddr; /* start block address of SIT */
__u32 nat_blkaddr; /* start block address of NAT */
__u32 ssa_blkaddr; /* start block address of SSA */
__u32 main_blkaddr; /* start block address of main area */
__u32 root_ino; /* root inode number */
__u32 node_ino; /* node inode number */
__u32 meta_ino; /* meta inode number */
__u8 uuid[16]; /* 128-bit uuid for volume */
__u16 volume_name[512]; /* volume name */
__u32 extension_count; /* # of extensions below */
__u8 extension_list[F2FS_MAX_EXTENSION][8]; /* extension array */
} __attribute__((__packed__));
struct exfat_super_block {
uint8_t jump[3];
uint8_t oem_name[8];
uint8_t __unused1[53];
uint64_t block_start;
uint64_t block_count;
uint32_t fat_block_start;
uint32_t fat_block_count;
uint32_t cluster_block_start;
uint32_t cluster_count;
uint32_t rootdir_cluster;
uint8_t volume_serial[4];
struct {
uint8_t vermin;
uint8_t vermaj;
} version;
uint16_t volume_state;
uint8_t block_bits;
uint8_t bpc_bits;
uint8_t fat_count;
uint8_t drive_no;
uint8_t allocated_percent;
} __attribute__((__packed__));
struct exfat_entry_label {
uint8_t type;
uint8_t length;
uint8_t name[30];
} __attribute__((__packed__));
#define BLOCK_SIZE(sb) (1 << (sb)->block_bits)
#define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)
#define EXFAT_FIRST_DATA_CLUSTER 2
#define EXFAT_LAST_DATA_CLUSTER 0xffffff6
#define EXFAT_ENTRY_SIZE 32
#define EXFAT_ENTRY_EOD 0x00
#define EXFAT_ENTRY_LABEL 0x83
/*
* Byte swap functions
*/
#ifdef __GNUC__
#define _INLINE_ static __inline__
#else /* For Watcom C */
#define _INLINE_ static inline
#endif
_INLINE_ __u16 blkid_swab16(__u16 val)
{
return (val >> 8) | (val << 8);
}
_INLINE_ __u32 blkid_swab32(__u32 val)
{
return ((val>>24) | ((val>>8)&0xFF00) |
((val<<8)&0xFF0000) | (val<<24));
}
_INLINE_ __u64 blkid_swab64(__u64 val)
{
return (blkid_swab32(val >> 32) |
(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
}
#ifdef WORDS_BIGENDIAN
#define blkid_le16(x) blkid_swab16(x)
#define blkid_le32(x) blkid_swab32(x)
#define blkid_le64(x) blkid_swab64(x)
#define blkid_be16(x) (x)
#define blkid_be32(x) (x)
#define blkid_be64(x) (x)
#else
#define blkid_le16(x) (x)
#define blkid_le32(x) (x)
#define blkid_le64(x) (x)
#define blkid_be16(x) blkid_swab16(x)
#define blkid_be32(x) blkid_swab32(x)
#define blkid_be64(x) blkid_swab64(x)
#endif
#undef _INLINE_
#endif /* _BLKID_PROBE_H */

678
include/e2fsprogs/config.h Executable file
View File

@@ -0,0 +1,678 @@
/* lib/config.h. Generated from config.h.in by configure. */
/* lib/config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* Define to 1 if debugging the blkid library */
/* #undef CONFIG_BLKID_DEBUG */
/* Define to 1 to compile findfs */
/* #undef CONFIG_BUILD_FINDFS */
/* Define to 1 for features for use by ext4 developers */
/* #undef CONFIG_DEVELOPER_FEATURES */
/* Define to 1 if using dlopen to access libarchive */
#define CONFIG_DLOPEN_LIBARCHIVE 1
/* Define to 1 if debugging ext3/4 journal code */
/* #undef CONFIG_JBD_DEBUG */
/* Define to 1 to enable mmp support */
#define CONFIG_MMP 1
/* Define to 1 to enable tdb support */
#define CONFIG_TDB 1
/* Define to 1 if the testio I/O manager should be enabled */
#define CONFIG_TESTIO_DEBUG 1
/* Define to 1 to disable use of backtrace */
/* #undef DISABLE_BACKTRACE */
/* Define to 1 to enable bitmap stats. */
#define ENABLE_BMAP_STATS 1
/* Define to 1 to enable bitmap stats. */
/* #undef ENABLE_BMAP_STATS_OPS */
/* Define to 1 if translation of program messages to the user's native
language is requested. */
/* #undef ENABLE_NLS */
/* Define to the version of FUSE to use */
#define FUSE_USE_VERSION 29
/* Define to 1 if you have the `add_key' function. */
/* #undef HAVE_ADD_KEY */
/* Define to 1 if you have the <archive.h> header file. */
#define HAVE_ARCHIVE_H 1
/* Define to 1 if you have the <attr/xattr.h> header file. */
/* #undef HAVE_ATTR_XATTR_H */
/* Define to 1 if you have the `backtrace' function. */
#define HAVE_BACKTRACE 1
/* Define to 1 if blkid has blkid_probe_enable_partitions */
// #define HAVE_BLKID_PROBE_ENABLE_PARTITIONS 1
/* Define to 1 if blkid has blkid_probe_get_topology */
/* #undef HAVE_BLKID_PROBE_GET_TOPOLOGY */
/* Define to 1 if blkid has blkid_topology_get_dax */
/* #undef HAVE_BLKID_TOPOLOGY_GET_DAX */
/* Define to 1 if you have the BSD-style 'qsort_r' function. */
/* #undef HAVE_BSD_QSORT_R */
/* Define to 1 if you have the Mac OS X function
CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES */
/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
the CoreFoundation framework. */
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
/* Define to 1 if you have the `chflags' function. */
/* #undef HAVE_CHFLAGS */
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
/* #undef HAVE_DCGETTEXT */
/* Define to 1 if you have the <dirent.h> header file. */
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the `dlopen' function. */
#define HAVE_DLOPEN 1
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the <execinfo.h> header file. */
#define HAVE_EXECINFO_H 1
/* Define to 1 if Ext2 ioctls present */
#define HAVE_EXT2_IOCTLS 1
/* Define to 1 if you have the `fadvise64' function. */
/* #undef HAVE_FADVISE64 */
/* Define to 1 if you have the `fallocate' function. */
#define HAVE_FALLOCATE 1
/* Define to 1 if you have the `fallocate64' function. */
#define HAVE_FALLOCATE64 1
/* Define to 1 if you have the `fchown' function. */
#define HAVE_FCHOWN 1
/* Define to 1 if you have the `fcntl' function. */
#define HAVE_FCNTL 1
/* Define to 1 if you have the `fdatasync' function. */
#define HAVE_FDATASYNC 1
/* Define to 1 if fsmap_sizeof() is declared in linux/fsmap.h */
/* #undef HAVE_FSMAP_SIZEOF */
/* Define to 1 if you have the `fstat64' function. */
#define HAVE_FSTAT64 1
/* Define to 1 if you have the `fsync' function. */
#define HAVE_FSYNC 1
/* Define to 1 if you have the `ftruncate64' function. */
#define HAVE_FTRUNCATE64 1
/* Define to 1 if you have the <fuse.h> header file. */
#define HAVE_FUSE_H 1
/* Define to 1 if you have the `futimes' function. */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the `getcwd' function. */
#define HAVE_GETCWD 1
/* Define to 1 if you have the `getdtablesize' function. */
/* #undef HAVE_GETDTABLESIZE */
/* Define to 1 if you have the `getentropy' function. */
#define HAVE_GETENTROPY 1
/* Define to 1 if you have the `gethostname' function. */
#define HAVE_GETHOSTNAME 1
/* Define to 1 if you have the `getmntinfo' function. */
/* #undef HAVE_GETMNTINFO */
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define to 1 if you have the `getpwuid_r' function. */
#define HAVE_GETPWUID_R 1
/* Define to 1 if you have the `getrandom' function. */
#define HAVE_GETRANDOM 1
/* Define to 1 if you have the `getrlimit' function. */
#define HAVE_GETRLIMIT 1
/* Define to 1 if you have the `getrusage' function. */
#define HAVE_GETRUSAGE 1
/* Define if the GNU gettext() function is already present or preinstalled. */
/* #undef HAVE_GETTEXT */
/* Define to 1 if you have the GNU-style 'qsort_r' function. */
/* #undef HAVE_GNU_QSORT_R */
/* Define if you have the iconv() function and it works. */
#define HAVE_ICONV 1
/* Define to 1 if the system has the type `intptr_t'. */
#define HAVE_INTPTR_T 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `jrand48' function. */
#define HAVE_JRAND48 1
/* Define to 1 if you have the `keyctl' function. */
/* #undef HAVE_KEYCTL */
/* Define to 1 if you have the <linux/falloc.h> header file. */
#define HAVE_LINUX_FALLOC_H 1
/* Define to 1 if you have the <linux/fd.h> header file. */
#define HAVE_LINUX_FD_H 1
/* Define to 1 if you have the <linux/fsmap.h> header file. */
#define HAVE_LINUX_FSMAP_H 1
/* Define to 1 if you have the <linux/loop.h> header file. */
#define HAVE_LINUX_LOOP_H 1
/* Define to 1 if you have the <linux/major.h> header file. */
#define HAVE_LINUX_MAJOR_H 1
/* Define to 1 if you have the <linux/types.h> header file. */
#define HAVE_LINUX_TYPES_H 1
/* Define to 1 if you have the `llistxattr' function. */
#define HAVE_LLISTXATTR 1
/* Define to 1 if you have the `llseek' function. */
/* #undef HAVE_LLSEEK */
/* Define to 1 if llseek declared in unistd.h */
/* #undef HAVE_LLSEEK_PROTOTYPE */
/* Define to 1 if you have the `lseek64' function. */
#define HAVE_LSEEK64 1
/* Define to 1 if lseek64 declared in unistd.h */
#define HAVE_LSEEK64_PROTOTYPE 1
/* Define to 1 if you have the <magic.h> header file. */
#define HAVE_MAGIC_H 1
/* Define to 1 if you have the `mallinfo' function. */
#define HAVE_MALLINFO 1
/* Define to 1 if you have the `mallinfo2' function. */
/* #undef HAVE_MALLINFO2 */
/* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define to 1 if you have the `mbstowcs' function. */
#define HAVE_MBSTOWCS 1
/* Define to 1 if you have the `memalign' function. */
#define HAVE_MEMALIGN 1
/* Define to 1 if you have the `mempcpy' function. */
#define HAVE_MEMPCPY 1
/* Define to 1 if you have the <minix/config.h> header file. */
/* #undef HAVE_MINIX_CONFIG_H */
/* Define to 1 if you have the `mmap' function. */
#define HAVE_MMAP 1
/* Define to 1 if you have the <mntent.h> header file. */
#define HAVE_MNTENT_H 1
/* Define to 1 if mount supports nodev. */
#define HAVE_MOUNT_NODEV 1
/* Define to 1 if mount supports nosuid. */
#define HAVE_MOUNT_NOSUID 1
/* Define to 1 if you have the `msync' function. */
#define HAVE_MSYNC 1
/* Define to 1 if you have the `nanosleep' function. */
#define HAVE_NANOSLEEP 1
/* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <net/if_dl.h> header file. */
/* #undef HAVE_NET_IF_DL_H */
/* Define to 1 if you have the <net/if.h> header file. */
#define HAVE_NET_IF_H 1
/* Define to 1 if you have the `open64' function. */
#define HAVE_OPEN64 1
/* Define to 1 if optreset for getopt is present */
/* #undef HAVE_OPTRESET */
/* Define to 1 if you have the `pathconf' function. */
#define HAVE_PATHCONF 1
/* Define to 1 if you have the <paths.h> header file. */
#define HAVE_PATHS_H 1
/* Define to 1 if you have the `posix_fadvise' function. */
#define HAVE_POSIX_FADVISE 1
/* Define to 1 if you have the `posix_fadvise64' function. */
#define HAVE_POSIX_FADVISE64 1
/* Define to 1 if you have the `posix_memalign' function. */
#define HAVE_POSIX_MEMALIGN 1
/* Define to 1 if you have the `prctl' function. */
#define HAVE_PRCTL 1
/* Define to 1 if you have the `pread' function. */
#define HAVE_PREAD 1
/* Define to 1 if you have the `pread64' function. */
#define HAVE_PREAD64 1
/* Define if you have POSIX threads libraries and header files. */
#define HAVE_PTHREAD 1
/* Define to 1 if you have the <pthread.h> header file. */
#define HAVE_PTHREAD_H 1
/* Have PTHREAD_PRIO_INHERIT. */
#define HAVE_PTHREAD_PRIO_INHERIT 1
/* Define to 1 if you have the `pwrite' function. */
#define HAVE_PWRITE 1
/* Define to 1 if you have the `pwrite64' function. */
#define HAVE_PWRITE64 1
/* Define to 1 if you have the `qsort_r' function. */
/* #undef HAVE_QSORT_R */
/* Define to 1 if dirent has d_reclen */
#define HAVE_RECLEN_DIRENT 1
/* Define to 1 if if struct sockaddr contains sa_len */
/* #undef HAVE_SA_LEN */
/* Define to 1 if you have the `secure_getenv' function. */
/* #undef HAVE_SECURE_GETENV */
/* Define to 1 if you have the <semaphore.h> header file. */
#define HAVE_SEMAPHORE_H 1
/* Define to 1 if sem_init() exists */
/* #undef HAVE_SEM_INIT */
/* Define to 1 if you have the <setjmp.h> header file. */
#define HAVE_SETJMP_H 1
/* Define to 1 if you have the `setmntent' function. */
#define HAVE_SETMNTENT 1
/* Define to 1 if you have the `setresgid' function. */
#define HAVE_SETRESGID 1
/* Define to 1 if you have the `setresuid' function. */
#define HAVE_SETRESUID 1
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1
/* Define to 1 if you have the `srandom' function. */
#define HAVE_SRANDOM 1
/* Define to 1 if struct stat has st_flags */
/* #undef HAVE_STAT_FLAGS */
/* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `stpcpy' function. */
#define HAVE_STPCPY 1
/* Define to 1 if you have the `strcasecmp' function. */
#define HAVE_STRCASECMP 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strnlen' function. */
#define HAVE_STRNLEN 1
/* Define to 1 if you have the `strptime' function. */
#define HAVE_STRPTIME 1
/* Define to 1 if you have the `strtoull' function. */
#define HAVE_STRTOULL 1
/* Define to 1 if `st_atim' is a member of `struct stat'. */
#define HAVE_STRUCT_STAT_ST_ATIM 1
/* Define to 1 if you have the `sync_file_range' function. */
#define HAVE_SYNC_FILE_RANGE 1
/* Define to 1 if you have the `sysconf' function. */
#define HAVE_SYSCONF 1
/* Define to 1 if you have the <sys/acl.h> header file. */
/* #undef HAVE_SYS_ACL_H */
/* Define to 1 if you have the <sys/disklabel.h> header file. */
/* #undef HAVE_SYS_DISKLABEL_H */
/* Define to 1 if you have the <sys/disk.h> header file. */
/* #undef HAVE_SYS_DISK_H */
/* Define to 1 if you have the <sys/file.h> header file. */
#define HAVE_SYS_FILE_H 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/key.h> header file. */
/* #undef HAVE_SYS_KEY_H */
/* Define to 1 if you have the <sys/mkdev.h> header file. */
/* #undef HAVE_SYS_MKDEV_H */
/* Define to 1 if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/mount.h> header file. */
#define HAVE_SYS_MOUNT_H 1
/* Define to 1 if you have the <sys/prctl.h> header file. */
#define HAVE_SYS_PRCTL_H 1
/* Define to 1 if you have the <sys/random.h> header file. */
#define HAVE_SYS_RANDOM_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/sockio.h> header file. */
/* #undef HAVE_SYS_SOCKIO_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/syscall.h> header file. */
#define HAVE_SYS_SYSCALL_H 1
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
#define HAVE_SYS_SYSMACROS_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/un.h> header file. */
#define HAVE_SYS_UN_H 1
/* Define to 1 if you have the <sys/wait.h> header file. */
#define HAVE_SYS_WAIT_H 1
/* Define to 1 if you have the <sys/xattr.h> header file. */
#define HAVE_SYS_XATTR_H 1
/* Define to 1 if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 1
/* Define to 1 if you have the <termio.h> header file. */
#define HAVE_TERMIO_H 1
/* Define to 1 if ssize_t declared */
#define HAVE_TYPE_SSIZE_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `usleep' function. */
#define HAVE_USLEEP 1
/* Define to 1 if you have the `utime' function. */
#define HAVE_UTIME 1
/* Define to 1 if you have the `utimes' function. */
#define HAVE_UTIMES 1
/* Define to 1 if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* Define to 1 if you have the `valloc' function. */
/* #undef HAVE_VALLOC */
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1
/* Define to 1 if you have the `__secure_getenv' function. */
/* #undef HAVE___SECURE_GETENV */
/* package name for gettext */
#define PACKAGE "e2fsprogs"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
/* #undef PTHREAD_CREATE_JOINABLE */
/* The size of `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 8
/* The size of `long long', as computed by sizeof. */
#define SIZEOF_LONG_LONG 8
/* The size of `off_t', as computed by sizeof. */
#define SIZEOF_OFF_T 8
/* The size of `short', as computed by sizeof. */
#define SIZEOF_SHORT 2
/* The size of `time_t', as computed by sizeof. */
#define SIZEOF_TIME_T 8
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#define STDC_HEADERS 1
/* If the compiler supports a TLS storage class define it to that here */
#define TLS __thread
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable general extensions on macOS. */
#ifndef _DARWIN_C_SOURCE
# define _DARWIN_C_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable X/Open compliant socket functions that do not require linking
with -lxnet on HP-UX 11.11. */
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
# define _HPUX_ALT_XOPEN_SOCKET_API 1
#endif
/* Identify the host operating system as Minix.
This macro does not affect the system headers' behavior.
A future release of Autoconf may stop defining this macro. */
#ifndef _MINIX
/* # undef _MINIX */
#endif
/* Enable general extensions on NetBSD.
Enable NetBSD compatibility extensions on Minix. */
#ifndef _NETBSD_SOURCE
# define _NETBSD_SOURCE 1
#endif
/* Enable OpenBSD compatibility extensions on NetBSD.
Oddly enough, this does nothing on OpenBSD. */
#ifndef _OPENBSD_SOURCE
# define _OPENBSD_SOURCE 1
#endif
/* Define to 1 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_SOURCE
/* # undef _POSIX_SOURCE */
#endif
/* Define to 2 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_1_SOURCE
/* # undef _POSIX_1_SOURCE */
#endif
/* Enable POSIX-compatible threading on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
# define __STDC_WANT_IEC_60559_BFP_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# define __STDC_WANT_IEC_60559_DFP_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
#ifndef __STDC_WANT_LIB_EXT2__
# define __STDC_WANT_LIB_EXT2__ 1
#endif
/* Enable extensions specified by ISO/IEC 24747:2009. */
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
# define __STDC_WANT_MATH_SPEC_FUNCS__ 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable X/Open extensions. Define to 500 only if necessary
to make mbstate_t available. */
#ifndef _XOPEN_SOURCE
/* # undef _XOPEN_SOURCE */
#endif
/* Define to 1 to build uuidd */
#define USE_UUIDD 1
/* version for gettext */
#define VERSION "0.14.1"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define to 1 if Apple Darwin libintl workaround is needed */
/* #undef _INTL_REDIRECT_MACROS */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
#include <dirpaths.h>

10
include/e2fsprogs/dirpaths.h Executable file
View File

@@ -0,0 +1,10 @@
/*
* This file contains the path names for various directories as
* controlled by the configure script.
*/
/* Where to put the messages file for internationalization support */
#define LOCALEDIR "/usr/share/locale"
/* Where to find the mke2fs.conf and e2fsck.conf files */
#define ROOT_SYSCONFDIR "/etc"

92
include/e2fsprogs/e2p/e2p.h Executable file
View File

@@ -0,0 +1,92 @@
/*
* e2p.h --- header file for the e2p library
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#include <sys/types.h> /* Needed by dirent.h on netbsd */
#include <stdio.h>
#include <dirent.h>
#include <ext2fs/ext2_fs.h>
#define E2P_FEATURE_COMPAT 0
#define E2P_FEATURE_INCOMPAT 1
#define E2P_FEATURE_RO_INCOMPAT 2
#define E2P_FEATURE_TYPE_MASK 0x03
#define E2P_FEATURE_NEGATE_FLAG 0x80
#define E2P_FS_FEATURE 0
#define E2P_JOURNAL_FEATURE 1
/* `options' for print_flags() */
#define PFOPT_LONG 1 /* Must be 1 for compatibility with `int long_format'. */
int fgetflags (const char * name, unsigned long * flags);
int fgetversion (const char * name, unsigned long * version);
int fsetflags (const char * name, unsigned long flags);
int fsetversion (const char * name, unsigned long version);
int fgetproject(const char *name, unsigned long *project);
int fsetproject(const char *name, unsigned long project);
int getflags (int fd, unsigned long * flags);
int getversion (int fd, unsigned long * version);
int iterate_on_dir (const char * dir_name,
int (*func) (const char *, struct dirent *, void *),
void * private_arg);
void list_super(struct ext2_super_block * s);
void list_super2(struct ext2_super_block * s, FILE *f);
void print_fs_errors (FILE * f, unsigned short errors);
void print_flags (FILE * f, unsigned long flags, unsigned options);
void print_fs_state (FILE * f, unsigned short state);
int setflags (int fd, unsigned long flags);
int setversion (int fd, unsigned long version);
#define E2P_LIST_JOURNAL_FLAG_FC 0x1
void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
int exp_block_size, int flags);
void e2p_feature_to_string(int compat, unsigned int mask, char *buf,
size_t buf_len);
const char *e2p_feature2string(int compat, unsigned int mask);
const char *e2p_jrnl_feature2string(int compat, unsigned int mask);
int e2p_string2feature(char *string, int *compat, unsigned int *mask);
int e2p_jrnl_string2feature(char *string, int *compat_type, unsigned int *mask);
int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array);
int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
__u32 *clear_ok_array, int *type_err,
unsigned int *mask_err);
int e2p_is_null_uuid(void *uu);
void e2p_uuid_to_str(void *uu, char *out);
const char *e2p_uuid2str(void *uu);
const char *e2p_hash2string(int num);
int e2p_string2hash(char *string);
const char *e2p_mntopt2string(unsigned int mask);
int e2p_string2mntopt(char *string, unsigned int *mask);
int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok);
unsigned long parse_num_blocks(const char *arg, int log_block_size);
unsigned long long parse_num_blocks2(const char *arg, int log_block_size);
char *e2p_os2string(int os_type);
int e2p_string2os(char *str);
unsigned int e2p_percent(int percent, unsigned int base);
const char *e2p_encmode2string(int num);
int e2p_string2encmode(char *string);
int e2p_str2encoding(const char *string);
const char *e2p_encoding2str(int encoding);
int e2p_get_encoding_flags(int encoding);
int e2p_str2encoding_flags(int encoding, char *param, __u16 *flags);
const char *e2p_errcode2str(unsigned int err);

27
include/e2fsprogs/e2p/project.h Executable file
View File

@@ -0,0 +1,27 @@
/*
* project.h
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#include <ext2fs/ext2_fs.h>
#if defined(__linux__) && !defined(FS_IOC_FSGETXATTR)
#define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr)
#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
/*
* Structure for FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR.
*/
struct fsxattr {
__u32 fsx_xflags; /* xflags field value (get/set) */
__u32 fsx_extsize; /* extsize field value (get/set)*/
__u32 fsx_nextents; /* nextents field value (get) */
__u32 fsx_projid; /* project identifier (get/set) */
unsigned char fsx_pad[12];
};
#endif

68
include/e2fsprogs/et/com_err.h Executable file
View File

@@ -0,0 +1,68 @@
/*
* Header file for common error description library.
*
* Copyright 1988, Student Information Processing Board of the
* Massachusetts Institute of Technology.
*
* For copyright and distribution info, see the documentation supplied
* with this package.
*/
#if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)
#ifdef __GNUC__
#define COM_ERR_ATTR(x) __attribute__(x)
#else
#define COM_ERR_ATTR(x)
#endif
#include <stddef.h>
#include <stdarg.h>
typedef long errcode_t;
struct error_table {
char const * const * msgs;
long base;
int n_msgs;
};
struct et_list;
extern void com_err (const char *, long, const char *, ...)
COM_ERR_ATTR((format(printf, 3, 4)));
extern void com_err_va (const char *whoami, errcode_t code, const char *fmt,
va_list args)
COM_ERR_ATTR((format(printf, 3, 0)));
extern char const *error_message (long);
extern void (*com_err_hook) (const char *, long, const char *, va_list);
extern void (*set_com_err_hook (void (*) (const char *, long,
const char *, va_list)))
(const char *, long, const char *, va_list);
extern void (*reset_com_err_hook (void)) (const char *, long,
const char *, va_list);
extern int init_error_table(const char * const *msgs, long base, int count);
extern char *(*set_com_err_gettext (char *(*) (const char *)))
(const char *);
extern errcode_t add_error_table(const struct error_table * et);
extern errcode_t remove_error_table(const struct error_table * et);
extern void add_to_error_table(struct et_list *new_table);
/* Provided for Heimdall compatibility */
extern const char *com_right(struct et_list *list, long code);
extern const char *com_right_r(struct et_list *list, long code, char *str, size_t len);
extern void initialize_error_table_r(struct et_list **list,
const char **messages,
int num_errors,
long base);
extern void free_error_table(struct et_list *et);
/* Provided for compatibility with other com_err libraries */
extern int et_list_lock(void);
extern int et_list_unlock(void);
#define __COM_ERR_H
#define __COM_ERR_H__
#endif /* !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)*/

View File

@@ -0,0 +1,29 @@
/*
* Copyright 1988 by the Student Information Processing Board of the
* Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose is hereby granted, provided that
* the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. M.I.T. and the
* M.I.T. S.I.P.B. make no representations about the suitability of
* this software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#ifndef _ET_H
struct et_list {
struct et_list *next;
const struct error_table *table;
};
extern struct et_list *_et_list, *_et_dynamic_list;
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
extern const char *error_table_name(errcode_t num);
#define _ET_H
#endif

19
include/e2fsprogs/et/internal.h Executable file
View File

@@ -0,0 +1,19 @@
/*
* internal include file for com_err package
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose is hereby granted, provided that
* the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. M.I.T. and the
* M.I.T. S.I.P.B. make no representations about the suitability of
* this software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#include <errno.h>
#ifdef NEED_SYS_ERRLIST
extern char const * const sys_errlist[];
extern const int sys_nerr;
#endif

606
include/e2fsprogs/ext2fs/bitops.h Executable file
View File

@@ -0,0 +1,606 @@
/*
* bitops.h --- Bitmap frobbing code. The byte swapping routines are
* also included here.
*
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifdef WORDS_BIGENDIAN
#define ext2fs_cpu_to_le64(x) ((__force __le64)ext2fs_swab64((__u64)(x)))
#define ext2fs_le64_to_cpu(x) ext2fs_swab64((__force __u64)(__le64)(x))
#define ext2fs_cpu_to_le32(x) ((__force __le32)ext2fs_swab32((__u32)(x)))
#define ext2fs_le32_to_cpu(x) ext2fs_swab32((__force __u32)(__le32)(x))
#define ext2fs_cpu_to_le16(x) ((__force __le16)ext2fs_swab16((__u16)(x)))
#define ext2fs_le16_to_cpu(x) ext2fs_swab16((__force __u16)(__le16)(x))
#define ext2fs_cpu_to_be64(x) ((__force __be64)(__u64)(x))
#define ext2fs_be64_to_cpu(x) ((__force __u64)(__be64)(x))
#define ext2fs_cpu_to_be32(x) ((__force __be32)(__u32)(x))
#define ext2fs_be32_to_cpu(x) ((__force __u32)(__be32)(x))
#define ext2fs_cpu_to_be16(x) ((__force __be16)(__u16)(x))
#define ext2fs_be16_to_cpu(x) ((__force __u16)(__be16)(x))
#else
#define ext2fs_cpu_to_le64(x) ((__force __le64)(__u64)(x))
#define ext2fs_le64_to_cpu(x) ((__force __u64)(__le64)(x))
#define ext2fs_cpu_to_le32(x) ((__force __le32)(__u32)(x))
#define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
#define ext2fs_cpu_to_le16(x) ((__force __le16)(__u16)(x))
#define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
#define ext2fs_cpu_to_be64(x) ((__force __be64)ext2fs_swab64((__u64)(x)))
#define ext2fs_be64_to_cpu(x) ext2fs_swab64((__force __u64)(__be64)(x))
#define ext2fs_cpu_to_be32(x) ((__force __be32)ext2fs_swab32((__u32)(x)))
#define ext2fs_be32_to_cpu(x) ext2fs_swab32((__force __u32)(__be32)(x))
#define ext2fs_cpu_to_be16(x) ((__force __be16)ext2fs_swab16((__u16)(x)))
#define ext2fs_be16_to_cpu(x) ext2fs_swab16((__force __u16)(__be16)(x))
#endif
/*
* EXT2FS bitmap manipulation routines.
*/
/* Support for sending warning messages from the inline subroutines */
extern const char *ext2fs_block_string;
extern const char *ext2fs_inode_string;
extern const char *ext2fs_mark_string;
extern const char *ext2fs_unmark_string;
extern const char *ext2fs_test_string;
extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
const char *description);
extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
int code, unsigned long arg);
#ifdef NO_INLINE_FUNCS
extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
extern __u16 ext2fs_swab16(__u16 val);
extern __u32 ext2fs_swab32(__u32 val);
extern __u64 ext2fs_swab64(__u64 val);
extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
#endif
/* These functions routines moved to gen_bitmap.c */
extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode, int num);
extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
__u32 bitno);
extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno);
extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
blk_t bitno);
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num);
extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
/* 64-bit versions */
#ifdef NO_INLINE_FUNCS
extern int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block);
extern void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
extern errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out);
extern errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out);
extern errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out);
extern errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out);
extern blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap);
extern blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap);
extern ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap);
extern int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num);
extern void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num);
extern void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num);
#endif
/* These routines moved to gen_bitmap64.c */
extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
extern errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
ext2fs_generic_bitmap bm1,
ext2fs_generic_bitmap bm2);
extern void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
blk64_t bitno);
extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
blk64_t bitno);
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
blk64_t bitno);
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap);
extern __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap);
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block, unsigned int num);
extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end,
__u64 *out);
extern errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 start, __u64 end,
__u64 *out);
/*
* The inline routines themselves...
*
* If NO_INLINE_FUNCS is defined, then we won't try to do inline
* functions at all; they will be included as normal functions in
* inline.c
*/
#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
#ifdef INCLUDE_INLINE_FUNCS
#if (__STDC_VERSION__ >= 199901L)
#define _INLINE_ extern inline
#else
#define _INLINE_ inline
#endif
#else /* !INCLUDE_INLINE FUNCS */
#if (__STDC_VERSION__ >= 199901L)
#define _INLINE_ inline
#else /* not C99 */
#ifdef __GNUC__
#define _INLINE_ extern __inline__
#else /* For Watcom C */
#define _INLINE_ extern inline
#endif /* __GNUC__ */
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* INCLUDE_INLINE_FUNCS */
/*
* Fast bit set/clear functions that doesn't need to return the
* previous bit value.
*/
_INLINE_ void ext2fs_fast_set_bit(unsigned int nr,void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR |= (unsigned char) (1 << (nr & 0x07));
}
_INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
}
_INLINE_ void ext2fs_fast_set_bit64(__u64 nr, void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR |= (unsigned char) (1 << (nr & 0x07));
}
_INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr)
{
unsigned char *ADDR = (unsigned char *) addr;
ADDR += nr >> 3;
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
}
_INLINE_ __u16 ext2fs_swab16(__u16 val)
{
return (val >> 8) | (__u16) (val << 8);
}
_INLINE_ __u32 ext2fs_swab32(__u32 val)
{
return ((val>>24) | ((val>>8)&0xFF00) |
((val<<8)&0xFF0000) | (val<<24));
}
_INLINE_ __u64 ext2fs_swab64(__u64 val)
{
return (ext2fs_swab32((__u32) (val >> 32)) |
(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
}
_INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
{
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
return ext2fs_test_block_bitmap_range(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
ext2fs_mark_block_bitmap_range(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
ext2fs_unmark_block_bitmap_range(bitmap, block, num);
}
/* 64-bit versions */
_INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
}
_INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t block)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
block);
}
_INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
}
_INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
inode);
}
_INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = o;
return rv;
}
_INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = (ext2_ino_t) o;
return rv;
}
_INLINE_ errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
blk64_t start,
blk64_t end,
blk64_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = o;
return rv;
}
_INLINE_ errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t start,
ext2_ino_t end,
ext2_ino_t *out)
{
__u64 o;
errcode_t rv;
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
start, end, &o);
if (!rv)
*out = (ext2_ino_t) o;
return rv;
}
_INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)
{
return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)
{
return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)
{
return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
}
_INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num)
{
return ext2fs_test_block_bitmap_range2(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num)
{
ext2fs_mark_block_bitmap_range2(bitmap, block, num);
}
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
blk64_t block,
unsigned int num)
{
ext2fs_unmark_block_bitmap_range2(bitmap, block, num);
}
#undef _INLINE_
#endif
extern int ext2fs_set_bit(unsigned int nr,void * addr);
extern int ext2fs_clear_bit(unsigned int nr, void * addr);
extern int ext2fs_test_bit(unsigned int nr, const void * addr);
extern int ext2fs_set_bit64(__u64 nr,void * addr);
extern int ext2fs_clear_bit64(__u64 nr, void * addr);
extern int ext2fs_test_bit64(__u64 nr, const void * addr);
extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);

106
include/e2fsprogs/ext2fs/bmap64.h Executable file
View File

@@ -0,0 +1,106 @@
/*
* bmap64.h --- 64-bit bitmap structure
*
* Copyright (C) 2007, 2008 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
struct ext2_bmap_statistics {
int type;
struct timeval created;
#ifdef ENABLE_BMAP_STATS_OPS
unsigned long copy_count;
unsigned long resize_count;
unsigned long mark_count;
unsigned long unmark_count;
unsigned long test_count;
unsigned long mark_ext_count;
unsigned long unmark_ext_count;
unsigned long test_ext_count;
unsigned long set_range_count;
unsigned long get_range_count;
unsigned long clear_count;
blk64_t last_marked;
blk64_t last_tested;
blk64_t mark_back;
blk64_t test_back;
unsigned long mark_seq;
unsigned long test_seq;
#endif /* ENABLE_BMAP_STATS_OPS */
};
struct ext2fs_struct_generic_bitmap_64 {
errcode_t magic;
ext2_filsys fs;
struct ext2_bitmap_ops *bitmap_ops;
int flags;
__u64 start, end;
__u64 real_end;
int cluster_bits;
char *description;
void *private;
errcode_t base_error_code;
#ifdef ENABLE_BMAP_STATS
struct ext2_bmap_statistics stats;
#endif
};
typedef struct ext2fs_struct_generic_bitmap_64 *ext2fs_generic_bitmap_64;
#define EXT2FS_IS_32_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
#define EXT2FS_IS_64_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
struct ext2_bitmap_ops {
int type;
/* Generic bmap operators */
errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap_64 bmap);
void (*free_bmap)(ext2fs_generic_bitmap_64 bitmap);
errcode_t (*copy_bmap)(ext2fs_generic_bitmap_64 src,
ext2fs_generic_bitmap_64 dest);
errcode_t (*resize_bmap)(ext2fs_generic_bitmap_64 bitmap,
__u64 new_end,
__u64 new_real_end);
/* bit set/test operators */
int (*mark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
int (*unmark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
int (*test_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
void (*mark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
unsigned int num);
void (*unmark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
unsigned int num);
int (*test_clear_bmap_extent)(ext2fs_generic_bitmap_64 bitmap,
__u64 arg, unsigned int num);
errcode_t (*set_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
__u64 start, size_t num, void *in);
errcode_t (*get_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
__u64 start, size_t num, void *out);
void (*clear_bmap)(ext2fs_generic_bitmap_64 bitmap);
void (*print_stats)(ext2fs_generic_bitmap_64);
/* Find the first zero bit between start and end, inclusive.
* May be NULL, in which case a generic function is used. */
errcode_t (*find_first_zero)(ext2fs_generic_bitmap_64 bitmap,
__u64 start, __u64 end, __u64 *out);
/* Find the first set bit between start and end, inclusive.
* May be NULL, in which case a generic function is used. */
errcode_t (*find_first_set)(ext2fs_generic_bitmap_64 bitmap,
__u64 start, __u64 end, __u64 *out);
};
extern struct ext2_bitmap_ops ext2fs_blkmap64_bitarray;
extern struct ext2_bitmap_ops ext2fs_blkmap64_rbtree;

86
include/e2fsprogs/ext2fs/brel.h Executable file
View File

@@ -0,0 +1,86 @@
/*
* brel.h
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
struct ext2_block_relocate_entry {
blk64_t new;
__s16 offset;
__u16 flags;
union {
blk64_t block_ref;
ext2_ino_t inode_ref;
} owner;
};
#define RELOCATE_TYPE_REF 0x0007
#define RELOCATE_BLOCK_REF 0x0001
#define RELOCATE_INODE_REF 0x0002
typedef struct ext2_block_relocation_table *ext2_brel;
struct ext2_block_relocation_table {
__u32 magic;
char *name;
blk64_t current;
void *priv_data;
/*
* Add a block relocation entry.
*/
errcode_t (*put)(ext2_brel brel, blk64_t old,
struct ext2_block_relocate_entry *ent);
/*
* Get a block relocation entry.
*/
errcode_t (*get)(ext2_brel brel, blk64_t old,
struct ext2_block_relocate_entry *ent);
/*
* Initialize for iterating over the block relocation entries.
*/
errcode_t (*start_iter)(ext2_brel brel);
/*
* The iterator function for the inode relocation entries.
* Returns an inode number of 0 when out of entries.
*/
errcode_t (*next)(ext2_brel brel, blk64_t *old,
struct ext2_block_relocate_entry *ent);
/*
* Move the inode relocation table from one block number to
* another.
*/
errcode_t (*move)(ext2_brel brel, blk64_t old, blk_t new);
/*
* Remove a block relocation entry.
*/
errcode_t (*delete)(ext2_brel brel, blk64_t old);
/*
* Free the block relocation table.
*/
errcode_t (*free)(ext2_brel brel);
};
errcode_t ext2fs_brel_memarray_create(char *name, blk64_t max_block,
ext2_brel *brel);
#define ext2fs_brel_put(brel, old, ent) ((brel)->put((brel), old, ent))
#define ext2fs_brel_get(brel, old, ent) ((brel)->get((brel), old, ent))
#define ext2fs_brel_start_iter(brel) ((brel)->start_iter((brel)))
#define ext2fs_brel_next(brel, old, ent) ((brel)->next((brel), old, ent))
#define ext2fs_brel_move(brel, old, new) ((brel)->move((brel), old, new))
#define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
#define ext2fs_brel_free(brel) ((brel)->free((brel)))

View File

@@ -0,0 +1,26 @@
#ifndef _EXT2FS_COMPILER_H
#define _EXT2FS_COMPILER_H
#include <stddef.h>
#ifdef __GNUC__
#ifndef __GNUC_PREREQ
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj, min) 0
#endif
#endif
#define container_of(ptr, type, member) ({ \
__typeof__( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#else
#define container_of(ptr, type, member) \
((type *)((char *)(ptr) - offsetof(type, member)))
#endif
#endif /* _EXT2FS_COMPILER_H */

View File

@@ -0,0 +1,74 @@
/*
* crc16.c
*
* This source code is licensed under the GNU General Public License,
* Version 2. See the file COPYING for more details.
*/
#include "config.h"
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <ext2fs/ext2_types.h>
#include "crc16.h"
/** CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1) */
static __u16 const crc16_table[256] = {
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
/**
* Compute the CRC-16 for the data buffer
*
* @param crc previous CRC value
* @param buffer data pointer
* @param len number of bytes in the buffer
* @return the updated CRC value
*/
crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len)
{
const unsigned char *cp = buffer;
while (len--)
/*
* for an unknown reason, PPC treats __u16 as signed
* and keeps doing sign extension on the value.
* Instead, use only the low 16 bits of an unsigned
* int for holding the CRC value to avoid this.
*/
crc = (((crc >> 8) & 0xffU) ^
crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU;
return crc;
}

View File

@@ -0,0 +1,26 @@
/*
* crc16.h - CRC-16 routine
*
* Implements the standard CRC-16:
* Width 16
* Poly 0x8005 (x16 + x15 + x2 + 1)
* Init 0
*
* Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
*
* This source code is licensed under the GNU General Public License,
* Version 2. See the file COPYING for more details.
*/
#ifndef __CRC16_H
#define __CRC16_H
/* for an unknown reason, PPC treats __u16 as signed and keeps doing sign
* extension on the value. Instead, use only the low 16 bits of an
* unsigned int for holding the CRC value to avoid this.
*/
typedef unsigned int crc16_t;
extern crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len);
#endif /* __CRC16_H */

View File

@@ -0,0 +1,59 @@
/*
* There are multiple 16-bit CRC polynomials in common use, but this is
* *the* standard CRC-32 polynomial, first popularized by Ethernet.
* x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
*/
#define CRCPOLY_LE 0xedb88320
#define CRCPOLY_BE 0x04c11db7
/*
* This is the CRC32c polynomial, as outlined by Castagnoli.
* x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+
* x^8+x^6+x^0
*/
#define CRC32C_POLY_LE 0x82F63B78
#define CRC32C_POLY_BE 0x1EDC6F41
/* How many bits at a time to use. Valid values are 1, 2, 4, 8, 32 and 64. */
/* For less performance-sensitive, use 4 */
#ifndef CRC_LE_BITS
# define CRC_LE_BITS 64
#endif
#ifndef CRC_BE_BITS
# define CRC_BE_BITS 64
#endif
/*
* Little-endian CRC computation. Used with serial bit streams sent
* lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC.
*/
#if CRC_LE_BITS > 64 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \
CRC_LE_BITS & CRC_LE_BITS-1
# error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32, 64}"
#endif
/*
* Big-endian CRC computation. Used with serial bit streams sent
* msbit-first. Be sure to use cpu_to_be32() to append the computed CRC.
*/
#if CRC_BE_BITS > 64 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \
CRC_BE_BITS & CRC_BE_BITS-1
# error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32, 64}"
#endif
#define ___constant_swab32(x) \
((uint32_t)( \
(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
(((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
#if (__GNUC__ >= 3)
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif

File diff suppressed because it is too large Load Diff

157
include/e2fsprogs/ext2fs/dosio.h Executable file
View File

@@ -0,0 +1,157 @@
/*
* v1.0
*
* Disk I/O include file for the ext2fs/DOS library.
*
* Copyright (c) 1997 Mark Habersack
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifndef __diskio_h
#define __diskio_h
#ifdef __TURBOC__
#ifndef __LARGE__
# error "ext2fs/DOS library requires LARGE model!"
#endif
#endif
#ifdef __TURBOC__
#include "msdos.h"
#endif
/*
* A helper structure used in LBA => CHS conversion
*/
typedef struct
{
unsigned short cyl; /* Cylinder (or track) */
unsigned short head;
unsigned short sector;
unsigned short offset; /* Offset of byte within the sector */
} CHS;
/*
* All partition data we need is here
*/
typedef struct
{
char *dev; /* _Linux_ device name (like "/dev/hda1") */
unsigned char phys; /* Physical DOS drive number */
unsigned long start; /* LBA address of partition start */
unsigned long len; /* length of partition in sectors */
unsigned char pno; /* Partition number (read from *dev) */
/* This partition's drive geometry */
unsigned short cyls;
unsigned short heads;
unsigned short sects;
} PARTITION;
/*
* PC partition table entry format
*/
#ifdef __DJGPP__
#pragma pack(1)
#endif
typedef struct
{
unsigned char active;
unsigned char start_head;
unsigned char start_sec;
unsigned char start_cyl;
unsigned char type;
unsigned char end_head;
unsigned char end_sec;
unsigned char end_cyl;
unsigned long first_sec_rel;
unsigned long size;
} PTABLE_ENTRY;
#ifdef __DJGPP__
#pragma pack()
#endif
/*
* INT 0x13 operation codes
*/
#define DISK_READ 0x02
#define DISK_WRITE 0x03
#define DISK_GET_GEOMETRY 0x08
#define DISK_READY 0x10
/*
* Errors to put in _dio_error
*/
#define ERR_BADDEV 0x00000001L
#define ERR_HARDWARE 0x00000002L
#define ERR_NOTSUPP 0x00000003L
#define ERR_NOTEXT2FS 0x00000004L
#define ERR_EMPTYPART 0x00000005L
#define ERR_LINUXSWAP 0x00000006L
/*
* Functions in diskio.c
*/
/*
* Variable contains last module's error
*/
extern unsigned long _dio_error;
/*
* This one contains last hardware error (if _dio_error == ERR_HARDWARE)
*/
extern unsigned long _dio_hw_error;
/*
* Macros to check for disk hardware errors
*/
#define HW_OK() ((unsigned char)_dio_hw_error == 0x00)
#define HW_BAD_CMD() ((unsigned char)_dio_hw_error == 0x01)
#define HW_NO_ADDR_MARK() ((unsigned char)_dio_hw_error == 0x02)
#define HW_WRITE_PROT() ((unsigned char)_dio_hw_error == 0x03)
#define HW_NO_SECTOR() ((unsigned char)_dio_hw_error == 0x04)
#define HW_RESET_FAIL() ((unsigned char)_dio_hw_error == 0x05)
#define HW_DISK_CHANGED() ((unsigned char)_dio_hw_error == 0x06)
#define HW_DRIVE_FAIL() ((unsigned char)_dio_hw_error == 0x07)
#define HW_DMA_OVERRUN() ((unsigned char)_dio_hw_error == 0x08)
#define HW_DMA_BOUNDARY() ((unsigned char)_dio_hw_error == 0x09)
#define HW_BAD_SECTOR() ((unsigned char)_dio_hw_error == 0x0A)
#define HW_BAD_TRACK() ((unsigned char)_dio_hw_error == 0x0B)
#define HW_UNSUPP_TRACK() ((unsigned char)_dio_hw_error == 0x0C)
#define HW_BAD_CRC_ECC() ((unsigned char)_dio_hw_error == 0x10)
#define HW_CRC_ECC_CORR() ((unsigned char)_dio_hw_error == 0x11)
#define HW_CONTR_FAIL() ((unsigned char)_dio_hw_error == 0x20)
#define HW_SEEK_FAIL() ((unsigned char)_dio_hw_error == 0x40)
#define HW_ATTACH_FAIL() ((unsigned char)_dio_hw_error == 0x80)
#define HW_DRIVE_NREADY() ((unsigned char)_dio_hw_error == 0xAA)
#define HW_UNDEF_ERROR() ((unsigned char)_dio_hw_error == 0xBB)
#define HW_WRITE_FAULT() ((unsigned char)_dio_hw_error == 0xCC)
#define HW_STATUS_ERROR() ((unsigned char)_dio_hw_error == 0xE0)
#define HW_SENSE_FAIL() ((unsigned char)_dio_hw_error == 0xFF)
/*
* Open the specified partition.
* String 'dev' must have a format:
*
* /dev/{sd|hd|fd}[X]
*
* where,
*
* only one of the option in curly braces can be used and X is an optional
* partition number for the given device. If X is not specified, function
* scans the drive's partition table in search for the first Linux ext2fs
* partition (signature 0x83). Along the way it dives into every extended
* partition encountered.
* Scan ends if either (a) there are no more used partition entries, or
* (b) there is no Xth partition.
*
* Routine returns 0 on success and !=0 otherwise.
*/
int open_partition(char *dev);
#endif /* __diskio_h */

View File

@@ -0,0 +1,37 @@
/*
* e2image.h --- header file describing the ext2 image format
*
* Copyright (C) 2000 Theodore Ts'o.
*
* Note: this uses the POSIX IO interfaces, unlike most of the other
* functions in this library. So sue me.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
struct ext2_image_hdr {
__u32 magic_number; /* This must be EXT2_ET_MAGIC_E2IMAGE */
char magic_descriptor[16]; /* "Ext2 Image 1.0", w/ null padding */
char fs_hostname[64];/* Hostname of machine of image */
char fs_netaddr[32]; /* Network address */
__u32 fs_netaddr_type;/* 0 = IPV4, 1 = IPV6, etc. */
__u32 fs_device; /* Device number of image */
char fs_device_name[64]; /* Device name */
char fs_uuid[16]; /* UUID of filesystem */
__u32 fs_blocksize; /* Block size of the filesystem */
__u32 fs_reserved[8];
__u32 image_device; /* Device number of image file */
__u32 image_inode; /* Inode number of image file */
__u32 image_time; /* Time of image creation */
__u32 image_reserved[8];
__u32 offset_super; /* Byte offset of the sb and descriptors */
__u32 offset_inode; /* Byte offset of the inode table */
__u32 offset_inodemap; /* Byte offset of the inode bitmaps */
__u32 offset_blockmap; /* Byte offset of the inode bitmaps */
__u32 offset_reserved[8];
};

View File

@@ -0,0 +1,201 @@
/*
* ext2_err.h:
* This file is automatically generated; please do not edit it.
*/
#include <et/com_err.h>
#define EXT2_ET_BASE (2133571328L)
#define EXT2_ET_MAGIC_EXT2FS_FILSYS (2133571329L)
#define EXT2_ET_MAGIC_BADBLOCKS_LIST (2133571330L)
#define EXT2_ET_MAGIC_BADBLOCKS_ITERATE (2133571331L)
#define EXT2_ET_MAGIC_INODE_SCAN (2133571332L)
#define EXT2_ET_MAGIC_IO_CHANNEL (2133571333L)
#define EXT2_ET_MAGIC_UNIX_IO_CHANNEL (2133571334L)
#define EXT2_ET_MAGIC_IO_MANAGER (2133571335L)
#define EXT2_ET_MAGIC_BLOCK_BITMAP (2133571336L)
#define EXT2_ET_MAGIC_INODE_BITMAP (2133571337L)
#define EXT2_ET_MAGIC_GENERIC_BITMAP (2133571338L)
#define EXT2_ET_MAGIC_TEST_IO_CHANNEL (2133571339L)
#define EXT2_ET_MAGIC_DBLIST (2133571340L)
#define EXT2_ET_MAGIC_ICOUNT (2133571341L)
#define EXT2_ET_MAGIC_PQ_IO_CHANNEL (2133571342L)
#define EXT2_ET_MAGIC_EXT2_FILE (2133571343L)
#define EXT2_ET_MAGIC_E2IMAGE (2133571344L)
#define EXT2_ET_MAGIC_INODE_IO_CHANNEL (2133571345L)
#define EXT2_ET_MAGIC_EXTENT_HANDLE (2133571346L)
#define EXT2_ET_BAD_MAGIC (2133571347L)
#define EXT2_ET_REV_TOO_HIGH (2133571348L)
#define EXT2_ET_RO_FILSYS (2133571349L)
#define EXT2_ET_GDESC_READ (2133571350L)
#define EXT2_ET_GDESC_WRITE (2133571351L)
#define EXT2_ET_GDESC_BAD_BLOCK_MAP (2133571352L)
#define EXT2_ET_GDESC_BAD_INODE_MAP (2133571353L)
#define EXT2_ET_GDESC_BAD_INODE_TABLE (2133571354L)
#define EXT2_ET_INODE_BITMAP_WRITE (2133571355L)
#define EXT2_ET_INODE_BITMAP_READ (2133571356L)
#define EXT2_ET_BLOCK_BITMAP_WRITE (2133571357L)
#define EXT2_ET_BLOCK_BITMAP_READ (2133571358L)
#define EXT2_ET_INODE_TABLE_WRITE (2133571359L)
#define EXT2_ET_INODE_TABLE_READ (2133571360L)
#define EXT2_ET_NEXT_INODE_READ (2133571361L)
#define EXT2_ET_UNEXPECTED_BLOCK_SIZE (2133571362L)
#define EXT2_ET_DIR_CORRUPTED (2133571363L)
#define EXT2_ET_SHORT_READ (2133571364L)
#define EXT2_ET_SHORT_WRITE (2133571365L)
#define EXT2_ET_DIR_NO_SPACE (2133571366L)
#define EXT2_ET_NO_INODE_BITMAP (2133571367L)
#define EXT2_ET_NO_BLOCK_BITMAP (2133571368L)
#define EXT2_ET_BAD_INODE_NUM (2133571369L)
#define EXT2_ET_BAD_BLOCK_NUM (2133571370L)
#define EXT2_ET_EXPAND_DIR_ERR (2133571371L)
#define EXT2_ET_TOOSMALL (2133571372L)
#define EXT2_ET_BAD_BLOCK_MARK (2133571373L)
#define EXT2_ET_BAD_BLOCK_UNMARK (2133571374L)
#define EXT2_ET_BAD_BLOCK_TEST (2133571375L)
#define EXT2_ET_BAD_INODE_MARK (2133571376L)
#define EXT2_ET_BAD_INODE_UNMARK (2133571377L)
#define EXT2_ET_BAD_INODE_TEST (2133571378L)
#define EXT2_ET_FUDGE_BLOCK_BITMAP_END (2133571379L)
#define EXT2_ET_FUDGE_INODE_BITMAP_END (2133571380L)
#define EXT2_ET_BAD_IND_BLOCK (2133571381L)
#define EXT2_ET_BAD_DIND_BLOCK (2133571382L)
#define EXT2_ET_BAD_TIND_BLOCK (2133571383L)
#define EXT2_ET_NEQ_BLOCK_BITMAP (2133571384L)
#define EXT2_ET_NEQ_INODE_BITMAP (2133571385L)
#define EXT2_ET_BAD_DEVICE_NAME (2133571386L)
#define EXT2_ET_MISSING_INODE_TABLE (2133571387L)
#define EXT2_ET_CORRUPT_SUPERBLOCK (2133571388L)
#define EXT2_ET_BAD_GENERIC_MARK (2133571389L)
#define EXT2_ET_BAD_GENERIC_UNMARK (2133571390L)
#define EXT2_ET_BAD_GENERIC_TEST (2133571391L)
#define EXT2_ET_SYMLINK_LOOP (2133571392L)
#define EXT2_ET_CALLBACK_NOTHANDLED (2133571393L)
#define EXT2_ET_BAD_BLOCK_IN_INODE_TABLE (2133571394L)
#define EXT2_ET_UNSUPP_FEATURE (2133571395L)
#define EXT2_ET_RO_UNSUPP_FEATURE (2133571396L)
#define EXT2_ET_LLSEEK_FAILED (2133571397L)
#define EXT2_ET_NO_MEMORY (2133571398L)
#define EXT2_ET_INVALID_ARGUMENT (2133571399L)
#define EXT2_ET_BLOCK_ALLOC_FAIL (2133571400L)
#define EXT2_ET_INODE_ALLOC_FAIL (2133571401L)
#define EXT2_ET_NO_DIRECTORY (2133571402L)
#define EXT2_ET_TOO_MANY_REFS (2133571403L)
#define EXT2_ET_FILE_NOT_FOUND (2133571404L)
#define EXT2_ET_FILE_RO (2133571405L)
#define EXT2_ET_DB_NOT_FOUND (2133571406L)
#define EXT2_ET_DIR_EXISTS (2133571407L)
#define EXT2_ET_UNIMPLEMENTED (2133571408L)
#define EXT2_ET_CANCEL_REQUESTED (2133571409L)
#define EXT2_ET_FILE_TOO_BIG (2133571410L)
#define EXT2_ET_JOURNAL_NOT_BLOCK (2133571411L)
#define EXT2_ET_NO_JOURNAL_SB (2133571412L)
#define EXT2_ET_JOURNAL_TOO_SMALL (2133571413L)
#define EXT2_ET_JOURNAL_UNSUPP_VERSION (2133571414L)
#define EXT2_ET_LOAD_EXT_JOURNAL (2133571415L)
#define EXT2_ET_NO_JOURNAL (2133571416L)
#define EXT2_ET_DIRHASH_UNSUPP (2133571417L)
#define EXT2_ET_BAD_EA_BLOCK_NUM (2133571418L)
#define EXT2_ET_TOO_MANY_INODES (2133571419L)
#define EXT2_ET_NOT_IMAGE_FILE (2133571420L)
#define EXT2_ET_RES_GDT_BLOCKS (2133571421L)
#define EXT2_ET_RESIZE_INODE_CORRUPT (2133571422L)
#define EXT2_ET_SET_BMAP_NO_IND (2133571423L)
#define EXT2_ET_TDB_SUCCESS (2133571424L)
#define EXT2_ET_TDB_ERR_CORRUPT (2133571425L)
#define EXT2_ET_TDB_ERR_IO (2133571426L)
#define EXT2_ET_TDB_ERR_LOCK (2133571427L)
#define EXT2_ET_TDB_ERR_OOM (2133571428L)
#define EXT2_ET_TDB_ERR_EXISTS (2133571429L)
#define EXT2_ET_TDB_ERR_NOLOCK (2133571430L)
#define EXT2_ET_TDB_ERR_EINVAL (2133571431L)
#define EXT2_ET_TDB_ERR_NOEXIST (2133571432L)
#define EXT2_ET_TDB_ERR_RDONLY (2133571433L)
#define EXT2_ET_DBLIST_EMPTY (2133571434L)
#define EXT2_ET_RO_BLOCK_ITERATE (2133571435L)
#define EXT2_ET_MAGIC_EXTENT_PATH (2133571436L)
#define EXT2_ET_MAGIC_GENERIC_BITMAP64 (2133571437L)
#define EXT2_ET_MAGIC_BLOCK_BITMAP64 (2133571438L)
#define EXT2_ET_MAGIC_INODE_BITMAP64 (2133571439L)
#define EXT2_ET_MAGIC_RESERVED_13 (2133571440L)
#define EXT2_ET_MAGIC_RESERVED_14 (2133571441L)
#define EXT2_ET_MAGIC_RESERVED_15 (2133571442L)
#define EXT2_ET_MAGIC_RESERVED_16 (2133571443L)
#define EXT2_ET_MAGIC_RESERVED_17 (2133571444L)
#define EXT2_ET_MAGIC_RESERVED_18 (2133571445L)
#define EXT2_ET_MAGIC_RESERVED_19 (2133571446L)
#define EXT2_ET_EXTENT_HEADER_BAD (2133571447L)
#define EXT2_ET_EXTENT_INDEX_BAD (2133571448L)
#define EXT2_ET_EXTENT_LEAF_BAD (2133571449L)
#define EXT2_ET_EXTENT_NO_SPACE (2133571450L)
#define EXT2_ET_INODE_NOT_EXTENT (2133571451L)
#define EXT2_ET_EXTENT_NO_NEXT (2133571452L)
#define EXT2_ET_EXTENT_NO_PREV (2133571453L)
#define EXT2_ET_EXTENT_NO_UP (2133571454L)
#define EXT2_ET_EXTENT_NO_DOWN (2133571455L)
#define EXT2_ET_NO_CURRENT_NODE (2133571456L)
#define EXT2_ET_OP_NOT_SUPPORTED (2133571457L)
#define EXT2_ET_CANT_INSERT_EXTENT (2133571458L)
#define EXT2_ET_CANT_SPLIT_EXTENT (2133571459L)
#define EXT2_ET_EXTENT_NOT_FOUND (2133571460L)
#define EXT2_ET_EXTENT_NOT_SUPPORTED (2133571461L)
#define EXT2_ET_EXTENT_INVALID_LENGTH (2133571462L)
#define EXT2_ET_IO_CHANNEL_NO_SUPPORT_64 (2133571463L)
#define EXT2_ET_NO_MTAB_FILE (2133571464L)
#define EXT2_ET_CANT_USE_LEGACY_BITMAPS (2133571465L)
#define EXT2_ET_MMP_MAGIC_INVALID (2133571466L)
#define EXT2_ET_MMP_FAILED (2133571467L)
#define EXT2_ET_MMP_FSCK_ON (2133571468L)
#define EXT2_ET_MMP_BAD_BLOCK (2133571469L)
#define EXT2_ET_MMP_UNKNOWN_SEQ (2133571470L)
#define EXT2_ET_MMP_CHANGE_ABORT (2133571471L)
#define EXT2_ET_MMP_OPEN_DIRECT (2133571472L)
#define EXT2_ET_BAD_DESC_SIZE (2133571473L)
#define EXT2_ET_INODE_CSUM_INVALID (2133571474L)
#define EXT2_ET_INODE_BITMAP_CSUM_INVALID (2133571475L)
#define EXT2_ET_EXTENT_CSUM_INVALID (2133571476L)
#define EXT2_ET_DIR_NO_SPACE_FOR_CSUM (2133571477L)
#define EXT2_ET_DIR_CSUM_INVALID (2133571478L)
#define EXT2_ET_EXT_ATTR_CSUM_INVALID (2133571479L)
#define EXT2_ET_SB_CSUM_INVALID (2133571480L)
#define EXT2_ET_UNKNOWN_CSUM (2133571481L)
#define EXT2_ET_MMP_CSUM_INVALID (2133571482L)
#define EXT2_ET_FILE_EXISTS (2133571483L)
#define EXT2_ET_BLOCK_BITMAP_CSUM_INVALID (2133571484L)
#define EXT2_ET_INLINE_DATA_CANT_ITERATE (2133571485L)
#define EXT2_ET_EA_BAD_NAME_LEN (2133571486L)
#define EXT2_ET_EA_BAD_VALUE_SIZE (2133571487L)
#define EXT2_ET_BAD_EA_HASH (2133571488L)
#define EXT2_ET_BAD_EA_HEADER (2133571489L)
#define EXT2_ET_EA_KEY_NOT_FOUND (2133571490L)
#define EXT2_ET_EA_NO_SPACE (2133571491L)
#define EXT2_ET_MISSING_EA_FEATURE (2133571492L)
#define EXT2_ET_NO_INLINE_DATA (2133571493L)
#define EXT2_ET_INLINE_DATA_NO_BLOCK (2133571494L)
#define EXT2_ET_INLINE_DATA_NO_SPACE (2133571495L)
#define EXT2_ET_MAGIC_EA_HANDLE (2133571496L)
#define EXT2_ET_INODE_IS_GARBAGE (2133571497L)
#define EXT2_ET_EA_BAD_VALUE_OFFSET (2133571498L)
#define EXT2_ET_JOURNAL_FLAGS_WRONG (2133571499L)
#define EXT2_ET_UNDO_FILE_CORRUPT (2133571500L)
#define EXT2_ET_UNDO_FILE_WRONG (2133571501L)
#define EXT2_ET_FILESYSTEM_CORRUPTED (2133571502L)
#define EXT2_ET_BAD_CRC (2133571503L)
#define EXT2_ET_CORRUPT_JOURNAL_SB (2133571504L)
#define EXT2_ET_INODE_CORRUPTED (2133571505L)
#define EXT2_ET_EA_INODE_CORRUPTED (2133571506L)
#define EXT2_ET_NO_GDESC (2133571507L)
#define EXT2_FILSYS_CORRUPTED (2133571508L)
#define EXT2_ET_EXTENT_CYCLE (2133571509L)
#define EXT2_ET_EXTERNAL_JOURNAL_NOSUPP (2133571510L)
extern const struct error_table et_ext2_error_table;
extern void initialize_ext2_error_table(void);
/* For compatibility with Heimdal */
extern void initialize_ext2_error_table_r(struct et_list **list);
#define ERROR_TABLE_BASE_ext2 (2133571328L)
/* for compatibility with older versions... */
#define init_ext2_err_tbl initialize_ext2_error_table
#define ext2_err_base ERROR_TABLE_BASE_ext2

View File

@@ -0,0 +1,73 @@
/*
File: linux/ext2_ext_attr.h
On-disk format of extended attributes for the ext2 filesystem.
(C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
*/
#ifndef _EXT2_EXT_ATTR_H
#define _EXT2_EXT_ATTR_H
/* Magic value in attribute blocks */
#define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
#define EXT2_EXT_ATTR_MAGIC 0xEA020000
/* Maximum number of references to one attribute block */
#define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
struct ext2_ext_attr_header {
__u32 h_magic; /* magic number for identification */
__u32 h_refcount; /* reference count */
__u32 h_blocks; /* number of disk blocks used */
__u32 h_hash; /* hash value of all attributes */
__u32 h_checksum; /* crc32c(uuid+id+xattrs) */
/* id = inum if refcount = 1, else blknum */
__u32 h_reserved[3]; /* zero right now */
};
struct ext2_ext_attr_entry {
__u8 e_name_len; /* length of name */
__u8 e_name_index; /* attribute name index */
__u16 e_value_offs; /* offset in disk block of value */
__u32 e_value_inum; /* inode in which the value is stored */
__u32 e_value_size; /* size of attribute value */
__u32 e_hash; /* hash value of name and value */
#if 0
char e_name[0]; /* attribute name */
#endif
};
#define EXT2_EXT_ATTR_PAD_BITS 2
#define EXT2_EXT_ATTR_PAD ((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS)
#define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
#define EXT2_EXT_ATTR_LEN(name_len) \
(((name_len) + EXT2_EXT_ATTR_ROUND + \
sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
#define EXT2_EXT_ATTR_NEXT(entry) \
( (struct ext2_ext_attr_entry *)( \
(char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
#define EXT2_EXT_ATTR_SIZE(size) \
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
#define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
#define EXT2_EXT_ATTR_NAME(entry) \
(((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
#define EXT2_XATTR_LEN(name_len) \
(((name_len) + EXT2_EXT_ATTR_ROUND + \
sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
#define EXT2_XATTR_SIZE(size) \
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
#ifdef __KERNEL__
# ifdef CONFIG_EXT2_FS_EXT_ATTR
extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
extern void ext2_ext_attr_free_inode(struct inode *inode);
extern void ext2_ext_attr_put_super(struct super_block *sb);
extern int ext2_ext_attr_init(void);
extern void ext2_ext_attr_done(void);
# else
# define ext2_get_ext_attr NULL
# define ext2_set_ext_attr NULL
# endif
#endif /* __KERNEL__ */
#endif /* _EXT2_EXT_ATTR_H */

1189
include/e2fsprogs/ext2fs/ext2_fs.h Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,179 @@
/*
* io.h --- the I/O manager abstraction
*
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifndef _EXT2FS_EXT2_IO_H
#define _EXT2FS_EXT2_IO_H
#include <ext2fs/ext2_types.h>
/*
* ext2_loff_t is defined here since unix_io.c needs it.
*/
#if defined(__GNUC__) || defined(HAS_LONG_LONG)
typedef long long ext2_loff_t;
#else
typedef long ext2_loff_t;
#endif
/* llseek.c */
ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
typedef struct struct_io_manager *io_manager;
typedef struct struct_io_channel *io_channel;
typedef struct struct_io_stats *io_stats;
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
#define CHANNEL_FLAGS_DISCARD_ZEROES 0x02
#define CHANNEL_FLAGS_BLOCK_DEVICE 0x04
#define CHANNEL_FLAGS_THREADS 0x08
#define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
struct struct_io_channel {
errcode_t magic;
io_manager manager;
char *name;
int block_size;
errcode_t (*read_error)(io_channel channel,
unsigned long block,
int count,
void *data,
size_t size,
int actual_bytes_read,
errcode_t error);
errcode_t (*write_error)(io_channel channel,
unsigned long block,
int count,
const void *data,
size_t size,
int actual_bytes_written,
errcode_t error);
int refcount;
int flags;
long reserved[14];
void *private_data;
void *app_data;
int align;
};
struct struct_io_stats {
int num_fields;
int reserved;
unsigned long long bytes_read;
unsigned long long bytes_written;
};
struct struct_io_manager {
errcode_t magic;
const char *name;
errcode_t (*open)(const char *name, int flags, io_channel *channel);
errcode_t (*close)(io_channel channel);
errcode_t (*set_blksize)(io_channel channel, int blksize);
errcode_t (*read_blk)(io_channel channel, unsigned long block,
int count, void *data);
errcode_t (*write_blk)(io_channel channel, unsigned long block,
int count, const void *data);
errcode_t (*flush)(io_channel channel);
errcode_t (*write_byte)(io_channel channel, unsigned long offset,
int count, const void *data);
errcode_t (*set_option)(io_channel channel, const char *option,
const char *arg);
errcode_t (*get_stats)(io_channel channel, io_stats *io_stats);
errcode_t (*read_blk64)(io_channel channel, unsigned long long block,
int count, void *data);
errcode_t (*write_blk64)(io_channel channel, unsigned long long block,
int count, const void *data);
errcode_t (*discard)(io_channel channel, unsigned long long block,
unsigned long long count);
errcode_t (*cache_readahead)(io_channel channel,
unsigned long long block,
unsigned long long count);
errcode_t (*zeroout)(io_channel channel, unsigned long long block,
unsigned long long count);
long reserved[14];
};
#define IO_FLAG_RW 0x0001
#define IO_FLAG_EXCLUSIVE 0x0002
#define IO_FLAG_DIRECT_IO 0x0004
#define IO_FLAG_FORCE_BOUNCE 0x0008
#define IO_FLAG_THREADS 0x0010
#define IO_FLAG_NOCACHE 0x0020
/*
* Convenience functions....
*/
#define io_channel_close(c) ((c)->manager->close((c)))
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
#define io_channel_flush(c) ((c)->manager->flush((c)))
#define io_channel_bumpcount(c) ((c)->refcount++)
/* io_manager.c */
extern errcode_t io_channel_set_options(io_channel channel,
const char *options);
extern errcode_t io_channel_write_byte(io_channel channel,
unsigned long offset,
int count, const void *data);
extern errcode_t io_channel_read_blk64(io_channel channel,
unsigned long long block,
int count, void *data);
extern errcode_t io_channel_write_blk64(io_channel channel,
unsigned long long block,
int count, const void *data);
extern errcode_t io_channel_discard(io_channel channel,
unsigned long long block,
unsigned long long count);
extern errcode_t io_channel_zeroout(io_channel channel,
unsigned long long block,
unsigned long long count);
extern errcode_t io_channel_alloc_buf(io_channel channel,
int count, void *ptr);
extern errcode_t io_channel_cache_readahead(io_channel io,
unsigned long long block,
unsigned long long count);
#ifdef _WIN32
/* windows_io.c */
extern io_manager windows_io_manager;
#define default_io_manager windows_io_manager
#else
/* unix_io.c */
extern io_manager unix_io_manager;
extern io_manager unixfd_io_manager;
#define default_io_manager unix_io_manager
#endif
/* sparse_io.c */
extern io_manager sparse_io_manager;
extern io_manager sparsefd_io_manager;
/* undo_io.c */
extern io_manager undo_io_manager;
extern errcode_t set_undo_io_backing_manager(io_manager manager);
extern errcode_t set_undo_io_backup_file(char *file_name);
/* test_io.c */
extern io_manager test_io_manager, test_io_backing_manager;
extern void (*test_io_cb_read_blk)
(unsigned long block, int count, errcode_t err);
extern void (*test_io_cb_write_blk)
(unsigned long block, int count, errcode_t err);
extern void (*test_io_cb_read_blk64)
(unsigned long long block, int count, errcode_t err);
extern void (*test_io_cb_write_blk64)
(unsigned long long block, int count, errcode_t err);
extern void (*test_io_cb_set_blksize)
(int blksize, errcode_t err);
#endif /* _EXT2FS_EXT2_IO_H */

View File

@@ -0,0 +1,45 @@
/*
* If linux/types.h is already been included, assume it has defined
* everything we need. (cross fingers) Other header files may have
* also defined the types that we need.
*/
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
!defined(_EXT2_TYPES_H) && !defined(_UUID_TYPES_H))
#define _EXT2_TYPES_H
typedef unsigned char __u8;
typedef __signed__ char __s8;
typedef unsigned short __u16;
typedef __signed__ short __s16;
typedef unsigned int __u32;
typedef __signed__ int __s32;
typedef unsigned long long __u64;
typedef __signed__ long long __s64;
#endif
#include <stdint.h> //uintptr_t
/* endian checking stuff */
#ifndef EXT2_ENDIAN_H_
#define EXT2_ENDIAN_H_
#ifdef __CHECKER__
#ifndef __bitwise
#define __bitwise __attribute__((bitwise))
#endif
#define __force __attribute__((force))
#else
#ifndef __bitwise
#define __bitwise
#endif
#define __force
#endif
typedef __u16 __bitwise __le16;
typedef __u32 __bitwise __le32;
typedef __u64 __bitwise __le64;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __be64;
#endif /* EXT2_ENDIAN_H_ */

2191
include/e2fsprogs/ext2fs/ext2fs.h Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,210 @@
/*
* ext2fsP.h --- private header file for ext2 library
*
* Copyright (C) 1997 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include "ext2fs.h"
#define EXT2FS_MAX_NESTED_LINKS 8
static inline int ext2fsP_is_disk_device(mode_t mode)
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
return S_ISBLK(mode) || S_ISCHR(mode);
#else
return S_ISBLK(mode);
#endif
}
/*
* Badblocks list
*/
struct ext2_struct_u32_list {
int magic;
int num;
int size;
__u32 *list;
int badblocks_flags;
};
struct ext2_struct_u32_iterate {
int magic;
ext2_u32_list bb;
int ptr;
};
/*
* Directory block iterator definition
*/
struct ext2_struct_dblist {
int magic;
ext2_filsys fs;
unsigned long long size;
unsigned long long count;
int sorted;
struct ext2_db_entry2 * list;
};
/*
* For directory iterators
*/
struct dir_context {
ext2_ino_t dir;
int flags;
char *buf;
unsigned int buflen;
int (*func)(ext2_ino_t dir,
int entry,
struct ext2_dir_entry *dirent,
int offset,
int blocksize,
char *buf,
void *priv_data);
void *priv_data;
errcode_t errcode;
};
/*
* Inode cache structure
*/
struct ext2_inode_cache {
void * buffer;
blk64_t buffer_blk;
int cache_last;
unsigned int cache_size;
int refcount;
struct ext2_inode_cache_ent *cache;
};
struct ext2_inode_cache_ent {
ext2_ino_t ino;
struct ext2_inode *inode;
};
/*
* NLS definitions
*/
struct ext2fs_nls_table {
int version;
const struct ext2fs_nls_ops *ops;
};
struct ext2fs_nls_ops {
int (*casefold)(const struct ext2fs_nls_table *charset,
const unsigned char *str, size_t len,
unsigned char *dest, size_t dlen);
int (*validate)(const struct ext2fs_nls_table *table,
char *s, size_t len, char **pos);
int (*casefold_cmp)(const struct ext2fs_nls_table *table,
const unsigned char *str1, size_t len1,
const unsigned char *str2, size_t len2);
};
/* Function prototypes */
extern int ext2fs_process_dir_block(ext2_filsys fs,
blk64_t *blocknr,
e2_blkcnt_t blockcnt,
blk64_t ref_block,
int ref_offset,
void *priv_data);
extern errcode_t ext2fs_inline_data_ea_remove(ext2_filsys fs, ext2_ino_t ino);
extern errcode_t ext2fs_inline_data_expand(ext2_filsys fs, ext2_ino_t ino);
extern int ext2fs_inline_data_dir_iterate(ext2_filsys fs,
ext2_ino_t ino,
void *priv_data);
/* Generic numeric progress meter */
struct ext2fs_numeric_progress_struct {
__u64 max;
int log_max;
int skip_progress;
};
/*
* progress callback functions
*/
struct ext2fs_progress_ops {
void (*init)(ext2_filsys fs,
struct ext2fs_numeric_progress_struct * progress,
const char *label, __u64 max);
void (*update)(ext2_filsys fs,
struct ext2fs_numeric_progress_struct * progress,
__u64 val);
void (*close)(ext2_filsys fs,
struct ext2fs_numeric_progress_struct * progress,
const char *message);
};
extern struct ext2fs_progress_ops ext2fs_numeric_progress_ops;
extern void ext2fs_numeric_progress_init(ext2_filsys fs,
struct ext2fs_numeric_progress_struct * progress,
const char *label, __u64 max);
extern void ext2fs_numeric_progress_update(ext2_filsys fs,
struct ext2fs_numeric_progress_struct * progress,
__u64 val);
extern void ext2fs_numeric_progress_close(ext2_filsys fs,
struct ext2fs_numeric_progress_struct * progress,
const char *message);
/*
* 64-bit bitmap support
*/
extern errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
int type, __u64 start, __u64 end,
__u64 real_end,
const char * description,
ext2fs_generic_bitmap *bmap);
extern void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
extern errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest);
extern errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
__u64 new_end,
__u64 new_real_end);
extern errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
errcode_t neq,
__u64 end, __u64 *oend);
extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 arg);
extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 arg);
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
__u64 arg);
extern errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bitmap,
__u64 start, unsigned int num,
void *in);
extern errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bitmap,
__u64 start, unsigned int num,
void *out);
extern void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap,const char *func);
extern int ext2fs_mem_is_zero(const char *mem, size_t len);
extern int ext2fs_file_block_offset_too_big(ext2_filsys fs,
struct ext2_inode *inode,
blk64_t offset);
/* atexit support */
typedef void (*ext2_exit_fn)(void *);
errcode_t ext2fs_add_exit_fn(ext2_exit_fn fn, void *data);
errcode_t ext2fs_remove_exit_fn(ext2_exit_fn fn, void *data);
#define EXT2FS_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2*!!(cond)]))

View File

@@ -0,0 +1,127 @@
/*
* Copyright (c) 2003,2004 Cluster File Systems, Inc, info@clusterfs.com
* Written by Alex Tomas <alex@clusterfs.com>
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
#ifndef _LINUX_EXT3_EXTENTS
#define _LINUX_EXT3_EXTENTS
/*
* ext3_inode has i_block array (total 60 bytes)
* first 4 bytes are used to store:
* - tree depth (0 mean there is no tree yet. all extents in the inode)
* - number of alive extents in the inode
*/
/*
* This is extent tail on-disk structure.
* All other extent structures are 12 bytes long. It turns out that
* block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
* covers all valid ext4 block sizes. Therefore, this tail structure can be
* crammed into the end of the block without having to rebalance the tree.
*/
struct ext3_extent_tail {
__le32 et_checksum; /* crc32c(uuid+inum+extent_block) */
};
/*
* this is extent on-disk structure
* it's used at the bottom of the tree
*/
struct ext3_extent {
__le32 ee_block; /* first logical block extent covers */
__le16 ee_len; /* number of blocks covered by extent */
__le16 ee_start_hi; /* high 16 bits of physical block */
__le32 ee_start; /* low 32 bigs of physical block */
};
/*
* this is index on-disk structure
* it's used at all the levels, but the bottom
*/
struct ext3_extent_idx {
__le32 ei_block; /* index covers logical blocks from 'block' */
__le32 ei_leaf; /* pointer to the physical block of the next *
* level. leaf or next index could bet here */
__le16 ei_leaf_hi; /* high 16 bits of physical block */
__le16 ei_unused;
};
/*
* each block (leaves and indexes), even inode-stored has header
*/
struct ext3_extent_header {
__le16 eh_magic; /* probably will support different formats */
__le16 eh_entries; /* number of valid entries */
__le16 eh_max; /* capacity of store in entries */
__le16 eh_depth; /* has tree real underlying blocks? */
__le32 eh_generation; /* generation of the tree */
};
#define EXT3_EXT_MAGIC 0xf30a
/*
* array of ext3_ext_path contains path to some extent
* creation/lookup routines use it for traversal/splitting/etc
* truncate uses it to simulate recursive walking
*/
struct ext3_ext_path {
__u32 p_block;
__u16 p_depth;
struct ext3_extent *p_ext;
struct ext3_extent_idx *p_idx;
struct ext3_extent_header *p_hdr;
struct buffer_head *p_bh;
};
/*
* EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
* initialized extent. This is 2^15 and not (2^16 - 1), since we use the
* MSB of ee_len field in the extent datastructure to signify if this
* particular extent is an initialized extent or an uninitialized (i.e.
* preallocated).
* EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
* uninitialized extent.
* If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
* uninitialized one. In other words, if MSB of ee_len is set, it is an
* uninitialized extent with only one special scenario when ee_len = 0x8000.
* In this case we can not have an uninitialized extent of zero length and
* thus we make it as a special case of initialized extent with 0x8000 length.
* This way we get better extent-to-group alignment for initialized extents.
* Hence, the maximum number of blocks we can have in an *initialized*
* extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
*/
#define EXT_INIT_MAX_LEN (1UL << 15)
#define EXT_UNINIT_MAX_LEN (EXT_INIT_MAX_LEN - 1)
#define EXT_MAX_EXTENT_LBLK (((__u64) 1 << 32) - 1)
#define EXT_MAX_EXTENT_PBLK (((__u64) 1 << 48) - 1)
#define EXT_FIRST_EXTENT(__hdr__) \
((struct ext3_extent *) (((char *) (__hdr__)) + \
sizeof(struct ext3_extent_header)))
#define EXT_FIRST_INDEX(__hdr__) \
((struct ext3_extent_idx *) (((char *) (__hdr__)) + \
sizeof(struct ext3_extent_header)))
#define EXT_HAS_FREE_INDEX(__path__) \
(ext2fs_le16_to_cpu((__path__)->p_hdr->eh_entries) < \
ext2fs_le16_to_cpu((__path__)->p_hdr->eh_max))
#define EXT_LAST_EXTENT(__hdr__) \
(EXT_FIRST_EXTENT((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
#define EXT_LAST_INDEX(__hdr__) \
(EXT_FIRST_INDEX((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
#define EXT_MAX_EXTENT(__hdr__) \
(EXT_FIRST_EXTENT((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
#define EXT_MAX_INDEX(__hdr__) \
(EXT_FIRST_INDEX((__hdr__)) + \
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
#endif /* _LINUX_EXT3_EXTENTS */

View File

@@ -0,0 +1,62 @@
/*
* Ext4's on-disk acl format. From linux/fs/ext4/acl.h
*/
#define EXT4_ACL_VERSION 0x0001
/* 23.2.5 acl_tag_t values */
#define ACL_UNDEFINED_TAG (0x00)
#define ACL_USER_OBJ (0x01)
#define ACL_USER (0x02)
#define ACL_GROUP_OBJ (0x04)
#define ACL_GROUP (0x08)
#define ACL_MASK (0x10)
#define ACL_OTHER (0x20)
/* 23.3.6 acl_type_t values */
#define ACL_TYPE_ACCESS (0x8000)
#define ACL_TYPE_DEFAULT (0x4000)
/* 23.2.7 ACL qualifier constants */
#define ACL_UNDEFINED_ID ((id_t)-1)
typedef struct {
__le16 e_tag;
__le16 e_perm;
__le32 e_id;
} ext4_acl_entry;
typedef struct {
__le16 e_tag;
__le16 e_perm;
} ext4_acl_entry_short;
typedef struct {
__le32 a_version;
} ext4_acl_header;
/* Supported ACL a_version fields */
#define POSIX_ACL_XATTR_VERSION 0x0002
typedef struct {
__le16 e_tag;
__le16 e_perm;
__le32 e_id;
} posix_acl_xattr_entry;
typedef struct {
__le32 a_version;
#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
posix_acl_xattr_entry a_entries[0];
#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
#endif
} posix_acl_xattr_header;

View File

@@ -0,0 +1,190 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __FAST_COMMIT_H__
#define __FAST_COMMIT_H__
#include "jfs_compat.h"
/*
* Note this file is present in e2fsprogs/lib/ext2fs/fast_commit.h and
* linux/fs/ext4/fast_commit.h. These file should always be byte identical.
*/
/* Fast commit tags */
#define EXT4_FC_TAG_ADD_RANGE 0x0001
#define EXT4_FC_TAG_DEL_RANGE 0x0002
#define EXT4_FC_TAG_CREAT 0x0003
#define EXT4_FC_TAG_LINK 0x0004
#define EXT4_FC_TAG_UNLINK 0x0005
#define EXT4_FC_TAG_INODE 0x0006
#define EXT4_FC_TAG_PAD 0x0007
#define EXT4_FC_TAG_TAIL 0x0008
#define EXT4_FC_TAG_HEAD 0x0009
#define EXT4_FC_SUPPORTED_FEATURES 0x0
/* On disk fast commit tlv value structures */
/* Fast commit on disk tag length structure */
struct ext4_fc_tl {
__le16 fc_tag;
__le16 fc_len;
};
/* Value structure for tag EXT4_FC_TAG_HEAD. */
struct ext4_fc_head {
__le32 fc_features;
__le32 fc_tid;
};
/* Value structure for EXT4_FC_TAG_ADD_RANGE. */
struct ext4_fc_add_range {
__le32 fc_ino;
__u8 fc_ex[12];
};
/* Value structure for tag EXT4_FC_TAG_DEL_RANGE. */
struct ext4_fc_del_range {
__le32 fc_ino;
__le32 fc_lblk;
__le32 fc_len;
};
/*
* This is the value structure for tags EXT4_FC_TAG_CREAT, EXT4_FC_TAG_LINK
* and EXT4_FC_TAG_UNLINK.
*/
struct ext4_fc_dentry_info {
__le32 fc_parent_ino;
__le32 fc_ino;
__u8 fc_dname[0];
};
/* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */
struct ext4_fc_inode {
__le32 fc_ino;
__u8 fc_raw_inode[0];
};
/* Value structure for tag EXT4_FC_TAG_TAIL. */
struct ext4_fc_tail {
__le32 fc_tid;
__le32 fc_crc;
};
/*
* Fast commit reason codes
*/
enum {
/*
* Commit status codes:
*/
EXT4_FC_REASON_OK = 0,
EXT4_FC_REASON_INELIGIBLE,
EXT4_FC_REASON_ALREADY_COMMITTED,
EXT4_FC_REASON_FC_START_FAILED,
EXT4_FC_REASON_FC_FAILED,
/*
* Fast commit ineligiblity reasons:
*/
EXT4_FC_REASON_XATTR = 0,
EXT4_FC_REASON_CROSS_RENAME,
EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,
EXT4_FC_REASON_NOMEM,
EXT4_FC_REASON_SWAP_BOOT,
EXT4_FC_REASON_RESIZE,
EXT4_FC_REASON_RENAME_DIR,
EXT4_FC_REASON_FALLOC_RANGE,
EXT4_FC_REASON_INODE_JOURNAL_DATA,
EXT4_FC_COMMIT_FAILED,
EXT4_FC_REASON_MAX
};
#ifdef __KERNEL__
/*
* In memory list of dentry updates that are performed on the file
* system used by fast commit code.
*/
struct ext4_fc_dentry_update {
int fcd_op; /* Type of update create / unlink / link */
int fcd_parent; /* Parent inode number */
int fcd_ino; /* Inode number */
struct qstr fcd_name; /* Dirent name */
unsigned char fcd_iname[DNAME_INLINE_LEN]; /* Dirent name string */
struct list_head fcd_list;
};
struct ext4_fc_stats {
unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX];
unsigned long fc_num_commits;
unsigned long fc_ineligible_commits;
unsigned long fc_numblks;
};
#define EXT4_FC_REPLAY_REALLOC_INCREMENT 4
/*
* Physical block regions added to different inodes due to fast commit
* recovery. These are set during the SCAN phase. During the replay phase,
* our allocator excludes these from its allocation. This ensures that
* we don't accidentally allocating a block that is going to be used by
* another inode.
*/
struct ext4_fc_alloc_region {
ext4_lblk_t lblk;
ext4_fsblk_t pblk;
int ino, len;
};
/*
* Fast commit replay state.
*/
struct ext4_fc_replay_state {
int fc_replay_num_tags;
int fc_replay_expected_off;
int fc_current_pass;
int fc_cur_tag;
int fc_crc;
struct ext4_fc_alloc_region *fc_regions;
int fc_regions_size, fc_regions_used, fc_regions_valid;
int *fc_modified_inodes;
int fc_modified_inodes_used, fc_modified_inodes_size;
};
#define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
#endif
static inline const char *tag2str(__u16 tag)
{
switch (tag) {
case EXT4_FC_TAG_LINK:
return "ADD_ENTRY";
case EXT4_FC_TAG_UNLINK:
return "DEL_ENTRY";
case EXT4_FC_TAG_ADD_RANGE:
return "ADD_RANGE";
case EXT4_FC_TAG_CREAT:
return "CREAT_DENTRY";
case EXT4_FC_TAG_DEL_RANGE:
return "DEL_RANGE";
case EXT4_FC_TAG_INODE:
return "INODE";
case EXT4_FC_TAG_PAD:
return "PAD";
case EXT4_FC_TAG_TAIL:
return "TAIL";
case EXT4_FC_TAG_HEAD:
return "HEAD";
default:
return "ERROR";
}
}
/* Get length of a particular tlv */
static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl)
{
return le16_to_cpu(tl->fc_len);
}
#endif /* __FAST_COMMIT_H__ */

View File

@@ -0,0 +1,93 @@
/*
* FS_IOC_FIEMAP ioctl infrastructure.
*
* Some portions copyright (C) 2007 Cluster File Systems, Inc
*
* Authors: Mark Fasheh <mfasheh@suse.com>
* Kalpak Shah <kalpak.shah@sun.com>
* Andreas Dilger <adilger@sun.com>
*/
#ifndef _LINUX_FIEMAP_H
#define _LINUX_FIEMAP_H
struct fiemap_extent {
__u64 fe_logical; /* logical offset in bytes for the start of
* the extent from the beginning of the file */
__u64 fe_physical; /* physical offset in bytes for the start
* of the extent from the beginning of the disk */
__u64 fe_length; /* length in bytes for this extent */
__u64 fe_reserved64[2];
__u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
__u32 fe_reserved[3];
};
struct fiemap {
__u64 fm_start; /* logical offset (inclusive) at
* which to start mapping (in) */
__u64 fm_length; /* logical length of mapping which
* userspace wants (in) */
__u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */
__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
__u32 fm_extent_count; /* size of fm_extents array (in) */
__u32 fm_reserved;
#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
#if __GNUC_PREREQ (4, 8)
#pragma GCC diagnostic pop
#endif
};
#if defined(__linux__) && !defined(FS_IOC_FIEMAP)
#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
#endif
#if defined(__linux__) && !defined(FS_IOC_GETSTATE)
#define EXT4_IOC_GETSTATE _IOW('f', 41, __u32)
#endif
#if defined(__linux__) && !defined(EXT4_IOC_GET_ES_CACHE)
#define EXT4_IOC_GET_ES_CACHE _IOWR('f', 42, struct fiemap)
#endif
#if defined(__linux__) && !defined(EXT4_STATE_FLAG_EXT_PRECACHED)
#define EXT4_STATE_FLAG_EXT_PRECACHED 0x00000001
#endif
#define FIEMAP_MAX_OFFSET (~0ULL)
#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */
#define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */
#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */
#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.
* Sets EXTENT_UNKNOWN. */
#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read
* while fs is unmounted */
#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs.
* Sets EXTENT_NO_BYPASS. */
#define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be
* block aligned. */
#define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata.
* Sets EXTENT_NOT_ALIGNED.*/
#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block.
* Sets EXTENT_NOT_ALIGNED.*/
#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but
* no data (i.e. zero). */
#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively
* support extents. Result
* merged for efficiency. */
#define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other
* files. */
#define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 /* Entry in extent status
cache for a hole*/
#endif /* _LINUX_FIEMAP_H */

View File

@@ -0,0 +1,42 @@
#ifndef HASHMAP_H
# define HASHMAP_H
# include <stdlib.h>
# include <stdint.h>
#ifndef __GNUC_PREREQ
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj, min) 0
#endif
#endif
struct ext2fs_hashmap;
struct ext2fs_hashmap_entry {
void *data;
const void *key;
size_t key_len;
struct ext2fs_hashmap_entry *next;
struct ext2fs_hashmap_entry *list_next;
struct ext2fs_hashmap_entry *list_prev;
};
struct ext2fs_hashmap *ext2fs_hashmap_create(
uint32_t(*hash_fct)(const void*, size_t),
void(*free_fct)(void*), size_t size);
int ext2fs_hashmap_add(struct ext2fs_hashmap *h,
void *data, const void *key,size_t key_len);
void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key,
size_t key_len);
void *ext2fs_hashmap_iter_in_order(struct ext2fs_hashmap *h,
struct ext2fs_hashmap_entry **it);
void ext2fs_hashmap_del(struct ext2fs_hashmap *h,
struct ext2fs_hashmap_entry *e);
void ext2fs_hashmap_free(struct ext2fs_hashmap *h);
uint32_t ext2fs_djb2_hash(const void *str, size_t size);
#endif /* !HASHMAP_H */

114
include/e2fsprogs/ext2fs/irel.h Executable file
View File

@@ -0,0 +1,114 @@
/*
* irel.h
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
* General Public License, version 2.
* %End-Header%
*/
struct ext2_inode_reference {
blk64_t block;
__u16 offset;
};
struct ext2_inode_relocate_entry {
ext2_ino_t new;
ext2_ino_t orig;
__u16 flags;
__u16 max_refs;
};
typedef struct ext2_inode_relocation_table *ext2_irel;
struct ext2_inode_relocation_table {
__u32 magic;
char *name;
ext2_ino_t current;
void *priv_data;
/*
* Add an inode relocation entry.
*/
errcode_t (*put)(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent);
/*
* Get an inode relocation entry.
*/
errcode_t (*get)(ext2_irel irel, ext2_ino_t old,
struct ext2_inode_relocate_entry *ent);
/*
* Get an inode relocation entry by its original inode number
*/
errcode_t (*get_by_orig)(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent);
/*
* Initialize for iterating over the inode relocation entries.
*/
errcode_t (*start_iter)(ext2_irel irel);
/*
* The iterator function for the inode relocation entries.
* Returns an inode number of 0 when out of entries.
*/
errcode_t (*next)(ext2_irel irel, ext2_ino_t *old,
struct ext2_inode_relocate_entry *ent);
/*
* Add an inode reference (i.e., note the fact that a
* particular block/offset contains a reference to an inode)
*/
errcode_t (*add_ref)(ext2_irel irel, ext2_ino_t ino,
struct ext2_inode_reference *ref);
/*
* Initialize for iterating over the inode references for a
* particular inode.
*/
errcode_t (*start_iter_ref)(ext2_irel irel, ext2_ino_t ino);
/*
* The iterator function for the inode references for an
* inode. The references for only one inode can be iterator
* over at a time, as the iterator state is stored in ext2_irel.
*/
errcode_t (*next_ref)(ext2_irel irel,
struct ext2_inode_reference *ref);
/*
* Move the inode relocation table from one inode number to
* another. Note that the inode references also must move.
*/
errcode_t (*move)(ext2_irel irel, ext2_ino_t old, ext2_ino_t new);
/*
* Remove an inode relocation entry, along with all of the
* inode references.
*/
errcode_t (*delete)(ext2_irel irel, ext2_ino_t old);
/*
* Free the inode relocation table.
*/
errcode_t (*free)(ext2_irel irel);
};
errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode,
ext2_irel *irel);
#define ext2fs_irel_put(irel, old, ent) ((irel)->put((irel), old, ent))
#define ext2fs_irel_get(irel, old, ent) ((irel)->get((irel), old, ent))
#define ext2fs_irel_get_by_orig(irel, orig, old, ent) \
((irel)->get_by_orig((irel), orig, old, ent))
#define ext2fs_irel_start_iter(irel) ((irel)->start_iter((irel)))
#define ext2fs_irel_next(irel, old, ent) ((irel)->next((irel), old, ent))
#define ext2fs_irel_add_ref(irel, ino, ref) ((irel)->add_ref((irel), ino, ref))
#define ext2fs_irel_start_iter_ref(irel, ino) ((irel)->start_iter_ref((irel), ino))
#define ext2fs_irel_next_ref(irel, ref) ((irel)->next_ref((irel), ref))
#define ext2fs_irel_move(irel, old, new) ((irel)->move((irel), old, new))
#define ext2fs_irel_delete(irel, old) ((irel)->delete((irel), old))
#define ext2fs_irel_free(irel) ((irel)->free((irel)))

View File

@@ -0,0 +1,113 @@
#ifndef _JFS_COMPAT_H
#define _JFS_COMPAT_H
#include "kernel-list.h"
#include <errno.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <arpa/inet.h>
#include <stdbool.h>
#define printk printf
#define KERN_ERR ""
#define KERN_DEBUG ""
#define REQ_OP_READ 0
#define REQ_OP_WRITE 1
#define cpu_to_le16(x) ext2fs_cpu_to_le16(x)
#define cpu_to_be16(x) ext2fs_cpu_to_be16(x)
#define cpu_to_le32(x) ext2fs_cpu_to_le32(x)
#define cpu_to_be32(x) ext2fs_cpu_to_be32(x)
#define cpu_to_le64(x) ext2fs_cpu_to_le64(x)
#define cpu_to_be64(x) ext2fs_cpu_to_be64(x)
#define le16_to_cpu(x) ext2fs_le16_to_cpu(x)
#define be16_to_cpu(x) ext2fs_be16_to_cpu(x)
#define le32_to_cpu(x) ext2fs_le32_to_cpu(x)
#define be32_to_cpu(x) ext2fs_be32_to_cpu(x)
#define le64_to_cpu(x) ext2fs_le64_to_cpu(x)
#define be64_to_cpu(x) ext2fs_be64_to_cpu(x)
typedef unsigned int tid_t;
typedef struct journal_s journal_t;
typedef struct kdev_s *kdev_t;
struct buffer_head;
struct inode;
typedef unsigned int gfp_t;
#define GFP_KERNEL 0
#define GFP_NOFS 0
#define __GFP_NOFAIL 0
#define JBD2_TAG_SIZE32 JBD_TAG_SIZE32
#define JBD2_BARRIER 0
typedef __u64 u64;
#define put_bh(x) brelse(x)
#define crc32_be(x, y, z) ext2fs_crc32_be((x), (y), (z))
#define spin_lock_init(x)
#define spin_lock(x)
#define spin_unlock(x)
#define SLAB_HWCACHE_ALIGN 0
#define SLAB_TEMPORARY 0
#define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\
sizeof(struct __struct), __alignof__(struct __struct),\
(__flags), NULL)
#define blkdev_issue_flush(kdev) sync_blockdev(kdev)
#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
#define pr_emerg(fmt)
#define pr_err(...)
enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
#define JBD2_FC_REPLAY_STOP 0
#define JBD2_FC_REPLAY_CONTINUE 1
struct journal_s
{
unsigned long j_flags;
int j_errno;
struct buffer_head * j_sb_buffer;
struct journal_superblock_s *j_superblock;
int j_format_version;
unsigned long j_head;
unsigned long j_tail;
unsigned long j_fc_first;
unsigned long j_fc_off;
unsigned long j_fc_last;
unsigned long j_free;
unsigned long j_first, j_last;
kdev_t j_dev;
kdev_t j_fs_dev;
int j_blocksize;
unsigned int j_blk_offset;
unsigned int j_total_len;
struct inode * j_inode;
tid_t j_tail_sequence;
tid_t j_transaction_sequence;
__u8 j_uuid[16];
struct jbd2_revoke_table_s *j_revoke;
struct jbd2_revoke_table_s *j_revoke_table[2];
tid_t j_failed_commit;
__u32 j_csum_seed;
int (*j_fc_replay_callback)(struct journal_s *journal,
struct buffer_head *bh,
enum passtype pass, int off,
tid_t expected_tid);
};
#define is_journal_abort(x) 0
#define BUFFER_TRACE(bh, info) do {} while (0)
/* Need this so we can compile with configure --enable-gcc-wall */
#ifdef NO_INLINE_FUNCS
#define inline
#endif
#endif /* _JFS_COMPAT_H */

View File

@@ -0,0 +1,456 @@
/*
* linux/include/linux/jbd.h
*
* Written by Stephen C. Tweedie <sct@redhat.com>
*
* Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
*
* This file is part of the Linux kernel and is made available under
* the terms of the GNU General Public License, version 2, or at your
* option, any later version, incorporated herein by reference.
*
* Definitions for transaction data structures for the buffer cache
* filesystem journaling support.
*/
#ifndef _LINUX_JBD_H
#define _LINUX_JBD_H
#include "jfs_compat.h"
#define JFS_DEBUG
#define jfs_debug jbd_debug
#ifndef __GNUC__
#define __FUNCTION__ ""
#endif
#define journal_oom_retry 0
#ifdef CONFIG_JBD_DEBUG
/*
* Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
* consistency checks. By default we don't do this unless
* CONFIG_JBD_DEBUG is on.
*/
#define JBD_EXPENSIVE_CHECKING
extern int journal_enable_debug;
#else
#define journal_enable_debug (-1)
#endif /* !CONFIG_JBD_DEBUG */
#ifdef __STDC__
#define jbd_debug(n, f, a...) \
do { \
if ((n) <= journal_enable_debug) { \
printk (KERN_DEBUG "(%s, %d): %s: ", \
__FILE__, __LINE__, __FUNCTION__); \
printk (f, ## a); \
} \
} while (0)
#else
#define jbd_debug(x) /* AIX doesn't do STDC */
#endif /* !__STDC__ */
extern void * __jbd_kmalloc (char *where, size_t size, int flags, int retry);
#define jbd_kmalloc(size, flags) \
__jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
#define jbd_rep_kmalloc(size, flags) \
__jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
#define JBD2_MIN_JOURNAL_BLOCKS 1024
#define JBD2_DEFAULT_FAST_COMMIT_BLOCKS 256
/*
* Internal structures used by the logging mechanism:
*/
#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
/*
* On-disk structures
*/
/*
* Descriptor block types:
*/
#define JBD2_DESCRIPTOR_BLOCK 1
#define JBD2_COMMIT_BLOCK 2
#define JBD2_SUPERBLOCK_V1 3
#define JBD2_SUPERBLOCK_V2 4
#define JBD2_REVOKE_BLOCK 5
#define JBD2_FC_BLOCK 6
/*
* Standard header for all descriptor blocks:
*/
typedef struct journal_header_s
{
__be32 h_magic;
__be32 h_blocktype;
__be32 h_sequence;
} journal_header_t;
/*
* Checksum types.
*/
#define JBD2_CRC32_CHKSUM 1
#define JBD2_MD5_CHKSUM 2
#define JBD2_SHA1_CHKSUM 3
#define JBD2_CRC32C_CHKSUM 4
#define JBD2_CRC32_CHKSUM_SIZE 4
#define JBD2_CHECKSUM_BYTES (32 / sizeof(__u32))
/*
* Commit block header for storing transactional checksums:
*
* NOTE: If FEATURE_COMPAT_CHECKSUM (checksum v1) is set, the h_chksum*
* fields are used to store a checksum of the descriptor and data blocks.
*
* If FEATURE_INCOMPAT_CSUM_V2 (checksum v2) is set, then the h_chksum
* field is used to store crc32c(uuid+commit_block). Each journal metadata
* block gets its own checksum, and data block checksums are stored in
* journal_block_tag (in the descriptor). The other h_chksum* fields are
* not used.
*
* If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
* journal_block_tag3_t to store a full 32-bit checksum. Everything else
* is the same as v2.
*
* Checksum v1, v2, and v3 are mutually exclusive features.
*/
struct commit_header {
__be32 h_magic;
__be32 h_blocktype;
__be32 h_sequence;
unsigned char h_chksum_type;
unsigned char h_chksum_size;
unsigned char h_padding[2];
__be32 h_chksum[JBD2_CHECKSUM_BYTES];
__be64 h_commit_sec;
__be32 h_commit_nsec;
};
/*
* The block tag: used to describe a single buffer in the journal
*/
typedef struct journal_block_tag3_s
{
__be32 t_blocknr; /* The on-disk block number */
__be32 t_flags; /* See below */
__be32 t_blocknr_high; /* most-significant high 32bits. */
__be32 t_checksum; /* crc32c(uuid+seq+block) */
} journal_block_tag3_t;
typedef struct journal_block_tag_s
{
__be32 t_blocknr; /* The on-disk block number */
__be16 t_checksum; /* truncated crc32c(uuid+seq+block) */
__be16 t_flags; /* See below */
__be32 t_blocknr_high; /* most-significant high 32bits. */
} journal_block_tag_t;
/* Tail of descriptor or revoke block, for checksumming */
struct jbd2_journal_block_tail {
__be32 t_checksum;
};
/*
* The revoke descriptor: used on disk to describe a series of blocks to
* be revoked from the log
*/
typedef struct journal_revoke_header_s
{
journal_header_t r_header;
__be32 r_count; /* Count of bytes used in the block */
} jbd2_journal_revoke_header_t;
/* Definitions for the journal tag flags word: */
#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
#define JBD2_FLAG_SAME_UUID 2 /* block has same uuid as previous */
#define JBD2_FLAG_DELETED 4 /* block deleted by this transaction */
#define JBD2_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
#define UUID_SIZE 16
#define JBD2_USERS_MAX 48
#define JBD2_USERS_SIZE (UUID_SIZE * JBD2_USERS_MAX)
/*
* The journal superblock. All fields are in big-endian byte order.
*/
typedef struct journal_superblock_s
{
/* 0x0000 */
journal_header_t s_header;
/* 0x000C */
/* Static information describing the journal */
__be32 s_blocksize; /* journal device blocksize */
__be32 s_maxlen; /* total blocks in journal file */
__be32 s_first; /* first block of log information */
/* 0x0018 */
/* Dynamic information describing the current state of the log */
__be32 s_sequence; /* first commit ID expected in log */
__be32 s_start; /* blocknr of start of log */
/* 0x0020 */
/* Error value, as set by journal_abort(). */
__s32 s_errno;
/* 0x0024 */
/* Remaining fields are only valid in a version-2 superblock */
__be32 s_feature_compat; /* compatible feature set */
__be32 s_feature_incompat; /* incompatible feature set */
__be32 s_feature_ro_compat; /* readonly-compatible feature set */
/* 0x0030 */
__u8 s_uuid[16]; /* 128-bit uuid for journal */
/* 0x0040 */
__be32 s_nr_users; /* Nr of filesystems sharing log */
__be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
/* 0x0048 */
__be32 s_max_transaction; /* Limit of journal blocks per trans.*/
__be32 s_max_trans_data; /* Limit of data blocks per trans. */
/* 0x0050 */
__u8 s_checksum_type; /* checksum type */
__u8 s_padding2[3];
/* 0x0054 */
__be32 s_num_fc_blks; /* Number of fast commit blocks */
/* 0x0058 */
__be32 s_padding[41];
__be32 s_checksum; /* crc32c(superblock) */
/* 0x0100 */
__u8 s_users[JBD2_USERS_SIZE]; /* ids of all fs'es sharing the log */
/* 0x0400 */
} journal_superblock_t;
#define JBD2_HAS_COMPAT_FEATURE(j,mask) \
((j)->j_format_version >= 2 && \
((j)->j_superblock->s_feature_compat & ext2fs_cpu_to_be32((mask))))
#define JBD2_HAS_RO_COMPAT_FEATURE(j,mask) \
((j)->j_format_version >= 2 && \
((j)->j_superblock->s_feature_ro_compat & ext2fs_cpu_to_be32((mask))))
#define JBD2_HAS_INCOMPAT_FEATURE(j,mask) \
((j)->j_format_version >= 2 && \
((j)->j_superblock->s_feature_incompat & ext2fs_cpu_to_be32((mask))))
#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
#define JBD2_FEATURE_INCOMPAT_FAST_COMMIT 0x00000020
/* Features known to this kernel version: */
#define JBD2_KNOWN_COMPAT_FEATURES 0
#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE|\
JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT| \
JBD2_FEATURE_INCOMPAT_64BIT|\
JBD2_FEATURE_INCOMPAT_CSUM_V2| \
JBD2_FEATURE_INCOMPAT_CSUM_V3 | \
JBD2_FEATURE_INCOMPAT_FAST_COMMIT)
#ifdef NO_INLINE_FUNCS
extern size_t journal_tag_bytes(journal_t *journal);
extern int jbd2_journal_has_csum_v2or3(journal_t *journal);
extern int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb);
extern int tid_gt(tid_t x, tid_t y) EXT2FS_ATTR((unused));
extern int tid_geq(tid_t x, tid_t y) EXT2FS_ATTR((unused));
#endif
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
#if (__STDC_VERSION__ >= 199901L)
#define _INLINE_ extern inline
#else
#define _INLINE_ inline
#endif
#else /* !E2FSCK_INCLUDE_INLINE FUNCS */
#if (__STDC_VERSION__ >= 199901L)
#define _INLINE_ inline
#else /* not C99 */
#ifdef __GNUC__
#define _INLINE_ extern __inline__
#else /* For Watcom C */
#define _INLINE_ extern inline
#endif /* __GNUC__ */
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* INCLUDE_INLINE_FUNCS */
/* journal feature predicate functions */
#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
{ \
return ((j)->j_format_version >= 2 && \
((j)->j_superblock->s_feature_compat & \
ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname)) != 0); \
} \
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_compat |= \
ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
} \
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_compat &= \
~ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
}
#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
{ \
return ((j)->j_format_version >= 2 && \
((j)->j_superblock->s_feature_ro_compat & \
ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname)) != 0); \
} \
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_ro_compat |= \
ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
} \
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_ro_compat &= \
~ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
}
#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
{ \
return ((j)->j_format_version >= 2 && \
((j)->j_superblock->s_feature_incompat & \
ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname)) != 0); \
} \
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_incompat |= \
ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
} \
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_incompat &= \
~ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
}
#else
#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
extern int jbd2_has_feature_##name(journal_t *j); \
extern void jbd2_set_feature_##name(journal_t *j); \
extern void jbd2_clear_feature_##name(journal_t *j);
#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
extern int jbd2_has_feature_##name(journal_t *j); \
extern void jbd2_set_feature_##name(journal_t *j); \
extern void jbd2_clear_feature_##name(journal_t *j);
#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
extern int jbd2_has_feature_##name(journal_t *j); \
extern void jbd2_set_feature_##name(journal_t *j); \
extern void jbd2_clear_feature_##name(journal_t *j);
#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */
JBD2_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
JBD2_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
JBD2_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
/*
* helper functions to deal with 32 or 64bit block numbers.
*/
_INLINE_ size_t journal_tag_bytes(journal_t *journal)
{
size_t sz;
if (jbd2_has_feature_csum3(journal))
return sizeof(journal_block_tag3_t);
sz = sizeof(journal_block_tag_t);
if (jbd2_has_feature_csum2(journal))
sz += sizeof(__u16);
if (jbd2_has_feature_64bit(journal))
return sz;
return sz - sizeof(__u32);
}
_INLINE_ int jbd2_journal_has_csum_v2or3(journal_t *journal)
{
if (jbd2_has_feature_csum2(journal) || jbd2_has_feature_csum3(journal))
return 1;
return 0;
}
_INLINE_ int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb)
{
int num_fc_blocks = be32_to_cpu(jsb->s_num_fc_blks);
return num_fc_blocks ? num_fc_blocks : JBD2_DEFAULT_FAST_COMMIT_BLOCKS;
}
/* Comparison functions for transaction IDs: perform comparisons using
* modulo arithmetic so that they work over sequence number wraps. */
_INLINE_ int tid_gt(tid_t x, tid_t y)
{
int difference = (x - y);
return (difference > 0);
}
_INLINE_ int tid_geq(tid_t x, tid_t y)
{
int difference = (x - y);
return (difference >= 0);
}
#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */
#undef _INLINE_
extern int journal_blocks_per_page(struct inode *inode);
/*
* Definitions which augment the buffer_head layer
*/
/* journaling buffer types */
#define BJ_None 0 /* Not journaled */
#define BJ_SyncData 1 /* Normal data: flush before commit */
#define BJ_AsyncData 2 /* writepage data: wait on it before commit */
#define BJ_Metadata 3 /* Normal journaled metadata */
#define BJ_Forget 4 /* Buffer superseded by this transaction */
#define BJ_IO 5 /* Buffer is for temporary IO use */
#define BJ_Shadow 6 /* Buffer contents being shadowed to the log */
#define BJ_LogCtl 7 /* Buffer contains log descriptors */
#define BJ_Reserved 8 /* Buffer is reserved for access by journal */
#define BJ_Types 9
extern int jbd_blocks_per_page(struct inode *inode);
#endif /* _LINUX_JBD_H */

View File

@@ -0,0 +1,111 @@
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
#include "compiler.h"
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
#if (!defined(__GNUC__) && !defined(__WATCOMC__))
#define __inline__
#endif
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_add(struct list_head * new,
struct list_head * prev,
struct list_head * next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
/*
* Insert a new entry after the specified head..
*/
static __inline__ void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
/*
* Insert a new entry at the tail
*/
static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
{
__list_add(new, head->prev, head);
}
/*
* Delete a list entry by making the prev/next entries
* point to each other.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_del(struct list_head * prev,
struct list_head * next)
{
next->prev = prev;
prev->next = next;
}
static __inline__ void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
}
static __inline__ int list_empty(struct list_head *head)
{
return head->next == head;
}
/*
* Splice in "list" into "head"
*/
static __inline__ void list_splice(struct list_head *list, struct list_head *head)
{
struct list_head *first = list->next;
if (first != list) {
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
}
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#endif

114
include/e2fsprogs/ext2fs/qcow2.h Executable file
View File

@@ -0,0 +1,114 @@
/*
* qcow2.h --- structures and function prototypes for qcow2.c to generate
* qcow2 formatted disk images. This format is used originally by QEMU
* for virtual machines, and stores the filesystem data on disk in a
* packed format to avoid creating sparse image files that need lots of
* seeking to read and write.
*
* The qcow2 format supports zlib compression, but that is not yet
* implemented.
*
* It is possible to directly mount a qcow2 image using qemu-nbd:
*
* [root]# modprobe nbd max_part=63
* [root]# qemu-nbd -c /dev/nbd0 image.img
* [root]# mount /dev/nbd0p1 /mnt/qemu
*
* Format details at http://people.gnome.org/~markmc/qcow-image-format.html
*
* Copyright (C) 2010 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
/* Number of l2 tables in memory before writeback */
#define L2_CACHE_PREALLOC 512
#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
#define QCOW_VERSION 2
#define QCOW_OFLAG_COPIED (1ULL << 63)
#define QCOW_OFLAG_COMPRESSED (1ULL << 62)
#define QCOW_COMPRESSED 1
#define QCOW_ENCRYPTED 2
#define QCOW_CORRUPTED 3
struct ext2_qcow2_hdr {
__u32 magic;
__u32 version;
__u64 backing_file_offset;
__u32 backing_file_size;
__u32 cluster_bits;
__u64 size;
__u32 crypt_method;
__u32 l1_size;
__u64 l1_table_offset;
__u64 refcount_table_offset;
__u32 refcount_table_clusters;
__u32 nb_snapshots;
__u64 snapshots_offset;
};
typedef struct ext2_qcow2_l2_table L2_CACHE_HEAD;
struct ext2_qcow2_l2_table {
__u32 l1_index;
__u64 offset;
__u64 *data;
L2_CACHE_HEAD *next;
};
struct ext2_qcow2_l2_cache {
L2_CACHE_HEAD *used_head;
L2_CACHE_HEAD *used_tail;
L2_CACHE_HEAD *free_head;
__u32 free;
__u32 count;
__u64 next_offset;
};
struct ext2_qcow2_refcount {
__u64 *refcount_table;
__u64 refcount_table_offset;
__u64 refcount_block_offset;
__u32 refcount_table_clusters;
__u32 refcount_table_index;
__u32 refcount_block_index;
__u16 *refcount_block;
};
struct ext2_qcow2_image {
int fd;
struct ext2_qcow2_hdr *hdr;
struct ext2_qcow2_l2_cache *l2_cache;
struct ext2_qcow2_refcount refcount;
__u32 cluster_size;
__u32 cluster_bits;
__u32 l1_size;
__u32 l2_size;
__u64 *l1_table;
__u64 l2_offset;
__u64 l1_offset;
__u64 image_size;
};
/* Function prototypes */
/* qcow2.c */
/* Functions for converting qcow2 image into raw image */
struct ext2_qcow2_hdr *qcow2_read_header(int);
int qcow2_write_raw_image(int, int, struct ext2_qcow2_hdr *);

183
include/e2fsprogs/ext2fs/rbtree.h Executable file
View File

@@ -0,0 +1,183 @@
/*
Red Black Trees
(C) 1999 Andrea Arcangeli <andrea@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
linux/include/linux/rbtree.h
To use rbtrees you'll have to implement your own insert and search cores.
This will avoid us to use callbacks and to drop dramatically performances.
I know it's not the cleaner way, but in C (not in C++) to get
performances and genericity...
Some example of insert and search follows here. The search is a plain
normal search over an ordered tree. The insert instead must be implemented
in two steps: First, the code must insert the element in order as a red leaf
in the tree, and then the support library function rb_insert_color() must
be called. Such function will do the not trivial work to rebalance the
rbtree, if necessary.
-----------------------------------------------------------------------
static inline struct page * rb_search_page_cache(struct inode * inode,
unsigned long offset)
{
struct rb_node * n = inode->i_rb_page_cache.rb_node;
struct page * page;
while (n)
{
page = rb_entry(n, struct page, rb_page_cache);
if (offset < page->offset)
n = n->rb_left;
else if (offset > page->offset)
n = n->rb_right;
else
return page;
}
return NULL;
}
static inline struct page * __rb_insert_page_cache(struct inode * inode,
unsigned long offset,
struct rb_node * node)
{
struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
struct rb_node * parent = NULL;
struct page * page;
while (*p)
{
parent = *p;
page = rb_entry(parent, struct page, rb_page_cache);
if (offset < page->offset)
p = &(*p)->rb_left;
else if (offset > page->offset)
p = &(*p)->rb_right;
else
return page;
}
rb_link_node(node, parent, p);
return NULL;
}
static inline struct page * rb_insert_page_cache(struct inode * inode,
unsigned long offset,
struct rb_node * node)
{
struct page * ret;
if ((ret = __rb_insert_page_cache(inode, offset, node)))
goto out;
rb_insert_color(node, &inode->i_rb_page_cache);
out:
return ret;
}
-----------------------------------------------------------------------
*/
#ifndef _LINUX_RBTREE_H
#define _LINUX_RBTREE_H
#include <stdlib.h>
#include <stdint.h>
#include "compiler.h"
#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
struct rb_node
{
uintptr_t rb_parent_color;
#define RB_RED 0
#define RB_BLACK 1
struct rb_node *rb_right;
struct rb_node *rb_left;
} __attribute__((aligned(sizeof(long))));
/* The alignment might seem pointless, but allegedly CRIS needs it */
struct rb_root
{
struct rb_node *rb_node;
};
#define ext2fs_rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
#define ext2fs_rb_color(r) ((r)->rb_parent_color & 1)
#define ext2fs_rb_is_red(r) (!ext2fs_rb_color(r))
#define ext2fs_rb_is_black(r) ext2fs_rb_color(r)
#define ext2fs_rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
#define ext2fs_rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
static inline void ext2fs_rb_set_parent(struct rb_node *rb, struct rb_node *p)
{
rb->rb_parent_color = (rb->rb_parent_color & 3) | (uintptr_t)p;
}
static inline void ext2fs_rb_set_color(struct rb_node *rb, int color)
{
rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
}
#define RB_ROOT (struct rb_root) { NULL, }
#define ext2fs_rb_entry(ptr, type, member) container_of(ptr, type, member)
static inline int ext2fs_rb_empty_root(struct rb_root *root)
{
return root->rb_node == NULL;
}
static inline int ext2fs_rb_empty_node(struct rb_node *node)
{
return ext2fs_rb_parent(node) == node;
}
static inline void ext2fs_rb_clear_node(struct rb_node *node)
{
ext2fs_rb_set_parent(node, node);
}
extern void ext2fs_rb_insert_color(struct rb_node *, struct rb_root *);
extern void ext2fs_rb_erase(struct rb_node *, struct rb_root *);
/* Find logical next and previous nodes in a tree */
extern struct rb_node *ext2fs_rb_next(struct rb_node *);
extern struct rb_node *ext2fs_rb_prev(struct rb_node *);
extern struct rb_node *ext2fs_rb_first(const struct rb_root *);
extern struct rb_node *ext2fs_rb_last(const struct rb_root *);
/* Fast replacement of a single node without remove/rebalance/add/rebalance */
extern void ext2fs_rb_replace_node(struct rb_node *victim, struct rb_node *new,
struct rb_root *root);
static inline void ext2fs_rb_link_node(struct rb_node * node,
struct rb_node * parent,
struct rb_node ** rb_link)
{
node->rb_parent_color = (uintptr_t)parent;
node->rb_left = node->rb_right = NULL;
*rb_link = node;
}
#if __GNUC_PREREQ (4, 6)
#pragma GCC diagnostic pop
#endif
#endif /* _LINUX_RBTREE_H */

215
include/e2fsprogs/ext2fs/tdb.h Executable file
View File

@@ -0,0 +1,215 @@
#ifndef __TDB_H__
#define __TDB_H__
/*
Unix SMB/CIFS implementation.
trivial database library
Copyright (C) Andrew Tridgell 1999-2004
** NOTE! The following LGPL license applies to the tdb
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef __cplusplus
extern "C" {
#endif
/* flags to tdb_store() */
#define TDB_REPLACE 1
#define TDB_INSERT 2
#define TDB_MODIFY 3
/* flags for tdb_open() */
#define TDB_DEFAULT 0 /* just a readability place holder */
#define TDB_CLEAR_IF_FIRST 1
#define TDB_INTERNAL 2 /* don't store on disk */
#define TDB_NOLOCK 4 /* don't do any locking */
#define TDB_NOMMAP 8 /* don't use mmap */
#define TDB_CONVERT 16 /* convert endian (internal use) */
#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */
#define TDB_NOSYNC 64 /* don't use synchronous transactions */
#define TDB_SEQNUM 128 /* maintain a sequence number */
#define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)
/* error codes */
enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
/* debugging uses one of the following levels */
enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR,
TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
typedef struct TDB_DATA {
unsigned char *dptr;
size_t dsize;
} TDB_DATA;
#ifndef PRINTF_ATTRIBUTE
#if (__GNUC__ >= 3)
/** Use gcc attribute to check printf fns. a1 is the 1-based index of
* the parameter containing the format, and a2 the index of the first
* argument. Note that some gcc 2.x versions don't handle this
* properly **/
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
#else
#define PRINTF_ATTRIBUTE(a1, a2)
#endif
#endif
/* ext2fs tdb renames */
#define tdb_open ext2fs_tdb_open
#define tdb_open_ex ext2fs_tdb_open_ex
#define tdb_set_max_dead ext2fs_tdb_set_max_dead
#define tdb_reopen ext2fs_tdb_reopen
#define tdb_reopen_all ext2fs_tdb_reopen_all
#define tdb_set_logging_function ext2fs_tdb_set_logging_function
#define tdb_error ext2fs_tdb_error
#define tdb_errorstr ext2fs_tdb_errorstr
#define tdb_fetch ext2fs_tdb_fetch
#define tdb_parse_record ext2fs_tdb_parse_record
#define tdb_delete ext2fs_tdb_delete
#define tdb_store ext2fs_tdb_store
#define tdb_append ext2fs_tdb_append
#define tdb_close ext2fs_tdb_close
#define tdb_firstkey ext2fs_tdb_firstkey
#define tdb_nextkey ext2fs_tdb_nextkey
#define tdb_traverse ext2fs_tdb_traverse
#define tdb_traverse_read ext2fs_tdb_traverse_read
#define tdb_exists ext2fs_tdb_exists
#define tdb_lockall ext2fs_tdb_lockall
#define tdb_unlockall ext2fs_tdb_unlockall
#define tdb_lockall_read ext2fs_tdb_lockall_read
#define tdb_unlockall_read ext2fs_tdb_unlockall_read
#define tdb_name ext2fs_tdb_name
#define tdb_fd ext2fs_tdb_fd
#define tdb_log_fn ext2fs_tdb_log_fn
#define tdb_get_logging_private ext2fs_tdb_get_logging_private
#define tdb_transaction_start ext2fs_tdb_transaction_start
#define tdb_transaction_commit ext2fs_tdb_transaction_commit
#define tdb_transaction_cancel ext2fs_tdb_transaction_cancel
#define tdb_transaction_recover ext2fs_tdb_transaction_recover
#define tdb_get_seqnum ext2fs_tdb_get_seqnum
#define tdb_hash_size ext2fs_tdb_hash_size
#define tdb_map_size ext2fs_tdb_map_size
#define tdb_get_flags ext2fs_tdb_get_flags
#define tdb_chainlock ext2fs_tdb_chainlock
#define tdb_chainunlock ext2fs_tdb_chainunlock
#define tdb_chainlock_read ext2fs_tdb_chainlock_read
#define tdb_chainunlock_read ext2fs_tdb_chainunlock_read
#define tdb_dump_all ext2fs_tdb_dump_all
#define tdb_printfreelist ext2fs_tdb_printfreelist
#define tdb_validate_freelist ext2fs_tdb_validate_freelist
#define tdb_chainlock_mark ext2fs_tdb_chainlock_mark
#define tdb_chainlock_nonblock ext2fs_tdb_chainlock_nonblock
#define tdb_chainlock_unmark ext2fs_tdb_chainlock_unmark
#define tdb_enable_seqnum ext2fs_tdb_enable_seqnum
#define tdb_increment_seqnum_nonblock ext2fs_tdb_increment_seqnum_nonblock
#define tdb_lock_nonblock ext2fs_tdb_lock_nonblock
#define tdb_lockall_mark ext2fs_tdb_lockall_mark
#define tdb_lockall_nonblock ext2fs_tdb_lockall_nonblock
#define tdb_lockall_read_nonblock ext2fs_tdb_lockall_read_nonblock
#define tdb_lockall_unmark ext2fs_tdb_lockall_unmark
#define tdb_flush ext2fs_tdb_flush
/* this is the context structure that is returned from a db open */
typedef struct tdb_context TDB_CONTEXT;
typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4);
typedef unsigned int (*tdb_hash_func)(TDB_DATA *key);
struct tdb_logging_context {
tdb_log_func log_fn;
void *log_private;
};
struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode);
struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode,
const struct tdb_logging_context *log_ctx,
tdb_hash_func hash_fn);
void tdb_set_max_dead(struct tdb_context *tdb, int max_dead);
int tdb_reopen(struct tdb_context *tdb);
int tdb_reopen_all(int parent_longlived);
void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx);
enum TDB_ERROR tdb_error(struct tdb_context *tdb);
const char *tdb_errorstr(struct tdb_context *tdb);
TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key);
int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
int (*parser)(TDB_DATA key, TDB_DATA data,
void *private_data),
void *private_data);
int tdb_delete(struct tdb_context *tdb, TDB_DATA key);
int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
int tdb_close(struct tdb_context *tdb);
TDB_DATA tdb_firstkey(struct tdb_context *tdb);
TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key);
int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *);
int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *);
int tdb_exists(struct tdb_context *tdb, TDB_DATA key);
int tdb_lockall(struct tdb_context *tdb);
int tdb_lockall_nonblock(struct tdb_context *tdb);
int tdb_unlockall(struct tdb_context *tdb);
int tdb_lockall_read(struct tdb_context *tdb);
int tdb_lockall_read_nonblock(struct tdb_context *tdb);
int tdb_unlockall_read(struct tdb_context *tdb);
int tdb_lockall_mark(struct tdb_context *tdb);
int tdb_lockall_unmark(struct tdb_context *tdb);
const char *tdb_name(struct tdb_context *tdb);
int tdb_fd(struct tdb_context *tdb);
tdb_log_func tdb_log_fn(struct tdb_context *tdb);
void *tdb_get_logging_private(struct tdb_context *tdb);
int tdb_transaction_start(struct tdb_context *tdb);
int tdb_transaction_commit(struct tdb_context *tdb);
int tdb_transaction_cancel(struct tdb_context *tdb);
int tdb_transaction_recover(struct tdb_context *tdb);
int tdb_get_seqnum(struct tdb_context *tdb);
int tdb_hash_size(struct tdb_context *tdb);
size_t tdb_map_size(struct tdb_context *tdb);
int tdb_get_flags(struct tdb_context *tdb);
void tdb_enable_seqnum(struct tdb_context *tdb);
void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
int tdb_flush(struct tdb_context *tdb);
/* Low level locking functions: use with care */
int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key);
int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key);
/* Debug functions. Not used in production. */
void tdb_dump_all(struct tdb_context *tdb);
int tdb_printfreelist(struct tdb_context *tdb);
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
#ifdef __cplusplus
}
#endif
#endif /* tdb.h */

File diff suppressed because it is too large Load Diff

120
include/e2fsprogs/ext2fs/utf8n.h Executable file
View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 2014 SGI.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
/* This code is copied from the linux kernel. We have a userspace
* version here to such that hashes will match that implementation.
*/
#ifndef UTF8NORM_H
#define UTF8NORM_H
#include <stdint.h>
#include <unistd.h>
#include <string.h>
/* Encoding a unicode version number as a single unsigned int. */
#define UNICODE_MAJ_SHIFT (16)
#define UNICODE_MIN_SHIFT (8)
#define UNICODE_AGE(MAJ, MIN, REV) \
(((unsigned int)(MAJ) << UNICODE_MAJ_SHIFT) | \
((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \
((unsigned int)(REV)))
/* Highest unicode version supported by the data tables. */
extern int utf8version_is_supported(uint8_t maj, uint8_t min, uint8_t rev);
extern int utf8version_latest(void);
/*
* Look for the correct const struct utf8data for a unicode version.
* Returns NULL if the version requested is too new.
*
* Two normalization forms are supported: nfdi and nfdicf.
*
* nfdi:
* - Apply unicode normalization form NFD.
* - Remove any Default_Ignorable_Code_Point.
*
* nfdicf:
* - Apply unicode normalization form NFD.
* - Remove any Default_Ignorable_Code_Point.
* - Apply a full casefold (C + F).
*/
extern const struct utf8data *utf8nfdi(unsigned int maxage);
extern const struct utf8data *utf8nfdicf(unsigned int maxage);
/*
* Determine the maximum age of any unicode character in the string.
* Returns 0 if only unassigned code points are present.
* Returns -1 if the input is not valid UTF-8.
*/
extern int utf8agemax(const struct utf8data *data, const char *s);
extern int utf8nagemax(const struct utf8data *data, const char *s, size_t len);
/*
* Determine the minimum age of any unicode character in the string.
* Returns 0 if any unassigned code points are present.
* Returns -1 if the input is not valid UTF-8.
*/
extern int utf8agemin(const struct utf8data *data, const char *s);
extern int utf8nagemin(const struct utf8data *data, const char *s, size_t len);
/*
* Determine the length of the normalized from of the string,
* excluding any terminating NULL byte.
* Returns 0 if only ignorable code points are present.
* Returns -1 if the input is not valid UTF-8.
*/
extern ssize_t utf8len(const struct utf8data *data, const char *s);
extern ssize_t utf8nlen(const struct utf8data *data, const char *s, size_t len);
/* Needed in struct utf8cursor below. */
#define UTF8HANGULLEAF (12)
/*
* Cursor structure used by the normalizer.
*/
struct utf8cursor {
const struct utf8data *data;
const char *s;
const char *p;
const char *ss;
const char *sp;
unsigned int len;
unsigned int slen;
short int ccc;
short int nccc;
unsigned char hangul[UTF8HANGULLEAF];
};
/*
* Initialize a utf8cursor to normalize a string.
* Returns 0 on success.
* Returns -1 on failure.
*/
extern int utf8cursor(struct utf8cursor *u8c, const struct utf8data *data,
const char *s);
extern int utf8ncursor(struct utf8cursor *u8c, const struct utf8data *data,
const char *s, size_t len);
/*
* Get the next byte in the normalization.
* Returns a value > 0 && < 256 on success.
* Returns 0 when the end of the normalization is reached.
* Returns -1 if the string being normalized is not valid UTF-8.
*/
extern int utf8byte(struct utf8cursor *u8c);
#endif /* UTF8NORM_H */

166
include/e2fsprogs/magic.h Executable file
View File

@@ -0,0 +1,166 @@
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _MAGIC_H
#define _MAGIC_H
#include <sys/types.h>
#define MAGIC_NONE 0x0000000 /* No flags */
#define MAGIC_DEBUG 0x0000001 /* Turn on debugging */
#define MAGIC_SYMLINK 0x0000002 /* Follow symlinks */
#define MAGIC_COMPRESS 0x0000004 /* Check inside compressed files */
#define MAGIC_DEVICES 0x0000008 /* Look at the contents of devices */
#define MAGIC_MIME_TYPE 0x0000010 /* Return the MIME type */
#define MAGIC_CONTINUE 0x0000020 /* Return all matches */
#define MAGIC_CHECK 0x0000040 /* Print warnings to stderr */
#define MAGIC_PRESERVE_ATIME 0x0000080 /* Restore access time on exit */
#define MAGIC_RAW 0x0000100 /* Don't convert unprintable chars */
#define MAGIC_ERROR 0x0000200 /* Handle ENOENT etc as real errors */
#define MAGIC_MIME_ENCODING 0x0000400 /* Return the MIME encoding */
#define MAGIC_MIME (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)
#define MAGIC_APPLE 0x0000800 /* Return the Apple creator/type */
#define MAGIC_EXTENSION 0x1000000 /* Return a /-separated list of
* extensions */
#define MAGIC_COMPRESS_TRANSP 0x2000000 /* Check inside compressed files
* but not report compression */
#define MAGIC_NO_COMPRESS_FORK 0x4000000 /* Don't allow decompression that
* needs to fork */
#define MAGIC_NODESC (MAGIC_EXTENSION|MAGIC_MIME|MAGIC_APPLE)
#define MAGIC_NO_CHECK_COMPRESS 0x0001000 /* Don't check for compressed files */
#define MAGIC_NO_CHECK_TAR 0x0002000 /* Don't check for tar files */
#define MAGIC_NO_CHECK_SOFT 0x0004000 /* Don't check magic entries */
#define MAGIC_NO_CHECK_APPTYPE 0x0008000 /* Don't check application type */
#define MAGIC_NO_CHECK_ELF 0x0010000 /* Don't check for elf details */
#define MAGIC_NO_CHECK_TEXT 0x0020000 /* Don't check for text files */
#define MAGIC_NO_CHECK_CDF 0x0040000 /* Don't check for cdf files */
#define MAGIC_NO_CHECK_CSV 0x0080000 /* Don't check for CSV files */
#define MAGIC_NO_CHECK_TOKENS 0x0100000 /* Don't check tokens */
#define MAGIC_NO_CHECK_ENCODING 0x0200000 /* Don't check text encodings */
#define MAGIC_NO_CHECK_JSON 0x0400000 /* Don't check for JSON files */
#define MAGIC_NO_CHECK_SIMH 0x0800000 /* Don't check for SIMH tape files */
/* No built-in tests; only consult the magic file */
#define MAGIC_NO_CHECK_BUILTIN ( \
MAGIC_NO_CHECK_COMPRESS | \
MAGIC_NO_CHECK_TAR | \
/* MAGIC_NO_CHECK_SOFT | */ \
MAGIC_NO_CHECK_APPTYPE | \
MAGIC_NO_CHECK_ELF | \
MAGIC_NO_CHECK_TEXT | \
MAGIC_NO_CHECK_CSV | \
MAGIC_NO_CHECK_CDF | \
MAGIC_NO_CHECK_TOKENS | \
MAGIC_NO_CHECK_ENCODING | \
MAGIC_NO_CHECK_JSON | \
MAGIC_NO_CHECK_SIMH | \
0 \
)
#define MAGIC_SNPRINTB "\177\020\
b\0debug\0\
b\1symlink\0\
b\2compress\0\
b\3devices\0\
b\4mime_type\0\
b\5continue\0\
b\6check\0\
b\7preserve_atime\0\
b\10raw\0\
b\11error\0\
b\12mime_encoding\0\
b\13apple\0\
b\14no_check_compress\0\
b\15no_check_tar\0\
b\16no_check_soft\0\
b\17no_check_sapptype\0\
b\20no_check_elf\0\
b\21no_check_text\0\
b\22no_check_cdf\0\
b\23no_check_csv\0\
b\24no_check_tokens\0\
b\25no_check_encoding\0\
b\26no_check_json\0\
b\27no_check_simh\0\
b\30extension\0\
b\31transp_compression\0\
"
/* Defined for backwards compatibility (renamed) */
#define MAGIC_NO_CHECK_ASCII MAGIC_NO_CHECK_TEXT
/* Defined for backwards compatibility; do nothing */
#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
#define MAGIC_VERSION 545 /* This implementation */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct magic_set *magic_t;
magic_t magic_open(int);
void magic_close(magic_t);
const char *magic_getpath(const char *, int);
const char *magic_file(magic_t, const char *);
const char *magic_descriptor(magic_t, int);
const char *magic_buffer(magic_t, const void *, size_t);
const char *magic_error(magic_t);
int magic_getflags(magic_t);
int magic_setflags(magic_t, int);
int magic_version(void);
int magic_load(magic_t, const char *);
int magic_load_buffers(magic_t, void **, size_t *, size_t);
int magic_compile(magic_t, const char *);
int magic_check(magic_t, const char *);
int magic_list(magic_t, const char *);
int magic_errno(magic_t);
#define MAGIC_PARAM_INDIR_MAX 0
#define MAGIC_PARAM_NAME_MAX 1
#define MAGIC_PARAM_ELF_PHNUM_MAX 2
#define MAGIC_PARAM_ELF_SHNUM_MAX 3
#define MAGIC_PARAM_ELF_NOTES_MAX 4
#define MAGIC_PARAM_REGEX_MAX 5
#define MAGIC_PARAM_BYTES_MAX 6
#define MAGIC_PARAM_ENCODING_MAX 7
#define MAGIC_PARAM_ELF_SHSIZE_MAX 8
int magic_setparam(magic_t, int, const void *);
int magic_getparam(magic_t, int, void *);
#ifdef __cplusplus
};
#endif
#endif /* _MAGIC_H */

View File

@@ -0,0 +1,57 @@
#ifndef _CREATE_INODE_H
#define _CREATE_INODE_H
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "et/com_err.h"
#include "e2p/e2p.h"
#include "ext2fs/ext2fs.h"
struct hdlink_s
{
dev_t src_dev;
ino_t src_ino;
ext2_ino_t dst_ino;
};
struct hdlinks_s
{
int count;
int size;
struct hdlink_s *hdl;
};
#define HDLINK_CNT (4)
struct fs_ops_callbacks {
errcode_t (* create_new_inode)(ext2_filsys fs, const char *target_path,
const char *name, ext2_ino_t parent_ino, ext2_ino_t root,
mode_t mode);
errcode_t (* end_create_new_inode)(ext2_filsys fs,
const char *target_path, const char *name,
ext2_ino_t parent_ino, ext2_ino_t root, mode_t mode);
};
extern int no_copy_xattrs; /* this should eventually be a flag
passed to populate_fs3() */
/* For populating the filesystem */
extern errcode_t populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
const char *source_dir, ext2_ino_t root);
extern errcode_t populate_fs2(ext2_filsys fs, ext2_ino_t parent_ino,
const char *source_dir, ext2_ino_t root,
struct fs_ops_callbacks *fs_callbacks);
extern errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd,
const char *name, unsigned int st_mode,
unsigned int st_rdev);
extern errcode_t do_symlink_internal(ext2_filsys fs, ext2_ino_t cwd,
const char *name, char *target,
ext2_ino_t root);
extern errcode_t do_mkdir_internal(ext2_filsys fs, ext2_ino_t cwd,
const char *name, ext2_ino_t root);
extern errcode_t do_write_internal(ext2_filsys fs, ext2_ino_t cwd,
const char *src, const char *dest,
ext2_ino_t root);
#endif /* _CREATE_INODE_H */

30
include/e2fsprogs/misc/mke2fs.h Executable file
View File

@@ -0,0 +1,30 @@
/*
* mke2fs.h
*
* Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
* 2003, 2004, 2005 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
/* mke2fs.c */
extern const char * program_name;
extern int quiet;
extern int verbose;
extern int zero_hugefile;
extern char **fs_types;
extern char *get_string_from_profile(char **types, const char *opt,
const char *def_val);
extern int get_int_from_profile(char **types, const char *opt, int def_val);
extern int get_bool_from_profile(char **types, const char *opt, int def_val);
extern int int_log10(unsigned long long arg);
/* mk_hugefiles.c */
extern errcode_t mk_hugefiles(ext2_filsys fs, const char *device_name);

29
include/e2fsprogs/misc/util.h Executable file
View File

@@ -0,0 +1,29 @@
/*
* util.h --- header file defining prototypes for helper functions
* used by tune2fs and mke2fs
*
* Copyright 2000 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
extern int journal_size;
extern int journal_fc_size;
extern int journal_flags;
extern char *journal_device;
extern char *journal_location_string;
#ifndef HAVE_STRCASECMP
extern int strcasecmp (char *s1, char *s2);
#endif
extern char *get_progname(char *argv_zero);
extern void proceed_question(int delay);
extern void parse_journal_opts(const char *opts);
extern void check_mount(const char *device, int force, const char *type);
extern void figure_journal_size(struct ext2fs_journal_params *jparams,
int requested_j_size, int requested_fc_size, ext2_filsys fs);
extern void print_check_message(int, unsigned int);
extern void dump_mmp_msg(struct mmp_struct *mmp, const char *msg);

View File

@@ -0,0 +1,43 @@
/*
* argv_parse.h --- header file for the argv parser.
*
* This file defines the interface for the functions argv_parse() and
* argv_free().
*
***********************************************************************
* int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
*
* This function takes as its first argument a string which it will
* parse into an argv argument vector, with each white-space separated
* word placed into its own slot in the argv. This function handles
* double quotes and backslashes so that the parsed words can contain
* special characters. The count of the number words found in the
* parsed string, as well as the argument vector, are returned into
* ret_argc and ret_argv, respectively.
***********************************************************************
* extern void argv_free(char **argv);
*
* This function frees the argument vector created by argv_parse().
***********************************************************************
*
* Copyright 1999 by Theodore Ts'o.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose with or without fee is hereby granted, provided that
* the above copyright notice and this permission notice appear in all
* copies. THE SOFTWARE IS PROVIDED "AS IS" AND THEODORE TS'O (THE
* AUTHOR) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (Isn't
* it sick that the U.S. culture of lawsuit-happy lawyers requires
* this kind of disclaimer?)
*
* Version 1.1, modified 2/27/1999
*/
extern int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv);
extern void argv_free(char **argv);

View File

@@ -0,0 +1,36 @@
/*
*
* Various things common for all utilities
*
*/
#ifndef __QUOTA_COMMON_H__
#define __QUOTA_COMMON_H__
#if EXT2_FLAT_INCLUDES
#include "e2_types.h"
#else
#include <ext2fs/ext2_types.h>
#endif /* EXT2_FLAT_INCLUDES */
/* #define DEBUG_QUOTA 1 */
#ifndef __attribute__
# if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
#endif
#define log_err(format, arg ...) \
fprintf(stderr, "[ERROR] %s:%d:%s: " format "\n", \
__FILE__, __LINE__, __func__, ## arg)
#ifdef DEBUG_QUOTA
# define log_debug(format, arg ...) \
fprintf(stderr, "[DEBUG] %s:%d:%s: " format "\n", \
__FILE__, __LINE__, __func__, ## arg)
#else
# define log_debug(...)
#endif
#endif /* __QUOTA_COMMON_H__ */

View File

@@ -0,0 +1,6 @@
/*
* cstring.h -- header file for C string parse/print utilities
*/
extern int parse_c_string(char *str);
extern void print_c_string(FILE *f, const char *cp, int len);

View File

@@ -0,0 +1,19 @@
/*
* devname.c --- Figure out if a pathname is ext* or something else.
*
* Copyright (C) 2022 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
#ifndef DEVNAME_H_
#define DEVNAME_H_
#include "blkid/blkid.h"
char *get_devname(blkid_cache cache, const char *token, const char *value);
#endif /* DEVNAME_H_ */

147
include/e2fsprogs/support/dict.h Executable file
View File

@@ -0,0 +1,147 @@
/*
* Dictionary Abstract Data Type
* Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>
*
* Free Software License:
*
* All rights are reserved by the author, with the following exceptions:
* Permission is granted to freely reproduce and distribute this software,
* possibly in exchange for a fee, provided that this copyright notice appears
* intact. Permission is also granted to adapt this software to produce
* derivative works, as long as the modified versions carry this copyright
* notice and additional notices stating that the work has been modified.
* This source code may be translated into executable form and incorporated
* into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source.
*
* $Id: dict.h,v 1.22.2.6 2000/11/13 01:36:44 kaz Exp $
* $Name: kazlib_1_20 $
* The work has been modified.
*/
#ifndef DICT_H
#define DICT_H
#include <limits.h>
#ifdef KAZLIB_SIDEEFFECT_DEBUG
#include "sfx.h"
#endif
/*
* Blurb for inclusion into C++ translation units
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned long dictcount_t;
#define DICTCOUNT_T_MAX ULONG_MAX
/*
* The dictionary is implemented as a red-black tree
*/
typedef enum { dnode_red, dnode_black } dnode_color_t;
typedef struct dnode_t {
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct dnode_t *dict_left;
struct dnode_t *dict_right;
struct dnode_t *dict_parent;
dnode_color_t dict_color;
const void *dict_key;
void *dict_data;
#else
int dict_dummy;
#endif
} dnode_t;
typedef int (*dict_comp_t)(const void *, const void *, const void *);
typedef dnode_t *(*dnode_alloc_t)(void *);
typedef void (*dnode_free_t)(dnode_t *, void *);
typedef struct dict_t {
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
dnode_t dict_nilnode;
dictcount_t dict_nodecount;
dictcount_t dict_maxcount;
dict_comp_t dict_compare;
dnode_alloc_t dict_allocnode;
dnode_free_t dict_freenode;
void *dict_context;
const void *cmp_ctx;
int dict_dupes;
#else
int dict_dummmy;
#endif
} dict_t;
typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *);
typedef struct dict_load_t {
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
dict_t *dict_dictptr;
dnode_t dict_nilnode;
#else
int dict_dummmy;
#endif
} dict_load_t;
extern dict_t *dict_create(dictcount_t, dict_comp_t);
extern void dict_set_allocator(dict_t *, dnode_alloc_t, dnode_free_t, void *);
extern void dict_set_cmp_context(dict_t *, const void *);
extern void dict_destroy(dict_t *);
extern void dict_free_nodes(dict_t *);
extern void dict_free(dict_t *);
extern dict_t *dict_init(dict_t *, dictcount_t, dict_comp_t);
extern void dict_init_like(dict_t *, const dict_t *);
extern int dict_verify(dict_t *);
extern int dict_similar(const dict_t *, const dict_t *);
extern dnode_t *dict_lookup(dict_t *, const void *);
extern dnode_t *dict_lower_bound(dict_t *, const void *);
extern dnode_t *dict_upper_bound(dict_t *, const void *);
extern void dict_insert(dict_t *, dnode_t *, const void *);
extern dnode_t *dict_delete(dict_t *, dnode_t *);
extern int dict_alloc_insert(dict_t *, const void *, void *);
extern void dict_delete_free(dict_t *, dnode_t *);
extern dnode_t *dict_first(dict_t *);
extern dnode_t *dict_last(dict_t *);
extern dnode_t *dict_next(dict_t *, dnode_t *);
extern dnode_t *dict_prev(dict_t *, dnode_t *);
extern dictcount_t dict_count(dict_t *);
extern int dict_isempty(dict_t *);
extern int dict_isfull(dict_t *);
extern int dict_contains(dict_t *, dnode_t *);
extern void dict_allow_dupes(dict_t *);
extern int dnode_is_in_a_dict(dnode_t *);
extern dnode_t *dnode_create(void *);
extern dnode_t *dnode_init(dnode_t *, void *);
extern void dnode_destroy(dnode_t *);
extern void *dnode_get(dnode_t *);
extern const void *dnode_getkey(dnode_t *);
extern void dnode_put(dnode_t *, void *);
extern void dict_process(dict_t *, void *, dnode_process_t);
extern void dict_load_begin(dict_load_t *, dict_t *);
extern void dict_load_next(dict_load_t *, dnode_t *, const void *);
extern void dict_load_end(dict_load_t *);
extern void dict_merge(dict_t *, dict_t *);
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
#ifdef KAZLIB_SIDEEFFECT_DEBUG
#define dict_isfull(D) (SFX_CHECK(D)->dict_nodecount == (D)->dict_maxcount)
#else
#define dict_isfull(D) ((D)->dict_nodecount == (D)->dict_maxcount)
#endif
#define dict_count(D) ((D)->dict_nodecount)
#define dict_isempty(D) ((D)->dict_nodecount == 0)
#define dnode_get(N) ((N)->dict_data)
#define dnode_getkey(N) ((N)->dict_key)
#define dnode_put(N, X) ((N)->dict_data = (X))
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,31 @@
/*
* Header file for disk format of new quotafile format
*
* Jan Kara <jack@suse.cz> - sponsored by SuSE CR
*/
#ifndef __QUOTA_DQBLK_V2_H__
#define __QUOTA_DQBLK_V2_H__
#include "quotaio_tree.h"
/* Structure for format specific information */
struct v2_mem_dqinfo {
struct qtree_mem_dqinfo dqi_qtree;
unsigned int dqi_flags; /* Flags set in quotafile */
unsigned int dqi_used_entries; /* Number of entries in file -
updated by scan_dquots */
unsigned int dqi_data_blocks; /* Number of data blocks in file -
updated by scan_dquots */
};
struct v2_mem_dqblk {
long long dqb_off; /* Offset of dquot in file */
};
struct quotafile_ops; /* Will be defined later in quotaio.h */
/* Operations above this format */
extern struct quotafile_ops quotafile_ops_2;
#endif /* __QUOTA_DQBLK_V2_H__ */

View File

@@ -0,0 +1,21 @@
#if defined(ENABLE_NLS) && !defined(DEBUGFS)
#include <libintl.h>
#include <locale.h>
#define _(a) (gettext (a))
#ifdef gettext_noop
#define N_(a) gettext_noop (a)
#else
#define N_(a) (a)
#endif
#define P_(singular, plural, n) (ngettext (singular, plural, n))
#ifndef NLS_CAT_NAME
#define NLS_CAT_NAME "e2fsprogs"
#endif
#ifndef LOCALEDIR
#define LOCALEDIR "/usr/share/locale"
#endif
#else
#define _(a) (a)
#define N_(a) a
#define P_(singular, plural, n) ((n) == 1 ? (singular) : (plural))
#endif

View File

@@ -0,0 +1,29 @@
/*
* plausible.h --- header file defining prototypes for helper functions
* used by tune2fs and mke2fs
*
* Copyright 2014 by Oracle, Inc.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
#ifndef PLAUSIBLE_H_
#define PLAUSIBLE_H_
/*
* Flags for check_plausibility()
*/
#define CHECK_BLOCK_DEV 0x0001
#define CREATE_FILE 0x0002
#define CHECK_FS_EXIST 0x0004
#define VERBOSE_CREATE 0x0008
#define NO_SIZE 0x0010
#define QUIET_CHECK 0x0020
extern int check_plausibility(const char *device, int flags,
int *ret_is_dev);
#endif /* PLAUSIBLE_H_ */

View File

@@ -0,0 +1,5 @@
/*
* print_flags.h -- header file for printing the fs flags
*/
void print_fs_flags(FILE * f, unsigned long flags);

View File

@@ -0,0 +1,49 @@
/*
* prof_err.h:
* This file is automatically generated; please do not edit it.
*/
#include <et/com_err.h>
#define PROF_VERSION (-1429577728L)
#define PROF_MAGIC_NODE (-1429577727L)
#define PROF_NO_SECTION (-1429577726L)
#define PROF_NO_RELATION (-1429577725L)
#define PROF_ADD_NOT_SECTION (-1429577724L)
#define PROF_SECTION_WITH_VALUE (-1429577723L)
#define PROF_BAD_LINK_LIST (-1429577722L)
#define PROF_BAD_GROUP_LVL (-1429577721L)
#define PROF_BAD_PARENT_PTR (-1429577720L)
#define PROF_MAGIC_ITERATOR (-1429577719L)
#define PROF_SET_SECTION_VALUE (-1429577718L)
#define PROF_EINVAL (-1429577717L)
#define PROF_READ_ONLY (-1429577716L)
#define PROF_SECTION_NOTOP (-1429577715L)
#define PROF_SECTION_SYNTAX (-1429577714L)
#define PROF_RELATION_SYNTAX (-1429577713L)
#define PROF_EXTRA_CBRACE (-1429577712L)
#define PROF_MISSING_OBRACE (-1429577711L)
#define PROF_MAGIC_PROFILE (-1429577710L)
#define PROF_MAGIC_SECTION (-1429577709L)
#define PROF_TOPSECTION_ITER_NOSUPP (-1429577708L)
#define PROF_INVALID_SECTION (-1429577707L)
#define PROF_END_OF_SECTIONS (-1429577706L)
#define PROF_BAD_NAMESET (-1429577705L)
#define PROF_NO_PROFILE (-1429577704L)
#define PROF_MAGIC_FILE (-1429577703L)
#define PROF_FAIL_OPEN (-1429577702L)
#define PROF_EXISTS (-1429577701L)
#define PROF_BAD_BOOLEAN (-1429577700L)
#define PROF_BAD_INTEGER (-1429577699L)
#define PROF_MAGIC_FILE_DATA (-1429577698L)
extern const struct error_table et_prof_error_table;
extern void initialize_prof_error_table(void);
/* For compatibility with Heimdal */
extern void initialize_prof_error_table_r(struct et_list **list);
#define ERROR_TABLE_BASE_prof (-1429577728L)
/* for compatibility with older versions... */
#define init_prof_err_tbl initialize_prof_error_table
#define prof_err_base ERROR_TABLE_BASE_prof

View File

@@ -0,0 +1,107 @@
/*
* profile.h
*
* Copyright (C) 2005 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*
* Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
*
* All rights reserved.
*
* Export of this software from the United States of America may require
* a specific license from the United States Government. It is the
* responsibility of any person or organization contemplating export to
* obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original MIT software.
* M.I.T. makes no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied
* warranty.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef _PROFILE_H
#define _PROFILE_H
typedef struct _profile_t *profile_t;
typedef void (*profile_syntax_err_cb_t)(const char *file, long err,
int line_num);
/*
* Used by the profile iterator in prof_get.c
*/
#define PROFILE_ITER_LIST_SECTION 0x0001
#define PROFILE_ITER_SECTIONS_ONLY 0x0002
#define PROFILE_ITER_RELATIONS_ONLY 0x0004
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
long profile_init
(const char * const *files, profile_t *ret_profile);
void profile_release
(profile_t profile);
long profile_set_default
(profile_t profile, const char *def_string);
long profile_get_string
(profile_t profile, const char *name, const char *subname,
const char *subsubname, const char *def_val,
char **ret_string);
long profile_get_integer
(profile_t profile, const char *name, const char *subname,
const char *subsubname, int def_val,
int *ret_default);
long profile_get_uint
(profile_t profile, const char *name, const char *subname,
const char *subsubname, unsigned int def_val,
unsigned int *ret_int);
long profile_get_double
(profile_t profile, const char *name, const char *subname,
const char *subsubname, double def_val,
double *ret_float);
long profile_get_boolean
(profile_t profile, const char *name, const char *subname,
const char *subsubname, int def_val,
int *ret_default);
long profile_iterator_create
(profile_t profile, const char *const *names,
int flags, void **ret_iter);
void profile_iterator_free
(void **iter_p);
long profile_iterator
(void **iter_p, char **ret_name, char **ret_value);
profile_syntax_err_cb_t profile_set_syntax_err_cb(profile_syntax_err_cb_t hook);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _KRB5_H */

View File

@@ -0,0 +1,28 @@
/*
* profile_helpers.h -- Function prototypes for profile helper functions
*
* Copyright (C) 2006 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
long profile_get_values
(profile_t profile, const char *const *names, char ***ret_values);
void profile_free_list
(char **list);
long profile_get_relation_names
(profile_t profile, const char **names, char ***ret_names);
long profile_get_subsection_names
(profile_t profile, const char **names, char ***ret_names);
void profile_release_string (char *str);
long profile_init_path
(const char * filelist, profile_t *ret_profile);

View File

@@ -0,0 +1,268 @@
/** quotaio.h
*
* Interface to the quota library.
*
* The quota library provides interface for creating and updating the quota
* files and the ext4 superblock fields. It supports the new VFS_V1 quota
* format. The quota library also provides support for keeping track of quotas
* in memory.
* The typical way to use the quota library is as follows:
* {
* quota_ctx_t qctx;
*
* quota_init_context(&qctx, fs, QUOTA_ALL_BIT);
* {
* quota_compute_usage(qctx);
* AND/OR
* quota_data_add/quota_data_sub/quota_data_inodes();
* }
* quota_write_inode(qctx, USRQUOTA);
* quota_write_inode(qctx, GRPQUOTA);
* quota_release_context(&qctx);
* }
*
* This initial version does not support reading the quota files. This support
* will be added in near future.
*
* Aditya Kali <adityakali@google.com>
* Header of IO operations for quota utilities
*
* Jan Kara <jack@suse.cz>
*/
#ifndef GUARD_QUOTAIO_H
#define GUARD_QUOTAIO_H
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "ext2fs/ext2_fs.h"
#include "ext2fs/ext2fs.h"
#include "dqblk_v2.h"
typedef int64_t qsize_t; /* Type in which we store size limitations */
enum quota_type {
USRQUOTA = 0,
GRPQUOTA = 1,
PRJQUOTA = 2,
MAXQUOTAS = 3,
};
#if MAXQUOTAS > 32
#error "cannot have more than 32 quota types to fit in qtype_bits"
#endif
#define QUOTA_USR_BIT (1 << USRQUOTA)
#define QUOTA_GRP_BIT (1 << GRPQUOTA)
#define QUOTA_PRJ_BIT (1 << PRJQUOTA)
#define QUOTA_ALL_BIT (QUOTA_USR_BIT | QUOTA_GRP_BIT | QUOTA_PRJ_BIT)
typedef struct quota_ctx *quota_ctx_t;
struct dict_t;
struct quota_ctx {
ext2_filsys fs;
struct dict_t *quota_dict[MAXQUOTAS];
struct quota_handle *quota_file[MAXQUOTAS];
};
/*
* Definitions of magics and versions of current quota files
*/
#define INITQMAGICS {\
0xd9c01f11, /* USRQUOTA */\
0xd9c01927, /* GRPQUOTA */\
0xd9c03f14 /* PRJQUOTA */\
}
/* Size of blocks in which are counted size limits in generic utility parts */
#define QUOTABLOCK_BITS 10
#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
/* Quota format type IDs */
#define QFMT_VFS_OLD 1
#define QFMT_VFS_V0 2
#define QFMT_VFS_V1 4
/*
* The following constants define the default amount of time given a user
* before the soft limits are treated as hard limits (usually resulting
* in an allocation failure). The timer is started when the user crosses
* their soft limit, it is reset when they go below their soft limit.
*/
#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
#define IOFL_INFODIRTY 0x01 /* Did info change? */
struct quotafile_ops;
/* Generic information about quotafile */
struct util_dqinfo {
time_t dqi_bgrace; /* Block grace time for given quotafile */
time_t dqi_igrace; /* Inode grace time for given quotafile */
union {
struct v2_mem_dqinfo v2_mdqi;
} u; /* Format specific info about quotafile */
};
struct quota_file {
ext2_filsys fs;
ext2_ino_t ino;
ext2_file_t e2_file;
};
/* Structure for one opened quota file */
struct quota_handle {
enum quota_type qh_type; /* Type of quotafile */
int qh_fmt; /* Quotafile format */
int qh_file_flags;
int qh_io_flags; /* IO flags for file */
struct quota_file qh_qf;
unsigned int (*e2fs_read)(struct quota_file *qf, ext2_loff_t offset,
void *buf, unsigned int size);
unsigned int (*e2fs_write)(struct quota_file *qf, ext2_loff_t offset,
void *buf, unsigned int size);
struct quotafile_ops *qh_ops; /* Operations on quotafile */
struct util_dqinfo qh_info; /* Generic quotafile info */
};
/* Utility quota block */
struct util_dqblk {
qsize_t dqb_ihardlimit;
qsize_t dqb_isoftlimit;
qsize_t dqb_curinodes;
qsize_t dqb_bhardlimit;
qsize_t dqb_bsoftlimit;
qsize_t dqb_curspace;
time_t dqb_btime;
time_t dqb_itime;
union {
struct v2_mem_dqblk v2_mdqb;
} u; /* Format specific dquot information */
};
/* Structure for one loaded quota */
struct dquot {
struct dquot *dq_next; /* Pointer to next dquot in the list */
qid_t dq_id; /* ID dquot belongs to */
int dq_flags; /* Some flags for utils */
struct quota_handle *dq_h; /* Handle of quotafile for this dquot */
struct util_dqblk dq_dqb; /* Parsed data of dquot */
};
#define DQF_SEEN 0x0001
/* Structure of quotafile operations */
struct quotafile_ops {
/* Check whether quotafile is in our format */
int (*check_file) (struct quota_handle *h, int type, int fmt);
/* Open quotafile */
int (*init_io) (struct quota_handle *h);
/* Create new quotafile */
int (*new_io) (struct quota_handle *h);
/* Write all changes and close quotafile */
int (*end_io) (struct quota_handle *h);
/* Write info about quotafile */
int (*write_info) (struct quota_handle *h);
/* Read dquot into memory */
struct dquot *(*read_dquot) (struct quota_handle *h, qid_t id);
/* Write given dquot to disk */
int (*commit_dquot) (struct dquot *dquot);
/* Scan quotafile and call callback on every structure */
int (*scan_dquots) (struct quota_handle *h,
int (*process_dquot) (struct dquot *dquot,
void *data),
void *data);
/* Function to print format specific file information */
int (*report) (struct quota_handle *h, int verbose);
};
/* This might go into a special header file but that sounds a bit silly... */
extern struct quotafile_ops quotafile_ops_meta;
/* Open existing quotafile of given type (and verify its format) on given
* filesystem. */
errcode_t quota_file_open(quota_ctx_t qctx, struct quota_handle *h,
ext2_ino_t qf_ino, enum quota_type type,
int fmt, int flags);
/* Create new quotafile of specified format on given filesystem */
errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs,
enum quota_type qtype, int fmt);
/* Close quotafile */
errcode_t quota_file_close(quota_ctx_t qctx, struct quota_handle *h);
/* Get empty quota structure */
struct dquot *get_empty_dquot(void);
errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino);
const char *quota_type2name(enum quota_type qtype);
ext2_ino_t quota_type2inum(enum quota_type qtype, struct ext2_super_block *);
void update_grace_times(struct dquot *q);
/* size for the buffer returned by quota_get_qf_name(); must be greater
than maxlen of extensions[] and fmtnames[] (plus 2) found in quotaio.c */
#define QUOTA_NAME_LEN 16
const char *quota_get_qf_name(enum quota_type, int fmt, char *buf);
/* In mkquota.c */
errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs,
unsigned int qtype_bits);
void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode_large *inode,
ext2_ino_t ino, int adjust);
void quota_data_add(quota_ctx_t qctx, struct ext2_inode_large *inode,
ext2_ino_t ino, qsize_t space);
void quota_data_sub(quota_ctx_t qctx, struct ext2_inode_large *inode,
ext2_ino_t ino, qsize_t space);
errcode_t quota_write_inode(quota_ctx_t qctx, enum quota_type qtype);
/* Flags for quota_read_all_dquots() */
#define QREAD_USAGE 0x01
#define QREAD_LIMITS 0x02
errcode_t quota_read_all_dquots(quota_ctx_t qctx, ext2_ino_t qf_ino,
enum quota_type type, unsigned int flags);
errcode_t quota_compute_usage(quota_ctx_t qctx);
void quota_release_context(quota_ctx_t *qctx);
errcode_t quota_remove_inode(ext2_filsys fs, enum quota_type qtype);
int quota_file_exists(ext2_filsys fs, enum quota_type qtype);
void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, enum quota_type qtype);
errcode_t quota_compare_and_update(quota_ctx_t qctx, enum quota_type qtype,
int *usage_inconsistent);
int parse_quota_opts(const char *opts, int (*func)(char *));
/* parse_qtype.c */
int parse_quota_types(const char *in_str, unsigned int *qtype_bits,
char **err_token);
/*
* Return pointer to reserved inode field in superblock for given quota type.
*
* This allows the caller to get or set the quota inode by type without the
* need for the quota array to be contiguous in the superblock.
*/
static inline ext2_ino_t *quota_sb_inump(struct ext2_super_block *sb,
enum quota_type qtype)
{
switch (qtype) {
case USRQUOTA:
return &sb->s_usr_quota_inum;
case GRPQUOTA:
return &sb->s_grp_quota_inum;
case PRJQUOTA:
return &sb->s_prj_quota_inum;
default:
return NULL;
}
return NULL;
}
#endif /* GUARD_QUOTAIO_H */

View File

@@ -0,0 +1,64 @@
/*
* Definitions of structures for vfsv0 quota format
*/
#ifndef _LINUX_QUOTA_TREE_H
#define _LINUX_QUOTA_TREE_H
#include <sys/types.h>
typedef __u32 qid_t; /* Type in which we store ids in memory */
#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
#define QT_TREEDEPTH 4 /* Depth of quota tree */
#define QT_BLKSIZE_BITS 10
#define QT_BLKSIZE (1 << QT_BLKSIZE_BITS) /* Size of block with quota
* structures */
/*
* Structure of header of block with quota structures. It is padded to 16 bytes
* so there will be space for exactly 21 quota-entries in a block
*/
struct qt_disk_dqdbheader {
__le32 dqdh_next_free; /* Number of next block with free
* entry */
__le32 dqdh_prev_free; /* Number of previous block with free
* entry */
__le16 dqdh_entries; /* Number of valid entries in block */
__le16 dqdh_pad1;
__le32 dqdh_pad2;
} __attribute__ ((packed));
struct dquot;
struct quota_handle;
/* Operations */
struct qtree_fmt_operations {
/* Convert given entry from in memory format to disk one */
void (*mem2disk_dqblk)(void *disk, struct dquot *dquot);
/* Convert given entry from disk format to in memory one */
void (*disk2mem_dqblk)(struct dquot *dquot, void *disk);
/* Is this structure for given id? */
int (*is_id)(void *disk, struct dquot *dquot);
};
/* In-memory copy of version specific information */
struct qtree_mem_dqinfo {
unsigned int dqi_blocks; /* # of blocks in quota file */
unsigned int dqi_free_blk; /* First block in list of free blocks */
unsigned int dqi_free_entry; /* First block with free entry */
unsigned int dqi_entry_size; /* Size of quota entry in quota file */
struct qtree_fmt_operations *dqi_ops; /* Operations for entry
* manipulation */
};
void qtree_write_dquot(struct dquot *dquot);
struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id);
void qtree_delete_dquot(struct dquot *dquot);
int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
int qtree_scan_dquots(struct quota_handle *h,
int (*process_dquot) (struct dquot *, void *), void *data);
int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info);
#endif /* _LINUX_QUOTAIO_TREE_H */

View File

@@ -0,0 +1,69 @@
/*
*
* Header file for disk format of new quotafile format
*
*/
#ifndef GUARD_QUOTAIO_V2_H
#define GUARD_QUOTAIO_V2_H
#include <sys/types.h>
#include "quotaio.h"
/* Offset of info header in file */
#define V2_DQINFOOFF sizeof(struct v2_disk_dqheader)
/* Supported version of quota-tree format */
#define V2_VERSION_R1 1
#define V2_VERSION_R0 0
struct v2_disk_dqheader {
__le32 dqh_magic; /* Magic number identifying file */
__le32 dqh_version; /* File version */
} __attribute__ ((packed));
/* Flags for version specific files */
#define V2_DQF_MASK 0x0000 /* Mask for all valid ondisk flags */
/* Header with type and version specific information */
struct v2_disk_dqinfo {
__le32 dqi_bgrace; /* Time before block soft limit becomes
* hard limit */
__le32 dqi_igrace; /* Time before inode soft limit becomes
* hard limit */
__le32 dqi_flags; /* Flags for quotafile (DQF_*) */
__le32 dqi_blocks; /* Number of blocks in file */
__le32 dqi_free_blk; /* Number of first free block in the list */
__le32 dqi_free_entry; /* Number of block with at least one
* free entry */
} __attribute__ ((packed));
struct v2r0_disk_dqblk {
__le32 dqb_id; /* id this quota applies to */
__le32 dqb_ihardlimit; /* absolute limit on allocated inodes */
__le32 dqb_isoftlimit; /* preferred inode limit */
__le32 dqb_curinodes; /* current # allocated inodes */
__le32 dqb_bhardlimit; /* absolute limit on disk space
* (in QUOTABLOCK_SIZE) */
__le32 dqb_bsoftlimit; /* preferred limit on disk space
* (in QUOTABLOCK_SIZE) */
__le64 dqb_curspace; /* current space occupied (in bytes) */
__le64 dqb_btime; /* time limit for excessive disk use */
__le64 dqb_itime; /* time limit for excessive inode use */
} __attribute__ ((packed));
struct v2r1_disk_dqblk {
__le32 dqb_id; /* id this quota applies to */
__le32 dqb_pad;
__le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
__le64 dqb_isoftlimit; /* preferred inode limit */
__le64 dqb_curinodes; /* current # allocated inodes */
__le64 dqb_bhardlimit; /* absolute limit on disk space
* (in QUOTABLOCK_SIZE) */
__le64 dqb_bsoftlimit; /* preferred limit on disk space
* (in QUOTABLOCK_SIZE) */
__le64 dqb_curspace; /* current space occupied (in bytes) */
__le64 dqb_btime; /* time limit for excessive disk use */
__le64 dqb_itime; /* time limit for excessive inode use */
} __attribute__ ((packed));
#endif

View File

@@ -0,0 +1,325 @@
/* Isaac Turner 29 April 2014 Public Domain */
#ifndef SORT_R_H_
#define SORT_R_H_
#include <stdlib.h>
#include <string.h>
/*
sort_r function to be exported.
Parameters:
base is the array to be sorted
nel is the number of elements in the array
width is the size in bytes of each element of the array
compar is the comparison function
arg is a pointer to be passed to the comparison function
void sort_r(void *base, size_t nel, size_t width,
int (*compar)(const void *_a, const void *_b, void *_arg),
void *arg);
*/
#define _SORT_R_INLINE inline
#if (defined HAVE_GNU_QSORT_R)
# define _SORT_R_GNU
#elif (defined HAVE_BSD_QSORT_R)
# define _SORT_R_BSD
#elif (defined __gnu_hurd__ || defined __GNU__ || \
defined __MINGW32__ || defined __GLIBC__)
# define _SORT_R_GNU
#elif (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || \
defined __FreeBSD__ || defined __DragonFly__)
# define _SORT_R_BSD
#elif (defined _WIN32 || defined _WIN64 || defined __WINDOWS__)
# define _SORT_R_WINDOWS
# undef _SORT_R_INLINE
# define _SORT_R_INLINE __inline
#else
/* Using our own recursive quicksort sort_r_simple() */
#endif
#if (defined NESTED_QSORT && NESTED_QSORT == 0)
# undef NESTED_QSORT
#endif
#define SORT_R_SWAP(a,b,tmp) ((tmp) = (a), (a) = (b), (b) = (tmp))
/* swap a and b */
/* a and b must not be equal! */
static _SORT_R_INLINE void sort_r_swap(char *__restrict a, char *__restrict b,
size_t w)
{
char tmp, *end = a+w;
for(; a < end; a++, b++) { SORT_R_SWAP(*a, *b, tmp); }
}
/* swap a, b iff a>b */
/* a and b must not be equal! */
/* __restrict is same as restrict but better support on old machines */
static _SORT_R_INLINE int sort_r_cmpswap(char *__restrict a,
char *__restrict b, size_t w,
int (*compar)(const void *_a,
const void *_b,
void *_arg),
void *arg)
{
if(compar(a, b, arg) > 0) {
sort_r_swap(a, b, w);
return 1;
}
return 0;
}
/*
Swap consecutive blocks of bytes of size na and nb starting at memory addr ptr,
with the smallest swap so that the blocks are in the opposite order. Blocks may
be internally re-ordered e.g.
12345ab -> ab34512
123abc -> abc123
12abcde -> deabc12
*/
static _SORT_R_INLINE void sort_r_swap_blocks(char *ptr, size_t na, size_t nb)
{
if(na > 0 && nb > 0) {
if(na > nb) { sort_r_swap(ptr, ptr+na, nb); }
else { sort_r_swap(ptr, ptr+nb, na); }
}
}
/* Implement recursive quicksort ourselves */
/* Note: quicksort is not stable, equivalent values may be swapped */
static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w,
int (*compar)(const void *_a,
const void *_b,
void *_arg),
void *arg)
{
char *b = (char *)base, *end = b + nel*w;
/* for(size_t i=0; i<nel; i++) {printf("%4i", *(int*)(b + i*sizeof(int)));}
printf("\n"); */
if(nel < 10) {
/* Insertion sort for arbitrarily small inputs */
char *pi, *pj;
for(pi = b+w; pi < end; pi += w) {
for(pj = pi; pj > b && sort_r_cmpswap(pj-w,pj,w,compar,arg); pj -= w) {}
}
}
else
{
/* nel > 6; Quicksort */
int cmp;
char *pl, *ple, *pr, *pre, *pivot;
char *last = b+w*(nel-1), *tmp;
/*
Use median of second, middle and second-last items as pivot.
First and last may have been swapped with pivot and therefore be extreme
*/
char *l[3];
l[0] = b + w;
l[1] = b+w*(nel/2);
l[2] = last - w;
/* printf("pivots: %i, %i, %i\n", *(int*)l[0], *(int*)l[1], *(int*)l[2]); */
if(compar(l[0],l[1],arg) > 0) { SORT_R_SWAP(l[0], l[1], tmp); }
if(compar(l[1],l[2],arg) > 0) {
SORT_R_SWAP(l[1], l[2], tmp);
if(compar(l[0],l[1],arg) > 0) { SORT_R_SWAP(l[0], l[1], tmp); }
}
/* swap mid value (l[1]), and last element to put pivot as last element */
if(l[1] != last) { sort_r_swap(l[1], last, w); }
/*
pl is the next item on the left to be compared to the pivot
pr is the last item on the right that was compared to the pivot
ple is the left position to put the next item that equals the pivot
ple is the last right position where we put an item that equals the pivot
v- end (beyond the array)
EEEEEELLLLLLLLuuuuuuuuGGGGGGGEEEEEEEE.
^- b ^- ple ^- pl ^- pr ^- pre ^- last (where the pivot is)
Pivot comparison key:
E = equal, L = less than, u = unknown, G = greater than, E = equal
*/
pivot = last;
ple = pl = b;
pre = pr = last;
/*
Strategy:
Loop into the list from the left and right at the same time to find:
- an item on the left that is greater than the pivot
- an item on the right that is less than the pivot
Once found, they are swapped and the loop continues.
Meanwhile items that are equal to the pivot are moved to the edges of the
array.
*/
while(pl < pr) {
/* Move left hand items which are equal to the pivot to the far left.
break when we find an item that is greater than the pivot */
for(; pl < pr; pl += w) {
cmp = compar(pl, pivot, arg);
if(cmp > 0) { break; }
else if(cmp == 0) {
if(ple < pl) { sort_r_swap(ple, pl, w); }
ple += w;
}
}
/* break if last batch of left hand items were equal to pivot */
if(pl >= pr) { break; }
/* Move right hand items which are equal to the pivot to the far right.
break when we find an item that is less than the pivot */
for(; pl < pr; ) {
pr -= w; /* Move right pointer onto an unprocessed item */
cmp = compar(pr, pivot, arg);
if(cmp == 0) {
pre -= w;
if(pr < pre) { sort_r_swap(pr, pre, w); }
}
else if(cmp < 0) {
if(pl < pr) { sort_r_swap(pl, pr, w); }
pl += w;
break;
}
}
}
pl = pr; /* pr may have gone below pl */
/*
Now we need to go from: EEELLLGGGGEEEE
to: LLLEEEEEEEGGGG
Pivot comparison key:
E = equal, L = less than, u = unknown, G = greater than, E = equal
*/
sort_r_swap_blocks(b, ple-b, pl-ple);
sort_r_swap_blocks(pr, pre-pr, end-pre);
/*for(size_t i=0; i<nel; i++) {printf("%4i", *(int*)(b + i*sizeof(int)));}
printf("\n");*/
sort_r_simple(b, (pl-ple)/w, w, compar, arg);
sort_r_simple(end-(pre-pr), (pre-pr)/w, w, compar, arg);
}
}
#if defined NESTED_QSORT
static _SORT_R_INLINE void sort_r(void *base, size_t nel, size_t width,
int (*compar)(const void *_a,
const void *_b,
void *aarg),
void *arg)
{
int nested_cmp(const void *a, const void *b)
{
return compar(a, b, arg);
}
qsort(base, nel, width, nested_cmp);
}
#else /* !NESTED_QSORT */
/* Declare structs and functions */
#if defined _SORT_R_BSD
/* Ensure qsort_r is defined */
extern void qsort_r(void *base, size_t nel, size_t width, void *thunk,
int (*compar)(void *_thunk,
const void *_a, const void *_b));
#endif
#if defined _SORT_R_BSD || defined _SORT_R_WINDOWS
/* BSD (qsort_r), Windows (qsort_s) require argument swap */
struct sort_r_data
{
void *arg;
int (*compar)(const void *_a, const void *_b, void *_arg);
};
static _SORT_R_INLINE int sort_r_arg_swap(void *s,
const void *a, const void *b)
{
struct sort_r_data *ss = (struct sort_r_data*)s;
return (ss->compar)(a, b, ss->arg);
}
#endif
#if defined _SORT_R_GNU
typedef int(* __compar_d_fn_t)(const void *, const void *, void *);
extern void qsort_r(void *base, size_t nel, size_t width,
__compar_d_fn_t __compar, void *arg)
__attribute__((nonnull (1, 4)));
#endif
/* implementation */
static _SORT_R_INLINE void sort_r(void *base, size_t nel, size_t width,
int (*compar)(const void *_a,
const void *_b, void *_arg),
void *arg)
{
#if defined _SORT_R_GNU
#if defined __GLIBC__ && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8))
/* no qsort_r in glibc before 2.8, need to use nested qsort */
sort_r_simple(base, nel, width, compar, arg);
#else
qsort_r(base, nel, width, compar, arg);
#endif
#elif defined _SORT_R_BSD
struct sort_r_data tmp;
tmp.arg = arg;
tmp.compar = compar;
qsort_r(base, nel, width, &tmp, sort_r_arg_swap);
#elif defined _SORT_R_WINDOWS
struct sort_r_data tmp;
tmp.arg = arg;
tmp.compar = compar;
qsort_s(base, nel, width, sort_r_arg_swap, &tmp);
#else
/* Fall back to our own quicksort implementation */
sort_r_simple(base, nel, width, compar, arg);
#endif
}
#endif /* !NESTED_QSORT */
#undef _SORT_R_INLINE
#undef _SORT_R_WINDOWS
#undef _SORT_R_GNU
#undef _SORT_R_BSD
#endif /* SORT_R_H_ */

103
include/e2fsprogs/uuid/uuid.h Executable file
View File

@@ -0,0 +1,103 @@
/*
* Public include file for the UUID library
*
* Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
#ifndef _UUID_UUID_H
#define _UUID_UUID_H
#include <sys/types.h>
#ifndef _WIN32
#include <sys/time.h>
#endif
#include <time.h>
typedef unsigned char uuid_t[16];
/* UUID Variant definitions */
#define UUID_VARIANT_NCS 0
#define UUID_VARIANT_DCE 1
#define UUID_VARIANT_MICROSOFT 2
#define UUID_VARIANT_OTHER 3
/* UUID Type definitions */
#define UUID_TYPE_DCE_TIME 1
#define UUID_TYPE_DCE_RANDOM 4
/* Allow UUID constants to be defined */
#ifdef __GNUC__
#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
#else
#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* clear.c */
void uuid_clear(uuid_t uu);
/* compare.c */
int uuid_compare(const uuid_t uu1, const uuid_t uu2);
/* copy.c */
void uuid_copy(uuid_t dst, const uuid_t src);
/* gen_uuid.c */
void uuid_generate(uuid_t out);
void uuid_generate_random(uuid_t out);
void uuid_generate_time(uuid_t out);
/* isnull.c */
int uuid_is_null(const uuid_t uu);
/* parse.c */
int uuid_parse(const char *in, uuid_t uu);
/* unparse.c */
void uuid_unparse(const uuid_t uu, char *out);
void uuid_unparse_lower(const uuid_t uu, char *out);
void uuid_unparse_upper(const uuid_t uu, char *out);
/* uuid_time.c */
time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
int uuid_type(const uuid_t uu);
int uuid_variant(const uuid_t uu);
#ifdef __cplusplus
}
#endif
#endif /* _UUID_UUID_H */

71
include/e2fsprogs/uuid/uuidP.h Executable file
View File

@@ -0,0 +1,71 @@
/*
* uuid.h -- private header file for uuids
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#else
#include <uuid/uuid_types.h>
#endif
#include <sys/types.h>
#include <uuid/uuid.h>
/*
* Offset between 15-Oct-1582 and 1-Jan-70
*/
#define TIME_OFFSET_HIGH 0x01B21DD2
#define TIME_OFFSET_LOW 0x13814000
struct uuid {
uint32_t time_low;
uint16_t time_mid;
uint16_t time_hi_and_version;
uint16_t clock_seq;
uint8_t node[6];
};
#ifndef __GNUC_PREREQ
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj, min) 0
#endif
#endif
/*
* prototypes
*/
void uuid_pack(const struct uuid *uu, uuid_t ptr);
void uuid_unpack(const uuid_t in, struct uuid *uu);

View File

@@ -0,0 +1,45 @@
/*
* If linux/types.h is already been included, assume it has defined
* everything we need. (cross fingers) Other header files may have
* also defined the types that we need.
*/
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
!defined(_EXT2_TYPES_H) && !defined(_UUID_TYPES_H))
#define _UUID_TYPES_H
typedef unsigned char __u8;
typedef __signed__ char __s8;
typedef unsigned short __u16;
typedef __signed__ short __s16;
typedef unsigned int __u32;
typedef __signed__ int __s32;
typedef unsigned long long __u64;
typedef __signed__ long long __s64;
#endif
#include <stdint.h> //uintptr_t
/* endian checking stuff */
#ifndef EXT2_ENDIAN_H_
#define EXT2_ENDIAN_H_
#ifdef __CHECKER__
#ifndef __bitwise
#define __bitwise __attribute__((bitwise))
#endif
#define __force __attribute__((force))
#else
#ifndef __bitwise
#define __bitwise
#endif
#define __force
#endif
typedef __u16 __bitwise __le16;
typedef __u32 __bitwise __le32;
typedef __u64 __bitwise __le64;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __be64;
#endif /* EXT2_ENDIAN_H_ */

54
include/e2fsprogs/uuid/uuidd.h Executable file
View File

@@ -0,0 +1,54 @@
/*
* Definitions used by the uuidd daemon
*
* Copyright (C) 2007 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
#ifndef _UUID_UUIDD_H
#define _UUID_UUIDD_H
#define UUIDD_DIR "/var/lib/libuuid"
#define UUIDD_SOCKET_PATH UUIDD_DIR "/request"
#define UUIDD_PIDFILE_PATH UUIDD_DIR "/uuidd.pid"
#define UUIDD_PATH "/usr/sbin/uuidd"
#define UUIDD_OP_GETPID 0
#define UUIDD_OP_GET_MAXOP 1
#define UUIDD_OP_TIME_UUID 2
#define UUIDD_OP_RANDOM_UUID 3
#define UUIDD_OP_BULK_TIME_UUID 4
#define UUIDD_OP_BULK_RANDOM_UUID 5
#define UUIDD_MAX_OP UUIDD_OP_BULK_RANDOM_UUID
extern void uuid__generate_time(uuid_t out, int *num);
extern void uuid__generate_random(uuid_t out, int *num);
#endif /* _UUID_UUID_H */

13
include/e2fsprogs/version.h Executable file
View File

@@ -0,0 +1,13 @@
/*
* version.h --- controls the version number printed by the e2fs
* programs.
*
* Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
* 2004, 2005, 2006, 2007, 2008, 2009, 2010 by Theodore Ts'o. This
* file may be redistributed under the GNU Public License v2.
*/
#define E2FSPROGS_VERSION "1.46.6 [pmt-static]"
#define E2FSPROGS_VERSION_PRIVATE "1.46.6"
#define EXT2FS_LIB_VERSION_PRIVATE "android-static-369-g8ed4b2673"
#define E2FSPROGS_DATE "1-Feb-2023"

345
jni/Android.mk Executable file
View File

@@ -0,0 +1,345 @@
# By YZBruh
# Copyright 2024 Partition Manager
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
########
# 2.9.1
########
LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/../build/config/env.mk
PMT_CXXFLAGS = \
-O3 \
-Wall \
-Wextra \
-Wno-vla-cxx-extension \
-Wno-nullability-completeness \
-Wno-writable-strings \
-Wno-nullability-extension \
-Wno-reorder-init-list \
-Wno-gnu-zero-variadic-macro-arguments \
-static \
$(PMT_EXTRA_CXXFLAGS)
E2FSPROGS_DEFAULT_CFLAGS = \
-Werror \
-Wno-pointer-arith \
-Wno-sign-compare \
-Wno-type-limits \
-Wno-typedef-redefinition \
-Wno-unused-parameter \
-Wno-unused-command-line-argument
ifneq ($(PMT_ENABLE_DEBUG),)
PMT_CXXFLAGS += -gdwarf-5 -fsanitize=address
endif
PMT := PartitionManager
MKE2FS := e2fsprogs/mke2fs
LIB := e2fsprogs/lib
LIBEXT2FS := $(LIB)/ext2fs
LIBEXT2_UUID := $(LIB)/uuid
LIBEXT2_E2P := $(LIB)/e2p
LIBEXT2_QUOTA := $(LIB)/support
LIBEXT2_MISC := $(LIB)/misc
LIBEXT2_COM_ERR := $(LIB)/et
LIBEXT2_BLKID := $(LIB)/blkid
INC_DIR := $(LOCAL_PATH)/../include/e2fsprogs
E2FSPROGS_INCLUDES := \
$(INC_DIR)/misc \
$(INC_DIR)/blkid \
$(INC_DIR)/e2p \
$(INC_DIR)/et \
$(INC_DIR)/ext2fs \
$(INC_DIR)/ss \
$(INC_DIR)/support \
$(INC_DIR)/uuid \
$(INC_DIR)/e2fsck \
$(INC_DIR)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2fs
LOCAL_SRC_FILES := \
$(LIBEXT2FS)/ext2_err.c \
$(LIBEXT2FS)/alloc.c \
$(LIBEXT2FS)/alloc_sb.c \
$(LIBEXT2FS)/alloc_stats.c \
$(LIBEXT2FS)/alloc_tables.c \
$(LIBEXT2FS)/atexit.c \
$(LIBEXT2FS)/badblocks.c \
$(LIBEXT2FS)/bb_inode.c \
$(LIBEXT2FS)/bitmaps.c \
$(LIBEXT2FS)/bitops.c \
$(LIBEXT2FS)/blkmap64_ba.c \
$(LIBEXT2FS)/blkmap64_rb.c \
$(LIBEXT2FS)/blknum.c \
$(LIBEXT2FS)/block.c \
$(LIBEXT2FS)/bmap.c \
$(LIBEXT2FS)/check_desc.c \
$(LIBEXT2FS)/crc16.c \
$(LIBEXT2FS)/crc32c.c \
$(LIBEXT2FS)/csum.c \
$(LIBEXT2FS)/closefs.c \
$(LIBEXT2FS)/dblist.c \
$(LIBEXT2FS)/dblist_dir.c \
$(LIBEXT2FS)/digest_encode.c \
$(LIBEXT2FS)/dirblock.c \
$(LIBEXT2FS)/dirhash.c \
$(LIBEXT2FS)/dir_iterate.c \
$(LIBEXT2FS)/dupfs.c \
$(LIBEXT2FS)/expanddir.c \
$(LIBEXT2FS)/ext_attr.c \
$(LIBEXT2FS)/extent.c \
$(LIBEXT2FS)/fallocate.c \
$(LIBEXT2FS)/fileio.c \
$(LIBEXT2FS)/finddev.c \
$(LIBEXT2FS)/flushb.c \
$(LIBEXT2FS)/freefs.c \
$(LIBEXT2FS)/gen_bitmap.c \
$(LIBEXT2FS)/gen_bitmap64.c \
$(LIBEXT2FS)/get_num_dirs.c \
$(LIBEXT2FS)/get_pathname.c \
$(LIBEXT2FS)/getsize.c \
$(LIBEXT2FS)/getsectsize.c \
$(LIBEXT2FS)/hashmap.c \
$(LIBEXT2FS)/i_block.c \
$(LIBEXT2FS)/icount.c \
$(LIBEXT2FS)/imager.c \
$(LIBEXT2FS)/ind_block.c \
$(LIBEXT2FS)/initialize.c \
$(LIBEXT2FS)/inline.c \
$(LIBEXT2FS)/inline_data.c \
$(LIBEXT2FS)/inode.c \
$(LIBEXT2FS)/io_manager.c \
$(LIBEXT2FS)/ismounted.c \
$(LIBEXT2FS)/link.c \
$(LIBEXT2FS)/llseek.c \
$(LIBEXT2FS)/lookup.c \
$(LIBEXT2FS)/mmp.c \
$(LIBEXT2FS)/mkdir.c \
$(LIBEXT2FS)/mkjournal.c \
$(LIBEXT2FS)/namei.c \
$(LIBEXT2FS)/native.c \
$(LIBEXT2FS)/newdir.c \
$(LIBEXT2FS)/nls_utf8.c \
$(LIBEXT2FS)/openfs.c \
$(LIBEXT2FS)/progress.c \
$(LIBEXT2FS)/punch.c \
$(LIBEXT2FS)/qcow2.c \
$(LIBEXT2FS)/rbtree.c \
$(LIBEXT2FS)/read_bb.c \
$(LIBEXT2FS)/read_bb_file.c \
$(LIBEXT2FS)/res_gdt.c \
$(LIBEXT2FS)/rw_bitmaps.c \
$(LIBEXT2FS)/sha256.c \
$(LIBEXT2FS)/sha512.c \
$(LIBEXT2FS)/swapfs.c \
$(LIBEXT2FS)/symlink.c \
$(LIBEXT2FS)/undo_io.c \
$(LIBEXT2FS)/unix_io.c \
$(LIBEXT2FS)/sparse_io.c \
$(LIBEXT2FS)/unlink.c \
$(LIBEXT2FS)/valid_blk.c \
$(LIBEXT2FS)/version.c \
$(LIBEXT2FS)/test_io.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-unused-but-set-variable \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2_blkid
LOCAL_SRC_FILES := \
$(LIBEXT2_BLKID)/cache.c \
$(LIBEXT2_BLKID)/dev.c \
$(LIBEXT2_BLKID)/devname.c \
$(LIBEXT2_BLKID)/devno.c \
$(LIBEXT2_BLKID)/getsize.c \
$(LIBEXT2_BLKID)/llseek.c \
$(LIBEXT2_BLKID)/probe.c \
$(LIBEXT2_BLKID)/read.c \
$(LIBEXT2_BLKID)/resolve.c \
$(LIBEXT2_BLKID)/save.c \
$(LIBEXT2_BLKID)/tag.c \
$(LIBEXT2_BLKID)/version.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=attributes \
-Wno-error=pointer-sign \
-Wno-unused-but-set-variable \
-fno-strict-aliasing \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2_uuid
LOCAL_SRC_FILES := \
$(LIBEXT2_UUID)/clear.c \
$(LIBEXT2_UUID)/compare.c \
$(LIBEXT2_UUID)/copy.c \
$(LIBEXT2_UUID)/gen_uuid.c \
$(LIBEXT2_UUID)/isnull.c \
$(LIBEXT2_UUID)/pack.c \
$(LIBEXT2_UUID)/parse.c \
$(LIBEXT2_UUID)/unpack.c \
$(LIBEXT2_UUID)/unparse.c \
$(LIBEXT2_UUID)/uuid_time.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2_e2p
LOCAL_SRC_FILES := \
$(LIBEXT2_E2P)/crypto_mode.c \
$(LIBEXT2_E2P)/encoding.c \
$(LIBEXT2_E2P)/errcode.c \
$(LIBEXT2_E2P)/feature.c \
$(LIBEXT2_E2P)/fgetflags.c \
$(LIBEXT2_E2P)/fgetproject.c \
$(LIBEXT2_E2P)/fgetversion.c \
$(LIBEXT2_E2P)/fsetflags.c \
$(LIBEXT2_E2P)/fsetproject.c \
$(LIBEXT2_E2P)/fsetversion.c \
$(LIBEXT2_E2P)/getflags.c \
$(LIBEXT2_E2P)/getversion.c \
$(LIBEXT2_E2P)/hashstr.c \
$(LIBEXT2_E2P)/iod.c \
$(LIBEXT2_E2P)/ljs.c \
$(LIBEXT2_E2P)/ls.c \
$(LIBEXT2_E2P)/mntopts.c \
$(LIBEXT2_E2P)/ostype.c \
$(LIBEXT2_E2P)/parse_num.c \
$(LIBEXT2_E2P)/pe.c \
$(LIBEXT2_E2P)/percent.c \
$(LIBEXT2_E2P)/pf.c \
$(LIBEXT2_E2P)/ps.c \
$(LIBEXT2_E2P)/setflags.c \
$(LIBEXT2_E2P)/setversion.c \
$(LIBEXT2_E2P)/uuid.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=attributes \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2_quota
LOCAL_SRC_FILES := \
$(LIBEXT2_QUOTA)/devname.c \
$(LIBEXT2_QUOTA)/dict.c \
$(LIBEXT2_QUOTA)/mkquota.c \
$(LIBEXT2_QUOTA)/parse_qtype.c \
$(LIBEXT2_QUOTA)/plausible.c \
$(LIBEXT2_QUOTA)/prof_err.c \
$(LIBEXT2_QUOTA)/profile.c \
$(LIBEXT2_QUOTA)/profile_helpers.c \
$(LIBEXT2_QUOTA)/quotaio.c \
$(LIBEXT2_QUOTA)/quotaio_tree.c \
$(LIBEXT2_QUOTA)/quotaio_v2.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2_misc
LOCAL_SRC_FILES := $(LIBEXT2_MISC)/create_inode.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-Wno-error=format-extra-args \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libext2_com_err
LOCAL_SRC_FILES := \
$(LIBEXT2_COM_ERR)/com_err.c \
$(LIBEXT2_COM_ERR)/com_right.c \
$(LIBEXT2_COM_ERR)/error_message.c \
$(LIBEXT2_COM_ERR)/et_name.c \
$(LIBEXT2_COM_ERR)/init_et.c
LOCAL_C_INCLUDES := $(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(E2FSPROGS_DEFAULT_CFLAGS) \
-fPIC \
-pthread
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := pmt
LOCAL_SRC_FILES := \
$(PMT)/Debug.cpp \
$(PMT)/Root.cpp \
$(PMT)/PartitionManager.cpp \
$(PMT)/PartitionTool.cpp \
$(PMT)/ListPartitions.cpp \
$(PMT)/Version.cpp \
$(PMT)/GetState.cpp \
$(PMT)/Tools.cpp \
$(PMT)/LanguageTools.cpp \
$(PMT)/Languages.cpp \
$(PMT)/Help.cpp \
$(MKE2FS)/default_profile.c \
$(MKE2FS)/mk_hugefiles.c \
$(MKE2FS)/mke2fs.c \
$(MKE2FS)/util.c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../include/PartitionManager \
$(E2FSPROGS_INCLUDES)
LOCAL_CFLAGS := \
$(PMT_CXXFLAGS) \
$(E2FSPROGS_DEFAULT_CFLAGS)
LOCAL_STATIC_LIBRARIES := \
libext2fs \
libext2_blkid \
libext2_uuid \
libext2_e2p \
libext2_quota \
libext2_misc \
libext2_com_err
include $(BUILD_EXECUTABLE)

23
mka/config.mk → jni/Application.mk Normal file → Executable file
View File

@@ -1,6 +1,6 @@
# By YZBruh
# Copyright 2024 YZBruh - Partition Backupper
# Copyright 2024 Partition Manager
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,16 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# use custom gcc | true or false
USE_CUST_GCC := false
########
# 2.9.1
########
# custom gcc ext (if used)
CUST_GCC :=
# architecture
APP_ABI := \
arm64-v8a \
armeabi-v7a
# addionital gcc flags
EXTRA_GCC_FLAGS :=
APP_PLATFORM := android-29
APP_OPTIM := release
APP_STL := c++_static
# apply configration
include mka/apply-config.mk
# end of config
# end

114
jni/PartitionManager/Debug.cpp Executable file
View File

@@ -0,0 +1,114 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define INC_MAIN_LIBS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
using namespace PartitionManager;
/* it's prints standart logs */
void Functions::DisplayLog(LogLevel status, const char* _Nullable fmt, ...)
{
va_list args;
va_start(args, fmt);
switch (status)
{
case LOG_LEVEL_ERROR:
if (!Booleans::SilentEnabled)
{
fprintf(stderr, "%s: ", Strings::ExecutingName.c_str());
vfprintf(stderr, fmt, args);
}
exit(1);
break;
case LOG_LEVEL_WARN:
if (!Booleans::SilentEnabled)
{
fprintf(stdout, "%s: ", Display::UsingDispString->warn);
vfprintf(stdout, fmt, args);
}
break;
case LOG_LEVEL_FATAL:
if (!Booleans::SilentEnabled)
{
fprintf(stderr, "%s: ", Display::UsingDispString->fatal);
vfprintf(stderr, fmt, args);
}
abort();
break;
case LOG_LEVEL_DEBUG:
if (!Booleans::SilentEnabled)
vfprintf(stdout, fmt, args);
break;
}
va_end(args);
}
/* it's prints verbose logs */
void Functions::DisplayVerboseLog(LogLevel status, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
switch (status)
{
case LOG_LEVEL_ERROR:
if (Booleans::VerboseMode)
{
fprintf(stderr, "E:[stderr]: ");
vfprintf(stderr, fmt, args);
}
break;
case LOG_LEVEL_WARN:
if (Booleans::VerboseMode)
{
fprintf(stdout, "W:[stdout]: ");
vfprintf(stdout, fmt, args);
}
break;
case LOG_LEVEL_FATAL:
if (Booleans::VerboseMode)
{
fprintf(stderr, "F:[stderr]: ");
vfprintf(stderr, fmt, args);
abort();
}
break;
case LOG_LEVEL_DEBUG:
if (Booleans::VerboseMode)
{
fprintf(stdout, "D:[stdout]: ");
vfprintf(stdout, fmt, args);
}
break;
}
va_end(args);
}
/**
* Last error is taken from strerror by taking
* the contents of errno or taking a special entry
*/
char* strqerror(int errno_macro) { return strerror(errno_macro); }
/* end of code */

View File

@@ -0,0 +1,54 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define INC_MAIN_LIBS
#define INC_STAT
#include <PartitionManager/PartitionManager.h>
/**
* The target file is controlled by the stat function.
* Files, directories, links and blocks (disks) are for.
* If it is never found, it returns 1 value.
* If he finds 0 value is returned.
* If the desired type is not in -1 value is returned.
* If the search type is unknown, 3 value is returned
*/
int PartitionManager::Functions::GetState(const string& filepath, const string& stype)
{
static struct stat GetStat;
VLOGD("GetStat: checking `%s' with 'stat <sys/stat.h>'...\n", filepath.c_str());
if (stat(filepath.c_str(), &GetStat) != 0)
return 1;
if (stype == "dir")
return (S_ISDIR(GetStat.st_mode)) ? 0 : -1;
else if (stype == "file")
return (S_ISREG(GetStat.st_mode)) ? 0 : -1;
else if (stype == "blk")
return (S_ISBLK(GetStat.st_mode)) ? 0 : -1;
else if (stype == "link")
return (S_ISLNK(GetStat.st_mode)) ? 0 : -1;
else
return 3;
return 2;
}
/* end of code */

74
jni/PartitionManager/Help.cpp Executable file
View File

@@ -0,0 +1,74 @@
/* By YZBruh */
/*
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define INC_MAIN_LIBS
#define INC_STRINGKEYS
#define HELP
#include <PartitionManager/PartitionManager.h>
#include <PartitionManager/HelpFn.h>
using namespace PartitionManager;
struct langdb_docs* Display::UsingDocDispString = nullptr;
static void
prepare_langconf_docs(void)
{
if (Strings::CurrentLanguage == "en")
Display::UsingDocDispString = &Display::LangDocEn;
else if (Strings::CurrentLanguage == "tr")
Display::UsingDocDispString = &Display::LangDocTr;
}
void Functions::DisplayHelp(void)
{
VLOGD("DisplayHelp: Loading language for help messages... Calling prepare_langconf_docs() <local function>...\n");
prepare_langconf_docs();
VLOGD("DisplayHelp: Printing...\n");
LOGD("%s: %s %s\n", Display::UsingDocDispString->usage_docstr, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l1);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l2);
LOGD(" %s: %s %s\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l3);
LOGD(" %s: %s %s\n\n", Display::UsingDocDispString->or_str, Strings::ExecutingName.c_str(), Display::UsingDocDispString->docs_strs_l4);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l5);
LOGD(" -l, --logical %s\n", Display::UsingDocDispString->docs_strs_l6);
LOGD(" -P, --search-path %s\n", Display::UsingDocDispString->docs_strs_l7);
LOGD(" -p, --list %s\n", Display::UsingDocDispString->docs_strs_l8);
LOGD(" -s, --silent %s\n", Display::UsingDocDispString->docs_strs_l9);
LOGD(" -f, --force %s\n", Display::UsingDocDispString->docs_strs_l10);
LOGD(" -V, --verbose %s\n", Display::UsingDocDispString->docs_strs_l11);
LOGD(" -S, --set-lang %s\n", Display::UsingDocDispString->docs_strs_l12);
LOGD(" -v, --version %s\n", Display::UsingDocDispString->docs_strs_l13);
LOGD(" --help %s\n\n", Display::UsingDocDispString->docs_strs_l14);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l15);
LOGD(" --only-size %s\n", Display::UsingDocDispString->docs_strs_l16);
LOGD(" --as-byte %s\n", Display::UsingDocDispString->docs_strs_l17);
LOGD(" --as-kilobyte %s\n", Display::UsingDocDispString->docs_strs_l18);
LOGD(" --as-megabyte %s\n", Display::UsingDocDispString->docs_strs_l19);
LOGD(" --as-gigabyte %s\n\n", Display::UsingDocDispString->docs_strs_l20);
LOGD("%s:\n", Display::UsingDocDispString->docs_strs_l21);
LOGD(" %s backup boot_a -P /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s flash boot_a /sdcard/twrp/boot.img -c /dev/block/platform/bootdevice/by-name\n", Strings::ExecutingName.c_str());
LOGD(" %s format system_a ext4 --logical\n", Strings::ExecutingName.c_str());
LOGD(" %s -P /dev/block/platform/bootdevice/by-name --list\n", Strings::ExecutingName.c_str());
LOGD(" %s partition-size boot --as-byte\n", Strings::ExecutingName.c_str());
LOGD(" %s partition-size system --only-size --as-gigabyte --logical\n\n", Strings::ExecutingName.c_str());
LOGD("%s <t.me/ShawkTeam | Topics | pmt>\n", Display::UsingDocDispString->docs_strs_l22);
}
/* end of code */

View File

@@ -0,0 +1,183 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define INC_MAIN_LIBS
#define INC_DEBUGERS
#define INC_STAT
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
using namespace PartitionManager;
/* pmt's man doc file path on termux */
#define INTERNAL_STORAGE_DIR "/sdcard"
#define TERMUX_PMT_MANDOC "/data/data/com.termux/files/usr/share/man/man8/pmt.8.gz"
#define PMTLANG_CONF "/sdcard/.pmtlang.conf"
#define PMT_SW_POINT "/sdcard/.pmtlangsw"
struct langdb_general* Display::UsingDispString = nullptr;
static fstream langconf;
string supp_langs[] = {
"en",
"tr",
""
};
static bool
InternalStorageDirFound(void)
{
return (Functions::GetState(INTERNAL_STORAGE_DIR, "dir") == 0) ? true : false;
}
static bool
LanguageControl(const string& lang)
{
for (int i = 0; !supp_langs[i].empty(); i++)
{
if (lang == supp_langs[i])
return true;
}
return false;
}
bool Functions::LoadLanguage(void)
{
string lang_fpr = "en";
langconf.close();
VLOGD("LoadLanguage: checking install type...\n");
if (Functions::GetState(TERMUX_PMT_MANDOC) == 0)
Booleans::InstalledOnTermux = true;
VLOGD("LoadLanguage: checking internal storage dir: `%s'\n", INTERNAL_STORAGE_DIR);
if (!InternalStorageDirFound())
LOGE("PartitionManagerLoadLanguage: internal storage directory (`%s') not found or accessible.\n", INTERNAL_STORAGE_DIR);
VLOGD("LoadLanguage: trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
langconf.open(PMTLANG_CONF, ios::in | ios::out);
VLOGD("LoadLanguage: checking status: `%s'...\n", PMTLANG_CONF);
if (!langconf.is_open())
{
langconf.open(PMTLANG_CONF, ios::out | ios::trunc);
VLOGD("LoadLanguage: calling SetLanguage()...\n");
Functions::SetLanguage("en", 1);
Display::UsingDispString = &Display::LangEn;
Strings::CurrentLanguage = "en";
if (langconf.is_open())
langconf.close();
return true;
}
else
{
VLOGD("LoadLanguage: reading `%s'\n", PMTLANG_CONF);
while (getline(langconf, lang_fpr))
{
if (lang_fpr == "en")
goto SetEn;
else if (lang_fpr == "tr")
goto SetTr;
else
{
VLOGD("LoadLanguage: calling SetLanguage()\n");
Functions::SetLanguage("en", 1);
VLOGD("LoadLanguage: re-calling LoadLanguage()\n");
Functions::LoadLanguage();
return true;
}
}
if (!getline(langconf, lang_fpr))
{
VLOGD("LoadLanguage: calling SetLanguage()\n");
Functions::SetLanguage("en", 1);
VLOGD("LoadLanguage: re-calling LoadLanguage()\n");
Functions::LoadLanguage();
return true;
}
}
SetEn:
langconf.close();
Display::UsingDispString = &Display::LangEn;
Strings::CurrentLanguage = "en";
VLOGD("LoadLanguage: loaded \"en\"\n");
return true;
SetTr:
langconf.close();
Display::UsingDispString = &Display::LangTr;
Strings::CurrentLanguage = "tr";
VLOGD("LoadLanguage: loaded \"tr\"\n");
return true;
return false;
}
void Functions::SetLanguage(const string& lang, unsigned short null_conf_stat)
{
VLOGD("SetLanguage: checking speficed language (from input).\n");
if (!LanguageControl(lang))
LOGE("Unknown language: %s.\n", lang.c_str());
langconf.close();
VLOGD("SetLanguage: checking internal storage dir: `%s'\n", INTERNAL_STORAGE_DIR);
if (!InternalStorageDirFound())
LOGE("PartitionManagerSetLanguage: internal storage directory (`%s') not found or accessible.\n", INTERNAL_STORAGE_DIR);
VLOGD("SetLanguage: trying to open `%s' with 'open <fstream>'\n", PMTLANG_CONF);
langconf.open(PMTLANG_CONF, ios::out | ios::trunc);
if (!langconf.is_open())
LOGE("PartitionManagerLanguageTools: Cannot open/write config file!!!\n");
VLOGD("SetLanguage: write \"%s\" to `%s' with 'std <iostream>'\n", lang.c_str(), PMTLANG_CONF);
langconf << lang;
if (!langconf)
LOGE("PartitionManagerLanguageTools: Couldn't write config!!!\n");
else
langconf.close();
if (null_conf_stat != 1)
{
VLOGD("SetLanguage: generating dummy file `%s' with 'ofstream <fstream>'\n", PMT_SW_POINT);
ofstream sw_point(PMT_SW_POINT, ios::trunc);
if (sw_point.is_open())
sw_point.close();
}
}
bool Functions::CleanSWPoint(void)
{
if (Functions::GetState(PMT_SW_POINT) == 0)
{
VLOGD("CleanSWPoint: removing (force) `%s' with 'remove <unistd.h>'\n", PMT_SW_POINT);
remove(PMT_SW_POINT);
return true;
}
else
return false;
}
/* end of code */

View File

@@ -0,0 +1,248 @@
/* By YZBruh */
/**
* Copyright 2024 Partition Manager
*
* Licensed under the Apache License, Version 2.0 (the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define INC_MAIN_LIBS
#define INC_STRINGKEYS
#include <PartitionManager/PartitionManager.h>
namespace PartitionManager {
namespace Display {
struct langdb_general LangEn = {
.lang_by_s = "YZBruh & r0manas",
.language = "English",
.lang_prefix = "en",
.not_logical = "This device does not have logical partitions!",
.not_file = "is not a file.",
.not_dir = "is not a directory.",
.not_in_dev = "Nothing found in /dev. Use force mode to avoid this error.",
.not_open = "Couldn't open",
.not_block = "The specified partition is not recognized as a block device. Use force mode to avoid this error.",
.not_read = "Couldn't read",
.not_readdir = "Couldn't read directory",
.not_write = "Couldn't write",
.not_gen = "Couldn't generate",
.no_root = "Root access could not be detected! Please run this with root permissions.",
.expected_backup_arg = "Expected backup argument 2 (1 of them are not mandatory), retrieved",
.expected_flash_arg = "Expected flash argument 2, retrieved",
.expected_format_arg = "Expected format argument 2, retrieved",
.expected_partsz_arg = "Expacted partition-size argument 2, retrieved",
.missing_operand = "Missing operand",
.multiple_wiewers = "Multiple viewers can't be used on the same line.",
.symbol_rule = "When specifying arguments for an option, ensure they do not begin with '-'. Each argument must correspond correctly to its respective option.",
.req_part_name = "Partition name required.",
.part_not_found = "Partition not found! Maybe a logical partition?",
.unsupported_fs = "Formatter: unsupported filesystem",
.cannot_stat = "Cannot stat",
.ffile_more_part = "Flash file size exceeds partition capacity. Use force mode to avoid this error (not recommended, riscy!).",
.cannot_get_bsz = "Failed to retrieve partition block size.",
.format_fail = "Formatting failed! There is a possibility of data damage.",
.fail_get_psize = "Cannot get partition size",
.depr_backup_opt = "These options for the backup are unavailable.",
.depr_flash_opt = "These options for the flash are unavailable.",
.depr_format_opt = "These options for the format are unavailable.",
.depr_Vlicense_opt = "Deprecated because it was unnecessary.",
.depr_ch_list_opt = "Use -p argument for listing partitions.",
.depr_ch_sp_opt = "Use -P (--search-path) argument instead of -c (--context).",
.not_spec_opt = "Specify the necessary arguments, not option",
.some_spec = "You may have indicated options, but they don't work much unless you speficy a main transaction",
.logical_warn = "This device uses logical partitions.",
.ab_warn = "This device uses A/B partition style.",
.out_not_spec = "Output file name not specified. Using created name",
.no_found_on_process = "The file that was processed was not found. Something wen wrong...",
.please_rerun = "Please rerun the command.",
.part_disk_sz = "Partition (backup) size",
.flash_file_sz = "Flash file size",
.part_disk_sz_fail = "Failed to retrieve partition disk size.",
.flash_file_sz_fail = "Failed to retrieve flash file size.",
.unknown_opr = "Unknown operand",
.req_an_arg = "option requires an argument",
.list_of_general = "List of general partitions",
.list_of_logc = "List of logical partitions",
.success_backup = "Backup successful. Output",
.success_flash = "Flash successful",
.success_format = "Format successful",
.formatting = "Formatting",
.warn = "WARNING",
.fatal = "FATAL ERROR",
.is_requires_arg = "requires an argument",
.only_partsz_args = "Flags can be used only in partition size view were identified. But target not this",
.unknw_arg = "unknown option",
.switching_lang = "Switching language...",
.welcome = "language!",
.welcome_ = "Welcome to ",
.for_more = "for more information",
.s_and_v = "Silent and verbose mode cannot be used together!",
.try_h = "Try",
.usage_head = "Usage",
.depr_opt_str = "DEPRECATED OPTION",
.switched_opt_str = "SWITCHED OPTION",
.not_changed_opt = "not changed",
.compiler_str = "compiler",
.version_str = "version",
.bin_str = "binary",
.part_name = "Partition name",
.part_type = "Partition is dynamic",
.fs_str = "Filesystem",
.unknw_str = "unknown",
.by_str = "By",
.yes = "true",
.no = "false"
};
struct langdb_general LangTr = {
.lang_by_s = "YZBruh",
.language = "Türkçe",
.lang_prefix = "tr",
.not_logical = "Bu cihaz mantıksal (logical) bölümlere sahip değil!",
.not_file = "Bu bir dosya değil",
.not_dir = "Bu bir dizin değil",
.not_in_dev = "Bu bir şakamı? Bunun /dev dizini ile bir ilgisi yok (içermiyor). Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.not_open = "ılamıyor",
.not_block = "Belirtilen bölüm bir blok değil. Yani aslında bu bir bölüm bile değil (disk). Bu hatayı almak için şanslı olmak gerek..! Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın.",
.not_read = "Veri okunamıyor",
.not_readdir = "Dizin verisi okunamıyor",
.not_write = "Veri yazılamıyor",
.not_gen = "Oluşturulamıyor",
.no_root = "Root erişimi tespit edilemedi! Lütfen root erişimi ile çalıştırın.",
.expected_backup_arg = "Beklenen yedekleme argümanı 2 (bir tanesi zorunlu değil), alınan",
.expected_flash_arg = "Beklenen flaş argümanı 2, alınan",
.expected_format_arg = "Beklenen format argümanı 2, alınan",
.expected_partsz_arg = "Beklenen partition-size argümanı 1, alınan",
.missing_operand = "İşlem belirtilmedi",
.multiple_wiewers = "Birden fazla görüntüleme işlemi yapan fonksiyonlar bir arada kullanılamaz. Aynı anda sadece bir tanesi kullanılabilir.",
.symbol_rule = "Bir seçeneğin argümanını verirken argüman önüne '-' sembolü getirilemez. Sembolü kaldırın ve tekrar deneyin.",
.req_part_name = "Bölüm adı gereklidir.",
.part_not_found = "Bölüm bulunamadı! Belki mantıksal (logical) bir bölümdür?",
.unsupported_fs = "Formatlayıcı: desteklenmeyen dosya sistemi:",
.cannot_stat = "Durumu tespit edilemedi",
.ffile_more_part = "Flaşlanacak dosyanın boyutu mevcut bölüm boyutundan fazla. Bu hatayla karşılaşmak istemiyorsanız zorlama (force) modu kullanın (bunu yapmanız asla önerilmez).",
.cannot_get_bsz = "Bölüm blok boyutu tespit edilemedi!",
.format_fail = "Formatlama başarısız oldu. Bazı şeyler zarar görmüş olabilir!",
.fail_get_psize = "Bölüm boyutu alınamadı",
.depr_backup_opt = "Yedek için artık bu seçeneği kullanamazsınız.",
.depr_flash_opt = "Flaşlama için artık bu seçeneği kullanamazsınız.",
.depr_format_opt = "Formatlama için artıi bu seçeneği kullanamazsınız.",
.depr_Vlicense_opt = "Gereksiz seçeneklere bellek yok!",
.depr_ch_list_opt = "Listeleme için -p seçeneğini kullanabilirsiniz.",
.depr_ch_sp_opt = "Özel arama dizini belirtmek için -P (--search-path) seçeneğini kullanabilirsiniz.",
.logical_warn = "Bu cihaz mantıksal (logical) bölümlere sahip.",
.not_spec_opt = "Seçenek değil, şuan gerekli argümanları verin",
.some_spec = "Seçenek belirtmiş olabilirsiniz fakat, ana işlem belirtmedikçe pek işe yaramazlar",
.ab_warn = "Bu cihazın bazı bölümleri A/B kullanıyor.",
.out_not_spec = "Çıktı dosya adı belirtilmedi. Oluşturulan çıktı adı",
.no_found_on_process = "İşlenmekte olan dosya bulunamadı. Bir şeyler yanlış...",
.please_rerun = "Lütfen yeniden çalıştırın",
.part_disk_sz = "Bölümün (yedek) boyutu",
.flash_file_sz = "Flaşlanacak dosyanın boyutu",
.flash_file_sz_fail = "Uyarı: flaşlanacak dosyanın boyutu tespit edilemedi.",
.part_disk_sz_fail = "Uyarı: bölüm boyutunun boyutu tespit edilemedi.",
.unknown_opr = "Bilinmeyen işlem",
.req_an_arg = "bu seçenek argüman gerektirir",
.list_of_general = "Genel bölümlerin listesi",
.list_of_logc = "Mantıksal (logical) bölümlerin listesi",
.success_backup = "Başarılı. Çıktı",
.success_flash = "Başarılı.",
.success_format = "Formatlama başarılı",
.formatting = "Formatlanıyor",
.warn = "UYARI",
.fatal = "KRİTİK HATA",
.is_requires_arg = "bir argüman gereklidir",
.only_partsz_args = "Sadece bölüm boyutu görüntülemesinde kullanılabilecek bayraklar tespit edildi. Ama hedef bu değil",
.unknw_arg = "bilinmeyen seçenek",
.switching_lang = "Dil değiştiriliyor...",
.welcome = "diline hoş geldiniz!",
.welcome_ = NULL,
.for_more = "komutunu kullanabilirsiniz",
.s_and_v = "Sessiz ve ayrıntılı günlüklenme aynı anda kullanılamaz!",
.try_h = "Daha fazla bilgi",
.usage_head = "Kullanımı",
.depr_opt_str = "KALDIRILMIŞ SEÇENEK",
.switched_opt_str = "DEĞİŞTİRİLMİŞ SEÇENEK",
.not_changed_opt = "değiştirilmedi",
.compiler_str = "derleyicisi",
.version_str = "versiyon",
.bin_str = "yapı",
.part_name = "Bölüm adı",
.part_type = "Dinamik bölüm",
.fs_str = "Dosya sistemi",
.unknw_str = "bilinmeyen",
.by_str = "Çeviriyi yapan(lar):",
.yes = "evet",
.no = "hayır"
};
struct langdb_docs LangDocEn = {
.docs_strs_l1 = "[OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...",
.docs_strs_l2 = "[OPTIONS] flash PARTITION FILE [OPTIONS]...",
.docs_strs_l3 = "[OPTIONS] format PARTITION FILE_SYSTEM[ext/2/3/4] [OPTIONS]...",
.docs_strs_l4 = "[OPTIONS] partition-size PARTITION [OPTIONS]...",
.docs_strs_l5 = "Options",
.docs_strs_l6 = "It is meant to determine whether the target partition is logical.",
.docs_strs_l7 = "It is meant to specify a custom partition search path. Only normal partitions (default: /dev/block/by-name).",
.docs_strs_l8 = "List partitions.",
.docs_strs_l9 = "Information and warning messages are silenced in normal work.",
.docs_strs_l10 = "Force mode. Some things are ignored.",
.docs_strs_l11 = "Verbose mode. Print detailed informations etc.",
.docs_strs_l12 = "Set current language.",
.docs_strs_l13 = "See version.",
.docs_strs_l14 = "See this help message.",
.docs_strs_l15 = "partition-size flags",
.docs_strs_l16 = "Only the size is displayed, the partition name etc is not displayed.",
.docs_strs_l17 = "Display size as byte.",
.docs_strs_l18 = "Display size as kilobyte.",
.docs_strs_l19 = "Display size as megabyte.",
.docs_strs_l20 = "Display size as gigabyte.",
.docs_strs_l21 = "Examples",
.docs_strs_l22 = "Report bugs and suggestions to",
.or_str = "or",
.usage_docstr = "Usage"
};
struct langdb_docs LangDocTr = {
.docs_strs_l1 = "[SEÇENEKLER] backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
.docs_strs_l2 = "[SEÇENEKLER] flash BÖLÜM DOSYA [SEÇENEKLER]...",
.docs_strs_l3 = "[SEÇENEKLER] format BÖLÜM DOSYA_SİSTEMİ[ext/2/3/4] [SEÇENEKLER]...",
.docs_strs_l4 = "[SEÇENEKLER] partition-size BÖLÜM [SEÇENEKLER]...",
.docs_strs_l5 = "Seçenekler",
.docs_strs_l6 = "Mantıksal (logical) bölüm ile işlem yapın.",
.docs_strs_l7 = "Özel bir bölüm arama dizini belirtin. Sadece normal bölümler içindir (Varsayılan: /dev/block/by-name).",
.docs_strs_l8 = "Bölümler listelenir.",
.docs_strs_l9 = "Bilgi ve uyarı mesajları susturulur.",
.docs_strs_l10 = "Zorlama modu. Bazı şeyler göz ardı edilir.",
.docs_strs_l11 = "Ayrıntılı bilgi modu. Daha fazla bilgi mesajı verilir.",
.docs_strs_l12 = "Mevcut dili ayarlayın.",
.docs_strs_l13 = "Sürümü görüntüleyin.",
.docs_strs_l14 = "Bu yardım mesajını görüntüleyin.",
.docs_strs_l15 = "partition-size bayrakları",
.docs_strs_l16 = "Boyut görüntülenirken bölüm adı vb gibi bilgiler verilmez, sadece boyut görüntülenir.",
.docs_strs_l17 = "Boyutu bayt olarak görüntüleyin.",
.docs_strs_l18 = "Boyutu kilobayt olarak görüntüleyin.",
.docs_strs_l19 = "Boyutu megabyte olarak görüntüleyin.",
.docs_strs_l20 = "Boyutu gigabayt olarak görüntüleyin.",
.docs_strs_l21 = "Örnekler",
.docs_strs_l22 = "Sorunları ve önerileri şuraya bildirin:",
.or_str = "yada",
.usage_docstr = "Kullanımı"
};
} /* namespace Display */
} /* namespace PartitionManager */
/* end of code */

Some files were not shown because too many files have changed in this diff Show More