Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
nvidia-patch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
nvidia-patch
Commits
f778b374
Commit
f778b374
authored
Jun 28, 2023
by
Jai Luthra
Committed by
GitHub
Jun 28, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #671 from guihkx/ensure-bytes-are-valid
linux: ensure bytes are valid before patching
parents
100af892
84e433fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
patch-fbc.sh
patch-fbc.sh
+15
-0
patch.sh
patch.sh
+15
-0
No files found.
patch-fbc.sh
View file @
f778b374
...
...
@@ -381,6 +381,20 @@ patch_common () {
}
ensure_bytes_are_valid
()
{
driver_file
=
"
$driver_dir
/
$object
.
$driver_version
"
original_bytes
=
$(
awk
-F
/
'$2 { print $2 }'
<<<
"
$patch
"
)
patched_bytes
=
$(
awk
-F
/
'$3 { print $3 }'
<<<
"
$patch
"
)
if
LC_ALL
=
C
grep
-qaP
"
$original_bytes
"
"
$driver_file
"
;
then
return
0
# file is ready to be patched
fi
if
LC_ALL
=
C
grep
-qaP
"
$patched_bytes
"
"
$driver_file
"
;
then
return
0
# file is likely patched already
fi
echo
"Error: Could not find bytes '
$original_bytes
' to patch in '
$driver_file
'."
exit
1
}
rollback
()
{
patch_common
if
[[
-f
"
$backup_path
/
$object
.
$driver_version$backup_suffix
"
]]
;
then
...
...
@@ -395,6 +409,7 @@ rollback () {
patch
()
{
patch_common
ensure_bytes_are_valid
if
[[
-f
"
$backup_path
/
$object
.
$driver_version$backup_suffix
"
]]
;
then
bkp_hash
=
"
$(
sha1sum
"
$backup_path
/
$object
.
$driver_version$backup_suffix
"
|
cut
-f1
-d
\
)
"
drv_hash
=
"
$(
sha1sum
"
$driver_dir
/
$object
.
$driver_version
"
|
cut
-f1
-d
\
)
"
...
...
patch.sh
View file @
f778b374
...
...
@@ -457,6 +457,20 @@ patch_common () {
}
ensure_bytes_are_valid
()
{
driver_file
=
"
$driver_dir
/
$object
.
$driver_version
"
original_bytes
=
$(
awk
-F
/
'$2 { print $2 }'
<<<
"
$patch
"
)
patched_bytes
=
$(
awk
-F
/
'$3 { print $3 }'
<<<
"
$patch
"
)
if
LC_ALL
=
C
grep
-qaP
"
$original_bytes
"
"
$driver_file
"
;
then
return
0
# file is ready to be patched
fi
if
LC_ALL
=
C
grep
-qaP
"
$patched_bytes
"
"
$driver_file
"
;
then
return
0
# file is likely patched already
fi
echo
"Error: Could not find bytes '
$original_bytes
' to patch in '
$driver_file
'."
exit
1
}
rollback
()
{
patch_common
if
[[
-f
"
$backup_path
/
$object
.
$driver_version$backup_suffix
"
]]
;
then
...
...
@@ -471,6 +485,7 @@ rollback () {
patch
()
{
patch_common
ensure_bytes_are_valid
if
[[
-f
"
$backup_path
/
$object
.
$driver_version$backup_suffix
"
]]
;
then
bkp_hash
=
"
$(
sha1sum
"
$backup_path
/
$object
.
$driver_version$backup_suffix
"
|
cut
-f1
-d
\
)
"
drv_hash
=
"
$(
sha1sum
"
$driver_dir
/
$object
.
$driver_version
"
|
cut
-f1
-d
\
)
"
...
...
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