Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fdtextract
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
system
fdtextract
Commits
e92fb432
Commit
e92fb432
authored
4 years ago
by
Jonas Höglund
Browse files
Options
Downloads
Patches
Plain Diff
Enable output of extrated file to stdout.
parent
152a2d96
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fdtextract.c
+11
-11
11 additions, 11 deletions
fdtextract.c
with
11 additions
and
11 deletions
fdtextract.c
+
11
−
11
View file @
e92fb432
...
@@ -96,11 +96,6 @@ static int extract_image(char *buf, char *name, char *out)
...
@@ -96,11 +96,6 @@ static int extract_image(char *buf, char *name, char *out)
unsigned
int
data_size
,
data_offset
;
unsigned
int
data_size
,
data_offset
;
const
fdt32_t
*
val
;
const
fdt32_t
*
val
;
if
(
!
out
)
{
printf
(
"Error: please specify output file name.
\n
"
);
return
-
1
;
}
snprintf
(
path
,
MAX_PATH_LEN
,
"/images/%s"
,
name
);
snprintf
(
path
,
MAX_PATH_LEN
,
"/images/%s"
,
name
);
noffset
=
fdt_path_offset
(
buf
,
path
);
noffset
=
fdt_path_offset
(
buf
,
path
);
if
(
noffset
<
0
)
{
if
(
noffset
<
0
)
{
...
@@ -108,8 +103,6 @@ static int extract_image(char *buf, char *name, char *out)
...
@@ -108,8 +103,6 @@ static int extract_image(char *buf, char *name, char *out)
return
-
1
;
return
-
1
;
}
}
printf
(
"Extracting %s to %s.
\n
"
,
name
,
out
);
/* Get offset of image. Try both relative and absolute offset. */
/* Get offset of image. Try both relative and absolute offset. */
val
=
fdt_getprop
(
buf
,
noffset
,
"data-offset"
,
NULL
);
val
=
fdt_getprop
(
buf
,
noffset
,
"data-offset"
,
NULL
);
if
(
val
)
{
if
(
val
)
{
...
@@ -135,11 +128,18 @@ static int extract_image(char *buf, char *name, char *out)
...
@@ -135,11 +128,18 @@ static int extract_image(char *buf, char *name, char *out)
data_size
=
fdt32_to_cpu
(
*
val
);
data_size
=
fdt32_to_cpu
(
*
val
);
fd
=
open
(
out
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0666
);
/* If output file is provided, write to that file. If not, write
if
(
fd
<
0
)
{
to stdout. */
printf
(
"Error opening output file %s.
\n
"
,
out
);
if
(
out
)
{
return
errno
;
fd
=
open
(
out
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0666
);
if
(
fd
<
0
)
{
printf
(
"Error opening output file %s.
\n
"
,
out
);
return
errno
;
}
}
else
{
fd
=
STDOUT_FILENO
;
}
}
count
=
write
(
fd
,
buf
+
data_offset
,
data_size
);
count
=
write
(
fd
,
buf
+
data_offset
,
data_size
);
if
(
count
<
data_size
)
{
if
(
count
<
data_size
)
{
printf
(
"Error writing output file %s.
\n
"
,
out
);
printf
(
"Error writing output file %s.
\n
"
,
out
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment