small patches to mdadm

--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline

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 [at] comedia.it
Communication Media & Services S.r.l.
/"\
\ / ASCII RIBBON CAMPAIGN
X AGAINST HTML MAIL
/ \

--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mdadm-1.7.0-makefile.patch"

--- 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
[at] [at] -31,6 +31,11 [at] [at]
# 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
[at] [at] -52,11 +57,9 [at] [at]
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

[at] [at] -66,7 +69,7 [at] [at]
$(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)
[at] [at] -78,15 +81,22 [at] [at]
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
[at] [at] -106,7 +116,8 [at] [at]
$(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

--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mdadm-1.7.0-pidfile.patch"

--- 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
[at] [at] -90,7 +90,7 [at] [at]
* 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::rfRS ow1t";
+char short_options[]="-ABCDEFGQhVvbc:i:l:p:m:n:x:u:c:d:z:U:sa::rf RSow1t";
struct option long_options[] = {
{"manage", 0, 0, ' [at] '},
{"misc", 0, 0, '#'},
[at] [at] -157,6 +157,7 [at] [at]
{"daemonise", 0, 0, 'f'},
{"daemonize", 0, 0, 'f'},
{"oneshot", 0, 0, '1'},
+ {"pid", 1, 0, 'i'},

{0, 0, 0, 0}
};
[at] [at] -418,6 +419,7 [at] [at]
" --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
[at] [at] -47,7 +47,7 [at] [at]
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
[at] [at] -127,7 +127,18 [at] [at]
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) {
[at] [at] -428,6 +439,8 [at] [at]
}
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
[at] [at] -233,6 +233,7 [at] [at]
char *program = NULL;
int delay = 0;
int daemonise = 0;
+ char *pidfile = NULL;
int oneshot = 0;

int copies;
[at] [at] -677,6 +678,13 [at] [at]
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;
[at] [at] -963,8 +971,13 [at] [at]
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
[at] [at] -187,7 +187,7 [at] [at]
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
[at] [at] -540,6 +540,13 [at] [at]
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

--/04w6evG8XlLl3ft--
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Luca Berra [ Mi, 25 August 2004 09:22 ] [ ID #90497 ]

Re: small patches to mdadm

--U+BazGySraz5kW0T
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline

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 [at] comedia.it
Communication Media & Services S.r.l.
/"\
\ / ASCII RIBBON CAMPAIGN
X AGAINST HTML MAIL
/ \

--U+BazGySraz5kW0T
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mdadm-1.7.0-mdassemble.patch"

--- 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
[at] [at] -193,7 +193,7 [at] [at]
}


-
+#ifndef MDASSEMBLE_AUTO
int main(int argc, char *argv[])
{
int mode = 0;
[at] [at] -1004,3 +1004,4 [at] [at]
}
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
[at] [at] -46,11 +46,15 [at] [at]
{ "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)
[at] [at] -64,6 +68,10 [at] [at]
}
return mdfd;
}
+#else
+#include "mdstat.c"
+#include "mdadm.c"
+#endif

char *configfile = NULL;
int rv;
[at] [at] -81,7 +89,7 [at] [at]
} 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
[at] [at] -44,6 +44,8 [at] [at]
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
[at] [at] -83,20 +85,20 [at] [at]

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
[at] [at] -27,6 +27,8 [at] [at]
* Australia
*/

+#ifndef _MDADM_H
+#define _MDADM_H 1
#define __USE_LARGEFILE64
#include <unistd.h>
#ifndef __dietlibc__
[at] [at] -227,3 +229,4 [at] [at]
extern char *get_md_name(int dev);

extern char DefaultConfFile[];
+#endif /* _MDADM_H */

--U+BazGySraz5kW0T--
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Luca Berra [ Mo, 30 August 2004 15:09 ] [ ID #90548 ]

Re: small patches to mdadm

On Monday August 30, bluca [at] 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
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Neil Brown [ Mo, 06 September 2004 06:47 ] [ ID #90623 ]
Linux » gmane.linux.raid » small patches to mdadm

Vorheriges Thema: [PATCH md 0 of 2] Introduction
Nächstes Thema: filesystem corruption with RAID6.