minor changes to xfstests as we transition to new EA/ACL interfaces.
return $exit
}
+_getfattr()
+{
+ getfattr $* 2>$tmp.err >$tmp.out
+ exit=$?
+ _filter $tmp.out
+ _filter $tmp.err 1>&2
+ return $exit
+}
+
_attr_list()
{
file=$1
echo " *** print attributes"
- if ! _attr -l $file >$tmp.raw
+ if ! _getfattr -ad $file >$tmp.raw
then
echo " !!! error return"
return 1
fi
-
- $AWK_PROG -v file=$file '
- {
- print substr($2,2,length($2)-2)
- count++
- }
- END {
- exit count
- }
- ' <$tmp.raw >$tmp.list
-
- echo " *** $? attribute(s)"
- for l in `cat $tmp.list`
- do
- if ! _attr -g $l $file >$tmp.raw
- then
- echo " *** $l"
- echo " !!! error return"
- return 1
- fi
- $AWK_PROG '
- NR==1 {
- print " *** field: " substr($2,2,length($2)-2) \
- " length: " $5
- next
- }
- {
- print " ::: " $0
- }
- ' <$tmp.raw
-
- done
}
+[ -x /usr/bin/attr ] || _notrun "attr is not installed"
+[ -x /usr/bin/getfattr ] || _notrun "getfattr is not installed"
# real QA test starts here
echo "*** check"
# don't print it all out...
-attr -l $testfile \
- | $AWK_PROG '{ l++ } END {print " *** " l " attribute(s)" }'
+getfattr $testfile \
+ | $AWK_PROG '{ l++ } END {print " *** " (l - 1) " attribute(s)" }'
echo "*** remove lots of attributes"
v=0
do
if ! attr -r "attribute_$v" $testfile >/dev/null
then
- echo "!!! failed to add \"attribute_$v\""
+ echo "!!! failed to remove \"attribute_$v\""
exit 1
fi
return $exit
}
+_getfattr()
+{
+ getfattr $* 2>$tmp.err >$tmp.out
+ exit=$?
+ sed "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g; s#$tmp[^ :]*#<TMPFILE>#g;" $tmp.out
+ sed "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g; s#$tmp[^ :]*#<TMPFILE>#g;" $tmp.err 1>&2
+ return $exit
+}
+
# real QA test starts here
_require_scratch
touch $testfile.1
echo "v1" | _attr -s "a1" $testfile.1 >/dev/null
echo "v2--" | _attr -s "a2--" $testfile.1 >/dev/null
-_attr -l $testfile.1
+_getfattr -a $testfile.1
inum_1=`ls -li $testfile.1 | $AWK_PROG '{ print $1 }'`
echo "*** make test file 2"
(echo start ; dd if=/dev/zero bs=65525 count=1 ; echo end ) \
| _attr -s "a3" $testfile.2 >/dev/null
-_attr -l $testfile.2
+_getfattr -a $testfile.2
inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'`
echo "*** unmount FS"
_need_to_be_root
_acl_setup_ids
-[ -x /bin/chacl ] || _notrun "chacl command not found"
+[ ! -x /bin/chacl -a ! -x /usr/bin/chacl ] && _notrun "chacl command not found"
[ -x $runas ] || _notrun "$runas executable not found"
# get dir
. ./common.filter
. ./common.attr
+[ ! -x /bin/chacl -a ! -x /usr/bin/chacl ] && _notrun "chacl command not found"
+
# real QA test starts here
_require_scratch
_acl_setup_ids
_need_to_be_root
[ -x $acl_get ] || _notrun "$acl_get command not found"
-[ -x /bin/chacl ] || _notrun "chacl command not found"
+[ ! -x /bin/chacl -a ! -x /usr/bin/chacl ] && _notrun "chacl command not found"
# get dir
cd $TEST_DIR
}
trap "_cleanup; exit \$status" 0 1 2 3 15
+_filter_scratch()
+{
+ sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
+}
+
+getfattr()
+{
+ /usr/bin/getfattr -adl $@ 2>&1 | _filter_scratch
+}
+
+setfattr()
+{
+ /usr/bin/setfattr $@
+}
+
_create_test_bed()
{
echo "*** create test bed"
mknod $SCRATCH_MNT/dev/c c 0 0
mknod $SCRATCH_MNT/dev/p p
# sanity check
- find $SCRATCH_MNT | LC_COLLATE=POSIX sort
-}
-
-getfattr()
-{
- /usr/bin/getfattr $@ | sed -e \
- "s/$SCRATCH_MNT/SCRATCH_MNT/g"
-}
-
-setfattr()
-{
- /usr/bin/setfattr $@ | sed -e \
- "s/$SCRATCH_MNT/SCRATCH_MNT/g"
+ find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch
}
_require_scratch
-[ -x /usr/bin/getfattr ] || _notrun "getfattr is not installed"
-[ -x /usr/bin/setfattr ] || _notrun "setfattr is not installed"
rm -f $tmp.backup1 $tmp.backup2 $seq.full
# real QA test starts here
echo "*** set/get one initially empty attribute"
setfattr -l -n $nsp.name $SCRATCH_MNT/$inode
- getfattr -al -d $SCRATCH_MNT/$inode
+ getfattr -r $nsp $SCRATCH_MNT/$inode
echo "*** overwrite empty, set several new attributes"
setfattr -l -n $nsp.name -v 0xbabe $SCRATCH_MNT/$inode
setfattr -l -n $nsp.name3 -v 0xdeface $SCRATCH_MNT/$inode
echo "*** fetch several attribute names and values (hex)"
- getfattr -al -d -e hex $SCRATCH_MNT/$inode
+ getfattr -r $nsp -e hex $SCRATCH_MNT/$inode
echo "*** fetch several attribute names and values (base64)"
- getfattr -al -d -e base64 $SCRATCH_MNT/$inode
+ getfattr -r $nsp -e base64 $SCRATCH_MNT/$inode
echo "*** shrink value of an existing attribute"
setfattr -l -n $nsp.name2 -v 0xdeaf $SCRATCH_MNT/$inode
- getfattr -al -d -e hex $SCRATCH_MNT/$inode
+ getfattr -r $nsp -e hex $SCRATCH_MNT/$inode
echo "*** grow value of existing attribute"
setfattr -l -n $nsp.name2 -v 0xdecade $SCRATCH_MNT/$inode
- getfattr -al -d -e hex $SCRATCH_MNT/$inode
+ getfattr -r $nsp -e hex $SCRATCH_MNT/$inode
echo "*** set an empty value for second attribute"
setfattr -l -n $nsp.name2 $SCRATCH_MNT/$inode
- getfattr -al -d -n $nsp.name2 $SCRATCH_MNT/$inode
+ getfattr -r $nsp -n $nsp.name2 $SCRATCH_MNT/$inode
echo "*** overwrite empty value"
setfattr -l -n $nsp.name2 -v 0xcafe $SCRATCH_MNT/$inode
- getfattr -al -d -e hex -n $nsp.name2 $SCRATCH_MNT/$inode
+ getfattr -r $nsp -e hex -n $nsp.name2 $SCRATCH_MNT/$inode
echo "*** remove attribute"
setfattr -l -x $nsp.name2 $SCRATCH_MNT/$inode
- getfattr -al -d -n $nsp.name2 $SCRATCH_MNT/$inode
+ getfattr -r $nsp -n $nsp.name2 $SCRATCH_MNT/$inode
echo "*** final list (strings, type=$inode, nsp=$nsp)"
- getfattr -als -d $SCRATCH_MNT/$inode
+ getfattr -r '^user|^xfsroot' $SCRATCH_MNT/$inode
done
done
# whack a symlink in the middle, just to be difficult
ln -s $SCRATCH_MNT/here/up $SCRATCH_MNT/descend/and
# dump out our new starting point
- find $SCRATCH_MNT | LC_COLLATE=POSIX sort
+ find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch
}
_extend_test_bed
echo
echo "*** forward directory descent with us following symlinks"
-getfattr -L -R -adls -e hex $SCRATCH_MNT
+getfattr -L -R -r '^user|^xfsroot' -e hex $SCRATCH_MNT
echo
echo "*** reverse directory descent with us following symlinks"
-getfattr -L -R -5 -adls -e hex $SCRATCH_MNT
+getfattr -L -R -5 -r '^user|^xfsroot' -e hex $SCRATCH_MNT
echo
echo "*** forward directory descent without following symlinks"
-getfattr -P -R -adls -e hex $SCRATCH_MNT
+getfattr -P -R -r '^user|^xfsroot' -e hex $SCRATCH_MNT
echo
echo "*** reverse directory descent without following symlinks"
-getfattr -P -R -5 -adls -e hex $SCRATCH_MNT
+getfattr -P -R -5 -r '^user|^xfsroot' -e hex $SCRATCH_MNT
#
_backup()
{
- getfattr -a -sdlR $SCRATCH_MNT >$1
+ # NB: no filtering of scratch here... (need to restore too)
+ /usr/bin/getfattr -adl -sR $SCRATCH_MNT >$1
echo BACKUP $1 >>$seq.full
cat $1 >> $seq.full
[ ! -s $1 ] && echo "warning: $1 (backup file) is empty"
echo "*** clear out the scratch device"
rm -fr $SCRATCH_MNT/*
echo "AFTER REMOVE" >>$seq.full
-getfattr -L -R -adls $SCRATCH_MNT >>$seq.full
+getfattr -L -R -r '^user|^xfsroot' $SCRATCH_MNT >>$seq.full
echo "*** reset test bed with no extended attributes"
_create_test_bed
_backup $tmp.backup2
echo "AFTER RESTORE" >>$seq.full
-getfattr -L -R -adls $SCRATCH_MNT >>$seq.full
+getfattr -L -R -r '^user|^xfsroot' $SCRATCH_MNT >>$seq.full
echo "*** compare before and after backups"
diff $tmp.backup1 $tmp.backup2
{
_path=$1
- find $_path -exec attr -l {} \; |\
- awk '{print $9, $2}' |\
- sed 's/["]//g' |\
+# Tim - this is the IRIX way...
+ # find $_path -exec attr -l {} \; |\
+ # awk '{print $9, $2}' |\
+ # sed 's/["]//g' |\
+ # sort |\
+# and this is now the Linux way...
+ getfattr -Rla $_path |\
+ perl -wn -e '
+ if (m/^# file: (\S+)/) { $file = $1 }
+ elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
sort |\
while read file ea_name; do
attr -g $ea_name $file
AC_SUBST(libhdl)
dnl Checks for Extended Attributes header and library.
-AC_CHECK_HEADER(attr/attributes.h,, [
+AC_CHECK_HEADER(attr/xattr.h,, [
echo
echo 'FATAL ERROR: could not find a valid Extended Attributes header.'
echo 'Install either the attr-devel (rpm) or the attr-dev (deb) package.'
echo 'Alternatively, run "make install-dev" from the attr source.'
exit 1
])
-AC_CHECK_LIB(attr, attr_get,, [
+AC_CHECK_LIB(attr, getxattr,, [
echo
echo 'FATAL ERROR: could not find a valid Extended Attributes library.'
echo 'Install either the attr-devel (rpm) or the attr-dev (deb) package.'
libattr="-lattr"
AC_SUBST(libattr)
-dnl Checks for Access Control List header and library.
+dnl Checks for Access Control List headers and library.
AC_CHECK_HEADER(sys/acl.h,, [
echo
- echo 'FATAL ERROR: could not find a valid Access Control List header.'
- echo 'Install either the acl-devel (rpm) or the acl-dev (deb) package.'
- echo 'Alternatively, run "make install-dev" from the acl source.'
+ echo 'FATAL ERROR: could not find a valid Access Control List headers.'
+ echo 'Install either the acl-devel (rpm) or the acl (deb) package.'
+ echo 'Alternatively, run "make install" from the acl source.'
+ exit 1
+])
+AC_CHECK_HEADER(acl/libacl.h,, [
+ echo
+ echo 'FATAL ERROR: could not find a valid Access Control List headers.'
+ echo 'Install either the acl-devel (rpm) or the acl (deb) package.'
+ echo 'Alternatively, run "make install" from the acl source.'
exit 1
])
AC_CHECK_LIB(acl, acl_init,, [
echo
echo 'FATAL ERROR: could not find a valid Access Control List library.'
- echo 'Install either the acl-devel (rpm) or the acl-dev (deb) package.'
- echo 'Alternatively, run "make install-dev" from the acl source.'
+ echo 'Install either the acl-devel (rpm) or the acl (deb) package.'
+ echo 'Alternatively, run "make install" from the acl source.'
exit 1
])
libacl="-lacl"
TOPDIR = ..
include $(TOPDIR)/include/builddefs
-TARGETS = alloc acl_get acl_test bstat devzero dirstress fault feature \
+TARGETS = alloc acl_get bstat devzero dirstress fault feature \
fsstress fill fill2 holes ioctl loggen lstat64 nametest permname \
randholes runas truncfile usemem
ifeq ($(HAVE_DB), true)
loggen: $(HFILES) $(LOGGEN_OBJECTS)
$(CCF) -o $@ $(LDFLAGS) $(LOGGEN_OBJECTS) $(LDLIBS)
-ACLGET_OBJECTS = acl_get.o $(LIBACL)
+ACLGET_OBJECTS = acl_get.o $(LIBACL) $(LIBATTR)
acl_get: $(HFILES) $(ACLGET_OBJECTS)
$(CCF) -o $@ $(LDFLAGS) $(ACLGET_OBJECTS) $(LDLIBS)
-
-ACLTEST_OBJECTS = acl_test.o $(LIBACL)
-acl_test: $(HFILES) $(ACLTEST_OBJECTS)
- $(CCF) -o $@ $(LDFLAGS) $(ACLTEST_OBJECTS) $(LDLIBS)
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/acl.h>
+#include <acl/libacl.h>
char *prog;
" -a - get access ACL\n"
" -d - get default ACL\n"
" -f - get access ACL using file descriptor\n"
- " -i - use irix semantics\n"
,prog);
}
char *file;
int getaccess = 0;
int getdefault = 0;
- int irixsemantics = 0;
int usefd = 0;
int fd = -1;
acl_t acl;
- char *buf_acl;
prog = basename(argv[0]);
- while ((c = getopt(argc, argv, "adif")) != -1) {
+ while ((c = getopt(argc, argv, "adf")) != -1) {
switch (c) {
case 'a':
getaccess = 1;
case 'd':
getdefault = 1;
break;
- case 'i':
- irixsemantics = 1;
- break;
case 'f':
usefd = 1;
break;
file = argv[optind];
}
- if (irixsemantics) {
- acl_set_compat(ACL_COMPAT_IRIXGET);
- }
-
if (usefd) {
fd = open(file, O_RDONLY);
if (fd < 0) {
prog, file, strerror(errno));
return 0;
}
- if (irixsemantics && acl->acl_cnt == ACL_NOT_PRESENT) {
- buf_acl = strdup("irix-empty");
- }
- else {
- buf_acl = acl_to_short_text (acl, (ssize_t *) NULL);
- if (buf_acl == NULL) {
- fprintf (stderr, "%s: error converting ACL to short text "
- "for file \"%s\": %s\n",
- prog, file, strerror(errno));
- return 0;
- }
- }
- printf("%s: access %s\n", file, buf_acl);
+ printf("%s: access ", file);
+ acl_print(stdout, acl, NULL, TEXT_ABBREVIATE||TEXT_NO_ENDOFLINE);
acl_free(acl);
- acl_free(buf_acl);
}
if (getdefault) {
prog, file, strerror(errno));
return 0;
}
- if (irixsemantics && acl->acl_cnt == ACL_NOT_PRESENT) {
- buf_acl = strdup("irix-empty");
- }
- else if (!irixsemantics && acl->acl_cnt == 0) {
- buf_acl = strdup("linux-empty");
- }
- else {
- buf_acl = acl_to_short_text (acl, (ssize_t *) NULL);
- if (buf_acl == NULL) {
- fprintf (stderr, "%s: error converting ACL to short text "
- "for file \"%s\": %s\n",
- prog, file, strerror(errno));
- return 0;
- }
- }
- printf("%s: default %s\n", file, buf_acl);
+ printf("%s: default ", file);
+ acl_print(stdout, acl, NULL, TEXT_ABBREVIATE||TEXT_NO_ENDOFLINE);
acl_free(acl);
- acl_free(buf_acl);
}
return 0;
*/
#include "global.h"
+#include <attr/xattr.h>
#define XFS_ERRTAG_MAX 17
void add_to_flist(int, int, int);
void append_pathname(pathname_t *, char *);
-int attr_list_path(pathname_t *, char *, const int, int,
- attrlist_cursor_t *);
+int attr_list_path(pathname_t *, char *, const int, int);
int attr_remove_path(pathname_t *, const char *, int);
int attr_set_path(pathname_t *, const char *, const char *, const int, int);
void check_cwd(void);
}
int
-attr_list_path(pathname_t *name, char *buffer, const int buffersize, int flags,
- attrlist_cursor_t *cursor)
+attr_list_path(pathname_t *name, char *buffer, const int buffersize, int flags)
{
char buf[MAXNAMELEN];
pathname_t newname;
int rval;
- rval = attr_list(name->path, buffer, buffersize, flags, cursor);
+ if (flags != ATTR_DONTFOLLOW) {
+ errno = EINVAL;
+ return -1;
+ }
+ rval = llistxattr(name->path, buffer, buffersize);
if (rval >= 0 || errno != ENAMETOOLONG)
return rval;
separate_pathname(name, buf, &newname);
if (chdir(buf) == 0) {
- rval = attr_list_path(&newname, buffer, buffersize, flags,
- cursor);
+ rval = attr_list_path(&newname, buffer, buffersize, flags);
chdir("..");
}
free_pathname(&newname);
void
attr_remove_f(int opno, long r)
{
- attrlist_ent_t *aep;
- attrlist_t *alist;
- char *aname;
+ char *aname, *l;
char buf[4096];
- attrlist_cursor_t cursor;
int e;
int ent;
pathname_t f;
if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
append_pathname(&f, ".");
total = 0;
- bzero(&cursor, sizeof(cursor));
- do {
- e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW,
- &cursor);
- check_cwd();
- if (e)
- break;
- alist = (attrlist_t *)buf;
- total += alist->al_count;
- } while (alist->al_more);
+ e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW);
+ check_cwd();
+ if (e > 0) {
+ for (l = buf; l - buf <= e; l += strlen(l)+1)
+ if (strncmp(l, "user.",5) == 0)
+ total++;
+ }
if (total == 0) {
if (v)
printf("%d/%d: attr_remove - no attrs for %s\n",
return;
}
which = (int)(random() % total);
- bzero(&cursor, sizeof(cursor));
ent = 0;
aname = NULL;
- do {
- e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW,
- &cursor);
- check_cwd();
- if (e)
- break;
- alist = (attrlist_t *)buf;
- if (which < ent + alist->al_count) {
- aep = (attrlist_ent_t *)
- &buf[alist->al_offset[which - ent]];
- aname = aep->a_name;
- break;
+ e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW);
+ check_cwd();
+ if (e <= 0)
+ return;
+ for (l = buf; l - buf <= e; l += strlen(l)+1) {
+ if (strncmp(l, "user.",5) == 0) {
+ if (++ent == which) {
+ aname = l;
+ break;
+ }
}
- ent += alist->al_count;
- } while (alist->al_more);
+ }
if (aname == NULL) {
if (v)
printf(
so it can update itself)
- copy an appropriate .config file to
$HOME/qa/$HOSTNAME.config
+ - You'll need to maunally install the "quota" and "acl"
+ userspace tools, rest will be installed automatically.
- You'll need a hacked version of 'su' in $HOME/qa that
lets your user su to root/root without a password
(if you want to run from cron, it mustn't require
*clean)
# we need to configure or else we might fail to clean
- for pkg in attr acl xfsprogs dmapi xfsdump xfstests
+ for pkg in attr xfsprogs dmapi xfsdump xfstests
do
cd $WORKAREA/cmd/$pkg
_log " *** clean $pkg tools"
|| _fail " !!! build modules failed"
_log " *** build and install tools"
- for pkg in attr acl xfsprogs dmapi xfsdump xfstests
+ for pkg in attr xfsprogs dmapi xfsdump xfstests
do
cd $WORKAREA/cmd/$pkg
}
straightdiff 'xfs_cred.h', 'cmd/xfsprogs/include', 'linux/fs/xfs/linux';
straightdiff 'xfs_fs.h', 'cmd/xfsprogs/include', 'linux/include/linux';
-straightdiff 'attr_kern.h', 'cmd/attr/include', 'linux/fs/xfs/linux';
-straightdiff 'attributes.h', 'cmd/attr/include', 'linux/include/linux';
straightdiff 'dmapi_kern.h', 'cmd/dmapi/include', 'linux/include/linux';
straightdiff 'dmapi.h', 'cmd/dmapi/include', 'linux/include/linux';
straightdiff 'arch.h', 'cmd/xfsprogs/include', 'linux/include/linux/xfs_support';