mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl_helper.device-mapper: Fix imprecise is_device_mapper() predicate
Fix is_device_mapper() predicate to not base on checking a hardcoded major number (253), which not always correct, since on some systems dm-devices have different majors". Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
6d7cdb9e10
commit
34a5e47508
@@ -31,6 +31,7 @@ struct util_proc_dev_entry {
|
||||
#define UTIL_PROC_DEV_ENTRY_SD "sd"
|
||||
#define UTIL_PROC_DEV_ENTRY_BLKEXT "blkext"
|
||||
#define UTIL_PROC_DEV_ENTRY_MD "md"
|
||||
#define UTIL_PROC_DEV_ENTRY_DM "device-mapper"
|
||||
|
||||
int util_proc_part_get_entry(dev_t device, struct util_proc_part_entry *entry);
|
||||
void util_proc_part_free_entry(struct util_proc_part_entry *entry);
|
||||
|
||||
@@ -58,6 +58,7 @@ int misc_check_writable_device(const char* devno, int blockdev, int chardev);
|
||||
void misc_ebcdic_to_ascii(unsigned char *from, unsigned char *to);
|
||||
void misc_ascii_to_ebcdic(unsigned char *from, unsigned char *to);
|
||||
unsigned int misc_check_secure_boot(void);
|
||||
void misc_warn_on_failed_pdge(dev_t device);
|
||||
|
||||
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||
#endif /* not MISC_H */
|
||||
|
||||
+1
-4
@@ -509,10 +509,7 @@ static void set_driver_name(int fd, struct disk_info *info, dev_t device)
|
||||
info->drv_name = misc_strdup(dev_entry.name);
|
||||
util_proc_dev_free_entry(&dev_entry);
|
||||
} else {
|
||||
fprintf(stderr, "Warning: Could not determine driver name for "
|
||||
"major %d from /proc/devices\n", major(device));
|
||||
fprintf(stderr, "Warning: Preparing a logical device for boot "
|
||||
"might fail\n");
|
||||
misc_warn_on_failed_pdge(device);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-1
@@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "error.h"
|
||||
@@ -662,4 +663,14 @@ void misc_ascii_to_ebcdic(unsigned char *from, unsigned char *to)
|
||||
*from = ascebc[*from];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* zipl-specific response on failed util_proc_dev_get_entry()
|
||||
*/
|
||||
void misc_warn_on_failed_pdge(dev_t device)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Warning: Could not determine driver name for major %d from /proc/devices\n",
|
||||
major(device));
|
||||
fprintf(stderr,
|
||||
"Warning: Preparing a logical device for boot might fail\n");
|
||||
}
|
||||
|
||||
@@ -180,7 +180,6 @@ struct helper {
|
||||
#define SCSI_PARTN_MASK 0x0f
|
||||
|
||||
#define MD_MAJOR 9
|
||||
#define DEVICE_MAPPER_MAJOR 253
|
||||
|
||||
/* Internal constants */
|
||||
enum dev_type {
|
||||
@@ -231,9 +230,19 @@ static int error_on(const char *state, const char *this, const char *fixup,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_device_mapper(unsigned int major)
|
||||
static int is_device_mapper(dev_t device)
|
||||
{
|
||||
return major == DEVICE_MAPPER_MAJOR;
|
||||
struct util_proc_dev_entry pde;
|
||||
int result = 0;
|
||||
|
||||
if (util_proc_dev_get_entry(device, 1, &pde) == 0) {
|
||||
if (strcmp(pde.name, UTIL_PROC_DEV_ENTRY_DM) == 0)
|
||||
result = 1;
|
||||
util_proc_dev_free_entry(&pde);
|
||||
} else {
|
||||
misc_warn_on_failed_pdge(device);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void get_type_name(char *name, unsigned short type)
|
||||
@@ -1705,7 +1714,7 @@ static int md_mirror_to_params(unsigned int major, unsigned int minor,
|
||||
ERR("Unsupported configuration: nested md devices\n");
|
||||
return -1;
|
||||
}
|
||||
if (is_device_mapper(major)) {
|
||||
if (is_device_mapper(dev)) {
|
||||
struct ext_dev xdev = {dev, data_start_md + fs_start_md};
|
||||
char *name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user