+#ifdef HAVE_XATTR
+void xainc(wchar_t *file, char *an, off_t inc)
+{
+ char buf[32];
+ ssize_t al;
+ off_t val;
+ char *fn;
+
+ if(file[0] != L'/')
+ return;
+ if((fn = icswcstombs(file, NULL, NULL)) == NULL) {
+ flog(LOG_WARNING, "could not convert filename %ls into local charset: %s", file, strerror(errno));
+ return;
+ }
+ if((al = getxattr(fn, an, buf, sizeof(buf) - 1)) < 0) {
+ if(errno != ENOATTR) {
+ flog(LOG_WARNING, "could not get xattr %s on %s: %s", an, fn, strerror(errno));
+ return;
+ }
+ val = 0;
+ } else {
+ buf[al] = 0;
+ val = strtoll(buf, NULL, 10);
+ }
+ val += inc;
+ al = snprintf(buf, sizeof(buf), "%ji", (intmax_t)val);
+ if(setxattr(fn, an, buf, al, 0) < 0)
+ flog(LOG_WARNING, "could not set xattr %s on %s: %s", an, fn, strerror(errno));
+}
+#endif
+