This file is indexed.

/usr/lib/fai/mkramdisk is in fai-client 3.4.8ubuntu5.

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
#! /bin/bash

#*********************************************************************
#
# mkramdisk -- mount a ramdisk on top of a directory
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2003-2010 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mount_ramdisk() {

    # save all dirs and files under directory $1
    # mount tmpfs on top of dir $1
    # extract dirs and files into tmpfs

    local n=

    if [ ! -d "$1" ]; then
	echo "WARNING: $1 is not a directory. Cannot make it writeable."
	return
    fi

    echo

    set -e
    local tmp1=$(mktemp) || exit 12
    tar -C $1 -cf $tmp1 .
    mount $2 $3 -t tmpfs tmpfs $1 || exit 13
    echo "Ramdisk mounted onto $1"
    tar -C $1 -xf $tmp1
    rm -f $tmp1
    set +e
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
umount_ramdisk() {

    # put contents of ramdisk back to original location on harddisk

    disk=$1
    ram=${disk}-in-ramdisk

    # test, if a ramdisk is mounted to this directory 
    mount | grep -q " $1 type tmpfs"
    if [ $? -eq 1 ]; then
	echo "$d is not a mounted ramdisk."
	return
    fi

    set -e
    mkdir $ram
    mount --move $disk $ram   # move current ramdisk to a new location
    rm -rf $disk
    cp -a  $ram $disk   # copy ramdisk contents to disk
    umount $ram
    echo "Ramdisk on $d umounted"
    rmdir  $ram
    set +e
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

size= # no default size
umount=0
useall=0

# mkramdisk



while getopts ans:u opt ; do
    case "$opt" in
    # -a: mount all dirs listed in FAI_RAMDISKS instead of dirs given as arguments
        a) useall=1 ;;
        u) umount=1 ;;       # umount instead of mount
        s) size="-o size=$OPTARG" ;; # give size of ramdisk
        n) mtab="-n" ;;      # do not wirte to /etc/mtab
        esac
done
shift $(($OPTIND - 1))

if [ -n "$FAI_NORAMDISK" ]; then
    echo "The use of \$FAI_NORAMDISK is now deprecated. Please use \$FAI_RAMDISKS instead."
    exit 99
fi

# set default dirs if FAI_RAMDISKS not already set
: ${FAI_RAMDISKS:="$target/var/lib/dpkg"}

# use arguments $@ unless -a was specified
[ $useall -eq 0 ] && FAI_RAMDISKS=$@

for d in $FAI_RAMDISKS; do
    if [ $umount -eq 1 ]; then
	umount_ramdisk $d
    else
	[ -d "$d" ] && mount_ramdisk $d $size $mtab
    fi
done