Fix ltt-armall/disarmall /debugfs auto-find
[ltt-control.git] / lttctl / ltt-disarmall.sh
CommitLineData
045880fb 1# Copyright (C) 2009 Benjamin Poirier
36cf2b17 2# Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
045880fb
BP
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
36cf2b17 18DEBUGFSROOT=$(awk '{if ($3 == "debugfs") print $2}' /proc/mounts | head -n 1)
80bb2806 19MARKERSROOT=${DEBUGFSROOT}/ltt/markers
024405bd 20
045880fb
BP
21usage () {
22 echo "Usage: $0 [OPTION]..." > /dev/stderr
23 echo "Disconnect lttng markers" > /dev/stderr
24 echo "" > /dev/stderr
25 echo "Options:" > /dev/stderr
26 printf "\t-q Quiet mode, suppress output\n" > /dev/stderr
27 printf "\t-h Print this help\n" > /dev/stderr
28 echo "" > /dev/stderr
29}
30
fde9c319 31if [ ! "${DEBUGFSROOT}" ]; then
045880fb
BP
32 echo "Error: debugfs not mounted" > /dev/stderr
33 exit 1;
34fi
35
fde9c319 36if [ ! -d "${MARKERSROOT}" ]; then
045880fb
BP
37 echo "Error: LTT trace controller not found (did you compile and load LTTng?)" > /dev/stderr
38 exit 1;
39fi
40
41while getopts "qh" options; do
fde9c319 42 case ${options} in
045880fb
BP
43 q) QUIET="0";;
44 h) usage;
45 exit 0;;
46 \?) usage;
47 exit 1;;
80bb2806 48 esac
024405bd 49done
fde9c319 50shift $((${OPTIND} - 1))
045880fb 51
6e8902bf 52(eval "find '${MARKERSROOT}' -name metadata -prune -o -name enable -print") | while read -r marker; do
fde9c319 53 grep "^1$" "${marker}" -q
045880fb
BP
54 if [ $? -ne 0 ]; then
55 continue
56 fi
fde9c319 57 if [ ! ${QUIET} ]; then
045880fb
BP
58 echo "Disconnecting ${marker%/enable}"
59 fi
fde9c319 60 echo 0 > ${marker}
d7a3410b 61done
This page took 0.024244 seconds and 4 git commands to generate.