From: Gernot P. <gp...@su...> - 2004-05-12 10:03:04
|
Hi, in acl_file_test.c and acl_link_test.c syscalls regarding xattrs are still done via syscall, although libc functions are available. Furthermore I found out that on older distros for non-intel architectures both attr/xattr.h and constants like __NR_getxattr are not available, so in this case the these testcases are not built. The following patch cleans up the first issue and fixes the second one. diff -ruNw ltp-full-20040506-old/testcases/kernel/fs/acls/Makefile ltp-full-20040506/testcases/kernel/fs/acls/Makefile --- ltp-full-20040506-old/testcases/kernel/fs/acls/Makefile 2004-04-21 20:23:28.000000000 +0200 +++ ltp-full-20040506/testcases/kernel/fs/acls/Makefile 2004-05-11 14:50:47.000000000 +0200 @@ -1,13 +1,15 @@ all: - @rm -f unistd.h - @cp /lib/modules/`uname -r`/build/include/asm/unistd.h ./unistd.h - $(CC) -Wall -o acl_file_test acl_file_test.c - $(CC) -Wall -o acl_link_test acl_link_test.c +ifneq ($(wildcard /usr/include/attr/xattr.h),) + $(CC) -o acl_file_test acl_file_test.c + $(CC) -o acl_link_test acl_link_test.c +else + @echo File attr/xattr.h does not exist, attr tests cannot be build! +endif install: - @ln -f acl_file_test ../../../bin/acl_file_test - @ln -f acl_link_test ../../../bin/acl_link_test - @ln -f acl_test01 ../../../bin/acl_test01 +ifneq ($(wildcard /usr/include/attr/xattr.h),) + ln -f acl_file_test ../../bin/ + ln -f acl_link_test ../../bin/ + ln -f acl_test01 ../../bin/ +endif clean: - rm -f acl_file_test - rm -f acl_link_test - rm ./unistd.h + rm -f acl_file_test acl_link_test diff -ruNw ltp-full-20040506-old/testcases/kernel/fs/acls/acl_file_test.c ltp-full-20040506/testcases/kernel/fs/acls/acl_file_test.c --- ltp-full-20040506-old/testcases/kernel/fs/acls/acl_file_test.c 2004-04-21 20:23:28.000000000 +0200 +++ ltp-full-20040506/testcases/kernel/fs/acls/acl_file_test.c 2004-05-10 17:03:12.000000000 +0200 @@ -1,18 +1,17 @@ #include <unistd.h> #include <stdio.h> +#include <sys/types.h> #include <errno.h> +#include <sys/syscall.h> #include <fcntl.h> +#include <attr/xattr.h> #include <string.h> -#include <sys/syscall.h> -#include <sys/types.h> -#include "unistd.h" int main(int argc, char *argv[]){ ssize_t s; char * tok; char value[1024]; char list[1024]; - char delim = '\0'; int rc = 0; char * file; int fd; @@ -30,14 +29,21 @@ return -1; } - //syscall(232, file, &list, 1024); //listxattr - syscall(__NR_listxattr, file, &list, 1024); //listxattr - tok = strtok((char *)&list, &delim); - //s = syscall(229, file,tok, (void *)&value, 1024); //getxattr - s = syscall(__NR_getxattr, file,tok, (void *)&value, 1024); //getxattr - - //s = syscall(228, fd,tok,(void *)&value,s, 0); //fsetxattr - s = syscall(__NR_fsetxattr, fd,tok,(void *)&value,s, 0); //fsetxattr + if(-1 == (s = flistxattr(fd, list, 1024)) ) { + perror("flistxattr"); + return 1; + } + if(s == 0) { + printf("No xattrs defined for %s, further testcase useless\n",file); + return 1; + } + tok = strtok(list, "\0"); + s = fgetxattr(fd, tok, (void*)value, 1024); + if(s == -1) { + perror("fgetxattr"); + return 1; + } + s = fsetxattr(fd, tok, (void*)value, s, 0); if (s == -1) { printf ("User unable to change extended attributes on file %s !\n", argv[1]); diff -ruNw ltp-full-20040506-old/testcases/kernel/fs/acls/acl_link_test.c ltp-full-20040506/testcases/kernel/fs/acls/acl_link_test.c --- ltp-full-20040506-old/testcases/kernel/fs/acls/acl_link_test.c 2004-04-21 20:23:28.000000000 +0200 +++ ltp-full-20040506/testcases/kernel/fs/acls/acl_link_test.c 2004-05-11 14:53:13.000000000 +0200 @@ -1,17 +1,16 @@ #include <unistd.h> #include <stdio.h> -#include <errno.h> -#include <string.h> #include <sys/types.h> +#include <errno.h> #include <sys/syscall.h> -#include "unistd.h" +#include <string.h> +#include <attr/xattr.h> int main(int argc, char *argv[]){ ssize_t s; char * tok; char value[1024]; char list[1024]; - char delim = '\0'; int rc = 0; if ( argc < 2) { @@ -19,11 +18,22 @@ return -1; } - syscall(__NR_listxattr, argv[1], &list, 1024); //listxattr - tok = strtok((char *)&list, &delim); - s = syscall(__NR_getxattr, argv[1],tok, (void *)&value, 1024); //getxattr + if(-1 == (s = listxattr(argv[1], list, 1024)) ) { + perror("listxattr"); + return 1; + } + if(s == 0) { + printf("No xattrs defined for %s, further testcase useless\n",argv[1]); + return 1; + } + tok = strtok(list, "\0"); + s = getxattr(argv[1], tok, (void*)value, 1024); + if(-1 == s) { + perror("getxattr"); + return -1; + } - s = syscall(__NR_lsetxattr,argv[1],tok,(void *)&value,s, 0); //lsetxattr + s = lsetxattr(argv[1], tok, (void*)value, s, 0); if (s == -1) { printf ("User unable to change extended attributes %s !\n", argv[1]); @@ -31,7 +41,7 @@ rc = 1; } - s = syscall(__NR_lremovexattr,argv[1],tok); //lremovexattr + s = lremovexattr(argv[1],tok); if (s == -1) { printf ("User unable to remove extended attributes %s !\n", argv[1]); printf("errno = %i\n", errno); |