Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
HardenedBSD
HardenedBSD
Commits
f2b600b2
Commit
f2b600b2
authored
May 22, 2018
by
Ed Maste
Browse files
intel-ucode-split: add -n flag to skip creating output files
Sponsored by: The FreeBSD Foundation
parent
3a327967
Changes
1
Show whitespace changes
Inline
Side-by-side
tools/tools/intel-ucode-split/intel-ucode-split.c
View file @
f2b600b2
...
...
@@ -112,7 +112,7 @@ static void
usage
(
void
)
{
printf
(
"ucode-split [-v] microcode_file
\n
"
);
printf
(
"ucode-split [-
n
v] microcode_file
\n
"
);
exit
(
1
);
}
...
...
@@ -124,11 +124,14 @@ main(int argc, char *argv[])
size_t
len
,
resid
;
ssize_t
rv
;
int
c
,
ifd
,
ofd
;
bool
vflag
;
bool
nflag
,
vflag
;
vflag
=
false
;
while
((
c
=
getopt
(
argc
,
argv
,
"v"
))
!=
-
1
)
{
nflag
=
vflag
=
false
;
while
((
c
=
getopt
(
argc
,
argv
,
"
n
v"
))
!=
-
1
)
{
switch
(
c
)
{
case
'n'
:
nflag
=
true
;
break
;
case
'v'
:
vflag
=
true
;
break
;
...
...
@@ -166,13 +169,24 @@ main(int argc, char *argv[])
if
(
vflag
)
dump_header
(
&
hdr
);
resid
=
(
hdr
.
total_size
!=
0
?
hdr
.
total_size
:
2048
)
-
sizeof
(
hdr
);
if
(
resid
>
1
<<
24
)
/* Arbitrary chosen maximum size. */
errx
(
1
,
"header total_size too large"
);
if
(
nflag
)
{
if
(
lseek
(
ifd
,
resid
,
SEEK_CUR
)
==
-
1
)
err
(
1
,
"lseek"
);
printf
(
"
\n
"
);
}
else
{
sig_str
=
format_signature
(
hdr
.
processor_signature
);
asprintf
(
&
output_file
,
"%s.%02x"
,
sig_str
,
hdr
.
processor_flags
&
0xff
);
free
(
sig_str
);
if
(
output_file
==
NULL
)
err
(
1
,
"asprintf"
);
ofd
=
open
(
output_file
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0600
);
ofd
=
open
(
output_file
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0600
);
if
(
ofd
<
0
)
err
(
1
,
"open"
);
...
...
@@ -182,10 +196,6 @@ main(int argc, char *argv[])
err
(
1
,
"write"
);
/* Copy data. */
resid
=
(
hdr
.
total_size
!=
0
?
hdr
.
total_size
:
2048
)
-
sizeof
(
hdr
);
if
(
resid
>
1
<<
24
)
/* Arbitrary chosen maximum size. */
errx
(
1
,
"header total_size too large"
);
while
(
resid
>
0
)
{
len
=
resid
<
bufsize
?
resid
:
bufsize
;
rv
=
read
(
ifd
,
buf
,
len
);
...
...
@@ -202,4 +212,5 @@ main(int argc, char *argv[])
close
(
ofd
);
free
(
output_file
);
}
}
}
Write
Preview
Supports
Markdown
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