diff mbox series

[v3,2/2] src/multi_open_unlink: Stop using attr_set

Message ID 20201209050816.1240404-2-yangx.jy@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/2] src/dmiperf: Remove obsolete dmiperf | expand

Commit Message

Xiao Yang Dec. 9, 2020, 5:08 a.m. UTC
Avoid the following warning by replacing deprecated
attr_set with setxattr:
---------------------------------------------------
warning: 'attr_set' is deprecated: Use setxattr or lsetxattr instead [-Wdeprecated-declarations]
---------------------------------------------------

Also remove unneeded flags, <attr/attributes.h> and $(LIBATTR).

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 src/Makefile            | 2 +-
 src/multi_open_unlink.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/src/Makefile b/src/Makefile
index 80f7b892..811b24e4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -33,7 +33,7 @@  LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 
 SUBDIRS = log-writes perf
 
-LLDLIBS = $(LIBATTR) $(LIBHANDLE) $(LIBACL) -lpthread -lrt
+LLDLIBS = $(LIBHANDLE) $(LIBACL) -lpthread -lrt
 
 ifeq ($(HAVE_XLOG_ASSIGN_LSN), true)
 LINUX_TARGETS += loggen
diff --git a/src/multi_open_unlink.c b/src/multi_open_unlink.c
index d697e5f1..c221d39e 100644
--- a/src/multi_open_unlink.c
+++ b/src/multi_open_unlink.c
@@ -12,9 +12,10 @@ 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <attr/attributes.h>
+#include <sys/xattr.h>
 
 #define MAX_EA_NAME 30
+#define MAX_VALUELEN	(64*1024)
 
 /*
  * multi_open_unlink path_prefix num_files sleep_time
@@ -40,7 +41,7 @@  main(int argc, char *argv[])
 	int sleep_time = 60;
 	int num_files = 100;
 	int num_eas = 0;
-	int value_size = ATTR_MAX_VALUELEN;
+	int value_size = MAX_VALUELEN;
 	int fd = -1;
 	int i,j,c;
 
@@ -87,7 +88,6 @@  main(int argc, char *argv[])
 			int sts;
 			char *attrvalue;
 			char attrname[MAX_EA_NAME];
-			int flags = 0;
 
 			snprintf(attrname, MAX_EA_NAME, "user.name.%d", j);
 
@@ -98,7 +98,7 @@  main(int argc, char *argv[])
 				return 1;
 			}
 
-			sts = attr_set(path, attrname, attrvalue, value_size, flags);
+			sts = setxattr(path, attrname, attrvalue, value_size, 0);
 			if (sts == -1) {
 				fprintf(stderr, "%s: failed to create EA \"%s\" of size %d on path \"%s\": %s\n",
 					prog, attrname, value_size, path, strerror(errno));