mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
const: rework conversion to enum
Easier code with string and also avoids mixing enums.
This commit is contained in:
parent
5d573cc91d
commit
c140601cf6
@ -5001,32 +5001,29 @@ uint64_t *dm_stats_update_regions_from_fd(struct dm_stats *dms, int fd,
|
|||||||
#endif /* HAVE_LINUX_FIEMAP */
|
#endif /* HAVE_LINUX_FIEMAP */
|
||||||
|
|
||||||
#ifdef DMFILEMAPD
|
#ifdef DMFILEMAPD
|
||||||
static const char *_filemapd_mode_names[] = {
|
static const char _filemapd_mode_names[][8] = {
|
||||||
"inode",
|
"inode",
|
||||||
"path",
|
"path",
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dm_filemapd_mode_t dm_filemapd_mode_from_string(const char *mode_str)
|
dm_filemapd_mode_t dm_filemapd_mode_from_string(const char *mode_str)
|
||||||
{
|
{
|
||||||
dm_filemapd_mode_t mode = DM_FILEMAPD_FOLLOW_INODE;
|
static const dm_filemapd_mode_t _mode[] = {
|
||||||
const char **mode_name;
|
DM_FILEMAPD_FOLLOW_INODE,
|
||||||
|
DM_FILEMAPD_FOLLOW_PATH
|
||||||
|
};
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
if (mode_str)
|
||||||
|
for (i = 0; i < DM_ARRAY_SIZE(_filemapd_mode_names); ++i)
|
||||||
|
if (!strcmp(_filemapd_mode_names[i], mode_str))
|
||||||
|
return _mode[i];
|
||||||
|
|
||||||
if (mode_str) {
|
|
||||||
for (mode_name = _filemapd_mode_names; *mode_name; mode_name++)
|
|
||||||
if (!strcmp(*mode_name, mode_str))
|
|
||||||
break;
|
|
||||||
if (*mode_name)
|
|
||||||
mode = DM_FILEMAPD_FOLLOW_INODE
|
|
||||||
+ (mode_name - _filemapd_mode_names);
|
|
||||||
else {
|
|
||||||
log_error("Could not parse dmfilemapd mode: %s",
|
log_error("Could not parse dmfilemapd mode: %s",
|
||||||
mode_str);
|
(mode_str) ? mode_str : "");
|
||||||
|
|
||||||
return DM_FILEMAPD_FOLLOW_NONE;
|
return DM_FILEMAPD_FOLLOW_NONE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DM_FILEMAPD "dmfilemapd"
|
#define DM_FILEMAPD "dmfilemapd"
|
||||||
#define NR_FILEMAPD_ARGS 7 /* includes argv[0] */
|
#define NR_FILEMAPD_ARGS 7 /* includes argv[0] */
|
||||||
|
Loading…
Reference in New Issue
Block a user