146 lines
3.9 KiB
Diff
146 lines
3.9 KiB
Diff
From 7fcbfd7c620e2dcd3b539d18e93cb503ee3a8a62 Mon Sep 17 00:00:00 2001
|
|
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
Date: Wed, 21 Dec 2022 12:50:17 +0100
|
|
Subject: [PATCH] mdadm: create ident_init()
|
|
|
|
Add a wrapper for repeated initializations in mdadm.c and config.c.
|
|
Move includes up.
|
|
|
|
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
|
|
---
|
|
config.c | 45 +++++++++++++++++++++++++++++----------------
|
|
mdadm.c | 16 ++--------------
|
|
mdadm.h | 7 +++++--
|
|
3 files changed, 36 insertions(+), 32 deletions(-)
|
|
|
|
Index: mdadm-4.2/config.c
|
|
===================================================================
|
|
--- mdadm-4.2.orig/config.c
|
|
+++ mdadm-4.2/config.c
|
|
@@ -119,6 +119,34 @@ int match_keyword(char *word)
|
|
return -1;
|
|
}
|
|
|
|
+/**
|
|
+ * ident_init() - Set defaults.
|
|
+ * @ident: ident pointer, not NULL.
|
|
+ */
|
|
+inline void ident_init(struct mddev_ident *ident)
|
|
+{
|
|
+ assert(ident);
|
|
+
|
|
+ ident->assembled = false;
|
|
+ ident->autof = 0;
|
|
+ ident->bitmap_fd = -1;
|
|
+ ident->bitmap_file = NULL;
|
|
+ ident->container = NULL;
|
|
+ ident->devices = NULL;
|
|
+ ident->devname = NULL;
|
|
+ ident->level = UnSet;
|
|
+ ident->member = NULL;
|
|
+ ident->name[0] = 0;
|
|
+ ident->next = NULL;
|
|
+ ident->raid_disks = UnSet;
|
|
+ ident->spare_group = NULL;
|
|
+ ident->spare_disks = 0;
|
|
+ ident->st = NULL;
|
|
+ ident->super_minor = UnSet;
|
|
+ ident->uuid[0] = 0;
|
|
+ ident->uuid_set = 0;
|
|
+}
|
|
+
|
|
struct conf_dev {
|
|
struct conf_dev *next;
|
|
char *name;
|
|
@@ -363,22 +391,7 @@ void arrayline(char *line)
|
|
struct mddev_ident mis;
|
|
struct mddev_ident *mi;
|
|
|
|
- mis.uuid_set = 0;
|
|
- mis.super_minor = UnSet;
|
|
- mis.level = UnSet;
|
|
- mis.raid_disks = UnSet;
|
|
- mis.spare_disks = 0;
|
|
- mis.devices = NULL;
|
|
- mis.devname = NULL;
|
|
- mis.spare_group = NULL;
|
|
- mis.autof = 0;
|
|
- mis.next = NULL;
|
|
- mis.st = NULL;
|
|
- mis.bitmap_fd = -1;
|
|
- mis.bitmap_file = NULL;
|
|
- mis.name[0] = 0;
|
|
- mis.container = NULL;
|
|
- mis.member = NULL;
|
|
+ ident_init(&mis);
|
|
|
|
for (w = dl_next(line); w != line; w = dl_next(w)) {
|
|
if (w[0] == '/' || strchr(w, '=') == NULL) {
|
|
Index: mdadm-4.2/mdadm.c
|
|
===================================================================
|
|
--- mdadm-4.2.orig/mdadm.c
|
|
+++ mdadm-4.2/mdadm.c
|
|
@@ -107,25 +107,13 @@ int main(int argc, char *argv[])
|
|
|
|
srandom(time(0) ^ getpid());
|
|
|
|
- ident.uuid_set = 0;
|
|
- ident.level = UnSet;
|
|
- ident.raid_disks = UnSet;
|
|
- ident.super_minor = UnSet;
|
|
- ident.devices = 0;
|
|
- ident.spare_group = NULL;
|
|
- ident.autof = 0;
|
|
- ident.st = NULL;
|
|
- ident.bitmap_fd = -1;
|
|
- ident.bitmap_file = NULL;
|
|
- ident.name[0] = 0;
|
|
- ident.container = NULL;
|
|
- ident.member = NULL;
|
|
-
|
|
if (get_linux_version() < 2006015) {
|
|
pr_err("This version of mdadm does not support kernels older than 2.6.15\n");
|
|
exit(1);
|
|
}
|
|
|
|
+ ident_init(&ident);
|
|
+
|
|
while ((option_index = -1),
|
|
(opt = getopt_long(argc, argv, shortopt, long_options,
|
|
&option_index)) != -1) {
|
|
Index: mdadm-4.2/mdadm.h
|
|
===================================================================
|
|
--- mdadm-4.2.orig/mdadm.h
|
|
+++ mdadm-4.2/mdadm.h
|
|
@@ -33,8 +33,10 @@ extern __off64_t lseek64 __P ((int __fd,
|
|
# endif
|
|
#endif
|
|
|
|
+#include <assert.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
+#include <stdarg.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
@@ -1554,6 +1556,8 @@ extern void enable_fds(int devices);
|
|
extern void manage_fork_fds(int close_all);
|
|
extern int continue_via_systemd(char *devnm, char *service_name, char *prefix);
|
|
|
|
+extern void ident_init(struct mddev_ident *ident);
|
|
+
|
|
extern int parse_auto(char *str, char *msg, int config);
|
|
extern struct mddev_ident *conf_get_ident(char *dev);
|
|
extern struct mddev_dev *conf_get_devs(void);
|
|
@@ -1781,8 +1785,7 @@ static inline sighandler_t signal_s(int
|
|
#define dprintf_cont(fmt, arg...) \
|
|
({ if (0) fprintf(stderr, fmt, ##arg); 0; })
|
|
#endif
|
|
-#include <assert.h>
|
|
-#include <stdarg.h>
|
|
+
|
|
static inline int xasprintf(char **strp, const char *fmt, ...) {
|
|
va_list ap;
|
|
int ret;
|