#include <signal.h>
#include <sys/wait.h>
#include <sys/utsname.h>
+#include <mntent.h>
#define report_log_ret_code(ret_code) report_current_object_cmdlog(REPORT_OBJECT_CMDLOG_NAME, \
((ret_code) == ECMD_PROCESSED) ? REPORT_OBJECT_CMDLOG_SUCCESS \
bad:
return 0;
}
+
+int get_rootvg_dev_uuid(struct cmd_context *cmd, char **dm_uuid_out)
+{
+ char dm_uuid[DM_UUID_LEN];
+ struct stat info;
+ FILE *fme = NULL;
+ struct mntent *me;
+ int found = 0;
+
+ if (!(fme = setmntent("/etc/mtab", "r")))
+ return_0;
+
+ while ((me = getmntent(fme))) {
+ if ((me->mnt_dir[0] == '/') && (me->mnt_dir[1] == '\0')) {
+ found = 1;
+ break;
+ }
+ }
+ endmntent(fme);
+
+ if (!found)
+ return_0;
+
+ if (stat(me->mnt_dir, &info) < 0)
+ return_0;
+
+ if (!device_get_uuid(cmd, MAJOR(info.st_dev), MINOR(info.st_dev), dm_uuid, sizeof(dm_uuid)))
+ return_0;
+
+ log_debug("Found root dm_uuid %s", dm_uuid);
+
+ /* UUID_PREFIX = "LVM-" */
+ if (strncmp(dm_uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
+ return_0;
+
+ if (strlen(dm_uuid) < sizeof(UUID_PREFIX) - 1 + ID_LEN)
+ return_0;
+
+ *dm_uuid_out = dm_pool_strdup(cmd->mem, dm_uuid);
+
+ return 1;
+}
int get_lvt_enum(struct logical_volume *lv);
+int get_rootvg_dev_uuid(struct cmd_context *cmd, char **dm_uuid_out);
+
#endif
#include "lib/device/device_id.h"
#include "lib/label/hints.h"
#include "device_mapper/misc/dm-ioctl.h"
-#include <mntent.h>
struct vgchange_params {
int lock_start_count;
* ExecStart=/usr/sbin/vgimportdevices --rootvg --auto
* ConditionPathExists=!/etc/lvm/devices/system.devices
*/
-
static void _get_rootvg_dev(struct cmd_context *cmd, char **dm_uuid_out)
{
char path[PATH_MAX];
- char dm_uuid[DM_UUID_LEN];
struct stat info;
- FILE *fme = NULL;
- struct mntent *me;
- int found = 0;
if (cmd->enable_devices_file || devices_file_exists(cmd))
return;
if (stat(path, &info) < 0)
return;
- if (!(fme = setmntent("/etc/mtab", "r")))
- return;
-
- while ((me = getmntent(fme))) {
- if ((me->mnt_dir[0] == '/') && (me->mnt_dir[1] == '\0')) {
- found = 1;
- break;
- }
- }
- endmntent(fme);
-
- if (!found)
- return;
-
- if (stat(me->mnt_dir, &info) < 0)
- return;
-
- if (!device_get_uuid(cmd, MAJOR(info.st_dev), MINOR(info.st_dev), dm_uuid, sizeof(dm_uuid)))
- return;
-
- log_debug("Found root dm_uuid %s", dm_uuid);
-
- /* UUID_PREFIX = "LVM-" */
- if (strncmp(dm_uuid, UUID_PREFIX, 4))
- return;
-
- if (strlen(dm_uuid) < 4 + ID_LEN)
- return;
-
- *dm_uuid_out = dm_pool_strdup(cmd->mem, dm_uuid);
+ if (!get_rootvg_dev_uuid(cmd, dm_uuid_out))
+ stack;
}
static int _vgchange_autoactivation_setup(struct cmd_context *cmd,
#include "lib/activate/activate.h"
/* coverity[unnecessary_header] needed for MuslC */
#include <sys/file.h>
-#include <mntent.h>
struct vgimportdevices_params {
uint32_t added_devices;
static int _get_rootvg_dev(struct cmd_context *cmd, char **dm_uuid_out, int *skip)
{
char path[PATH_MAX];
- char dm_uuid[DM_UUID_LEN];
struct stat info;
- FILE *fme = NULL;
- struct mntent *me;
- int found = 0;
/*
* When --auto is set, the command does nothing
cmd->device_ids_auto_import = 1;
}
- if (!(fme = setmntent("/etc/mtab", "r")))
+ if (!get_rootvg_dev_uuid(cmd, dm_uuid_out))
return_0;
- while ((me = getmntent(fme))) {
- if ((me->mnt_dir[0] == '/') && (me->mnt_dir[1] == '\0')) {
- found = 1;
- break;
- }
- }
- endmntent(fme);
-
- if (!found)
- return_0;
-
- if (stat(me->mnt_dir, &info) < 0)
- return_0;
-
- if (!device_get_uuid(cmd, MAJOR(info.st_dev), MINOR(info.st_dev), dm_uuid, sizeof(dm_uuid)))
- return_0;
-
- /* UUID_PREFIX = "LVM-" */
- if (strncmp(dm_uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
- return_0;
-
- if (strlen(dm_uuid) < sizeof(UUID_PREFIX) - 1 + ID_LEN)
- return_0;
-
- *dm_uuid_out = dm_pool_strdup(cmd->mem, dm_uuid);
return 1;
}