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