mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cleanup: tiny speedup of lib_dir checking
Instead of repeated lookup of global/library_dir - remember first search in command context - saves couple lines in debug output...
This commit is contained in:
parent
0fcdc8a020
commit
9f0e27a18c
@ -1,5 +1,6 @@
|
||||
Version 2.02.105 -
|
||||
=====================================
|
||||
Cache global library dir in command context.
|
||||
Return success when inserting dirs and links into device cache.
|
||||
Test for remote exclusive activation after activation fails.
|
||||
Support lvconvert --merge for thin snapshots.
|
||||
|
@ -1654,6 +1654,8 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
||||
|
||||
cmd->hosttags = 0;
|
||||
|
||||
cmd->lib_dir = NULL;
|
||||
|
||||
if (!_init_lvm_conf(cmd))
|
||||
return 0;
|
||||
|
||||
|
@ -121,6 +121,7 @@ struct cmd_context {
|
||||
struct dm_list tags;
|
||||
int hosttags;
|
||||
|
||||
const char *lib_dir; /* Cache value global/library_dir */
|
||||
char system_dir[PATH_MAX];
|
||||
char dev_dir[PATH_MAX];
|
||||
char proc_dir[PATH_MAX];
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "lib.h"
|
||||
#include "config.h"
|
||||
#include "sharedlib.h"
|
||||
#include "toolcontext.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
@ -25,13 +26,13 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname,
|
||||
char *path, size_t path_len)
|
||||
{
|
||||
struct stat info;
|
||||
const char *lib_dir;
|
||||
|
||||
/* If libname doesn't begin with '/' then use lib_dir/libname,
|
||||
* if present */
|
||||
if (libname[0] == '/' ||
|
||||
!(lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL)) ||
|
||||
(dm_snprintf(path, path_len, "%s/%s", lib_dir,
|
||||
(!cmd->lib_dir &&
|
||||
!(cmd->lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL))) ||
|
||||
(dm_snprintf(path, path_len, "%s/%s", cmd->lib_dir,
|
||||
libname) == -1) || stat(path, &info) == -1) {
|
||||
strncpy(path, libname, path_len - 1);
|
||||
path[path_len - 1] = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user