| 1 |
#! /usr/bin/env stap |
| 2 |
|
| 3 |
// Copyright (c) 2009, 2015 Red Hat Inc. |
| 4 |
// |
| 5 |
// This file is part of systemtap, and is free software. You can |
| 6 |
// redistribute it and/or modify it under the terms of the GNU General |
| 7 |
// Public License (GPL); either version 2, or (at your option) any |
| 8 |
// later version. |
| 9 |
|
| 10 |
|
| 11 |
probe kernel.function("autofs4_lookup") !, |
| 12 |
module("autofs4").function("autofs4_lookup") |
| 13 |
{ |
| 14 |
/* |
| 15 |
* Don't log automounts travels in its own directory hierarchy, as |
| 16 |
* they are treated differently, and certainly not something that is |
| 17 |
* useful for admins to see. |
| 18 |
*/ |
| 19 |
if (!isinstr(execname(), "automount")) { |
| 20 |
printf("%s process %s[%d] looking up %s%s\n", |
| 21 |
ctime(gettimeofday_s()), execname(), pid(), |
| 22 |
(@defined($nd) ? fullpath_struct_nameidata($nd) |
| 23 |
: inode_name($dir)), |
| 24 |
d_name($dentry)); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
probe kernel.function("autofs4_follow_link") !, |
| 30 |
module("autofs4").function("autofs4_follow_link") |
| 31 |
{ |
| 32 |
if (!isinstr(execname(), "automount")) { |
| 33 |
/* |
| 34 |
* dentry->d_name will be '/' for the mount trigger. Thus, |
| 35 |
* the path that the trigger lives on is one level up the |
| 36 |
* directory stack, and the root of that is yet another level |
| 37 |
* up. |
| 38 |
*/ |
| 39 |
printf("%s process %s[%d] following mount trigger %s\n", |
| 40 |
ctime(gettimeofday_s()), execname(), pid(), |
| 41 |
(@defined($nd) ? d_path($nd) |
| 42 |
: reverse_path_walk($dentry))) |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
probe kernel.function("autofs4_expire_direct").return !, |
| 48 |
module("autofs4").function("autofs4_expire_direct").return ? |
| 49 |
{ |
| 50 |
if ($return != 0) { |
| 51 |
if (@defined($mnt->mnt_mountpoint)) { |
| 52 |
relative_path = reverse_path_walk(@entry($mnt->mnt_mountpoint)) |
| 53 |
root_path = sprintf("/%s", reverse_path_walk(@entry($mnt->mnt_parent->mnt_mountpoint))) |
| 54 |
} |
| 55 |
else { |
| 56 |
relative_path = "" |
| 57 |
root_path = task_dentry_path(task_current(), @entry($mnt->mnt_root), @entry($mnt)) |
| 58 |
} |
| 59 |
printf("%s process %s[%d] expiring direct mount %s/%s\n", |
| 60 |
ctime(gettimeofday_s()), execname(), pid(), |
| 61 |
root_path, relative_path) |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
/* |
| 66 |
probe |
| 67 |
module("autofs4").statement("autofs4_expire_direct@fs/autofs4/expire.c+17").nearest ? |
| 68 |
{ |
| 69 |
relative_path = reverse_path_walk($mnt->mnt_mountpoint) |
| 70 |
root_path = reverse_path_walk($mnt->mnt_parent->mnt_mountpoint) |
| 71 |
printf("%s process %s[%d] expiring direct mount /%s/%s\n", |
| 72 |
ctime(gettimeofday_s()), execname(), pid(), |
| 73 |
root_path, relative_path) |
| 74 |
} |
| 75 |
*/ |
| 76 |
|
| 77 |
probe kernel.function("autofs4_expire_indirect").return !, |
| 78 |
module("autofs4").function("autofs4_expire_indirect").return |
| 79 |
{ |
| 80 |
if ($return != 0) { |
| 81 |
relative_path = reverse_path_walk($return) |
| 82 |
|
| 83 |
root_path = (@defined($mnt->mnt_root) |
| 84 |
? task_dentry_path(task_current(), |
| 85 |
@entry($mnt->mnt_root), @entry($mnt)) |
| 86 |
: reverse_path_walk(@entry($mnt->mnt_mountpoint))) |
| 87 |
printf("%s process %s[%d] expiring indirect mount %s/%s\n", |
| 88 |
ctime(gettimeofday_s()), execname(), pid(), |
| 89 |
root_path, relative_path) |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
/* |
| 95 |
* The struct dentry's name may be '/' if this is a mount trigger, which |
| 96 |
* is not really something that is useful to print out. Instead, we just |
| 97 |
* indicate whether a mount or umount succeeded or failed. Coupled with the |
| 98 |
* messages printed out when looking up a directory and traversing a symlink, |
| 99 |
* this should be relatively easy to correlate to the appropriate directory. |
| 100 |
*/ |
| 101 |
probe kernel.function("autofs4_wait").return !, |
| 102 |
module("autofs4").function("autofs4_wait").return |
| 103 |
{ |
| 104 |
if (@entry($notify) > 0) { |
| 105 |
dname = d_name(@entry($dentry)) |
| 106 |
printf("%s %s of %s %s\n", |
| 107 |
ctime(gettimeofday_s()), |
| 108 |
(@entry($notify)==1?"mount":"unmount"), |
| 109 |
dname, |
| 110 |
$return == 0?"succeeded":"failed") |
| 111 |
} |
| 112 |
} |