[CRIU] [PATCH 08/16] parasite: Make sure no dots in
names generated
Kir Kolyshkin
kir at openvz.org
Tue Feb 14 07:29:56 EST 2012
On 02/14/2012 03:46 PM, Andrew Vagin wrote:
> On Mon, Feb 13, 2012 at 11:26:31PM +0400, Cyrill Gorcunov wrote:
>> Some names may be "dot" mangled.
>>
>> Signed-off-by: Cyrill Gorcunov<gorcunov at openvz.org>
>> ---
>> gen-offsets.sh | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/gen-offsets.sh b/gen-offsets.sh
>> index 0948aed..70158fb 100644
>> --- a/gen-offsets.sh
>> +++ b/gen-offsets.sh
>> @@ -12,7 +12,7 @@ echo "/* Autogenerated file, don't edit */"
>> echo "#ifndef $name_ifndef"
>> echo "#define $name_ifndef"
>> echo ""
>> -nm $name_objname | grep ' [Tt] ' | awk "$awk_cmd"
>> +nm $name_objname | grep ' [Tt] ' | sed -e 's/\./_/g' | awk "$awk_cmd"
> Using grep, sed and awk together is a bad style. awk is enough for all
> these things.
(1) I rewrote this some time ago w/o grep but didn't send the patch,
thought it was not important.
Here is the change to awk command
-awk_cmd="{ print \"#define $name_prefix_offset\" \$3 \" 0x\" \$1; }"
+awk_cmd='$2 ~ "^[tT]$" { print "#define '$name_prefix_offset'" $3 " 0x"
$1; }'
Note
1. I used single quotes to eliminate the need to escape $ and "
2. This check is better because we specifically require second column to
be 't',
not just any ' t ' in the text.
(2) If you want to change dots with underscores, you can use "sed 'y/./_/'"
(differences from s is it's single char and not regex) or just "tr . _".
With awk it will be gsub which doesn't look as elegant.
So, I propose this:
diff --git a/gen-offsets.sh b/gen-offsets.sh
index 0948aed..3541084 100644
--- a/gen-offsets.sh
+++ b/gen-offsets.sh
@@ -6,13 +6,13 @@ name_blob=$3
name_objname=$4
name_bin=$5
-awk_cmd="{ print \"#define $name_prefix_offset\" \$3 \" 0x\" \$1; }"
+awk_cmd='$2 ~ "^[tT]$" { print "#define '$name_prefix_offset'" $3 " 0x"
$1; }'
echo "/* Autogenerated file, don't edit */"
echo "#ifndef $name_ifndef"
echo "#define $name_ifndef"
echo ""
-nm $name_objname | grep ' [Tt] ' | awk "$awk_cmd"
+nm $name_objname | awk "$awk_cmd" | tr . _
echo ""
echo "static char $name_blob[] = {"
hexdump -v -e '"\t"' -e '8/1 "0x%02x, "' -e '"\n"' $name_bin
More information about the CRIU
mailing list