Lines Matching +full:y +full:- +full:rc
1 // SPDX-License-Identifier: CDDL-1.0
10 * or https://opensource.org/licenses/CDDL-1.0.
57 { "verify", no_argument, 0, 'y' },
103 "usage: %s [-hvycdrRk] [-n <nth>] [-f <files>] [-x <xattrs>]\n" in usage()
104 " [-s <bytes>] [-p <path>] [-t <script> ] [-o <phase>]\n", in usage()
108 " --help -h This help\n" in usage()
109 " --verbose -v Increase verbosity\n" in usage()
110 " --verify -y Verify xattr contents\n" in usage()
111 " --nth -n <nth> Print every nth file\n" in usage()
112 " --files -f <files> Set xattrs on N files\n" in usage()
113 " --xattrs -x <xattrs> Set N xattrs on each file\n" in usage()
114 " --size -s <bytes> Set N bytes per xattr\n" in usage()
115 " --path -p <path> Path to files\n" in usage()
116 " --synccaches -c Sync caches between phases\n" in usage()
117 " --dropcaches -d Drop caches between phases\n" in usage()
118 " --script -t <script> Exec script between phases\n" in usage()
119 " --seed -e <seed> Random seed value\n" in usage()
120 " --random -r Randomly sized xattrs [16-size]\n" in usage()
121 " --randomvalue -R Random xattr values\n" in usage()
122 " --keep -k Don't unlink files\n" in usage()
123 " --only -o <num> Only run phase N\n" in usage()
135 int rc = 0; in parse_args() local
137 while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) { in parse_args()
144 case 'y': in parse_args()
159 fprintf(stderr, "Error: the -s value may not " in parse_args()
161 rc = 1; in parse_args()
191 fprintf(stderr, "Error: the -o value must be " in parse_args()
194 rc = 1; in parse_args()
198 rc = 1; in parse_args()
203 if (rc != 0) in parse_args()
204 return (rc); in parse_args()
227 return (rc); in parse_args()
234 int fd, rc; in drop_caches() local
237 if (fd == -1) { in drop_caches()
242 rc = write(fd, "3", 1); in drop_caches()
243 if ((rc == -1) || (rc != 1)) { in drop_caches()
249 rc = close(fd); in drop_caches()
250 if (rc == -1) { in drop_caches()
262 int rc, devnull_fd; in run_process() local
269 _exit(-1); in run_process()
276 _exit(-1); in run_process()
280 while ((rc = waitpid(pid, &status, 0)) == -1 && in run_process()
283 if (rc < 0 || !WIFEXITED(status)) in run_process()
284 return (-1); in run_process()
289 return (-1); in run_process()
296 int rc; in post_hook() local
302 rc = drop_caches(); in post_hook()
303 if (rc) in post_hook()
304 return (rc); in post_hook()
307 rc = run_process(script, argv); in post_hook()
308 if (rc) in post_hook()
309 return (rc); in post_hook()
320 usec -= USEC_PER_SEC; in timeval_normalize()
326 sec--; in timeval_normalize()
329 tv->tv_sec = sec; in timeval_normalize()
330 tv->tv_usec = usec; in timeval_normalize()
337 tv1->tv_sec - tv2->tv_sec, in timeval_sub()
338 tv1->tv_usec - tv2->tv_usec); in timeval_sub()
353 int i, rc; in create_files() local
362 rc = ENOMEM; in create_files()
363 ERROR("Error %d: malloc(%d) bytes for file name\n", rc, in create_files()
371 if (snprintf(file, fsize, "%s/file-%d", path, i) >= fsize) { in create_files()
372 rc = EINVAL; in create_files()
373 ERROR("Error %d: path too long\n", rc); in create_files()
380 rc = unlink(file); in create_files()
381 if ((rc == -1) && (errno != ENOENT)) { in create_files()
383 rc = errno; in create_files()
387 rc = open(file, O_CREAT, 0644); in create_files()
388 if (rc == -1) { in create_files()
391 rc = errno; in create_files()
395 rc = close(rc); in create_files()
396 if (rc == -1) { in create_files()
397 ERROR("Error %d: close(%d)\n", errno, rc); in create_files()
398 rc = errno; in create_files()
408 rc = post_hook("post"); in create_files()
413 return (rc); in create_files()
428 ssize_t rc = read(rand, buf + bytes_read, bytes - bytes_read); in get_random_bytes() local
429 if (rc < 0) in get_random_bytes()
431 bytes_read += rc; in get_random_bytes()
442 int i, j, rnd_size = size, shift, rc = 0; in setxattrs() local
452 rc = ENOMEM; in setxattrs()
453 ERROR("Error %d: malloc(%d) bytes for xattr value\n", rc, in setxattrs()
461 rc = ENOMEM; in setxattrs()
462 ERROR("Error %d: malloc(%d) bytes for file name\n", rc, in setxattrs()
470 if (snprintf(file, fsize, "%s/file-%d", path, i) >= fsize) { in setxattrs()
471 rc = EINVAL; in setxattrs()
472 ERROR("Error %d: path too long\n", rc); in setxattrs()
481 rnd_size = (random() % (size - 16)) + 16; in setxattrs()
486 sizeof (xattrbytes) - shift); in setxattrs()
488 rc = lsetxattr(file, name, value, rnd_size, 0); in setxattrs()
489 if (rc == -1) { in setxattrs()
502 rc = post_hook("post"); in setxattrs()
510 return (rc); in setxattrs()
516 int i, j, rnd_size, shift, rc = 0; in getxattrs() local
529 rc = ENOMEM; in getxattrs()
530 ERROR("Error %d: malloc(%d) bytes for xattr verify\n", rc, in getxattrs()
537 rc = ENOMEM; in getxattrs()
538 ERROR("Error %d: malloc(%d) bytes for xattr value\n", rc, in getxattrs()
550 rc = ENOMEM; in getxattrs()
551 ERROR("Error %d: malloc(%d) bytes for file name\n", rc, in getxattrs()
559 if (snprintf(file, fsize, "%s/file-%d", path, i) >= fsize) { in getxattrs()
560 rc = EINVAL; in getxattrs()
561 ERROR("Error %d: path too long\n", rc); in getxattrs()
571 rc = lgetxattr(file, name, value, XATTR_SIZE_MAX); in getxattrs()
572 if (rc == -1) { in getxattrs()
581 sscanf(value, "size=%d [a-z]", &rnd_size); in getxattrs()
585 sizeof (xattrbytes) - shift); in getxattrs()
587 if (rnd_size != rc || in getxattrs()
592 rc = 1; in getxattrs()
603 rc = post_hook("post"); in getxattrs()
614 return (rc); in getxattrs()
620 int i, rc; in unlink_files() local
629 rc = ENOMEM; in unlink_files()
631 rc, PATH_MAX); in unlink_files()
638 if (snprintf(file, fsize, "%s/file-%d", path, i) >= fsize) { in unlink_files()
639 rc = EINVAL; in unlink_files()
640 ERROR("Error %d: path too long\n", rc); in unlink_files()
647 rc = unlink(file); in unlink_files()
648 if ((rc == -1) && (errno != ENOENT)) { in unlink_files()
660 rc = post_hook("post"); in unlink_files()
665 return (rc); in unlink_files()
671 int rc; in main() local
673 rc = parse_args(argc, argv); in main()
674 if (rc) in main()
675 return (rc); in main()
680 rc = get_random_bytes(xattrbytes, rndsz); in main()
681 if (rc < rndsz) { in main()
683 "got %d\n", errno, rndsz, rc); in main()
684 return (rc); in main()
691 rc = create_files(); in main()
692 if (rc) in main()
693 return (rc); in main()
697 rc = setxattrs(); in main()
698 if (rc) in main()
699 return (rc); in main()
703 rc = getxattrs(); in main()
704 if (rc) in main()
705 return (rc); in main()
709 rc = unlink_files(); in main()
710 if (rc) in main()
711 return (rc); in main()