This file is indexed.

/usr/bin/hwloc-gather-topology is in hwloc 1.3.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/sh
#-*-sh-*-

#
# Copyright © 2009 CNRS
# Copyright © 2009-2010 INRIA.  All rights reserved.
# Copyright © 2009-2011 Université Bordeaux 1
# See COPYING in top-level directory.
#

prefix="/usr"
exec_prefix="${prefix}"
bindir="${exec_prefix}/bin"
# this will be changed into $bindir/lstopo during make install
lstopo="$bindir/lstopo"

# make sure we use default numeric formats
LANG=C
LC_ALL=C
export LANG LC_ALL

error()
{
    echo $@ 2>&1
}

usage()
{
   echo "$0 <savepath>"
   echo "  Saves the Linux topology files (/sys, /proc, ...) under <savepath>.tar.bz2"
   echo "  and the corresponding lstopo verbose output under <savepath>.output"
   echo "Example:"
   echo "  $0 /tmp/\$(uname -n)"
}

name="$1"; shift
if [ -z "$name" -o x`echo $name | cut -c1` = x- ] ; then
  [ x$name != x -a x$name != x-h -a x$name != x--help ] && echo "Unrecognized option: $name"
  usage
  exit 1
fi
basename=`basename "$name"`
dirname=`dirname "$name"`

if ! mkdir -p "$dirname" ; then
    error "Failed to create directory $dirname."
    exit 1
fi

if [ ! -w  "$dirname" ] ; then
    echo "$dirname is not writable."
    exit 1
fi

destdir=`mktemp -d`

# Use cat so that we properly get proc/sys files even if their
# file length is wrong
savefile() {
  local dest="$1"
  local file="$2"
  dir=`dirname "$file"`
  mkdir -p "$dest/$dir" 2>/dev/null
  cat "$file" > "$dest/$file" 2>/dev/null
}

# Gather the following list of files
cat << EOF | while read -r path ; do savefile "$destdir/$basename" "$path" ; done
/proc/cpuinfo
/proc/meminfo
/proc/mounts
/proc/stat
/proc/self/cpuset
EOF

# Get all files from the given directory
# Ignore errors since some files may be missing, and some may be
# restricted to root (but we don't need them).
savedir() {
  local dest="$1"
  local path="$2"
  # gather all directories, including empty ones
  find "$path" -type d 2>/dev/null | while read -r dir ; do
    mkdir -p "$dest/$dir" 2>/dev/null
  done
  # gather all files now
  find "$path" -type f 2>/dev/null | while read -r file ; do
    savefile "$dest" "$file"
  done
}

# Gather the following list of directories
cat << EOF | while read -r path ; do savedir "$destdir/$basename" "$path" ; done
/sys/devices/system/cpu/
/sys/devices/system/node/
/sys/class/dmi/id/
/sys/kernel/mm/hugepages/
/proc/device-tree/cpus/
EOF

# Get an entire mount point, after decoding its path
# we don't support path with \n since it would break in 'find ... | while read ..." above
savemntpnt() {
  local encodedpath=$1
  if echo "$1" | grep "\\012" ; then
    echo "Ignoring mount point whose filename contains an end of line."
    return
  fi
  local path=$(echo "$1" | sed -e 's@\\134@\\@g' -e 's@\\040@ @g' -e 's@\\011@	@g')
  savedir "$destdir/$basename" "${path}/"
}

# Gather cgroup/cpuset mntpnts
cat /proc/mounts | while read -r dummy1 mntpath mnttype mntopts dummy2 ; do
  [ x$mnttype = xcpuset ] && savemntpnt "$mntpath"
  [ x$mnttype = xcgroup ] && echo $mntopts | grep -w cpuset >/dev/null && savemntpnt "$mntpath"
done

# Create the archive and keep the tree in /tmp for testing
( cd "$destdir/" && tar cfj "$basename.tar.bz2" "$basename" )
mv "$destdir/$basename.tar.bz2" "$dirname/$basename.tar.bz2"
echo "Hierarchy gathered in $dirname/$basename.tar.bz2 and kept in $destdir/$basename/"

# Generate the output as well
if [ ! -x "$lstopo" ]
then
    error "Could not find lstopo executable in the install or build dir."
    exit 1
fi
# we need "Topology not from this system" in the output so as to make test-topology.sh happy
export HWLOC_THISSYSTEM=0
"$lstopo" - -v > "$dirname/$basename.output"
echo "Expected topology output stored in $dirname/$basename.output"

exit 0