Initial commit

This commit is contained in:
domenico
2025-06-24 15:51:28 +02:00
commit 22031d9dab
6862 changed files with 1462554 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
#
# Copyright (C) 2008-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=mdadm
PKG_VERSION:=4.0
PKG_RELEASE:=4
PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_HASH:=1d6ae7f24ced3a0fa7b5613b32f4a589bb4881e3946a5a2c3724056254ada3a9
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/mdadm
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=Disc
TITLE:=A tool for managing Soft RAID under Linux
URL:=http://www.kernel.org/pub/linux/utils/raid/mdadm/
DEPENDS:=+libpthread +kmod-md-mod +kmod-md-raid0 +kmod-md-raid10 +kmod-md-raid1
endef
define Package/mdadm/description
A tool for managing Linux Software RAID arrays.
RAID 0, 1 and 10 support included.
If you need RAID 4,5 or 6 functionality please
install kmod-md-raid456 .
endef
define Package/mdadm/conffiles
/etc/config/mdadm
endef
TARGET_CFLAGS += \
-ffunction-sections -fdata-sections \
-DHAVE_STDINT_H -DNO_COROSYNC -DNO_DLM -DUSE_PTHREADS \
-DCONFFILE='\"/var/etc/mdadm.conf\"' \
-DMAP_DIR='\"/var/run/mdadm\"' \
-DMDMON_DIR='\"/var/run/mdadm\"' \
-DFAILED_SLOTS_DIR='\"/var/run/mdadm/failed-slots\"'
TARGET_LDFLAGS += -Wl,--gc-sections
MAKE_VARS += CHECK_RUN_DIR=0
define Build/Compile
$(call Build/Compile/Default,mdadm)
endef
define Package/mdadm/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mdadm $(1)/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/mdadm.init $(1)/etc/init.d/mdadm
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/mdadm.config $(1)/etc/config/mdadm
endef
$(eval $(call BuildPackage,mdadm))

View File

@@ -0,0 +1,18 @@
config mdadm
option email root
# list devices /dev/hd*
# list devices /dev/sd*
# list devices partitions
config array
option uuid 52c5c44a:d2162820:f75d3464:799750f8
option device /dev/md0
# option name raid:0
# option super_minor 0
# list devices /dev/sda1
# list devices /dev/sdb1
# option spares 0
# option spare_group spares
# option bitmap /bitmap.md
# option container 00000000:00000000:00000000:00000000
# option member 1

View File

@@ -0,0 +1,93 @@
#!/bin/sh /etc/rc.common
START=13
STOP=98
USE_PROCD=1
PROG=/sbin/mdadm
NAME=mdadm
CONF="/var/etc/mdadm.conf"
append_list_item() {
append "$2" "$1" "$3"
}
append_option() {
local var="$1"
local cfg="$2"
local opt="$3"
local name="$4"
local sep="$5"
local str
if [ -n "$sep" ]; then
config_list_foreach "$cfg" "$opt" append_list_item str "$sep"
else
config_get str "$cfg" "$opt"
fi
[ -n "$str" ] && append "$var" $(printf "%s=%s" "${name:-${opt//_/-}}" "$str")
}
mdadm_common() {
local cfg="$1"
local email devices
if [ -x /usr/sbin/sendmail ]; then
config_get email "$cfg" email
[ -n "$email" ] && printf "MAILADDR %s\n" "$email" >> $CONF
fi
config_list_foreach "$cfg" devices append_list_item devices " "
[ -n "$devices" ] && printf "DEVICE %s\n" "$devices" >> $CONF
}
mdadm_array() {
local cfg="$1"
local uuid device devices name array
config_get uuid "$cfg" uuid
config_get name "$cfg" name
config_get device "$cfg" device
if [ -z "$device" ] || [ -z "$uuid$name" ]; then
echo "Skipping array without device, uuid or name" >&2
return
fi
[ -n "$uuid" ] && append array "uuid=$uuid"
[ -n "$name" ] && append array "name=$name"
append_option array "$cfg" super_minor
append_option array "$cfg" spares
append_option array "$cfg" spare_group
append_option array "$cfg" bitmap
append_option array "$cfg" container
append_option array "$cfg" member
append_option array "$cfg" devices devices ","
printf "ARRAY %s %s\n" "$device" "$array" >> $CONF
}
start_service() {
local email
mkdir -p "${CONF%/*}"
printf "# Autogenerated from /etc/config/mdadm, do not edit!\n" > $CONF
config_load mdadm
config_foreach mdadm_common mdadm
config_foreach mdadm_array array
$PROG --assemble --scan --config="$CONF"
procd_open_instance
procd_set_param command "$PROG" --monitor --syslog --scan --config="$CONF"
procd_close_instance
}
stop_service() {
$PROG --stop --scan
}

View File

@@ -0,0 +1,11 @@
--- a/Makefile
+++ b/Makefile
@@ -86,7 +86,7 @@ DLM:=$(shell [ -f /usr/include/libdlm.h
DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\"
DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\"
DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\"
-CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS) $(COROSYNC) $(DLM)
+# CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS) $(COROSYNC) $(DLM)
VERSION = $(shell [ -d .git ] && git describe HEAD | sed 's/mdadm-//')
VERS_DATE = $(shell [ -d .git ] && date --date="`git log -n1 --format=format:%cd --date=short`" '+%0dth %B %Y' | sed -e 's/1th/1st/' -e 's/2th/2nd/' -e 's/11st/11th/' -e 's/12nd/12th/')

View File

@@ -0,0 +1,38 @@
From 6d369e8f226594632ce4260129509daf7030de0a Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 9 May 2016 22:03:57 +0000
Subject: [PATCH] mdadm.h: Undefine dprintf before redefining
dprintf is also defined in libc see
usr/include/bits/stdio2.h, this comes into
play especially when fortify sources is enabled
and compilers like clang reports the override
In file included from policy.c:25:
./mdadm.h:1562:9: error: 'dprintf' macro redefined [-Werror,-Wmacro-redefined]
^
/mnt/oe/openembedded-core/build/tmp-glibc/sysroots/qemux86/usr/include/bits/stdio2.h:145:12: note: previous definition is here
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
mdadm.h | 2 ++
1 file changed, 2 insertions(+)
--- a/mdadm.h
+++ b/mdadm.h
@@ -1595,11 +1595,13 @@ static inline char *to_subarray(struct m
}
#ifdef DEBUG
+#undef dprintf
#define dprintf(fmt, arg...) \
fprintf(stderr, "%s: %s: "fmt, Name, __func__, ##arg)
#define dprintf_cont(fmt, arg...) \
fprintf(stderr, fmt, ##arg)
#else
+#undef dprintf
#define dprintf(fmt, arg...) \
({ if (0) fprintf(stderr, "%s: %s: " fmt, Name, __func__, ##arg); 0; })
#define dprintf_cont(fmt, arg...) \

View File

@@ -0,0 +1,25 @@
--- a/Incremental.c
+++ b/Incremental.c
@@ -1642,6 +1642,10 @@ static int Incremental_container(struct
if (ra_all == ra_blocked)
return 0;
+#ifndef MDADM_FULL
+ return 0;
+#endif
+
/* Now move all suitable spares from spare container */
domains = domain_from_array(list, st->ss->name);
memcpy(suuid, uuid_zero, sizeof(int[4]));
--- a/util.c
+++ b/util.c
@@ -1151,7 +1151,9 @@ void wait_for(char *dev, int fd)
struct superswitch *superlist[] =
{
&super0, &super1,
+#ifdef MDADM_FULL
&super_ddf, &super_imsm,
+#endif
&mbr, &gpt,
NULL };