| 1 |
#!/usr/bin/stap |
| 2 |
/* |
| 3 |
* opensnoop-nd.stp Trace file open()s. Basic version of opensnoop. |
| 4 |
* For Linux, uses SystemTap (non-debuginfo). |
| 5 |
* |
| 6 |
* Copyright (C) 2015 Brendan Gregg. |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation; either version 2 of the License, or |
| 11 |
* (at your option) any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* 21-Mar-2014 Brendan Gregg Created this. |
| 19 |
*/ |
| 20 |
|
| 21 |
probe begin |
| 22 |
{ |
| 23 |
printf("%6s %6s %16s %4s %s\n", "UID", "PID", "COMM", "FD", "PATH"); |
| 24 |
} |
| 25 |
|
| 26 |
probe nd_syscall.open.return |
| 27 |
{ |
| 28 |
/* trace on return to ensure the pathname has faulted in */ |
| 29 |
printf("%6d %6d %16s %4d %s\n", uid(), pid(), execname(), |
| 30 |
retval, user_string(@entry(pointer_arg(1)), "-")); |
| 31 |
} |