[PATCH] Fix name for jm format
Matthias Koenig <[email protected]>
| Newsgroups | gmane.linux.ataraid |
|---|---|
| Organization | SUSE Linux Products GmbH, Nuernberg |
| Message-ID | <[email protected]> |
Hi, this patch fixes a problem with the name of the jm metaformat. The ondisk name is 16 chars with leading spaces if the actual name is shorter and does not have a zero termination. The current code does correctly extract the name: It assumes implicitly a zero termination and also includes the spaces in the name. Matthias _______________________________________________ Ataraid-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/ataraid-list
dmraid-1.0.0.rc13-jm_termination.patch
(text/x-patch, 703 B)
Index: 1.0.0.rc13/lib/format/ataraid/jm.c
===================================================================
--- 1.0.0.rc13.orig/lib/format/ataraid/jm.c
+++ 1.0.0.rc13/lib/format/ataraid/jm.c
@@ -28,10 +28,15 @@ static char *name(struct lib_context *lc
size_t len;
struct jm *jm = META(rd, jm);
char buf[2], *ret, *name = (char *) jm->name;
+ char buf0[JM_NAME_LEN+1] = { '\0' };
+ size_t i = JM_NAME_LEN-1;
- /* Name always 0 terminated ? */
- if ((len = strlen(name)) > JM_NAME_LEN)
- len = JM_NAME_LEN;
+ strncpy(buf0, jm->name, JM_NAME_LEN);
+ while (i!=0 && buf0[i]==' ') {
+ buf0[i]='\0';
+ --i;
+ }
+ len = strlen(buf0);
len += sizeof(HANDLER) + 2;
if (jm->mode == JM_T_RAID01)