diff options
author | aw148015 <Andrew.W.Wilson@sun.com> | 2009-04-13 08:55:44 -0700 |
---|---|---|
committer | aw148015 <Andrew.W.Wilson@sun.com> | 2009-04-13 08:55:44 -0700 |
commit | 57c911815cf9a6ce6df110cc669f6df3517813af (patch) | |
tree | a09230d91e13f7e1fcf3824bbcf22fab96a73796 /usr/src/cmd/filebench/common/fileset.c | |
parent | ea2f5b9e5bf4966630882d6d681a94768aea1d75 (diff) | |
download | illumos-gate-57c911815cf9a6ce6df110cc669f6df3517813af.tar.gz |
6543078 A ',' in the description field of a profile file breaks in a confusing manner
6573651 Have an option to not collect utilization data from /proc
6697106 filebench needs a way to remove cruft after run
Diffstat (limited to 'usr/src/cmd/filebench/common/fileset.c')
-rw-r--r-- | usr/src/cmd/filebench/common/fileset.c | 82 |
1 files changed, 78 insertions, 4 deletions
diff --git a/usr/src/cmd/filebench/common/fileset.c b/usr/src/cmd/filebench/common/fileset.c index 03184162ec..38a075be42 100644 --- a/usr/src/cmd/filebench/common/fileset.c +++ b/usr/src/cmd/filebench/common/fileset.c @@ -1029,11 +1029,8 @@ fileset_create(fileset_t *fileset) } if (!reusing) { - char cmd[MAXPATHLEN]; - /* Remove existing */ - (void) snprintf(cmd, sizeof (cmd), "rm -rf %s", path); - (void) system(cmd); + FB_RECUR_RM(path); filebench_log(LOG_VERBOSE, "Removed any existing %s %s in %llu seconds", fileset_entity_name(fileset), fileset_name, @@ -1169,6 +1166,83 @@ exit: } /* + * Removes all files and directories associated with a fileset + * from the storage subsystem. + */ +static void +fileset_delete_storage(fileset_t *fileset) +{ + char path[MAXPATHLEN]; + char *fileset_path; + char *fileset_name; + + if ((fileset_path = avd_get_str(fileset->fs_path)) == NULL) + return; + + if ((fileset_name = avd_get_str(fileset->fs_name)) == NULL) + return; + +#ifdef HAVE_RAW_SUPPORT + /* treat raw device as special case */ + if (fileset->fs_attrs & FILESET_IS_RAW_DEV) + return; +#endif /* HAVE_RAW_SUPPORT */ + + /* set up path to file */ + (void) fb_strlcpy(path, fileset_path, MAXPATHLEN); + (void) fb_strlcat(path, "/", MAXPATHLEN); + (void) fb_strlcat(path, fileset_name, MAXPATHLEN); + + /* now delete any files and directories on the disk */ + FB_RECUR_RM(path); +} + +/* + * Removes the fileset entity and all of its filesetentry entities. + */ +static void +fileset_delete_fileset(fileset_t *fileset) +{ + filesetentry_t *entry, *next_entry; + + /* run down the file list, removing and freeing each filesetentry */ + for (entry = fileset->fs_filelist; entry; entry = next_entry) { + + /* free the entry */ + next_entry = entry->fse_next; + + /* return it to the pool */ + switch (entry->fse_flags & FSE_TYPE_MASK) { + case FSE_TYPE_FILE: + case FSE_TYPE_LEAFDIR: + case FSE_TYPE_DIR: + ipc_free(FILEBENCH_FILESETENTRY, (void *)entry); + break; + default: + filebench_log(LOG_ERROR, + "Unallocated filesetentry found on list"); + break; + } + } + + ipc_free(FILEBENCH_FILESET, (void *)fileset); +} + +void +fileset_delete_all_filesets(void) +{ + fileset_t *fileset, *next_fileset; + + for (fileset = filebench_shm->shm_filesetlist; + fileset; fileset = next_fileset) { + next_fileset = fileset->fs_next; + fileset_delete_storage(fileset); + fileset_delete_fileset(fileset); + } + + filebench_shm->shm_filesetlist = NULL; +} +/* * Adds an entry to the fileset's file list. Single threaded so * no locking needed. */ |