util: Move virIsDevMapperDevice() to virdevmapper.c

When introducing virdevmapper.c (in v4.3.0-rc1~427) I didn't
realize there is a function that calls in devmapper. The function
is called virIsDevMapperDevice() and lives in virutil.c. Now that
we have a special file for handling devmapper move it there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Michal Privoznik 2020-06-11 11:57:14 +02:00
parent e57323ece1
commit dfa0e118f7
7 changed files with 30 additions and 28 deletions

View File

@ -1943,6 +1943,7 @@ virDBusSetSharedBus;
# util/virdevmapper.h # util/virdevmapper.h
virDevMapperGetTargets; virDevMapperGetTargets;
virIsDevMapperDevice;
# util/virdnsmasq.h # util/virdnsmasq.h
@ -3432,7 +3433,6 @@ virGetUserShell;
virHostGetDRMRenderNode; virHostGetDRMRenderNode;
virHostHasIOMMU; virHostHasIOMMU;
virIndexToDiskName; virIndexToDiskName;
virIsDevMapperDevice;
virMemoryLimitIsSet; virMemoryLimitIsSet;
virMemoryLimitTruncate; virMemoryLimitTruncate;
virMemoryMaxValue; virMemoryMaxValue;

View File

@ -36,10 +36,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include "virutil.h"
#include "virfile.h" #include "virfile.h"
#include "virstring.h" #include "virstring.h"
#include "virgettext.h" #include "virgettext.h"
#include "virdevmapper.h"
/* we don't need to include the full internal.h just for this */ /* we don't need to include the full internal.h just for this */
#define STREQ(a, b) (strcmp(a, b) == 0) #define STREQ(a, b) (strcmp(a, b) == 0)

View File

@ -32,6 +32,7 @@
#include "virutil.h" #include "virutil.h"
#include "configmake.h" #include "configmake.h"
#include "virstring.h" #include "virstring.h"
#include "virdevmapper.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE #define VIR_FROM_THIS VIR_FROM_STORAGE

View File

@ -212,3 +212,27 @@ virDevMapperGetTargets(const char *path G_GNUC_UNUSED,
return -1; return -1;
} }
#endif /* ! WITH_DEVMAPPER */ #endif /* ! WITH_DEVMAPPER */
#if WITH_DEVMAPPER
bool
virIsDevMapperDevice(const char *dev_name)
{
struct stat buf;
if (!stat(dev_name, &buf) &&
S_ISBLK(buf.st_mode) &&
dm_is_dm_major(major(buf.st_rdev)))
return true;
return false;
}
#else /* ! WITH_DEVMAPPER */
bool
virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED)
{
return false;
}
#endif /* ! WITH_DEVMAPPER */

View File

@ -25,3 +25,6 @@
int int
virDevMapperGetTargets(const char *path, virDevMapperGetTargets(const char *path,
char ***devPaths) G_GNUC_NO_INLINE; char ***devPaths) G_GNUC_NO_INLINE;
bool
virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);

View File

@ -37,10 +37,6 @@
#include <sys/types.h> #include <sys/types.h>
#if WITH_DEVMAPPER
# include <libdevmapper.h>
#endif
#ifdef HAVE_GETPWUID_R #ifdef HAVE_GETPWUID_R
# include <pwd.h> # include <pwd.h>
# include <grp.h> # include <grp.h>
@ -1340,26 +1336,6 @@ void virWaitForDevices(void)
ignore_value(virCommandRun(cmd, &exitstatus)); ignore_value(virCommandRun(cmd, &exitstatus));
} }
#if WITH_DEVMAPPER
bool
virIsDevMapperDevice(const char *dev_name)
{
struct stat buf;
if (!stat(dev_name, &buf) &&
S_ISBLK(buf.st_mode) &&
dm_is_dm_major(major(buf.st_rdev)))
return true;
return false;
}
#else
bool virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED)
{
return false;
}
#endif
bool bool
virValidateWWN(const char *wwn) virValidateWWN(const char *wwn)
{ {

View File

@ -114,8 +114,6 @@ bool virDoesUserExist(const char *name);
bool virDoesGroupExist(const char *name); bool virDoesGroupExist(const char *name);
bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
bool virValidateWWN(const char *wwn); bool virValidateWWN(const char *wwn);
int virGetDeviceID(const char *path, int virGetDeviceID(const char *path,