/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2016 Lawrence Livermore National Security, LLC. */ /* * An extended attribute (xattr) correctness test. This program creates * N files and sets M attrs on them of size S. Optionally is will verify * a pattern stored in the xattr. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern char *program_invocation_short_name; #define ERROR(fmt, ...) \ fprintf(stderr, "%s: %s:%d: %s: " fmt "\n", \ program_invocation_short_name, __FILE__, __LINE__, \ __func__, ## __VA_ARGS__); static const char shortopts[] = "hvycdn:f:x:s:p:t:e:rRko:"; static const struct option longopts[] = { { "help", no_argument, 0, 'h' }, { "verbose", no_argument, 0, 'v' }, { "verify", no_argument, 0, 'y' }, { "nth", required_argument, 0, 'n' }, { "files", required_argument, 0, 'f' }, { "xattrs", required_argument, 0, 'x' }, { "size", required_argument, 0, 's' }, { "path", required_argument, 0, 'p' }, { "synccaches", no_argument, 0, 'c' }, { "dropcaches", no_argument, 0, 'd' }, { "script", required_argument, 0, 't' }, { "seed", required_argument, 0, 'e' }, { "random", no_argument, 0, 'r' }, { "randomvalue", no_argument, 0, 'R' }, { "keep", no_argument, 0, 'k' }, { "only", required_argument, 0, 'o' }, { 0, 0, 0, 0 } }; enum phases { PHASE_ALL = 0, PHASE_CREATE, PHASE_SETXATTR, PHASE_GETXATTR, PHASE_UNLINK, PHASE_INVAL }; static int verbose = 0; static int verify = 0; static int synccaches = 0; static int dropcaches = 0; static int nth = 0; static int files = 1000; static int xattrs = 1; static int size = 6; static int size_is_random = 0; static int value_is_random = 0; static int keep_files = 0; static int phase = PHASE_ALL; static char path[PATH_MAX] = "/tmp/xattrtest"; static char script[PATH_MAX] = "/bin/true"; static char xattrbytes[XATTR_SIZE_MAX]; static int usage(int argc, char **argv) { fprintf(stderr, "usage: %s [-hvycdrRk] [-n ] [-f ] [-x ]\n" " [-s ] [-p ] [-t