#!/bin/sh # # (c)2010 - lists@nerdbynature.de # Test filesystems if ACLs, EAs, attributes are working # FILESYSTEMS="btrfs:: ext2:q:acl,user_xattr ext3:q:acl,user_xattr ext4:q:acl,user_xattr jfs:fq reiserfs:fq:acl,user_xattr reiser4:fy xfs:fq" # unset me! # DEBUG=echo if [ ! -b "$1" -o ! -d "$2" ]; then echo "Usage: `basename $0` [dev] [dir]" exit 1 else DEV="$1" DIR="$2" fi for fs in $FILESYSTEMS; do FS="`echo $fs | awk -F: '{print $1}'`" MKFS_O="`echo $fs | awk -F: '{ if($2=="") {printf ""} else {print "-"$2}}'`" MOUNT_O="`echo $fs | awk -F: '{ if($3=="") {printf ""} else {print "-o" $3}}'`" $DEBUG mkfs."$FS" $MKFS_O "$DEV" > /dev/null 2>&1 $DEBUG mount -t "$FS" $MOUNT_O "$DEV" "$DIR" echo "*** `fgrep $DEV /proc/mounts`" $DEBUG touch "$DIR"/file.txt echo "$FS: testing ACLs..." $DEBUG chacl u::rw-,g::r--,o::r--,u:nobody:--x,m::r-x "$DIR"/file.txt || echo "$FS: chacl (set) failed!" $DEBUG chacl -l "$DIR"/file.txt > /dev/null || echo "$FS: chacl (get) failed!" $DEBUG setfacl -m u::rw-,g::---,o::---,u:nobody:r--,m::r-x "$DIR"/file.txt || echo "$FS: setfacl failed!" $DEBUGgetfacl "$DIR"/file.txt > /dev/null || echo "$FS: getfacl failed!" echo "$FS: testing EAs..." $DEBUG attr -q -s foo -V 42 "$DIR"/file.txt || echo "$FS: attr (set) failed!" $DEBUG attr -g foo "$DIR"/file.txt > /dev/null || echo "$FS: attr (get) failed!" # https://bugs.launchpad.net/ubuntu/+bug/43954/comments/4 $DEBUG setfattr -n user.bar -v 23 "$DIR"/file.txt || echo "$FS: setfattr failed!" $DEBUG getfattr -n user.bar --absolute-names "$DIR"/file.txt > /dev/null || echo "$FS: getfattr failed!" echo "$FS: testing ext2 attributes..." $DEBUG chattr +i "$DIR"/file.txt || echo "$FS: chattr failed!" $DEBUG lsattr "$DIR"/file.txt > /dev/null || echo "$FS: lsattr failed!" $DEBUG umount "$DIR" echo done