mirror of
https://github.com/versity/scoutfs.git
synced 2026-06-06 19:52:33 +00:00
Remove find_xattr commands
We're no longer maintaining xattr backrefs. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -1,134 +0,0 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "sparse.h"
|
||||
#include "util.h"
|
||||
#include "ioctl.h"
|
||||
#include "format.h"
|
||||
#include "cmd.h"
|
||||
|
||||
static int find_xattrs(bool find_name, int argc, char **argv)
|
||||
{
|
||||
struct scoutfs_ioctl_find_xattr find;
|
||||
char *endptr;
|
||||
u64 first;
|
||||
u64 last;
|
||||
u64 *ino;
|
||||
int ret;
|
||||
int fd;
|
||||
int ioc;
|
||||
int count;
|
||||
int i;
|
||||
|
||||
if (find_name)
|
||||
ioc = SCOUTFS_IOC_FIND_XATTR_NAME;
|
||||
else
|
||||
ioc = SCOUTFS_IOC_FIND_XATTR_VAL;
|
||||
|
||||
if (argc != 4) {
|
||||
fprintf(stderr, "must specify ino range, xattr str, and path\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
first = strtoull(argv[0], &endptr, 0);
|
||||
if (*endptr != '\0' ||
|
||||
((first == LLONG_MIN || first == LLONG_MAX) && errno == ERANGE)) {
|
||||
fprintf(stderr, "error parsing inode number '%s'\n",
|
||||
argv[0]);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
last = strtoull(argv[1], &endptr, 0);
|
||||
if (*endptr != '\0' ||
|
||||
((last == LLONG_MIN || last == LLONG_MAX) && errno == ERANGE)) {
|
||||
fprintf(stderr, "error parsing inode number '%s'\n",
|
||||
argv[1]);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
fd = open(argv[3], O_RDONLY);
|
||||
if (fd < 0) {
|
||||
ret = -errno;
|
||||
fprintf(stderr, "failed to open '%s': %s (%d)\n",
|
||||
argv[3], strerror(errno), errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
count = 256;
|
||||
ino = calloc(count, sizeof(*ino));
|
||||
if (!ino) {
|
||||
fprintf(stderr, "couldn't allocate buffer for results\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
find.first_ino = first;
|
||||
find.last_ino = last;
|
||||
find.str_ptr = (unsigned long)argv[2];
|
||||
find.str_len = strlen(argv[2]);
|
||||
find.ino_ptr = (unsigned long)ino;
|
||||
find.ino_count = count;
|
||||
|
||||
if (find.str_len > SCOUTFS_MAX_XATTR_LEN) {
|
||||
fprintf(stderr, "xattr string len %u > %d\n",
|
||||
find.str_len, SCOUTFS_MAX_XATTR_LEN);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
ret = ioctl(fd, ioc, &find);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
fprintf(stderr, "inodes_find_xattr ioctl failed: %s (%d)\n",
|
||||
strerror(errno), errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; i < ret; i++) {
|
||||
printf("%llu\n", ino[i]);
|
||||
find.first_ino = ino[i] + 1;
|
||||
|
||||
if (find.first_ino == 0) {
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (ret > 0);
|
||||
|
||||
out:
|
||||
free(ino);
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
static int find_xattr_name(int argc, char **argv)
|
||||
{
|
||||
return find_xattrs(true, argc, argv);
|
||||
}
|
||||
|
||||
static int find_xattr_val(int argc, char **argv)
|
||||
{
|
||||
return find_xattrs(false, argc, argv);
|
||||
}
|
||||
|
||||
static void __attribute__((constructor)) find_xattr_ctor(void)
|
||||
{
|
||||
cmd_register("find-xattr-name", "<first> <last> <name> <path>",
|
||||
"print inodes that might contain xattr name",
|
||||
find_xattr_name);
|
||||
cmd_register("find-xattr-value", "<first> <last> <value> <path>",
|
||||
"print inodes that might contain xattr value",
|
||||
find_xattr_val);
|
||||
}
|
||||
@@ -80,26 +80,10 @@ struct scoutfs_ioctl_ino_path {
|
||||
#define SCOUTFS_IOC_INO_PATH _IOW(SCOUTFS_IOCTL_MAGIC, 2, \
|
||||
struct scoutfs_ioctl_ino_path)
|
||||
|
||||
|
||||
/* XXX might as well include a seq? 0 for current behaviour? */
|
||||
struct scoutfs_ioctl_find_xattr {
|
||||
__u64 first_ino;
|
||||
__u64 last_ino;
|
||||
__u64 str_ptr;
|
||||
__u32 str_len;
|
||||
__u64 ino_ptr;
|
||||
__u32 ino_count;
|
||||
} __packed;
|
||||
|
||||
#define SCOUTFS_IOC_FIND_XATTR_NAME _IOW(SCOUTFS_IOCTL_MAGIC, 3, \
|
||||
struct scoutfs_ioctl_find_xattr)
|
||||
#define SCOUTFS_IOC_FIND_XATTR_VAL _IOW(SCOUTFS_IOCTL_MAGIC, 4, \
|
||||
struct scoutfs_ioctl_find_xattr)
|
||||
|
||||
#define SCOUTFS_IOC_INODE_DATA_SINCE _IOW(SCOUTFS_IOCTL_MAGIC, 5, \
|
||||
#define SCOUTFS_IOC_INODE_DATA_SINCE _IOW(SCOUTFS_IOCTL_MAGIC, 3, \
|
||||
struct scoutfs_ioctl_inodes_since)
|
||||
|
||||
#define SCOUTFS_IOC_DATA_VERSION _IOW(SCOUTFS_IOCTL_MAGIC, 6, u64)
|
||||
#define SCOUTFS_IOC_DATA_VERSION _IOW(SCOUTFS_IOCTL_MAGIC, 4, u64)
|
||||
|
||||
struct scoutfs_ioctl_release {
|
||||
__u64 offset;
|
||||
@@ -107,7 +91,7 @@ struct scoutfs_ioctl_release {
|
||||
__u64 data_version;
|
||||
} __packed;
|
||||
|
||||
#define SCOUTFS_IOC_RELEASE _IOW(SCOUTFS_IOCTL_MAGIC, 7, \
|
||||
#define SCOUTFS_IOC_RELEASE _IOW(SCOUTFS_IOCTL_MAGIC, 5, \
|
||||
struct scoutfs_ioctl_release)
|
||||
|
||||
struct scoutfs_ioctl_stage {
|
||||
@@ -117,7 +101,7 @@ struct scoutfs_ioctl_stage {
|
||||
__s32 count;
|
||||
} __packed;
|
||||
|
||||
#define SCOUTFS_IOC_STAGE _IOW(SCOUTFS_IOCTL_MAGIC, 8, \
|
||||
#define SCOUTFS_IOC_STAGE _IOW(SCOUTFS_IOCTL_MAGIC, 6, \
|
||||
struct scoutfs_ioctl_stage)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user