A few patches for dmraid
Subsystems (2)
cover A few patches for dmraid
Hi,
following are 4 patches for dmraid, based on the current CVS. Three are extracted from the current openSUSE package. One I added myself while trying to understand how I should arrange for the various shared libraries to be installed.
Thanks,
NeilBrown
PATCH 1/4 Parse "-cc" as required by man page.
This is a bit of a hack but....
The man page says that "-cc" will provide 'CSV' style output. The code only provides this if "-c -c" is given. This hack effectively maps "-cc" to "-c -c".
patch extracted from openSUSE package
From: [email protected]
--- tools/commands.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
tools/commands.c +12 -4
@@ -142,10 +142,18 @@ check_identifiers(struct lib_context *lcconst char delim = *OPT_STR_SEPARATOR (lc);char *p = optarg; - p =remove_white_space (lc, p,strlen (p)); - p =collapse_delimiter (lc, p,strlen (p), delim); -if (!lc_strcat_opt (lc, o, p, delim)) -return 0 ; +if (o ==LC_COLUMN ) { +while (p && *p =='c' ) { +lc_inc_opt (lc, o); + p++; + } + } +if (p && *p) { + p =remove_white_space (lc, p,strlen (p)); + p =collapse_delimiter (lc, p,strlen (p), delim); +if (!lc_strcat_opt (lc, o, p, delim)) +return 0 ; + } }lc_inc_opt (lc, o);
Re: [dmraid 1/4] Parse "-cc" as required by man page.
Neil,
what do you think of the following to handle all such multi-opt cases more generically? Would allow for not neing stuch to just 'c' with future extensions.
Heinz
Index: lib/metadata/metadata.c
===================================================================
RCS file: /cvs/dm/dmraid/lib/metadata/metadata.c,v retrieving revision 1.8
metadata/metadata.c +2 -2
@@ -82,8 +82,8 @@enum args args;/* Arguments allowed ? */ /* Function to call on hit or NULL */ -int (*f_set) (struct lib_context * lc,int arg); -int arg;/* Argument for above function call */ +int (*f_set) (struct lib_context * lc,struct actions *action); +int arg;/* Argument for above function call. */ };/*************************************/
Index: tools/commands.c
===================================================================
RCS file: /cvs/dm/dmraid/tools/commands.c,v
retrieving revision 1.4
commands.c +45 -22
179 lines not on this page · raw message
Index: tools/commands.h
===================================================================
RCS file: /cvs/dm/dmraid/tools/commands.h,v
retrieving revision 1.3
commands.h +2 -2
@@ -33,8 +33,8 @@enum args args;/* Arguments allowed ? */ /* Function to call on hit or NULL */ -int (*f_set) (struct lib_context * lc,int arg); -int arg;/* Argument for above function call */ +int (*f_set) (struct lib_context * lc,struct actions *action); +int arg;/* Argument for above function call. */ };int handle_args (struct lib_context *lc,int argc,char ***argv);
Index: tools/dmraid.c
===================================================================
RCS file: /cvs/dm/dmraid/tools/dmraid.c,v
retrieving revision 1.2
dmraid.c +2 -1
@@ -33,7 +33,8 @@* If both are ok -> perform the required action. */ ret =handle_args (lc, argc, &argv) && -init_locking (lc) &&perform (lc, argv); +init_locking (lc) && +perform (lc, argv);/* Cleanup the library context. */ libdmraid_exit (lc);
Quoted 46 lines · On Thu, 2009-12-17 at 16:44 +1100, [email protected] wrote:
plain text document attachment (dmraid_duplicate_args.patch) This is a bit of a hack but....
The man page says that "-cc" will provide 'CSV' style output. The code only provides this if "-c -c" is given. This hack effectively maps "-cc" to "-c -c".
patch extracted from openSUSE package
From: [email protected]
Signed-off-by NeilBrown <[email protected]>--- tools/commands.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)tools/commands.c +12
-5@@ -142,10 +142,18 @@ check_identifiers(struct lib_context *lcconst char delim = *OPT_STR_SEPARATOR (lc);char *p = optarg; - p =remove_white_space (lc, p,strlen (p)); - p =collapse_delimiter (lc, p,strlen (p), delim); -if (!lc_strcat_opt (lc, o, p, delim)) -return 0 ; +if (o ==LC_COLUMN ) { +while (p && *p =='c' ) { +lc_inc_opt (lc, o); + p++; + } + } +if (p && *p) { + p =remove_white_space (lc, p,strlen (p)); + p =collapse_delimiter (lc, p,strlen (p), delim); +if (!lc_strcat_opt (lc, o, p, delim)) +return 0 ; + } }lc_inc_opt (lc, o); --dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
PATCH 2/4 Avoid fd leak in remove_device_partitions.
In reply to [email protected]As this removes partitions for a list of devices, it could leak a large number of file descriptors.
From: [email protected]
--- lib/device/partition.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/device/partition.c +4 -1
@@ -30,12 +30,15 @@ _remove_subset_partitions(struct lib_con/* There is no way to enumerate partitions */ for (part.pno =1 ; part.pno <=256 ; part.pno++) {if (ioctl (fd,BLKPG , &io) <0 && errno !=ENXIO && - (part.pno <16 || errno !=EINVAL )) + (part.pno <16 || errno !=EINVAL )) { +close (fd);LOG_ERR (lc,0 ,"removing part %d from %s: %s\n" , part.pno, rd->di->path,strerror (errno)); + } } +close (fd); }return 1 ; }
PATCH 3/4 Fix min/max macros
In reply to [email protected]These need parentheses around them.
In particular, in hpt37x.c, in 'to_cpu'
we have an expression:
x + min(y,z)
which will become
x + y > z ? y : z
which is not what is wanted.
From: dmraid-fdleak.patch
--- lib/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/internal.h +2 -2
@@ -50,8 +50,8 @@#define u_int64_t uint64_t#endif -#define min (a, b) (a) < (b) ? (a) : (b) -#define max (a, b) (a) > (b) ? (a) : (b) +#define min (a, b) ((a) < (b) ? (a) : (b)) +#define max (a, b) ((a) > (b) ? (a) : (b))#define ARRAY_SIZE (a) (sizeof(a) / sizeof(*a))#define ARRAY_END (a) (a + ARRAY_SIZE(a))
PATCH 4/4 Fix two issues with installing shared libraries.
In reply to [email protected]1/ the [[ =~ ]] operator only treats the RHS as a regular expression
if it isn't quoted. So we need to remove the quotes.
2/ The libdmraid-event-* library is not a shared library in the regular
sense. i.e. programs are not linked against it and so do not have the library version number encoded in them.
Rather, this is a shared-object that is explicitly loaded by dmeventd on request from dmraid. dmraid asks for "libdmraid-event-ism.so", so that is the only name that the shared object should be stored under. Providing a name with a trailing version number just makes it look like something that it is not.
--- lib/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Makefile.in +1 -1
@@ -82,7 +82,7 @@ install_dmraid_libs: $(INSTALL_TARGETS) for f in $(INSTALL_TARGETS); \ do \ n=$$(basename $${f}) ; \ - if [[ "$$n" =~ '.so$$' ]]; then \ + if [[ "$$n" =~ .so$$ && ! "$$n" =~ libdmraid-events-.* ]]; then \ $(INSTALL) -m 555 $(STRIP) \ $$f $(libdir)/$${n}.@DMRAID_LIB_VERSION@; \ $(LN_S) -f $${n}.@DMRAID_LIB_VERSION@ $(libdir)/$${n}; \