mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-05 13:18:20 +03:00
Add dm_set_sysfs_dir to libdevmapper to set sysfs location.
Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set.
This commit is contained in:
parent
2f64783850
commit
1f92ab6e8a
@ -1,5 +1,7 @@
|
|||||||
Version 1.02.68 -
|
Version 1.02.68 -
|
||||||
==================================
|
==================================
|
||||||
|
Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set.
|
||||||
|
Add dm_set_sysfs_dir to libdevmapper to set sysfs location.
|
||||||
Add --retry option for dmsetup remove to retry removal if not successful.
|
Add --retry option for dmsetup remove to retry removal if not successful.
|
||||||
Add dm_task_retry_remove fn to use retry logic for device removal.
|
Add dm_task_retry_remove fn to use retry logic for device removal.
|
||||||
Remove unused passed parameters for _mirror_emit_segment_line().
|
Remove unused passed parameters for _mirror_emit_segment_line().
|
||||||
|
@ -255,6 +255,12 @@ void dm_task_update_nodes(void);
|
|||||||
int dm_set_dev_dir(const char *dir);
|
int dm_set_dev_dir(const char *dir);
|
||||||
const char *dm_dir(void);
|
const char *dm_dir(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configure sysfs directory, /sys by default
|
||||||
|
*/
|
||||||
|
int dm_set_sysfs_dir(const char *dir);
|
||||||
|
const char *dm_sysfs_dir(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine whether a major number belongs to device-mapper or not.
|
* Determine whether a major number belongs to device-mapper or not.
|
||||||
*/
|
*/
|
||||||
|
@ -58,6 +58,7 @@ union semun
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
|
static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
|
||||||
|
static char _sysfs_dir[PATH_MAX] = "/sys/";
|
||||||
|
|
||||||
static int _verbose = 0;
|
static int _verbose = 0;
|
||||||
static int _suspended_dev_counter = 0;
|
static int _suspended_dev_counter = 0;
|
||||||
@ -1008,32 +1009,53 @@ void update_devs(void)
|
|||||||
_pop_node_ops();
|
_pop_node_ops();
|
||||||
}
|
}
|
||||||
|
|
||||||
int dm_set_dev_dir(const char *dev_dir)
|
static int _canonicalize_and_set_dir(const char *src, const char *suffix, size_t max_len, char *dir)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *slash;
|
const char *slash;
|
||||||
if (*dev_dir != '/') {
|
|
||||||
log_debug("Invalid dev_dir value, %s: "
|
if (*src != '/') {
|
||||||
"not an absolute name.", dev_dir);
|
log_debug("Invalid directory value, %s: "
|
||||||
|
"not an absolute name.", src);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(dev_dir);
|
len = strlen(src);
|
||||||
slash = dev_dir[len-1] == '/' ? "" : "/";
|
slash = src[len-1] == '/' ? "" : "/";
|
||||||
|
|
||||||
if (dm_snprintf(_dm_dir, sizeof _dm_dir, "%s%s%s", dev_dir, slash, DM_DIR) < 0) {
|
if (dm_snprintf(dir, max_len, "%s%s%s", src, slash, suffix ? suffix : "") < 0) {
|
||||||
log_debug("Invalid dev_dir value, %s: name too long.", dev_dir);
|
log_debug("Invalid directory value, %s: name too long.", src);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dm_set_dev_dir(const char *dev_dir)
|
||||||
|
{
|
||||||
|
return _canonicalize_and_set_dir(dev_dir, DM_DIR, sizeof _dm_dir, _dm_dir);
|
||||||
|
}
|
||||||
|
|
||||||
const char *dm_dir(void)
|
const char *dm_dir(void)
|
||||||
{
|
{
|
||||||
return _dm_dir;
|
return _dm_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dm_set_sysfs_dir(const char *sysfs_dir)
|
||||||
|
{
|
||||||
|
if (!sysfs_dir || !*sysfs_dir) {
|
||||||
|
_sysfs_dir[0] = '\0';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return _canonicalize_and_set_dir(sysfs_dir, NULL, sizeof _sysfs_dir, _sysfs_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dm_sysfs_dir(void)
|
||||||
|
{
|
||||||
|
return _sysfs_dir;
|
||||||
|
}
|
||||||
|
|
||||||
int dm_mknodes(const char *name)
|
int dm_mknodes(const char *name)
|
||||||
{
|
{
|
||||||
struct dm_task *dmt;
|
struct dm_task *dmt;
|
||||||
|
Loading…
Reference in New Issue
Block a user