* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*/
-#include <xfs/libxfs.h>
+#include "global.h"
+
+#ifdef HAVE_ATTR_XATTR_H
#include <attr/xattr.h>
-#include <attr/attributes.h>
-#include <sys/statvfs.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <dirent.h>
+#endif
+#include <math.h>
#define XFS_ERRTAG_MAX 17
#define XFS_IDMODULO_MAX 32
void add_to_flist(int, int, int);
void append_pathname(pathname_t *, char *);
+#ifdef HAVE_LIBATTR
int attr_list_path(pathname_t *, char *, const int, int);
+#else
+int attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *);
+#endif
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);
struct timeval t;
ptrdiff_t srval;
int nousage = 0;
- xfs_error_injection_t err_inj;
+ xfs_error_injection_t err_inj;
errrange = errtag = 0;
umask(0);
perror(dirname);
exit(1);
}
- sprintf(buf, "fss%x", getpid());
+ sprintf(buf, "fss%x", (unsigned int)getpid());
fd = creat(buf, 0666);
if (lseek64(fd, (off64_t)(MAXFSIZE32 + 1ULL), SEEK_SET) < 0)
maxfsize = (off64_t)MAXFSIZE32;
}
int
-attr_list_path(pathname_t *name, char *buffer, const int buffersize, int flags)
+attr_list_path(pathname_t *name,
+ char *buffer,
+ const int buffersize,
+ int flags
+#ifndef HAVE_LIBATTR
+ , attrlist_cursor_t *cursor
+#endif
+ )
{
char buf[MAXNAMELEN];
pathname_t newname;
int rval;
+#ifdef ATTR_DONTFOLLOW
if (flags != ATTR_DONTFOLLOW) {
errno = EINVAL;
return -1;
}
+#endif
+
+#ifdef HAVE_LIBATTR
rval = llistxattr(name->path, buffer, buffersize);
+#else
+ rval = attr_list(name->path, buffer, buffersize, flags, cursor);
+#endif
if (rval >= 0 || errno != ENAMETOOLONG)
return rval;
separate_pathname(name, buf, &newname);
if (chdir(buf) == 0) {
+#ifdef HAVE_LIBATTR
rval = attr_list_path(&newname, buffer, buffersize, flags);
+#else
+ rval = attr_list_path(&newname, buffer, buffersize, flags, cursor);
+#endif
chdir("..");
}
free_pathname(&newname);
int e;
pathname_t f;
int fd;
- struct flock64 fl;
+ struct xfs_flock64 fl;
__int64_t lr;
off64_t off;
struct stat64 stb;
void
attr_remove_f(int opno, long r)
{
- char *aname, *l;
+ attrlist_ent_t *aep;
+ attrlist_t *alist;
+ char *aname;
char buf[4096];
+#ifndef HAVE_LIBATTR
+ attrlist_cursor_t cursor;
+#endif
int e;
int ent;
pathname_t f;
if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
append_pathname(&f, ".");
total = 0;
- 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++;
- }
+#ifndef HAVE_LIBATTR
+ bzero(&cursor, sizeof(cursor));
+#endif
+ do {
+ bzero(buf, sizeof(buf));
+#ifdef HAVE_LIBATTR
+ e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW);
+#else
+ e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW, &cursor);
+#endif
+ check_cwd();
+ if (e)
+ break;
+ alist = (attrlist_t *)buf;
+ total += alist->al_count;
+ } while (alist->al_more);
if (total == 0) {
if (v)
printf("%d/%d: attr_remove - no attrs for %s\n",
return;
}
which = (int)(random() % total);
+#ifndef HAVE_LIBATTR
+ bzero(&cursor, sizeof(cursor));
+#endif
ent = 0;
aname = NULL;
- 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;
- }
+ do {
+ bzero(buf, sizeof(buf));
+#ifdef HAVE_LIBATTR
+ e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW);
+#else
+ e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW, &cursor);
+#endif
+ 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;
}
- }
+ ent += alist->al_count;
+ } while (alist->al_more);
if (aname == NULL) {
if (v)
printf(
total += count;
free(t);
if (verbose)
- printf("%d/%d: bulkstat nent %d total %llu\n",
+ printf("%d/%d: bulkstat nent %d total %lld\n",
procid, opno, nent, (long long)total);
close(fd);
}
e = lchown_path(&f, u, g) < 0 ? errno : 0;
check_cwd();
if (v)
- printf("%d/%d: chown %s %d/%d %d\n", procid, opno, f.path, u, g, e);
+ printf("%d/%d: chown %s %d/%d %d\n", procid, opno, f.path, (int)u, (int)g, e);
free_pathname(&f);
}
int e;
pathname_t f;
int fd;
- struct flock64 fl;
+ struct xfs_flock64 fl;
__int64_t lr;
off64_t off;
struct stat64 stb;
int e;
pathname_t f;
int fd;
- struct flock64 fl;
+ struct xfs_flock64 fl;
__int64_t lr;
off64_t off;
struct stat64 stb;
int e;
pathname_t f;
int fd;
- struct flock64 fl;
+ struct xfs_flock64 fl;
__int64_t lr;
off64_t off;
struct stat64 stb;