From 13b2d9bb882ab23a09206a09caf4232e132bf5e5 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 9 Feb 2017 15:41:48 -0800 Subject: [PATCH] Remove find_xattr commands We're no longer maintaining xattr backrefs. Signed-off-by: Zach Brown --- utils/src/find_xattr.c | 134 ----------------------------------------- utils/src/ioctl.h | 24 ++------ 2 files changed, 4 insertions(+), 154 deletions(-) delete mode 100644 utils/src/find_xattr.c diff --git a/utils/src/find_xattr.c b/utils/src/find_xattr.c deleted file mode 100644 index 9d489d07..00000000 --- a/utils/src/find_xattr.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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", " ", - "print inodes that might contain xattr name", - find_xattr_name); - cmd_register("find-xattr-value", " ", - "print inodes that might contain xattr value", - find_xattr_val); -} diff --git a/utils/src/ioctl.h b/utils/src/ioctl.h index 5a047328..190199fc 100644 --- a/utils/src/ioctl.h +++ b/utils/src/ioctl.h @@ -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