* small patches to mdadm
@ 2004-08-25 7:22 Luca Berra
[not found] ` <16686.39118.516906.365004@cse.unsw.edu.au>
0 siblings, 1 reply; 3+ messages in thread
From: Luca Berra @ 2004-08-25 7:22 UTC (permalink / raw)
To: Neil Brown; +Cc: linux raid
[-- Attachment #1: Type: text/plain, Size: 449 bytes --]
Neil,
i made some small patches to mdadm 1.7.0
the first is just some makefile cleanup
the second adds a -i (pid) option to monitor mode which causes mdadm to
write its own pid to the specified file, this comes useful to simplify
init scripts that call mdadm --monitor --daemonize.
Regards,
L.
--
Luca Berra -- bluca@comedia.it
Communication Media & Services S.r.l.
/"\
\ / ASCII RIBBON CAMPAIGN
X AGAINST HTML MAIL
/ \
[-- Attachment #2: mdadm-1.7.0-makefile.patch --]
[-- Type: text/plain, Size: 2983 bytes --]
--- mdadm-1.7.0/Makefile.makefile 2004-08-11 03:28:50.000000000 +0200
+++ mdadm-1.7.0/Makefile 2004-08-25 09:17:36.993441628 +0200
@@ -31,6 +31,11 @@
# e.g. make CXFLAGS=-O to optimise
TCC = tcc
UCLIBC_GCC = $(shell for nm in i386-uclibc-linux-gcc i386-uclibc-gcc; do which $$nm > /dev/null && { echo $$nm ; exit; } ; done; echo false No uclibc found )
+DIET_GCC = diet gcc
+
+KLIBC=/home/src/klibc/klibc-0.77
+
+KLIBC_GCC = gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32
CC = gcc
CXFLAGS = -ggdb
@@ -52,11 +57,9 @@
MAN5DIR = $(MANDIR)/man5
MAN8DIR = $(MANDIR)/man8
-
-KLIBC=/home/src/klibc/klibc-0.77
-
OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o
SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c
+ASSEMBLE_SRCS = mdassemble.c Assemble.c config.c dlink.c util.c
all : mdadm mdadm.man md.man mdadm.conf.man
@@ -66,7 +69,7 @@
$(CC) $(LDFLAGS) -o mdadm $^
mdadm.static : $(OBJS)
- $(CC) $(LDFLAGS) --static -o mdadm.static $^
+ $(CC) $(LDFLAGS) -static -o mdadm.static $^
mdadm.tcc : $(SRCS) mdadm.h
$(TCC) -o mdadm.tcc $(SRCS)
@@ -78,15 +81,22 @@
rm -f $(OBJS)
gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
-mdassemble : mdassemble.c Assemble.c config.c dlink.c util.c mdadm.h
+mdassemble : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
- diet gcc -o mdassemble mdassemble.c Assemble.c config.c dlink.c util.c
+ $(DIET_GCC) -o mdassemble $(ASSEMBLE_SRCS)
-# This doesn't work
-mdassemble.klibc : mdassemble.c Assemble.c config.c dlink.c util.c mdadm.h
+mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
+ rm -f $(OBJS)
+ $(CC) $(LDFLAGS) -static -o mdassemble $(ASSEMBLE_SRCS)
+
+mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
- gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) -o mdassemble mdassemble.c Assemble.c config.c dlink.c util.c
+ $(UCLIBC_GCC) -DUCLIBC -static -o mdassemble.uclibc $(ASSEMBLE_SRCS)
+# This doesn't work
+mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
+ rm -f $(OBJS)
+ $(KLIBC_GCC) $(CFLAGS) -o mdassemble $(ASSEMBLE_SRCS)
mdadm.man : mdadm.8
nroff -man mdadm.8 > mdadm.man
@@ -106,7 +116,8 @@
$(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
clean :
- rm -f mdadm $(OBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt
+ rm -f mdadm $(OBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
+ mdassemble mdassemble.static mdassemble.uclibc mdassemble.klibc
dist : clean
./makedist
[-- Attachment #3: mdadm-1.7.0-pidfile.patch --]
[-- Type: text/plain, Size: 3877 bytes --]
--- mdadm-1.7.0/ReadMe.c.pidfile 2004-08-11 04:05:15.000000000 +0200
+++ mdadm-1.7.0/ReadMe.c 2004-08-25 07:59:23.224003584 +0200
@@ -90,7 +90,7 @@
* At the time if writing, there is only minimal support.
*/
-char short_options[]="-ABCDEFGQhVvbc:l:p:m:n:x:u:c:d:z:U:sa::rfRSow1t";
+char short_options[]="-ABCDEFGQhVvbc:i:l:p:m:n:x:u:c:d:z:U:sa::rfRSow1t";
struct option long_options[] = {
{"manage", 0, 0, '@'},
{"misc", 0, 0, '#'},
@@ -157,6 +157,7 @@
{"daemonise", 0, 0, 'f'},
{"daemonize", 0, 0, 'f'},
{"oneshot", 0, 0, '1'},
+ {"pid", 1, 0, 'i'},
{0, 0, 0, 0}
};
@@ -418,6 +419,7 @@
" --config= -c : specify a different config file\n"
" --scan -s : find mail-address/program in config file\n"
" --daemonise -f : Fork and continue in child, parent exits\n"
+" --pid= -i : In daemon mode write pid to specified file instead of stdout\n"
" --oneshot -1 : Check for degraded arrays, then exit\n"
" --test -t : Generate a TestMessage event against each array at startup\n"
;
--- mdadm-1.7.0/Monitor.c.pidfile 2004-08-11 03:52:40.000000000 +0200
+++ mdadm-1.7.0/Monitor.c 2004-08-25 08:25:14.554960895 +0200
@@ -47,7 +47,7 @@
int Monitor(mddev_dev_t devlist,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,
- char *config, int test)
+ char *config, int test, char* pidfile)
{
/*
* Every few seconds, scan every md device looking for changes
@@ -127,7 +127,18 @@
if (daemonise) {
int pid = fork();
if (pid > 0) {
- printf("%d\n", pid);
+ if (!pidfile)
+ printf("%d\n", pid);
+ else {
+ FILE *pid_file;
+ pid_file=fopen(pidfile, "w");
+ if (!pid_file)
+ perror("cannot create pid file");
+ else {
+ fprintf(pid_file,"%d\n", pid);
+ fclose(pid_file);
+ }
+ }
return 0;
}
if (pid < 0) {
@@ -428,6 +439,8 @@
}
test = 0;
}
+ if (pidfile)
+ unlink(pidfile);
return 0;
}
--- mdadm-1.7.0/mdadm.c.pidfile 2004-08-11 03:35:16.000000000 +0200
+++ mdadm-1.7.0/mdadm.c 2004-08-25 07:59:23.226003626 +0200
@@ -233,6 +233,7 @@
char *program = NULL;
int delay = 0;
int daemonise = 0;
+ char *pidfile = NULL;
int oneshot = 0;
int copies;
@@ -677,6 +678,13 @@
case O(MONITOR,'f'): /* daemonise */
daemonise = 1;
continue;
+ case O(MONITOR,'i'): /* pid */
+ if (pidfile)
+ fprintf(stderr, Name ": only specify one pid file. %s ignored.\n",
+ optarg);
+ else
+ pidfile = optarg;
+ continue;
case O(MONITOR,'1'): /* oneshot */
oneshot = 1;
continue;
@@ -963,8 +971,13 @@
rv = 1;
break;
}
+ if (pidfile && !daemonise) {
+ fprintf(stderr, Name ": Cannot write a pid file when not in daemon mode\n");
+ rv = 1;
+ break;
+ }
rv= Monitor(devlist, mailaddr, program,
- delay?delay:60, daemonise, scan, oneshot, configfile, test);
+ delay?delay:60, daemonise, scan, oneshot, configfile, test, pidfile);
break;
case GROW:
--- mdadm-1.7.0/mdadm.h.pidfile 2004-08-11 03:28:50.000000000 +0200
+++ mdadm-1.7.0/mdadm.h 2004-08-25 07:59:23.227003647 +0200
@@ -187,7 +187,7 @@
extern int Monitor(mddev_dev_t devlist,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,
- char *config, int test);
+ char *config, int test, char *pidfile);
extern int Kill(char *dev, int force);
--- mdadm-1.7.0/mdadm.8.pidfile 2004-08-11 04:05:28.000000000 +0200
+++ mdadm-1.7.0/mdadm.8 2004-08-25 08:11:28.142831013 +0200
@@ -540,6 +540,13 @@
is found in the config file.
.TP
+.BR -i ", " --pid
+When
+.B mdadm
+is running in daemon mode, write the pid of the daemon process to
+the specified file, instead of printing it on standard output.
+
+.TP
.BR -1 ", " --oneshot
Check arrays only once. This will generate
.B NewArray
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: small patches to mdadm
[not found] ` <16686.39118.516906.365004@cse.unsw.edu.au>
@ 2004-08-30 13:09 ` Luca Berra
2004-09-06 4:47 ` Neil Brown
0 siblings, 1 reply; 3+ messages in thread
From: Luca Berra @ 2004-08-30 13:09 UTC (permalink / raw)
To: Neil Brown; +Cc: linux raid
[-- Attachment #1: Type: text/plain, Size: 456 bytes --]
On Fri, Aug 27, 2004 at 12:13:34PM +1000, Neil Brown wrote:
>They'll both be in the next release.
thanks a lot!
here is another patch for mdassemble.
1) add raid6 and raid10
2) add support for the auto=... option.
the auto= can be disabled in the Makefile, allowing users to save about
5k (on x86).
L.
--
Luca Berra -- bluca@comedia.it
Communication Media & Services S.r.l.
/"\
\ / ASCII RIBBON CAMPAIGN
X AGAINST HTML MAIL
/ \
[-- Attachment #2: mdadm-1.7.0-mdassemble.patch --]
[-- Type: text/plain, Size: 2926 bytes --]
--- mdadm-1.7.0/mdadm.c.mdassemble 2004-08-29 11:35:31.986605997 +0200
+++ mdadm-1.7.0/mdadm.c 2004-08-29 11:35:31.991606047 +0200
@@ -193,7 +193,7 @@
}
-
+#ifndef MDASSEMBLE_AUTO
int main(int argc, char *argv[])
{
int mode = 0;
@@ -1004,3 +1004,4 @@
}
exit(rv);
}
+#endif /* MDASSEMBLE_AUTO */
--- mdadm-1.7.0/mdassemble.c.mdassemble 2004-08-11 03:28:50.000000000 +0200
+++ mdadm-1.7.0/mdassemble.c 2004-08-29 11:35:31.992606057 +0200
@@ -46,11 +46,15 @@
{ "5", 5},
{ "multipath", -4},
{ "mp", -4},
+ { "raid6", 6},
+ { "6", 6},
+ { "raid10", 10},
+ { "10", 10},
{ NULL, 0}
};
-/* from mdadm.c */
-int open_mddev(char *dev)
+#ifndef MDASSEMBLE_AUTO
+int open_mddev(char *dev, int autof /*ignored*/)
{
int mdfd = open(dev, O_RDWR, 0);
if (mdfd < 0)
@@ -64,6 +68,10 @@
}
return mdfd;
}
+#else
+#include "mdstat.c"
+#include "mdadm.c"
+#endif
char *configfile = NULL;
int rv;
@@ -81,7 +89,7 @@
} else
for (; array_list; array_list = array_list->next) {
mdu_array_info_t array;
- mdfd = open_mddev(array_list->devname);
+ mdfd = open_mddev(array_list->devname, array_list->autof);
if (mdfd < 0) {
rv |= 1;
continue;
--- mdadm-1.7.0/Makefile.mdassemble 2004-08-29 11:35:31.980605936 +0200
+++ mdadm-1.7.0/Makefile 2004-08-29 11:35:31.993606067 +0200
@@ -44,6 +44,8 @@
CONFFILE = $(SYSCONFDIR)/mdadm.conf
MAILCMD =/usr/sbin/sendmail -t
CFLAGS = $(CWFLAGS) -DCONFFILE=\"$(CONFFILE)\" $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\"
+# build mdassemble with support for auto=
+ASSEMBLE_FLAGS=-DMDASSEMBLE_AUTO
# If you want a static binary, you might uncomment these
# LDFLAGS = -static
@@ -83,20 +85,20 @@
mdassemble : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
- $(DIET_GCC) -o mdassemble $(ASSEMBLE_SRCS)
+ $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
- $(CC) $(LDFLAGS) -static -o mdassemble $(ASSEMBLE_SRCS)
+ $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -o mdassemble $(ASSEMBLE_SRCS)
mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
- $(UCLIBC_GCC) -DUCLIBC -static -o mdassemble.uclibc $(ASSEMBLE_SRCS)
+ $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -static -o mdassemble.uclibc $(ASSEMBLE_SRCS)
# This doesn't work
mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
- $(KLIBC_GCC) $(CFLAGS) -o mdassemble $(ASSEMBLE_SRCS)
+ $(KLIBC_GCC) $(CFLAGS) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
mdadm.man : mdadm.8
nroff -man mdadm.8 > mdadm.man
--- mdadm-1.7.0/mdadm.h.mdassemble 2004-08-29 11:35:31.987606007 +0200
+++ mdadm-1.7.0/mdadm.h 2004-08-29 11:35:31.993606067 +0200
@@ -27,6 +27,8 @@
* Australia
*/
+#ifndef _MDADM_H
+#define _MDADM_H 1
#define __USE_LARGEFILE64
#include <unistd.h>
#ifndef __dietlibc__
@@ -227,3 +229,4 @@
extern char *get_md_name(int dev);
extern char DefaultConfFile[];
+#endif /* _MDADM_H */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: small patches to mdadm
2004-08-30 13:09 ` Luca Berra
@ 2004-09-06 4:47 ` Neil Brown
0 siblings, 0 replies; 3+ messages in thread
From: Neil Brown @ 2004-09-06 4:47 UTC (permalink / raw)
To: Luca Berra; +Cc: linux raid
On Monday August 30, bluca@comedia.it wrote:
> On Fri, Aug 27, 2004 at 12:13:34PM +1000, Neil Brown wrote:
> >They'll both be in the next release.
> thanks a lot!
> here is another patch for mdassemble.
> 1) add raid6 and raid10
> 2) add support for the auto=... option.
> the auto= can be disabled in the Makefile, allowing users to save about
> 5k (on x86).
Thanks.
I redid the auto= stuff. I moved mddev_open into a separate file.
It'll be in the next mdadm.
NeilBrown
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-09-06 4:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-25 7:22 small patches to mdadm Luca Berra
[not found] ` <16686.39118.516906.365004@cse.unsw.edu.au>
2004-08-30 13:09 ` Luca Berra
2004-09-06 4:47 ` Neil Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).