Skip to contentSkip to conversation

gfs2_edit: Fix savemeta compression for older zlibs

PATCH New Andrew Price 2 participants 2 messages Jun 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2_edit: Fix savemeta compression for older zlibs

gzdopen in zlib 1.2.3 parses the mode string in a different way to subsequent versions and the mode string we use causes the older gzwrite to fail with EBADF. This patch fixes the mode string so that the gzwrites succeed with the old and new zlibs.

rhbz#702313

---
 gfs2/edit/savemeta.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
gfs2/edit/savemeta.c +2 -2
index cb7e243..160277c 100644
@@ -209,7 +209,7 @@ static void warm_fuzzy_stuff(uint64_t wfsblock, int force)
 static struct metafd savemetaopen(char *out_fn, int gziplevel)
 {
 	struct metafd mfd;
-	char gzmode[5] = "rwb9";
+	char gzmode[3] = "w9";
 	char dft_fn[] = DFT_SAVE_FILE;
 
 	if (!out_fn) {
@@ -232,7 +232,7 @@ static struct metafd savemetaopen(char *out_fn, int gziplevel)
 
 	mfd.gziplevel = gziplevel;
 	if (gziplevel > 0) {
-		gzmode[3] = '0' + gziplevel;
+		gzmode[1] = '0' + gziplevel;
 		mfd.gzfd = gzdopen(mfd.fd, gzmode);
 		if (!mfd.gzfd) {
 			fprintf(stderr, "gzdopen error: %s\n", strerror(errno));
Signature · 1 line
1.7.5.2
#1 lore raw

PATCH 1/1 gfs2_edit: Fix savemeta compression for older zlibs

Hi,

Looks good,

Steve.

Quoted 34 lines · Andrew Price

gzdopen in zlib 1.2.3 parses the mode string in a different way to subsequent versions and the mode string we use causes the older gzwrite to fail with EBADF. This patch fixes the mode string so that the gzwrites succeed with the old and new zlibs.

rhbz#702313

---
 gfs2/edit/savemeta.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
gfs2/edit/savemeta.c +2 -2
index cb7e243..160277c 100644
@@ -209,7 +209,7 @@ static void warm_fuzzy_stuff(uint64_t wfsblock, int force)
 static struct metafd savemetaopen(char *out_fn, int gziplevel)
 {
 	struct metafd mfd;
-	char gzmode[5] = "rwb9";
+	char gzmode[3] = "w9";
 	char dft_fn[] = DFT_SAVE_FILE;
 
 	if (!out_fn) {
@@ -232,7 +232,7 @@ static struct metafd savemetaopen(char *out_fn, int gziplevel)
 
 	mfd.gziplevel = gziplevel;
 	if (gziplevel > 0) {
-		gzmode[3] = '0' + gziplevel;
+		gzmode[1] = '0' + gziplevel;
 		mfd.gzfd = gzdopen(mfd.fd, gzmode);
 		if (!mfd.gzfd) {
 			fprintf(stderr, "gzdopen error: %s\n", strerror(errno));