mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
uuid: add id_read_format_try
Provide id_read_format() functionality without log_error when ID is not valid one - it will just return 0. Does not need to use log_suppress() then.
This commit is contained in:
parent
aec58c8620
commit
c15c44a492
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.137 -
|
Version 2.02.137 -
|
||||||
=====================================
|
=====================================
|
||||||
|
Added internal id_read_format_try() function to check and read valid UUID.
|
||||||
Use dm_get_status_mirror() instead of individual parsers.
|
Use dm_get_status_mirror() instead of individual parsers.
|
||||||
Add mem pool arg for check_transient_status() target function.
|
Add mem pool arg for check_transient_status() target function.
|
||||||
Avoid misleading error with -m is omitted with lvconvert to raid types.
|
Avoid misleading error with -m is omitted with lvconvert to raid types.
|
||||||
|
@ -132,7 +132,7 @@ static void _build_inverse(void)
|
|||||||
_inverse_c[(int) *ptr] = (char) 0x1;
|
_inverse_c[(int) *ptr] = (char) 0x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id_valid(struct id *id)
|
static int _id_valid(struct id *id, int e)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -140,6 +140,7 @@ int id_valid(struct id *id)
|
|||||||
|
|
||||||
for (i = 0; i < ID_LEN; i++)
|
for (i = 0; i < ID_LEN; i++)
|
||||||
if (!_inverse_c[id->uuid[i]]) {
|
if (!_inverse_c[id->uuid[i]]) {
|
||||||
|
if (e)
|
||||||
log_error("UUID contains invalid character '%c'", id->uuid[i]);
|
log_error("UUID contains invalid character '%c'", id->uuid[i]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -147,6 +148,12 @@ int id_valid(struct id *id)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int id_valid(struct id *id)
|
||||||
|
{
|
||||||
|
return _id_valid(id, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int id_equal(const struct id *lhs, const struct id *rhs)
|
int id_equal(const struct id *lhs, const struct id *rhs)
|
||||||
{
|
{
|
||||||
return !memcmp(lhs->uuid, rhs->uuid, sizeof(lhs->uuid));
|
return !memcmp(lhs->uuid, rhs->uuid, sizeof(lhs->uuid));
|
||||||
@ -179,7 +186,7 @@ int id_write_format(const struct id *id, char *buffer, size_t size)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id_read_format(struct id *id, const char *buffer)
|
static int _id_read_format(struct id *id, const char *buffer, int e)
|
||||||
{
|
{
|
||||||
int out = 0;
|
int out = 0;
|
||||||
|
|
||||||
@ -192,6 +199,7 @@ int id_read_format(struct id *id, const char *buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (out >= ID_LEN) {
|
if (out >= ID_LEN) {
|
||||||
|
if (e)
|
||||||
log_error("Too many characters to be uuid.");
|
log_error("Too many characters to be uuid.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -200,12 +208,23 @@ int id_read_format(struct id *id, const char *buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (out != ID_LEN) {
|
if (out != ID_LEN) {
|
||||||
|
if (e)
|
||||||
log_error("Couldn't read uuid: incorrect number of "
|
log_error("Couldn't read uuid: incorrect number of "
|
||||||
"characters.");
|
"characters.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return id_valid(id);
|
return _id_valid(id, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
int id_read_format(struct id *id, const char *buffer)
|
||||||
|
{
|
||||||
|
return _id_read_format(id, buffer, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int id_read_format_try(struct id *id, const char *buffer)
|
||||||
|
{
|
||||||
|
return _id_read_format(id, buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *id_format_and_copy(struct dm_pool *mem, const struct id *id)
|
char *id_format_and_copy(struct dm_pool *mem, const struct id *id)
|
||||||
|
@ -56,6 +56,10 @@ int id_write_format(const struct id *id, char *buffer, size_t size);
|
|||||||
* Reads a formatted uuid.
|
* Reads a formatted uuid.
|
||||||
*/
|
*/
|
||||||
int id_read_format(struct id *id, const char *buffer);
|
int id_read_format(struct id *id, const char *buffer);
|
||||||
|
/*
|
||||||
|
* Tries to read a formatted uuid without logging error for invalid ID
|
||||||
|
*/
|
||||||
|
int id_read_format_try(struct id *id, const char *buffer);
|
||||||
|
|
||||||
char *id_format_and_copy(struct dm_pool *mem, const struct id *id);
|
char *id_format_and_copy(struct dm_pool *mem, const struct id *id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user