opensnoop: Introduce process name filtering

Signed-off-by: KarimAllah Ahmed <karim.allah.ahmed@gmail.com>
diff --git a/tools/opensnoop.py b/tools/opensnoop.py
index 78c3fea..f2bac4b 100755
--- a/tools/opensnoop.py
+++ b/tools/opensnoop.py
@@ -23,6 +23,7 @@
     ./opensnoop -t        # include timestamps
     ./opensnoop -x        # only show failed opens
     ./opensnoop -p 181    # only trace PID 181
+    ./opensnoop -n main   # only print process names containing "main"
 """
 parser = argparse.ArgumentParser(
     description="Trace open() syscalls",
@@ -34,6 +35,8 @@
     help="only show failed opens")
 parser.add_argument("-p", "--pid",
     help="trace this PID only")
+parser.add_argument("-n", "--name",
+    help="only print process names containing this name")
 args = parser.parse_args()
 debug = 0
 
@@ -155,6 +158,9 @@
     if args.failed and (event.ret >= 0):
         return
 
+    if args.name and args.name not in event.comm:
+        return
+
     if args.timestamp:
         delta = event.ts - initial_ts
         print("%-14.9f" % (float(delta) / 1000000), end="")