1#!/bin/sh 2# 3# This program is free software; you can redistribute it and/or 4# modify it under the terms of the GNU General Public 5# License as published by the Free Software Foundation; either 6# version 2 of the License, or (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 GNU 11# General Public License for more details. 12# 13# You should have received a copy of the GNU General Public 14# License along with this program; if not, write to the 15# Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16# Boston, MA 021110-1307, USA. 17# 18# Copyright (C) 2008 Andrea Righi <righi.andrea@gmail.com> 19# 20# usage . myfunctions.sh 21 22setup() 23{ 24 # create testcase cgroups 25 if [ -e /dev/blockioctl ]; then 26 echo "WARN: /dev/blockioctl already exist! overwriting." 27 cleanup 28 fi 29 mkdir /dev/blockioctl 30 mount -t cgroup -o blockio cgroup /dev/blockioctl 31 if [ $? -ne 0 ]; then 32 echo "ERROR: could not mount cgroup filesystem " \ 33 " on /dev/blockioctl. Exiting test." 34 cleanup 35 exit 1 36 fi 37 for i in `seq 1 3`; do 38 if [ -e /dev/blockioctl/cgroup-$i ]; then 39 rmdir /dev/blockioctl/cgroup-$i 40 echo "WARN: earlier cgroup-$i found and removed" 41 fi 42 mkdir /dev/blockioctl/cgroup-$i 43 if [ $? -ne 0 ]; then 44 echo "ERROR: could not create cgroup-$i" \ 45 "Check your permissions. Exiting test." 46 cleanup 47 exit 1 48 fi 49 done 50} 51 52cleanup() 53{ 54 echo "Cleanup called" 55 for i in `seq 1 3`; do 56 rmdir /dev/blockioctl/cgroup-$i 57 rm -f /tmp/cgroup-$i.out 58 done 59 umount /dev/blockioctl 60 rmdir /dev/blockioctl 61} 62