Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
e59c5c87
Commit
e59c5c87
authored
Feb 21, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modernize compress and decompress
parent
86d80263
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
195 additions
and
183 deletions
+195
-183
bootimg.cpp
native/jni/magiskboot/bootimg.cpp
+3
-5
compress.cpp
native/jni/magiskboot/compress.cpp
+106
-126
compress.h
native/jni/magiskboot/compress.h
+4
-0
format.cpp
native/jni/magiskboot/format.cpp
+51
-26
format.h
native/jni/magiskboot/format.h
+24
-5
magiskboot.h
native/jni/magiskboot/magiskboot.h
+0
-6
main.cpp
native/jni/magiskboot/main.cpp
+7
-15
No files found.
native/jni/magiskboot/bootimg.cpp
View file @
e59c5c87
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include "bootimg.h"
#include "bootimg.h"
#include "magiskboot.h"
#include "magiskboot.h"
#include "compress.h"
static
void
dump
(
void
*
buf
,
size_t
size
,
const
char
*
filename
)
{
static
void
dump
(
void
*
buf
,
size_t
size
,
const
char
*
filename
)
{
if
(
size
==
0
)
if
(
size
==
0
)
...
@@ -163,11 +164,8 @@ int boot_img::parse_image(const char * image) {
...
@@ -163,11 +164,8 @@ int boot_img::parse_image(const char * image) {
r_fmt
=
check_fmt
(
ramdisk
,
hdr
->
ramdisk_size
);
r_fmt
=
check_fmt
(
ramdisk
,
hdr
->
ramdisk_size
);
}
}
char
fmt
[
16
];
fprintf
(
stderr
,
"KERNEL_FMT [%s]
\n
"
,
fmt2name
[
k_fmt
]);
get_fmt_name
(
k_fmt
,
fmt
);
fprintf
(
stderr
,
"RAMDISK_FMT [%s]
\n
"
,
fmt2name
[
r_fmt
]);
fprintf
(
stderr
,
"KERNEL_FMT [%s]
\n
"
,
fmt
);
get_fmt_name
(
r_fmt
,
fmt
);
fprintf
(
stderr
,
"RAMDISK_FMT [%s]
\n
"
,
fmt
);
return
flags
&
CHROMEOS_FLAG
?
CHROMEOS_RET
:
0
;
return
flags
&
CHROMEOS_FLAG
?
CHROMEOS_RET
:
0
;
default
:
default
:
...
...
native/jni/magiskboot/compress.cpp
View file @
e59c5c87
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/mman.h>
#include <memory>
#include <logging.h>
#include <logging.h>
#include <utils.h>
#include <utils.h>
...
@@ -10,142 +11,121 @@
...
@@ -10,142 +11,121 @@
#include "magiskboot.h"
#include "magiskboot.h"
#include "compress.h"
#include "compress.h"
using
namespace
std
;
int64_t
decompress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
)
{
int64_t
decompress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
)
{
auto
cmp
=
get_decoder
(
type
);
unique_ptr
<
Compression
>
cmp
(
get_decoder
(
type
));
int64_t
ret
=
cmp
->
one_step
(
fd
,
from
,
size
);
return
cmp
->
one_step
(
fd
,
from
,
size
);
delete
cmp
;
return
ret
;
}
}
int64_t
compress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
)
{
int64_t
compress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
)
{
auto
cmp
=
get_encoder
(
type
);
unique_ptr
<
Compression
>
cmp
(
get_encoder
(
type
));
int64_t
ret
=
cmp
->
one_step
(
fd
,
from
,
size
);
return
cmp
->
one_step
(
fd
,
from
,
size
);
delete
cmp
;
}
return
ret
;
}
void
decompress
(
char
*
from
,
const
char
*
to
)
{
int
strip
=
1
;
void
*
file
;
size_t
size
=
0
;
if
(
strcmp
(
from
,
"-"
)
==
0
)
stream_full_read
(
STDIN_FILENO
,
&
file
,
&
size
);
else
mmap_ro
(
from
,
&
file
,
&
size
);
format_t
type
=
check_fmt
(
file
,
size
);
char
*
ext
;
ext
=
strrchr
(
from
,
'.'
);
if
(
to
==
nullptr
)
to
=
from
;
if
(
ext
!=
nullptr
)
{
// Strip out a matched file extension
switch
(
type
)
{
case
GZIP
:
if
(
strcmp
(
ext
,
".gz"
)
!=
0
)
strip
=
0
;
break
;
case
XZ
:
if
(
strcmp
(
ext
,
".xz"
)
!=
0
)
strip
=
0
;
break
;
case
LZMA
:
if
(
strcmp
(
ext
,
".lzma"
)
!=
0
)
strip
=
0
;
break
;
case
BZIP2
:
if
(
strcmp
(
ext
,
".bz2"
)
!=
0
)
strip
=
0
;
break
;
case
LZ4_LEGACY
:
case
LZ4
:
if
(
strcmp
(
ext
,
".lz4"
)
!=
0
)
strip
=
0
;
break
;
default:
LOGE
(
"Provided file
\'
%s
\'
is not a supported archive format
\n
"
,
from
);
}
if
(
strip
)
*
ext
=
'\0'
;
}
int
fd
;
static
bool
read_file
(
FILE
*
fp
,
const
function
<
void
(
void
*
,
size_t
)
>
&
fn
)
{
char
buf
[
4096
];
size_t
len
;
while
((
len
=
fread
(
buf
,
1
,
sizeof
(
buf
),
fp
)))
fn
(
buf
,
len
);
return
true
;
}
if
(
strcmp
(
to
,
"-"
)
==
0
)
{
void
decompress
(
char
*
infile
,
const
char
*
outfile
)
{
fd
=
STDOUT_FILENO
;
bool
in_std
=
strcmp
(
infile
,
"-"
)
==
0
;
}
else
{
bool
rm_in
=
false
;
fd
=
creat
(
to
,
0644
);
fprintf
(
stderr
,
"Decompressing to [%s]
\n
"
,
to
);
FILE
*
in_file
=
in_std
?
stdin
:
xfopen
(
infile
,
"re"
);
int
out_fd
=
-
1
;
unique_ptr
<
Compression
>
cmp
;
read_file
(
in_file
,
[
&
](
void
*
buf
,
size_t
len
)
->
void
{
if
(
out_fd
<
0
)
{
format_t
type
=
check_fmt
(
buf
,
len
);
if
(
!
COMPRESSED
(
type
))
LOGE
(
"Input file is not a compressed type!
\n
"
);
cmp
=
std
::
move
(
unique_ptr
<
Compression
>
(
get_decoder
(
type
)));
fprintf
(
stderr
,
"Detected format: [%s]
\n
"
,
fmt2name
[
type
]);
/* If user does not provide outfile, infile has to be either
* <path>.[ext], or '-'. Outfile will be either <path> or '-'.
* If the input does not have proper format, abort */
char
*
ext
=
nullptr
;
if
(
outfile
==
nullptr
)
{
outfile
=
infile
;
if
(
!
in_std
)
{
ext
=
strrchr
(
infile
,
'.'
);
if
(
ext
==
nullptr
||
strcmp
(
ext
,
fmt2ext
[
type
])
!=
0
)
LOGE
(
"Input file is not a supported type!
\n
"
);
// Strip out extension and remove input
*
ext
=
'\0'
;
rm_in
=
true
;
fprintf
(
stderr
,
"Decompressing to [%s]
\n
"
,
outfile
);
}
}
}
decompress
(
type
,
fd
,
file
,
size
);
out_fd
=
strcmp
(
outfile
,
"-"
)
==
0
?
STDOUT_FILENO
:
creat
(
outfile
,
0644
);
close
(
fd
);
cmp
->
set_outfd
(
out_fd
);
if
(
to
==
from
&&
ext
!=
nullptr
)
{
if
(
ext
)
*
ext
=
'.'
;
*
ext
=
'.'
;
unlink
(
from
);
}
}
if
(
strcmp
(
from
,
"-"
)
==
0
)
if
(
!
cmp
->
update
(
buf
,
len
)
)
free
(
file
);
LOGE
(
"Decompression error!
\n
"
);
else
});
munmap
(
file
,
size
);
}
cmp
->
finalize
();
fclose
(
in_file
);
void
compress
(
const
char
*
method
,
const
char
*
from
,
const
char
*
to
)
{
close
(
out_fd
);
format_t
type
;
const
char
*
ext
;
if
(
rm_in
)
char
dest
[
PATH_MAX
]
;
unlink
(
infile
)
;
if
(
strcmp
(
method
,
"gzip"
)
==
0
)
{
}
type
=
GZIP
;
ext
=
"gz"
;
void
compress
(
const
char
*
method
,
const
char
*
infile
,
const
char
*
outfile
)
{
}
else
if
(
strcmp
(
method
,
"xz"
)
==
0
)
{
auto
it
=
name2fmt
.
find
(
method
);
type
=
XZ
;
if
(
it
==
name2fmt
.
end
())
ext
=
"xz"
;
LOGE
(
"Unsupported compression method: [%s]
\n
"
,
method
)
;
}
else
if
(
strcmp
(
method
,
"lzma"
)
==
0
)
{
type
=
LZMA
;
unique_ptr
<
Compression
>
cmp
(
get_encoder
(
it
->
second
))
;
ext
=
"lzma"
;
}
else
if
(
strcmp
(
method
,
"lz4"
)
==
0
)
{
bool
in_std
=
strcmp
(
infile
,
"-"
)
==
0
;
type
=
LZ4
;
bool
rm_in
=
false
;
ext
=
"lz4"
;
}
else
if
(
strcmp
(
method
,
"lz4_legacy"
)
==
0
)
{
FILE
*
in_file
=
in_std
?
stdin
:
xfopen
(
infile
,
"re"
);
type
=
LZ4_LEGACY
;
int
out_fd
;
ext
=
"lz4"
;
}
else
if
(
strcmp
(
method
,
"bzip2"
)
==
0
)
{
if
(
outfile
==
nullptr
)
{
type
=
BZIP2
;
if
(
in_std
)
{
ext
=
"bz2"
;
out_fd
=
STDOUT_FILENO
;
}
else
{
}
else
{
fprintf
(
stderr
,
"Only support following methods: "
);
/* If user does not provide outfile and infile is not
for
(
int
i
=
0
;
SUP_LIST
[
i
];
++
i
)
* STDIN, output to <infile>.[ext] */
fprintf
(
stderr
,
"%s "
,
SUP_LIST
[
i
]);
char
*
tmp
=
new
char
[
strlen
(
infile
)
+
5
];
fprintf
(
stderr
,
"
\n
"
);
sprintf
(
tmp
,
"%s%s"
,
infile
,
fmt2ext
[
it
->
second
]);
exit
(
1
);
out_fd
=
creat
(
tmp
,
0644
);
fprintf
(
stderr
,
"Compressing to [%s]
\n
"
,
tmp
);
delete
[]
tmp
;
rm_in
=
true
;
}
}
void
*
file
;
size_t
size
;
if
(
strcmp
(
from
,
"-"
)
==
0
)
stream_full_read
(
STDIN_FILENO
,
&
file
,
&
size
);
else
mmap_ro
(
from
,
&
file
,
&
size
);
if
(
to
==
nullptr
)
{
if
(
strcmp
(
from
,
"-"
)
==
0
)
strcpy
(
dest
,
"-"
);
else
snprintf
(
dest
,
sizeof
(
dest
),
"%s.%s"
,
from
,
ext
);
}
else
strcpy
(
dest
,
to
);
int
fd
;
if
(
strcmp
(
dest
,
"-"
)
==
0
)
{
fd
=
STDOUT_FILENO
;
}
else
{
}
else
{
fd
=
creat
(
dest
,
0644
);
out_fd
=
strcmp
(
infile
,
"-"
)
==
0
?
STDOUT_FILENO
:
creat
(
infile
,
0644
);
fprintf
(
stderr
,
"Compressing to [%s]
\n
"
,
dest
);
}
}
compress
(
type
,
fd
,
file
,
size
);
close
(
fd
);
cmp
->
set_outfd
(
out_fd
);
if
(
strcmp
(
from
,
"-"
)
==
0
)
free
(
file
);
read_file
(
in_file
,
[
&
](
void
*
buf
,
size_t
len
)
->
void
{
else
if
(
!
cmp
->
update
(
buf
,
len
))
munmap
(
file
,
size
);
LOGE
(
"Compression error!
\n
"
);
if
(
to
==
nullptr
)
});
unlink
(
from
);
cmp
->
finalize
();
fclose
(
in_file
);
close
(
out_fd
);
if
(
rm_in
)
unlink
(
infile
);
}
}
...
...
native/jni/magiskboot/compress.h
View file @
e59c5c87
...
@@ -185,3 +185,7 @@ private:
...
@@ -185,3 +185,7 @@ private:
Compression
*
get_encoder
(
format_t
type
);
Compression
*
get_encoder
(
format_t
type
);
Compression
*
get_decoder
(
format_t
type
);
Compression
*
get_decoder
(
format_t
type
);
int64_t
compress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
);
int64_t
decompress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
);
void
compress
(
const
char
*
method
,
const
char
*
infile
,
const
char
*
outfile
);
void
decompress
(
char
*
infile
,
const
char
*
outfile
);
native/jni/magiskboot/format.cpp
View file @
e59c5c87
...
@@ -2,6 +2,24 @@
...
@@ -2,6 +2,24 @@
#include "format.h"
#include "format.h"
std
::
map
<
std
::
string_view
,
format_t
>
name2fmt
;
Fmt2Name
fmt2name
;
Fmt2Ext
fmt2ext
;
class
FormatInit
{
public
:
FormatInit
()
{
name2fmt
[
"gzip"
]
=
GZIP
;
name2fmt
[
"xz"
]
=
XZ
;
name2fmt
[
"lzma"
]
=
LZMA
;
name2fmt
[
"bzip2"
]
=
BZIP2
;
name2fmt
[
"lz4"
]
=
LZ4
;
name2fmt
[
"lz4_legacy"
]
=
LZ4_LEGACY
;
}
};
static
FormatInit
init
;
#define MATCH(s) (len >= (sizeof(s) - 1) && memcmp(buf, s, sizeof(s) - 1) == 0)
#define MATCH(s) (len >= (sizeof(s) - 1) && memcmp(buf, s, sizeof(s) - 1) == 0)
format_t
check_fmt
(
const
void
*
buf
,
size_t
len
)
{
format_t
check_fmt
(
const
void
*
buf
,
size_t
len
)
{
...
@@ -41,44 +59,51 @@ format_t check_fmt(const void *buf, size_t len) {
...
@@ -41,44 +59,51 @@ format_t check_fmt(const void *buf, size_t len) {
}
}
}
}
void
get_fmt_name
(
format_t
fmt
,
char
*
name
)
{
const
char
*
Fmt2Name
::
operator
[](
format_t
fmt
)
{
const
char
*
s
;
switch
(
fmt
)
{
switch
(
fmt
)
{
case
CHROMEOS
:
case
CHROMEOS
:
s
=
"chromeos"
;
return
"chromeos"
;
break
;
case
AOSP
:
case
AOSP
:
s
=
"aosp"
;
return
"aosp"
;
break
;
case
GZIP
:
case
GZIP
:
s
=
"gzip"
;
return
"gzip"
;
break
;
case
LZOP
:
case
LZOP
:
s
=
"lzop"
;
return
"lzop"
;
break
;
case
XZ
:
case
XZ
:
s
=
"xz"
;
return
"xz"
;
break
;
case
LZMA
:
case
LZMA
:
s
=
"lzma"
;
return
"lzma"
;
break
;
case
BZIP2
:
case
BZIP2
:
s
=
"bzip2"
;
return
"bzip2"
;
break
;
case
LZ4
:
case
LZ4
:
s
=
"lz4"
;
return
"lz4"
;
break
;
case
LZ4_LEGACY
:
case
LZ4_LEGACY
:
s
=
"lz4_legacy"
;
return
"lz4_legacy"
;
break
;
case
MTK
:
case
MTK
:
s
=
"mtk"
;
return
"mtk"
;
break
;
case
DTB
:
case
DTB
:
s
=
"dtb"
;
return
"dtb"
;
break
;
default
:
return
"raw"
;
}
}
const
char
*
Fmt2Ext
::
operator
[](
format_t
fmt
)
{
switch
(
fmt
)
{
case
GZIP
:
return
".gz"
;
case
LZOP
:
return
".lzop"
;
case
XZ
:
return
".xz"
;
case
LZMA
:
return
".lzma"
;
case
BZIP2
:
return
".bz2"
;
case
LZ4
:
case
LZ4_LEGACY
:
return
".lz4"
;
default
:
default
:
s
=
"raw
"
;
return
"
"
;
}
}
strcpy
(
name
,
s
);
}
}
native/jni/magiskboot/format.h
View file @
e59c5c87
#ifndef _FORMAT_H_
#ifndef _FORMAT_H_
#define _FORMAT_H_
#define _FORMAT_H_
#include <map>
#include <string_view>
typedef
enum
{
typedef
enum
{
UNKNOWN
,
UNKNOWN
,
/* Boot formats */
CHROMEOS
,
CHROMEOS
,
AOSP
,
AOSP
,
ELF32
,
ELF32
,
ELF64
,
ELF64
,
DHTB
,
BLOB
,
/* Compression formats */
GZIP
,
GZIP
,
LZOP
,
XZ
,
XZ
,
LZMA
,
LZMA
,
BZIP2
,
BZIP2
,
LZ4
,
LZ4
,
LZ4_LEGACY
,
LZ4_LEGACY
,
/* Misc */
LZOP
,
MTK
,
MTK
,
DTB
,
DTB
,
DHTB
,
BLOB
}
format_t
;
}
format_t
;
#define COMPRESSED(fmt) (
fmt >= GZIP && fmt
<= LZ4_LEGACY)
#define COMPRESSED(fmt) (
(fmt) >= GZIP && (fmt)
<= LZ4_LEGACY)
#define BOOT_MAGIC "ANDROID!"
#define BOOT_MAGIC "ANDROID!"
#define CHROMEOS_MAGIC "CHROMEOS"
#define CHROMEOS_MAGIC "CHROMEOS"
...
@@ -47,7 +53,20 @@ typedef enum {
...
@@ -47,7 +53,20 @@ typedef enum {
#define SUP_LIST ((const char *[]) { "gzip", "xz", "lzma", "bzip2", "lz4", "lz4_legacy", NULL })
#define SUP_LIST ((const char *[]) { "gzip", "xz", "lzma", "bzip2", "lz4", "lz4_legacy", NULL })
#define SUP_EXT_LIST ((const char *[]) { "gz", "xz", "lzma", "bz2", "lz4", "lz4", NULL })
#define SUP_EXT_LIST ((const char *[]) { "gz", "xz", "lzma", "bz2", "lz4", "lz4", NULL })
class
Fmt2Name
{
public
:
const
char
*
operator
[](
format_t
fmt
);
};
class
Fmt2Ext
{
public
:
const
char
*
operator
[](
format_t
fmt
);
};
format_t
check_fmt
(
const
void
*
buf
,
size_t
len
);
format_t
check_fmt
(
const
void
*
buf
,
size_t
len
);
void
get_fmt_name
(
format_t
fmt
,
char
*
name
);
extern
std
::
map
<
std
::
string_view
,
format_t
>
name2fmt
;
extern
Fmt2Name
fmt2name
;
extern
Fmt2Ext
fmt2ext
;
#endif
#endif
native/jni/magiskboot/magiskboot.h
View file @
e59c5c87
...
@@ -18,14 +18,8 @@ int unpack(const char *image);
...
@@ -18,14 +18,8 @@ int unpack(const char *image);
void
repack
(
const
char
*
orig_image
,
const
char
*
out_image
);
void
repack
(
const
char
*
orig_image
,
const
char
*
out_image
);
void
hexpatch
(
const
char
*
image
,
const
char
*
from
,
const
char
*
to
);
void
hexpatch
(
const
char
*
image
,
const
char
*
from
,
const
char
*
to
);
int
cpio_commands
(
int
argc
,
char
*
argv
[]);
int
cpio_commands
(
int
argc
,
char
*
argv
[]);
void
compress
(
const
char
*
method
,
const
char
*
from
,
const
char
*
to
);
void
decompress
(
char
*
from
,
const
char
*
to
);
int
dtb_commands
(
const
char
*
cmd
,
int
argc
,
char
*
argv
[]);
int
dtb_commands
(
const
char
*
cmd
,
int
argc
,
char
*
argv
[]);
// Compressions
int64_t
compress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
);
int64_t
decompress
(
format_t
type
,
int
fd
,
const
void
*
from
,
size_t
size
);
// Pattern
// Pattern
int
patch_verity
(
void
**
buf
,
uint32_t
*
size
,
int
patch
);
int
patch_verity
(
void
**
buf
,
uint32_t
*
size
,
int
patch
);
void
patch_encryption
(
void
**
buf
,
uint32_t
*
size
);
void
patch_encryption
(
void
**
buf
,
uint32_t
*
size
);
...
...
native/jni/magiskboot/main.cpp
View file @
e59c5c87
...
@@ -10,10 +10,7 @@
...
@@ -10,10 +10,7 @@
#include <flags.h>
#include <flags.h>
#include "magiskboot.h"
#include "magiskboot.h"
#include "compress.h"
/********************
Patch Boot Image
*********************/
static
void
usage
(
char
*
arg0
)
{
static
void
usage
(
char
*
arg0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
...
@@ -137,24 +134,19 @@ int main(int argc, char *argv[]) {
...
@@ -137,24 +134,19 @@ int main(int argc, char *argv[]) {
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--unpack"
)
==
0
)
{
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--unpack"
)
==
0
)
{
return
unpack
(
argv
[
2
]);
return
unpack
(
argv
[
2
]);
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--repack"
)
==
0
)
{
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--repack"
)
==
0
)
{
repack
(
argv
[
2
],
arg
c
>
3
?
argv
[
3
]
:
NEW_BOOT
);
repack
(
argv
[
2
],
arg
v
[
3
]
?
argv
[
3
]
:
NEW_BOOT
);
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--decompress"
)
==
0
)
{
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--decompress"
)
==
0
)
{
decompress
(
argv
[
2
],
arg
c
>
3
?
argv
[
3
]
:
nullptr
);
decompress
(
argv
[
2
],
arg
v
[
3
]
);
}
else
if
(
argc
>
2
&&
strncmp
(
argv
[
1
],
"--compress"
,
10
)
==
0
)
{
}
else
if
(
argc
>
2
&&
strncmp
(
argv
[
1
],
"--compress"
,
10
)
==
0
)
{
const
char
*
method
;
compress
(
argv
[
1
][
10
]
==
'='
?
&
argv
[
1
][
11
]
:
"gzip"
,
argv
[
2
],
argv
[
3
]);
method
=
strchr
(
argv
[
1
],
'='
);
if
(
method
==
nullptr
)
method
=
"gzip"
;
else
method
++
;
compress
(
method
,
argv
[
2
],
argc
>
3
?
argv
[
3
]
:
nullptr
);
}
else
if
(
argc
>
4
&&
strcmp
(
argv
[
1
],
"--hexpatch"
)
==
0
)
{
}
else
if
(
argc
>
4
&&
strcmp
(
argv
[
1
],
"--hexpatch"
)
==
0
)
{
hexpatch
(
argv
[
2
],
argv
[
3
],
argv
[
4
]);
hexpatch
(
argv
[
2
],
argv
[
3
],
argv
[
4
]);
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--cpio"
)
==
0
)
{
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--cpio"
)
==
0
)
{
if
(
cpio_commands
(
argc
-
2
,
argv
+
2
))
usage
(
argv
[
0
]);
if
(
cpio_commands
(
argc
-
2
,
argv
+
2
))
usage
(
argv
[
0
]);
}
else
if
(
argc
>
2
&&
strncmp
(
argv
[
1
],
"--dtb"
,
5
)
==
0
)
{
}
else
if
(
argc
>
2
&&
strncmp
(
argv
[
1
],
"--dtb"
,
5
)
==
0
)
{
char
*
cmd
=
argv
[
1
]
+
5
;
if
(
argv
[
1
][
5
]
!=
'-'
)
if
(
*
cmd
==
'\0'
)
usage
(
argv
[
0
]);
usage
(
argv
[
0
]);
else
++
cmd
;
if
(
dtb_commands
(
&
argv
[
1
][
6
],
argc
-
2
,
argv
+
2
))
if
(
dtb_commands
(
cmd
,
argc
-
2
,
argv
+
2
))
usage
(
argv
[
0
]);
usage
(
argv
[
0
]);
}
else
{
}
else
{
usage
(
argv
[
0
]);
usage
(
argv
[
0
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment