#!/bin/sh # Test for xattr support in a directory # or the root directory of all (rw) mounted filesystems # Author: Julien Goodwin 19/2/2006 # Updated: Julien Goodwin 19/2/2006 set -e set +x # Functions ## The test function function testdir() { CHECKDIR=$1 TESTFILE=xattrtest$$ echo Checking the xattr support in ${CHECKDIR} cd ${CHECKDIR} touch ${TESTFILE} ${SETFATTR} -n user.text -v "test1" ${TESTFILE} ${SETFATTR} -n security.text -v "test2" ${TESTFILE} if `${GETFATTR} -d ${TESTFILE} | grep "user.text" | grep -q "test1"`; then echo "User test succeeded" else echo "User test failed" fi if `${GETFATTR} -n security.text -d ${TESTFILE} | grep "security.text" | grep -q "test2"`; then echo "Security test succeeded" else echo "Security test failed" fi rm ${TESTFILE} exit 0 } # Check commands SETFATTR=`which setfattr` GETFATTR=`which getfattr` if [ "x${SETFATTR}" = "x" ]; then echo setfattr not found in path, do you need to install the attr package? exit 1 fi if [ "x${GETFATTR}" = "x" ]; then echo getfattr not found in path, do you need to install the attr package? exit 1 fi # Check how we were called if [ $# -eq 0 ]; then echo Checking all mounted filesystems for TESTDIR in `mount | grep rw | grep -vE '(proc|sysfs|tmpfs|devfs|devpts)' | awk '{ print $3 }'`; do testdir ${TESTDIR} done exit 0 elif [ $# -eq 1 ]; then echo Checking $1 testdir $1 exit $? else echo USAGE: echo $0: echo Check all mounted filesystems echo echo "$0 :" echo Check for xattr support in "" exit 1 fi