[gfs2-utils] 12/38: fsck.gfs2: Handle gfs2_readi() errors in
check_statfs()
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 2bf3a98449c55702e22129cab7766479167ef163
Author: Andrew Price <anprice(a)redhat.com>
Date: Fri Nov 11 13:24:34 2016 +0000
fsck.gfs2: Handle gfs2_readi() errors in check_statfs()
Discovered by static analysis with clang.
Related: rhbz#1394235
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index c5967bc..51f3e03 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -170,9 +170,12 @@ static int check_statfs(struct gfs2_sbd *sdp)
/* Read the current statfs values */
count = gfs2_readi(sdp->md.statfs, buf, 0,
sdp->md.statfs->i_di.di_size);
- if (count == sizeof(struct gfs2_statfs_change))
- gfs2_statfs_change_in(&sc, buf);
-
+ if (count != sizeof(struct gfs2_statfs_change)) {
+ log_err(_("Failed to read statfs values (%d of %"PRIu64" read)\n"),
+ count, (uint64_t)sdp->md.statfs->i_di.di_size);
+ return FSCK_ERROR;
+ }
+ gfs2_statfs_change_in(&sc, buf);
/* Calculate the real values from the rgrp information */
sdp->blks_total = 0;
sdp->blks_alloced = 0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 11/38: gfs2-utils tests: Disable timeout for check_rgrp
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit da98a63e9bd7e20d82a94a5e3c6a0d172eb756e4
Author: Andrew Price <anprice(a)redhat.com>
Date: Mon Aug 15 14:43:42 2016 +0100
gfs2-utils tests: Disable timeout for check_rgrp
This test can take some time but it is bounded so the fixed timeout can
be removed. This will stop the test from failing on slow machines
without having to guess at a sensible duration.
Related: Debian bug #823583
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
tests/check_rgrp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/check_rgrp.c b/tests/check_rgrp.c
index 792b3ae..ce22c38 100644
--- a/tests/check_rgrp.c
+++ b/tests/check_rgrp.c
@@ -125,7 +125,7 @@ static Suite * libgfs2_suite(void)
tcase_add_test(tc_rgrp, test_rbm_find_good);
tcase_add_test(tc_rgrp, test_rbm_find_bad);
tcase_add_test(tc_rgrp, test_rbm_find_lastblock);
- tcase_set_timeout(tc_rgrp, 120);
+ tcase_set_timeout(tc_rgrp, 0);
suite_add_tcase(s, tc_rgrp);
return s;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 10/38: gfs2-utils: Use libuuid for uuid handling
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit bab5c29ec162c0d4730fc30f2c5340c78a4bf17b
Author: Andrew Price <anprice(a)redhat.com>
Date: Sun Aug 14 20:46:12 2016 +0100
gfs2-utils: Use libuuid for uuid handling
Use libuuid to generate, parse, to-string and copy uuids when the
sb_uuid field is available. This allows seven custom uuid-related
functions to be removed.
Also add some missing #ifdef GFS2_HAS_UUID guards which fixes building
against a gfs2_ondisk.h without sb_uuid.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/Makefile.am | 1 +
gfs2/edit/Makefile.am | 6 ++-
gfs2/edit/gfs2hex.c | 10 ++++-
gfs2/fsck/Makefile.am | 5 ++-
gfs2/glocktop/Makefile.am | 3 +-
gfs2/libgfs2/Makefile.am | 4 +-
gfs2/libgfs2/lang.c | 60 ++++++++++-------------------
gfs2/libgfs2/libgfs2.h | 2 -
gfs2/libgfs2/meta.c | 15 +++++++-
gfs2/libgfs2/ondisk.c | 37 +++++-------------
gfs2/libgfs2/structures.c | 51 +++---------------------
gfs2/mkfs/Makefile.am | 13 +++++--
gfs2/mkfs/main_mkfs.c | 11 +++++-
gfs2/tune/Makefile.am | 5 ++-
gfs2/tune/super.c | 98 ++++++++++-------------------------------------
tests/Makefile.am | 4 ++
16 files changed, 120 insertions(+), 205 deletions(-)
diff --git a/gfs2/convert/Makefile.am b/gfs2/convert/Makefile.am
index 30924d7..4db643f 100644
--- a/gfs2/convert/Makefile.am
+++ b/gfs2/convert/Makefile.am
@@ -8,3 +8,4 @@ gfs2_convert_CPPFLAGS = \
-I$(top_srcdir)/gfs2/libgfs2
gfs2_convert_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
+gfs2_convert_LDFLAGS = $(uuid_LIBS)
diff --git a/gfs2/edit/Makefile.am b/gfs2/edit/Makefile.am
index 5d2942e..a9b177e 100644
--- a/gfs2/edit/Makefile.am
+++ b/gfs2/edit/Makefile.am
@@ -22,10 +22,12 @@ gfs2_edit_CPPFLAGS = \
gfs2_edit_CFLAGS = \
$(ncurses_CFLAGS) \
- $(zlib_CFLAGS)
+ $(zlib_CFLAGS) \
+ $(uuid_CFLAGS)
gfs2_edit_LDFLAGS = \
$(ncurses_LIBS) \
- $(zlib_LIBS)
+ $(zlib_LIBS) \
+ $(uuid_LIBS)
gfs2_edit_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 3d280b5..3d0f10d 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -20,6 +20,9 @@
#include "extended.h"
#include "gfs2hex.h"
#include "libgfs2.h"
+#ifdef GFS2_HAS_UUID
+#include <uuid.h>
+#endif
#define pv(struct, member, fmt, fmt2) do { \
print_it(" "#member, fmt, fmt2, struct->member); \
@@ -415,7 +418,12 @@ static void gfs2_sb_print2(struct gfs2_sb *sbp2)
gfs2_inum_print2("license ", &gfs1_license_di);
}
#ifdef GFS2_HAS_UUID
- print_it(" sb_uuid", "%s", NULL, str_uuid(sbp2->sb_uuid));
+ {
+ char readable_uuid[36+1];
+
+ uuid_unparse(sbp2->sb_uuid, readable_uuid);
+ print_it(" sb_uuid", "%s", NULL, readable_uuid);
+ }
#endif
}
diff --git a/gfs2/fsck/Makefile.am b/gfs2/fsck/Makefile.am
index 4c3498b..97fcd40 100644
--- a/gfs2/fsck/Makefile.am
+++ b/gfs2/fsck/Makefile.am
@@ -35,4 +35,7 @@ fsck_gfs2_CPPFLAGS = \
-I$(top_srcdir)/gfs2/include \
-I$(top_srcdir)/gfs2/libgfs2
-fsck_gfs2_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
+fsck_gfs2_LDADD = \
+ $(top_builddir)/gfs2/libgfs2/libgfs2.la
+fsck_gfs2_LDFLAGS = \
+ $(uuid_LIBS)
diff --git a/gfs2/glocktop/Makefile.am b/gfs2/glocktop/Makefile.am
index a43c519..1102c8e 100644
--- a/gfs2/glocktop/Makefile.am
+++ b/gfs2/glocktop/Makefile.am
@@ -10,7 +10,8 @@ glocktop_CFLAGS = \
$(ncurses_CFLAGS)
glocktop_LDFLAGS = \
- $(ncurses_LIBS)
+ $(ncurses_LIBS) \
+ $(uuid_LIBS)
glocktop_CPPFLAGS = \
-D_FILE_OFFSET_BITS=64 \
diff --git a/gfs2/libgfs2/Makefile.am b/gfs2/libgfs2/Makefile.am
index 2b7aa16..4321a67 100644
--- a/gfs2/libgfs2/Makefile.am
+++ b/gfs2/libgfs2/Makefile.am
@@ -48,10 +48,12 @@ libgfs2_la_CPPFLAGS = \
-D_FILE_OFFSET_BITS=64 \
-D_LARGEFILE64_SOURCE \
-D_GNU_SOURCE \
- -I$(top_srcdir)/gfs2/include
+ -I$(top_srcdir)/gfs2/include \
+ $(uuid_CFLAGS)
gfs2l_SOURCES = gfs2l.c
gfs2l_LDADD = libgfs2.la
+gfs2l_LDFLAGS = $(uuid_LIBS)
gfs2l_CPPFLAGS = \
-I$(top_srcdir)/gfs2/include \
-D_FILE_OFFSET_BITS=64
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 13333a1..2f93c56 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -9,6 +9,9 @@
#include "lang.h"
#include "parser.h"
+#ifdef GFS2_HAS_UUID
+#include <uuid.h>
+#endif
const char* ast_type_string[] = {
[AST_NONE] = "NONE",
@@ -312,7 +315,14 @@ static int field_print(const struct gfs2_buffer_head *bh, const struct lgfs2_met
printf("%s\t%"PRIu64"\t%u\t%u\t%s\t", mtype->name, bh->b_blocknr, field->offset, field->length, field->name);
if (field->flags & LGFS2_MFF_UUID) {
- printf("'%s'\n", str_uuid((const unsigned char *)fieldp));
+#ifdef GFS2_HAS_UUID
+ char readable_uuid[36+1];
+ uuid_t uuid;
+
+ memcpy(uuid, fieldp, sizeof(uuid_t));
+ uuid_unparse(uuid, readable_uuid);
+ printf("'%s'\n", readable_uuid);
+#endif
} else if (field->flags & LGFS2_MFF_STRING) {
printf("'%s'\n", fieldp);
} else {
@@ -431,40 +441,6 @@ static struct lgfs2_lang_result *ast_interp_get(struct lgfs2_lang_state *state,
}
/**
- * Interpret a UUID string by removing hyphens from the string and then
- * interprets 16 pairs of hex digits as octets.
- */
-static int ast_str_to_uuid(const char *str, uint8_t *uuid)
-{
- char s[33];
- int head, tail, tmp;
-
- for (head = tail = 0; head < strlen(str) && tail < 33; head++) {
- if (str[head] == '-')
- continue;
- s[tail] = tolower(str[head]);
- if (!((s[tail] >= 'a' && s[tail] <= 'f') ||
- (s[tail] >= '0' && s[tail] <= '9')))
- goto invalid;
- tail++;
- }
- if (tail != 32) {
- goto invalid;
- }
- s[tail] = '\0';
- for (head = 0; head < 16; head++) {
- if (sscanf(s+(head*2), "%02x", &tmp) != 1) {
- goto invalid;
- }
- *(uuid + head) = tmp;
- }
- return AST_INTERP_SUCCESS;
-invalid:
- fprintf(stderr, "Invalid UUID\n");
- return AST_INTERP_INVAL;
-}
-
-/**
* Set a field of a gfs2 block of a given type to a given value.
* Returns AST_INTERP_* to signal success, an invalid field/value or an error.
*/
@@ -474,12 +450,18 @@ static int ast_field_set(struct gfs2_buffer_head *bh, const struct lgfs2_metafie
int err = 0;
if (field->flags & LGFS2_MFF_UUID) {
- uint8_t uuid[16];
- int ret = ast_str_to_uuid(val->ast_str, uuid);
+#ifdef GFS2_HAS_UUID
+ uuid_t uuid;
- if (ret != AST_INTERP_SUCCESS)
- return ret;
+ if (uuid_parse(val->ast_str, uuid) != 0) {
+ fprintf(stderr, "Invalid UUID\n");
+ return AST_INTERP_INVAL;
+ }
err = lgfs2_field_assign(bh->b_data, field, uuid);
+#else
+ fprintf(stderr, "No UUID support\n");
+ err = 1;
+#endif
} else if (field->flags & LGFS2_MFF_STRING) {
err = lgfs2_field_assign(bh->b_data, field, val->ast_str);
} else {
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 5414a20..ebf6bca 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -711,8 +711,6 @@ extern int write_sb(struct gfs2_sbd *sdp);
/* ondisk.c */
extern uint32_t gfs2_disk_hash(const char *data, int len);
-extern const char *str_uuid(const unsigned char *uuid);
-extern void gfs2_print_uuid(const unsigned char *uuid);
extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
__attribute__((format(printf,2,4)));
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index 90d5647..500757d 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -3,6 +3,10 @@
#include "libgfs2.h"
#include "clusterautoconfig.h"
+#ifdef GFS2_HAS_UUID
+#include <uuid.h>
+#endif
+
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define SYM(x) { x, #x },
@@ -150,7 +154,9 @@ F(sb_lockproto, .flags = LGFS2_MFF_STRING)
F(sb_locktable, .flags = LGFS2_MFF_STRING)
INR(__pad3, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
INR(__pad4, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
+#ifdef GFS2_HAS_UUID
F(sb_uuid, .flags = LGFS2_MFF_UUID)
+#endif
};
#undef STRUCT
@@ -878,7 +884,14 @@ int lgfs2_field_str(char *str, const size_t size, const char *blk, const struct
return 1;
if (field->flags & LGFS2_MFF_UUID) {
- snprintf(str, size, "%s", str_uuid((unsigned char *)fieldp));
+#ifdef GFS2_HAS_UUID
+ char readable_uuid[36+1];
+ uuid_t uuid;
+
+ memcpy(uuid, fieldp, sizeof(uuid_t));
+ uuid_unparse(uuid, readable_uuid);
+ snprintf(str, size, "%s", readable_uuid);
+#endif
} else if (field->flags & LGFS2_MFF_STRING) {
snprintf(str, size, "%s", fieldp);
} else {
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index d49455e..66de223 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -6,9 +6,11 @@
#include <stdint.h>
#include <inttypes.h>
#include <ctype.h>
-
#include <linux/types.h>
#include "libgfs2.h"
+#ifdef GFS2_HAS_UUID
+#include <uuid.h>
+#endif
#define pv(struct, member, fmt, fmt2) do { \
print_it(" "#member, fmt, fmt2, struct->member); \
@@ -151,32 +153,6 @@ void gfs2_sb_out(const struct gfs2_sb *sb, char *buf)
#endif
}
-const char *str_uuid(const unsigned char *uuid)
-{
- static char str[64];
- char *ch;
- int i;
-
- memset(str, 0, sizeof(str));
- ch = str;
- for (i = 0; i < 16; i++) {
- sprintf(ch, "%02x", uuid[i]);
- ch += 2;
- if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) {
- *ch = '-';
- ch++;
- }
- }
- return str;
-}
-
-#ifdef GFS2_HAS_UUID
-void gfs2_print_uuid(const unsigned char *uuid)
-{
- print_it(" uuid", "%s", NULL, str_uuid(uuid));
-}
-#endif
-
void gfs2_sb_print(const struct gfs2_sb *sb)
{
gfs2_meta_header_print(&sb->sb_header);
@@ -194,7 +170,12 @@ void gfs2_sb_print(const struct gfs2_sb *sb)
pv(sb, sb_locktable, "%s", NULL);
#ifdef GFS2_HAS_UUID
- gfs2_print_uuid(sb->sb_uuid);
+ {
+ char readable_uuid[36+1];
+
+ uuid_unparse(sb->sb_uuid, readable_uuid);
+ print_it(" uuid", "%36s", NULL, readable_uuid);
+ }
#endif
}
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 87ffde7..1cc88b5 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -16,6 +16,10 @@
#include "libgfs2.h"
#include "config.h"
+#ifdef GFS2_HAS_UUID
+#include <uuid.h>
+#endif
+
int build_master(struct gfs2_sbd *sdp)
{
struct gfs2_inum inum;
@@ -45,51 +49,6 @@ int build_master(struct gfs2_sbd *sdp)
return 0;
}
-#ifdef GFS2_HAS_UUID
-/**
- * Generate a series of random bytes using /dev/urandom.
- * Modified from original code in gen_uuid.c in e2fsprogs/lib
- */
-static void get_random_bytes(void *buf, int nbytes)
-{
- int i, n = nbytes, fd;
- int lose_counter = 0;
- unsigned char *cp = (unsigned char *) buf;
- struct timeval tv;
-
- gettimeofday(&tv, 0);
- fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
- srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
- /* Crank the random number generator a few times */
- gettimeofday(&tv, 0);
- for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--)
- rand();
- if (fd >= 0) {
- while (n > 0) {
- i = read(fd, cp, n);
- if (i <= 0) {
- if (lose_counter++ > 16)
- break;
- continue;
- }
- n -= i;
- cp += i;
- lose_counter = 0;
- }
- close(fd);
- }
-
- /*
- * We do this all the time, but this is the only source of
- * randomness if /dev/random/urandom is out to lunch.
- */
- for (cp = buf, i = 0; i < nbytes; i++)
- *cp++ ^= (rand() >> 7) & 0xFF;
-
- return;
-}
-#endif
-
/**
* Initialise a gfs2_sb structure with sensible defaults.
*/
@@ -104,7 +63,7 @@ void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
sb->sb_bsize = bsize;
sb->sb_bsize_shift = ffs(bsize) - 1;
#ifdef GFS2_HAS_UUID
- get_random_bytes(&sb->sb_uuid, sizeof(sb->sb_uuid));
+ uuid_generate(sb->sb_uuid);
#endif
}
diff --git a/gfs2/mkfs/Makefile.am b/gfs2/mkfs/Makefile.am
index 074c4c1..f0dd961 100644
--- a/gfs2/mkfs/Makefile.am
+++ b/gfs2/mkfs/Makefile.am
@@ -22,8 +22,12 @@ mkfs_gfs2_SOURCES = \
progress.h
mkfs_gfs2_CPPFLAGS = $(COMMON_CPPFLAGS)
-mkfs_gfs2_CFLAGS = $(blkid_CFLAGS)
-mkfs_gfs2_LDFLAGS = $(blkid_LIBS)
+mkfs_gfs2_CFLAGS = \
+ $(blkid_CFLAGS) \
+ $(uuid_CFLAGS)
+mkfs_gfs2_LDFLAGS = \
+ $(blkid_LIBS) \
+ $(uuid_LIBS)
mkfs_gfs2_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
gfs2_grow_SOURCES = \
@@ -32,7 +36,9 @@ gfs2_grow_SOURCES = \
gfs2_grow_CPPFLAGS = $(COMMON_CPPFLAGS)
gfs2_grow_CFLAGS = $(blkid_CFLAGS)
-gfs2_grow_LDFLAGS = $(blkid_LIBS)
+gfs2_grow_LDFLAGS = \
+ $(blkid_LIBS) \
+ $(uuid_LIBS)
gfs2_grow_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
gfs2_jadd_SOURCES = \
@@ -41,4 +47,5 @@ gfs2_jadd_SOURCES = \
gfs2_jadd_CPPFLAGS = $(COMMON_CPPFLAGS)
gfs2_jadd_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
+gfs2_jadd_LDFLAGS = $(uuid_LIBS)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 7ede5ad..363878c 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -30,6 +30,10 @@
#include "gfs2_mkfs.h"
#include "progress.h"
+#ifdef GFS2_HAS_UUID
+#include <uuid.h>
+#endif
+
static void print_usage(const char *prog_name)
{
int i;
@@ -537,8 +541,13 @@ static void print_results(struct gfs2_sb *sb, struct mkfs_opts *opts, uint64_t r
printf("%-27s\"%s\"\n", _("Locking protocol:"), opts->lockproto);
printf("%-27s\"%s\"\n", _("Lock table:"), opts->locktable);
#ifdef GFS2_HAS_UUID
+ {
+ char readable_uuid[36+1];
+
+ uuid_unparse(sb->sb_uuid, readable_uuid);
/* Translators: "UUID" = universally unique identifier. */
- printf("%-27s%s\n", _("UUID:"), str_uuid(sb->sb_uuid));
+ printf("%-27s%s\n", _("UUID:"), readable_uuid);
+ }
#endif
}
diff --git a/gfs2/tune/Makefile.am b/gfs2/tune/Makefile.am
index c060183..7628f42 100644
--- a/gfs2/tune/Makefile.am
+++ b/gfs2/tune/Makefile.am
@@ -7,8 +7,11 @@ noinst_HEADERS = tunegfs2.h
tunegfs2_SOURCES = \
main.c \
super.c
-
tunegfs2_CPPFLAGS = \
-D_FILE_OFFSET_BITS=64 \
-I$(top_srcdir)/gfs2/include \
-I$(top_srcdir)/group/include
+tunegfs2_CFLAGS = \
+ $(uuid_CFLAGS)
+tunegfs2_LDFLAGS = \
+ $(uuid_LIBS)
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index 560ce68..c4ffd7e 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -14,78 +14,9 @@
#include <linux/gfs2_ondisk.h>
#include "tunegfs2.h"
-static int str_to_hexchar(const char *estring)
-{
- int ch = 0;
-
- if (isdigit(*estring))
- ch = (*estring - '0') * 0x10;
- else if (*estring >= 'a' && *estring <= 'f')
- ch = (*estring - 'a' + 0x0a) * 0x10;
- else if (*estring >= 'A' && *estring <= 'F')
- ch = (*estring - 'A' + 0x0a) * 0x10;
-
- estring++;
- if (isdigit(*estring))
- ch += (*estring - '0');
- else if (*estring >= 'a' && *estring <= 'f')
- ch += (*estring - 'a' + 0x0a);
- else if (*estring >= 'A' && *estring <= 'F')
- ch += (*estring - 'A' + 0x0a);
- return ch;
-}
-
-
-
-static const char *uuid2str(const unsigned char *uuid)
-{
- static char str[64];
- char *ch;
- int i;
-
- memset(str, 0, 64);
- ch = str;
- for (i = 0; i < 16; i++) {
- sprintf(ch, "%02x", uuid[i]);
- ch += 2;
- if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) {
- *ch = '-';
- ch++;
- }
- }
- return str;
-}
-
-static int str2uuid(const char *newval, char *uuid)
-{
- char *cp;
- int i;
-
- if (strlen(newval) != 36) {
- fprintf(stderr, _("Invalid UUID: %s\n"), newval);
- return EX_DATAERR;
- }
-
- cp = uuid;
- for (i = 0; i < 36; i++) {
- if ((i == 8) || (i == 13) ||
- (i == 18) || (i == 23)) {
- if (newval[i] == '-')
- continue;
- fprintf(stderr, _("Invalid UUID: %s\n"), newval);
- return EX_DATAERR;
- }
- if (!isxdigit(newval[i])) {
- fprintf(stderr, _("Invalid UUID: %s\n"), newval);
- fprintf(stderr, _("Bad digit '%c' at position %d\n"),
- newval[i], i + 1);
- return EX_DATAERR;
- }
- *cp = str_to_hexchar(&newval[i++]);
- cp++;
- }
- return 0;
-}
+#ifdef GFS2_HAS_UUID
+#include <uuid.h>
+#endif
int read_super(struct tunegfs2 *tfs)
{
@@ -125,7 +56,12 @@ int print_super(const struct tunegfs2 *tfs)
{
printf(_("File system volume name: %s\n"), tfs->sb->sb_locktable);
#ifdef GFS2_HAS_UUID
- printf(_("File system UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+ {
+ char readable_uuid[36+1];
+
+ uuid_unparse(tfs->sb->sb_uuid, readable_uuid);
+ printf(_("File system UUID: %s\n"), readable_uuid);
+ }
#endif
printf( _("File system magic number: 0x%X\n"), be32_to_cpu(tfs->sb->sb_header.mh_magic));
printf(_("Block size: %d\n"), be32_to_cpu(tfs->sb->sb_bsize));
@@ -152,12 +88,18 @@ int write_super(const struct tunegfs2 *tfs)
int change_uuid(struct tunegfs2 *tfs, const char *str)
{
- char uuid[16];
- int status = 0;
- status = str2uuid(str, uuid);
- if (!status)
- memcpy(tfs->sb->sb_uuid, uuid, 16);
+#ifdef GFS2_HAS_UUID
+ uuid_t uuid;
+ int status;
+
+ status = uuid_parse(str, uuid);
+ if (status == 0)
+ uuid_copy(tfs->sb->sb_uuid, uuid);
return status;
+#else
+ fprintf(stderr, _("UUID support unavailable in this build\n"));
+ return 1;
+#endif
}
int change_lockproto(struct tunegfs2 *tfs, const char *lockproto)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 273be71..1dedc2b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,6 +23,8 @@ nukerg_CFLAGS = \
-I$(top_srcdir)/gfs2/include
nukerg_LDADD = \
$(top_builddir)/gfs2/libgfs2/libgfs2.la
+nukerg_LDFLAGS = \
+ $(uuid_LIBS)
if HAVE_CHECK
UNIT_TESTS = \
@@ -49,6 +51,7 @@ check_meta_SOURCES = \
check_meta.c
check_meta_CFLAGS = $(UNIT_CFLAGS)
check_meta_LDADD = $(UNIT_LDADD)
+check_meta_LDFLAGS = $(uuid_LIBS)
check_meta_CPPFLAGS = $(UNIT_CPPFLAGS)
check_rgrp_SOURCES = \
@@ -56,6 +59,7 @@ check_rgrp_SOURCES = \
check_rgrp.c
check_rgrp_CFLAGS = $(UNIT_CFLAGS)
check_rgrp_LDADD = $(UNIT_LDADD)
+check_rgrp_LDFLAGS = $(uuid_LIBS)
check_rgrp_CPPFLAGS = $(UNIT_CPPFLAGS)
endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 09/38: gfs2-utils: Add a configure check for libuuid
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit ec6abad6a3cbed34453da39991591189dac61d2d
Author: Andrew Price <anprice(a)redhat.com>
Date: Sun Aug 14 16:55:15 2016 +0100
gfs2-utils: Add a configure check for libuuid
libuuid is already required indirectly via libblkid but make the
requirement explicit and set uuid_LIBS etc. so that we can use it for
UUID handling.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index cc49642..f1d8351 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,9 @@ AM_CONDITIONAL([HAVE_CHECK], [test "x$have_check" = "xyes"])
PKG_CHECK_MODULES([zlib],[zlib])
PKG_CHECK_MODULES([blkid],[blkid])
+PKG_CHECK_MODULES([uuid],[uuid],
+ [have_uuid=yes],
+ [have_uuid=no])
# old versions of ncurses don't ship pkg-config files
PKG_CHECK_MODULES([ncurses],[ncurses],,
@@ -126,7 +129,8 @@ AC_CHECK_HEADER([linux/fs.h], [], [AC_MSG_ERROR([Unable to find linux/fs.h])])
AC_CHECK_HEADER([linux/types.h], [], [AC_MSG_ERROR([Unable to find linux/types.h])])
AC_CHECK_HEADER([linux/limits.h], [], [AC_MSG_ERROR([Unable to find linux/limits.h])])
AC_CHECK_HEADER([linux/gfs2_ondisk.h], [], [AC_MSG_ERROR([Unable to find linux/gfs2_ondisk.h])])
-AC_CHECK_MEMBER([struct gfs2_sb.sb_uuid], [], [], [[#include <linux/gfs2_ondisk.h>]])
+AC_CHECK_MEMBER([struct gfs2_sb.sb_uuid], [sb_has_uuid=yes], [sb_has_uuid=no],
+ [[#include <linux/gfs2_ondisk.h>]])
AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[],[Leaf block hints])],
[], [[#include <linux/gfs2_ondisk.h>]])
AC_CHECK_MEMBER([struct gfs2_dirent.de_rahead],[AC_DEFINE([GFS2_HAS_DE_RAHEAD],[],[Dirent readahead field])],
@@ -134,6 +138,11 @@ AC_CHECK_MEMBER([struct gfs2_dirent.de_rahead],[AC_DEFINE([GFS2_HAS_DE_RAHEAD],[
AC_CHECK_MEMBER([struct gfs2_dirent.de_cookie],[AC_DEFINE([GFS2_HAS_DE_COOKIE],[],[Dirent cookie field])],
[], [[#include <linux/gfs2_ondisk.h>]])
+# libuuid is only required if struct gfs2_sb.sb_uuid exists
+if test "$sb_has_uuid" = "yes" -a "$have_uuid" = "no"; then
+ AC_MSG_ERROR([libuuid is required for this version of gfs2])
+fi
+
# *FLAGS handling
ENV_CFLAGS="$CFLAGS"
ENV_CPPFLAGS="$CPPFLAGS"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 08/38: gfs2-utils: Build with -D_FORTIFY_SOURCE=2
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 0067299783bae59fb793b10a180b319dc5a74ca6
Author: Andrew Price <anprice(a)redhat.com>
Date: Wed Jun 29 20:07:04 2016 +0100
gfs2-utils: Build with -D_FORTIFY_SOURCE=2
A survey of popular Linux distros shows that they all compile their
packages with _FORTIFY_SOURCE=2 defined so it makes sense to enable it
upstream too, in order to fix any issues it highlights before they reach
the distros. It will also allow us to factor the overhead it adds into
perf measurements.
Briefly, using this flag adds buffer overflow detection to some
functions, and enables -Wunused-result warnings.
It requires the optimization level to be -O1 or higher so it is only
added to CPPFLAGS when --enable-debug is not used.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index b421fbe..cc49642 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,8 +143,10 @@ ENV_LDFLAGS="$LDFLAGS"
if test "x${enable_debug}" = xyes; then
AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code])
OPT_CFLAGS="-O0"
+ OPT_CPPFLAGS=""
else
OPT_CFLAGS="-O2"
+ OPT_CPPFLAGS="-D_FORTIFY_SOURCE=2"
fi
# gdb flags
@@ -203,7 +205,7 @@ for j in $WARNLIST; do
done
CFLAGS="$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS $EXTRA_WARNINGS $WERROR_CFLAGS"
-CPPFLAGS="-I\$(top_builddir)/make -I\$(top_srcdir)/make -I. $ENV_CPPFLAGS"
+CPPFLAGS="-I\$(top_builddir)/make -I\$(top_srcdir)/make -I. $ENV_CPPFLAGS $OPT_CPPFLAGS"
LDFLAGS="$ENV_LDFLAGS"
AC_CONFIG_TESTDIR([tests], [gfs2/libgfs2:gfs2/mkfs:gfs2/fsck:gfs2/edit:gfs2/convert:gfs2/tune:tests])
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 07/38: gfs2_convert: Fix misleading indentation warning
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 32f73f5fe0ffc4c311d94cdc8a161886b28c79e7
Author: Andrew Price <anprice(a)redhat.com>
Date: Wed Jun 29 00:29:03 2016 +0100
gfs2_convert: Fix misleading indentation warning
Caught by the new -Wmisleading-indentation warning in gcc 6:
CC gfs2_convert-gfs2_convert.o
gfs2_convert.c: In function 'inode_renumber':
gfs2_convert.c:1073:5: warning: this 'if' clause does not guard...
if (block != rindex_addr && block != jindex_addr)
^~
gfs2_convert.c:1075:6: note: ...this statement, but the latter is
misleadingly indented as if it is guarded by the 'if'
if (error) {
^~
Fortunately, this wasn't actually a bug, it just caused the value of
'error' to be checked when it couldn't possibly be non-zero as well as
the one time it could be.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index aac4853..9845049 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1070,11 +1070,11 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
bh = bread(sbp, block);
if (!gfs2_check_meta(bh, GFS_METATYPE_DI)) {/* if it is an dinode */
/* Skip the rindex and jindex inodes for now. */
- if (block != rindex_addr && block != jindex_addr)
+ if (block != rindex_addr && block != jindex_addr) {
error = adjust_inode(sbp, bh);
- if (error) {
+ if (error)
return error;
- }
+ }
} else { /* It's metadata, but not an inode, so fix the bitmap. */
int blk, buf_offset;
int bitmap_byte; /* byte within the bitmap to fix */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 06/38: gfs2-utils: Add --enable-gprof to configure
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 652335ae01b4f6b80e2dd50e7eb433739b2ee726
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Jun 16 23:39:44 2016 +0100
gfs2-utils: Add --enable-gprof to configure
Add a convenience flag to the configure script which inserts -pg into
the build flags.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/configure.ac b/configure.ac
index f6174ff..b421fbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,6 +92,10 @@ AC_ARG_ENABLE([debug],
AC_ARG_ENABLE([gcov],
AC_HELP_STRING([--enable-gcov],[enable coverage instrumentation [default=no]]),
[], [enable_gcov="no"])
+AC_ARG_ENABLE([gprof],
+ AC_HELP_STRING([--enable-gprof],[enable profiling instrumentation [default=no]]),
+ [], [enable_gprof="no"])
+
# We use the Check framework for unit tests
PKG_CHECK_MODULES([check], [check >= 0.9.8],
@@ -162,6 +166,14 @@ if test "x${enable_gcov}" = xyes; then
OPT_CFLAGS="-O0 $GCOV_CFLAGS"
fi
+if test "x${enable_gprof}" = xyes; then
+ GPROF_CFLAGS="-pg"
+ if ! cc_supports_flag $GPROF_CFLAGS; then
+ AC_MSG_ERROR([your compiler does not support gprof instrumentation])
+ fi
+ OPT_CFLAGS="$OPT_CFLAGS $GPROF_CFLAGS"
+fi
+
# extra warnings
EXTRA_WARNINGS=""
@@ -226,6 +238,7 @@ echo " udevdir : $udevdir"
echo " ------------------"
echo " debug build : $enable_debug"
echo " C unit tests : $have_check"
+echo " gprof build : $enable_gprof"
echo " gcov build : $enable_gcov"
echo
echo "Now run 'make' to build and 'make check' to run tests"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 05/38: mkfs.gfs2: Tidy up are_you_sure()
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit ffe94a73a147c6ef5086530734772bccfff6e70c
Author: Andrew Price <anprice(a)redhat.com>
Date: Fri Jun 10 11:44:10 2016 +0100
mkfs.gfs2: Tidy up are_you_sure()
Coverity pointed out that the 'line' pointer was dereferenced before it
was NULL-checked and although that wasn't a bug it highlighted this
function's strange structure. This patch tidies it up somewhat, keeping
in mind that the memory allocated by getline() always has to be freed
whether it succeeds or not.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_mkfs.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 4436f93..7ede5ad 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -422,34 +422,29 @@ static void test_locking(struct mkfs_opts *opts)
static void are_you_sure(void)
{
- char *line = NULL;
- size_t len = 0;
- int ret = -1;
- int res = 0;
+ while (1) {
+ char *line = NULL;
+ size_t len = 0;
+ int ret;
+ int res;
- do{
/* Translators: We use rpmatch(3) to match the answers to y/n
questions in the user's own language, so the [y/n] here must also be
translated to match one of the letters in the pattern printed by
`locale -k yesexpr` and one of the letters in the pattern printed by
`locale -k noexpr` */
- printf( _("Are you sure you want to proceed? [y/n]"));
+ printf( _("Are you sure you want to proceed? [y/n] "));
ret = getline(&line, &len, stdin);
res = rpmatch(line);
-
- if (res > 0){
- free(line);
- return;
- }
- if (!res){
- printf("\n");
- die( _("Aborted.\n"));
- }
-
- }while(ret >= 0);
-
- if(line)
free(line);
+ if (ret <= 0)
+ continue;
+ if (res == 1) /* Yes */
+ return;
+ if (res == 0) /* No */
+ exit(1);
+ /* Unrecognized input; go again. */
+ };
}
static unsigned choose_blocksize(struct mkfs_opts *opts)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 04/38: libgfs2: Propagate the value of
gfs2_rindex.__pad
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 9b3f6ced9c1c6555b0d544ea572ff7f1f7359e6e
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Jun 9 15:43:49 2016 +0100
libgfs2: Propagate the value of gfs2_rindex.__pad
Values of padding fields shouldn't be ignored as we might decide to use
them some day.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/ondisk.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index ea1f61f..d49455e 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -204,12 +204,10 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf)
CPIN_64(ri, str, ri_addr);
CPIN_32(ri, str, ri_length);
-
+ CPIN_32(ri, str, __pad);
CPIN_64(ri, str, ri_data0);
CPIN_32(ri, str, ri_data);
-
CPIN_32(ri, str, ri_bitbytes);
-
CPIN_08(ri, str, ri_reserved, 64);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years
[gfs2-utils] 03/38: glocktop: Check the return value of fgets()
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 68568398c79a7e00a411f8960000c0a4d6b86da1
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Jun 9 11:50:44 2016 +0100
glocktop: Check the return value of fgets()
Fixes 3 occurrences of:
warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/glocktop/glocktop.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index b418d2a..bcee3d8 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -673,11 +673,14 @@ static const char *show_details(const char *id, const char *fsname, int btype,
memset(dlm_rsbtbl_size, 0, sizeof(dlm_rsbtbl_size));
memset(dlm_lkbtbl_size, 0, sizeof(dlm_lkbtbl_size));
if (!strcmp(sd_sb[mnt_num].sb_lockproto, "lock_dlm")) {
+ char *sp;
char *p;
dlmf = fopen(DLM_DIRTBL, "rt");
if (dlmf) {
- fgets(dlm_dirtbl_size, sizeof(dlm_dirtbl_size), dlmf);
+ sp = fgets(dlm_dirtbl_size, sizeof(dlm_dirtbl_size), dlmf);
+ if (sp == NULL)
+ goto out_err;
p = strchr(dlm_dirtbl_size, '\n');
if (p)
*p = '\0';
@@ -687,7 +690,9 @@ static const char *show_details(const char *id, const char *fsname, int btype,
}
dlmf = fopen(DLM_RSBTBL, "rt");
if (dlmf) {
- fgets(dlm_rsbtbl_size, sizeof(dlm_rsbtbl_size), dlmf);
+ sp = fgets(dlm_rsbtbl_size, sizeof(dlm_rsbtbl_size), dlmf);
+ if (sp == NULL)
+ goto out_err;
p = strchr(dlm_rsbtbl_size, '\n');
if (p)
*p = '\0';
@@ -697,7 +702,9 @@ static const char *show_details(const char *id, const char *fsname, int btype,
}
dlmf = fopen(DLM_LKBTBL, "rt");
if (dlmf) {
- fgets(dlm_lkbtbl_size, sizeof(dlm_lkbtbl_size), dlmf);
+ sp = fgets(dlm_lkbtbl_size, sizeof(dlm_lkbtbl_size), dlmf);
+ if (sp == NULL)
+ goto out_err;
p = strchr(dlm_lkbtbl_size, '\n');
if (p)
*p = '\0';
@@ -727,6 +734,9 @@ static const char *show_details(const char *id, const char *fsname, int btype,
blk_type = "";
}
return blk_type;
+out_err:
+ fclose(dlmf);
+ return "error";
}
static int is_dlm_waiting(int dlmwaiters, int locktype, char *id)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
7 years