Minor changes to ztest for this environment. These including
updating ztest to run in the local development tree, as well
as relocating some local variables in this function to the heap.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
ztest_run_zdb(char *pool)
{
int status;
ztest_run_zdb(char *pool)
{
int status;
- char zdb[MAXPATHLEN + MAXNAMELEN + 20];
- char zbuf[1024];
- char *ztest;
- char *isa;
- int isalen;
+ char *zdb;
+ char *zbuf;
- (void) realpath(getexecname(), zdb);
+ bin = umem_alloc(MAXPATHLEN + MAXNAMELEN + 20, UMEM_NOFAIL);
+ zdb = umem_alloc(MAXPATHLEN + MAXNAMELEN + 20, UMEM_NOFAIL);
+ zbuf = umem_alloc(1024, UMEM_NOFAIL);
- /* zdb lives in /usr/sbin, while ztest lives in /usr/bin */
- bin = strstr(zdb, "/usr/bin/");
- ztest = strstr(bin, "/ztest");
- isa = bin + 8;
- isalen = ztest - isa;
- isa = strdup(isa);
- /* LINTED */
- (void) sprintf(bin,
- "/usr/sbin%.*s/zdb -bcc%s%s -U %s %s",
- isalen,
- isa,
+ VERIFY(realpath(getexecname(), bin) != NULL);
+ if (strncmp(bin, "/usr/sbin/ztest", 14) == 0) {
+ strcpy(bin, "/usr/sbin/zdb"); /* Installed */
+ } else {
+ strstr(bin, "/ztest/")[0] = '\0'; /* In-tree */
+ strcat(bin, "/zdb/zdb");
+ }
+
+ (void) sprintf(zdb,
+ "%s -bcc%s%s -U %s %s",
+ bin,
zopt_verbose >= 3 ? "s" : "",
zopt_verbose >= 4 ? "v" : "",
spa_config_path,
pool);
zopt_verbose >= 3 ? "s" : "",
zopt_verbose >= 4 ? "v" : "",
spa_config_path,
pool);
if (zopt_verbose >= 5)
(void) printf("Executing %s\n", strstr(zdb, "zdb "));
if (zopt_verbose >= 5)
(void) printf("Executing %s\n", strstr(zdb, "zdb "));
status = pclose(fp);
if (status == 0)
status = pclose(fp);
if (status == 0)
ztest_dump_core = 0;
if (WIFEXITED(status))
fatal(0, "'%s' exit code %d", zdb, WEXITSTATUS(status));
else
fatal(0, "'%s' died with signal %d", zdb, WTERMSIG(status));
ztest_dump_core = 0;
if (WIFEXITED(status))
fatal(0, "'%s' exit code %d", zdb, WEXITSTATUS(status));
else
fatal(0, "'%s' died with signal %d", zdb, WTERMSIG(status));
+out:
+ umem_free(bin, MAXPATHLEN + MAXNAMELEN + 20);
+ umem_free(zdb, MAXPATHLEN + MAXNAMELEN + 20);
+ umem_free(zbuf, 1024);
kernel_fini();
list_destroy(&zcl.zcl_callbacks);
kernel_fini();
list_destroy(&zcl.zcl_callbacks);
-
- (void) _mutex_destroy(&zcl.zcl_callbacks_lock);
-
- (void) rwlock_destroy(&zs->zs_name_lock);
- (void) _mutex_destroy(&zs->zs_vdev_lock);
+ mutex_destroy(&zcl.zcl_callbacks_lock);
+ rw_destroy(&zs->zs_name_lock);
+ mutex_destroy(&zs->zs_vdev_lock);
ztest_random_fd = open("/dev/urandom", O_RDONLY);
ztest_random_fd = open("/dev/urandom", O_RDONLY);
+ dprintf_setup(&argc, argv);
process_options(argc, argv);
/* Override location of zpool.cache */
process_options(argc, argv);
/* Override location of zpool.cache */