[gfs2-utils] 01/01: gfs2_edit savemeta: Fix up saving of
dinodes/symlinks
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 52fce21ef94182fbe99b4e4344bdab42c6c95868
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 17 17:45:31 2017 +0100
gfs2_edit savemeta: Fix up saving of dinodes/symlinks
Factor out the code that decides whether to save the dinode contents,
improve its error reporting (and don't exit) and make sure contents of
symlink dinodes are saved.
Resolves: rhbz#1482542
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 52 +++++++++++++++++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 19 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index dee405b..04f67fc 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -190,6 +190,38 @@ static const char *anthropomorphize(unsigned long long inhuman_value)
return out_val;
}
+static int di_save_len(struct gfs2_buffer_head *bh, uint64_t owner)
+{
+ struct gfs2_inode *inode;
+ struct gfs2_dinode *dn;
+ int len;
+
+ if (sbd.gfs1)
+ inode = lgfs2_gfs_inode_get(&sbd, bh);
+ else
+ inode = lgfs2_inode_get(&sbd, bh);
+
+ if (inode == NULL) {
+ fprintf(stderr, "Error reading inode at %"PRIu64": %s\n",
+ bh->b_blocknr, strerror(errno));
+ return 0; /* Skip the block */
+ }
+ dn = &inode->i_di;
+ len = sizeof(struct gfs2_dinode);
+
+ /* Do not save (user) data from the inode block unless they are
+ indirect pointers, dirents, symlinks or fs internal data */
+ if (dn->di_height != 0 ||
+ S_ISDIR(dn->di_mode) ||
+ S_ISLNK(dn->di_mode) ||
+ (sbd.gfs1 && dn->__pad1 == GFS_FILE_DIR) ||
+ block_is_systemfile(owner))
+ len = sbd.bsize;
+
+ inode_put(&inode);
+ return len;
+}
+
/*
* get_gfs_struct_info - get block type and structure length
*
@@ -205,7 +237,6 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, uint64_t owner,
int *block_type, int *gstruct_len)
{
struct gfs2_meta_header mh;
- struct gfs2_inode *inode;
if (block_type != NULL)
*block_type = 0;
@@ -229,24 +260,7 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, uint64_t owner,
*gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_DI: /* 4 (disk inode) */
- if (sbd.gfs1) {
- inode = lgfs2_gfs_inode_get(&sbd, lbh);
- } else {
- inode = lgfs2_inode_get(&sbd, lbh);
- }
- if (inode == NULL) {
- perror("Error reading inode");
- exit(-1);
- }
- if (S_ISDIR(inode->i_di.di_mode) ||
- (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
- *gstruct_len = sbd.bsize;
- else if (!inode->i_di.di_height && !block_is_systemfile(owner) &&
- !S_ISDIR(inode->i_di.di_mode))
- *gstruct_len = sizeof(struct gfs2_dinode);
- else
- *gstruct_len = sbd.bsize;
- inode_put(&inode);
+ *gstruct_len = di_save_len(lbh, owner);
break;
case GFS2_METATYPE_IN: /* 5 (indir inode blklst) */
*gstruct_len = sbd.bsize; /*sizeof(struct gfs_indirect);*/
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 9 months
[gfs2-utils] 02/02: gfs2_edit savemeta: Use size_t for saved
structure lengths
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 4cb82588eb104c4649404d0fe999b5c92bcf24a9
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 17 17:57:34 2017 +0100
gfs2_edit savemeta: Use size_t for saved structure lengths
Although the value range can fit in an int it's better to use an
unsigned type consistent with sizeof and memcpy.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 04f67fc..664484f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -190,11 +190,11 @@ static const char *anthropomorphize(unsigned long long inhuman_value)
return out_val;
}
-static int di_save_len(struct gfs2_buffer_head *bh, uint64_t owner)
+static size_t di_save_len(struct gfs2_buffer_head *bh, uint64_t owner)
{
struct gfs2_inode *inode;
struct gfs2_dinode *dn;
- int len;
+ size_t len;
if (sbd.gfs1)
inode = lgfs2_gfs_inode_get(&sbd, bh);
@@ -234,7 +234,7 @@ static int di_save_len(struct gfs2_buffer_head *bh, uint64_t owner)
* -1 if this isn't gfs metadata.
*/
static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, uint64_t owner,
- int *block_type, int *gstruct_len)
+ int *block_type, size_t *gstruct_len)
{
struct gfs2_meta_header mh;
@@ -423,8 +423,8 @@ static int savemetaclose(struct metafd *mfd)
static int save_bh(struct metafd *mfd, struct gfs2_buffer_head *savebh, uint64_t owner, int *blktype)
{
struct saved_metablock *savedata;
+ size_t blklen;
size_t outsz;
- int blklen;
/* If this isn't metadata and isn't a system file, we don't want it.
Note that we're checking "owner" here rather than blk. That's
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 9 months
[gfs2-utils] 01/02: gfs2_edit savemeta: Fix up saving of
dinodes/symlinks
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 1742ab40bfbdc1b411710cb2263460cc43753c51
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 17 17:45:31 2017 +0100
gfs2_edit savemeta: Fix up saving of dinodes/symlinks
Factor out the code that decides whether to save the dinode contents,
improve its error reporting (and don't exit) and make sure contents of
symlink dinodes are saved.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 52 +++++++++++++++++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 19 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index dee405b..04f67fc 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -190,6 +190,38 @@ static const char *anthropomorphize(unsigned long long inhuman_value)
return out_val;
}
+static int di_save_len(struct gfs2_buffer_head *bh, uint64_t owner)
+{
+ struct gfs2_inode *inode;
+ struct gfs2_dinode *dn;
+ int len;
+
+ if (sbd.gfs1)
+ inode = lgfs2_gfs_inode_get(&sbd, bh);
+ else
+ inode = lgfs2_inode_get(&sbd, bh);
+
+ if (inode == NULL) {
+ fprintf(stderr, "Error reading inode at %"PRIu64": %s\n",
+ bh->b_blocknr, strerror(errno));
+ return 0; /* Skip the block */
+ }
+ dn = &inode->i_di;
+ len = sizeof(struct gfs2_dinode);
+
+ /* Do not save (user) data from the inode block unless they are
+ indirect pointers, dirents, symlinks or fs internal data */
+ if (dn->di_height != 0 ||
+ S_ISDIR(dn->di_mode) ||
+ S_ISLNK(dn->di_mode) ||
+ (sbd.gfs1 && dn->__pad1 == GFS_FILE_DIR) ||
+ block_is_systemfile(owner))
+ len = sbd.bsize;
+
+ inode_put(&inode);
+ return len;
+}
+
/*
* get_gfs_struct_info - get block type and structure length
*
@@ -205,7 +237,6 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, uint64_t owner,
int *block_type, int *gstruct_len)
{
struct gfs2_meta_header mh;
- struct gfs2_inode *inode;
if (block_type != NULL)
*block_type = 0;
@@ -229,24 +260,7 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, uint64_t owner,
*gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_DI: /* 4 (disk inode) */
- if (sbd.gfs1) {
- inode = lgfs2_gfs_inode_get(&sbd, lbh);
- } else {
- inode = lgfs2_inode_get(&sbd, lbh);
- }
- if (inode == NULL) {
- perror("Error reading inode");
- exit(-1);
- }
- if (S_ISDIR(inode->i_di.di_mode) ||
- (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
- *gstruct_len = sbd.bsize;
- else if (!inode->i_di.di_height && !block_is_systemfile(owner) &&
- !S_ISDIR(inode->i_di.di_mode))
- *gstruct_len = sizeof(struct gfs2_dinode);
- else
- *gstruct_len = sbd.bsize;
- inode_put(&inode);
+ *gstruct_len = di_save_len(lbh, owner);
break;
case GFS2_METATYPE_IN: /* 5 (indir inode blklst) */
*gstruct_len = sbd.bsize; /*sizeof(struct gfs_indirect);*/
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 9 months
[gfs2-utils] 05/05: gfs2_grow: Remove unnecessary nesting in
fix_rindex()
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 9166d69692a15a8033a0ae5e61cbf93dc2f8ea30
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 3 17:08:39 2017 +0100
gfs2_grow: Remove unnecessary nesting in fix_rindex()
For readability.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_grow.c | 58 ++++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 10676a1..dbee4bc 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -262,42 +262,44 @@ static void fix_rindex(int rindex_fd, lgfs2_rgrps_t rgs, unsigned old_rg_count,
char *buf;
ssize_t count;
ssize_t writelen;
+ off_t rindex_size;
const size_t entrysize = sizeof(struct gfs2_rindex);
log_info( _("%d new rindex entries.\n"), rgcount);
buf = rindex_buffer(rgs, rgcount);
writelen = rgcount * entrysize;
- if (!test) {
- off_t rindex_size = lseek(rindex_fd, 0, SEEK_END);
- if (rindex_size != old_rg_count * entrysize) {
- log_crit(_("Incorrect rindex size. Want %ld (%d resource groups), have %ld\n"),
- (long)(old_rg_count * entrysize), old_rg_count,
- (long)rindex_size);
+ if (test)
+ goto out;
+
+ rindex_size = lseek(rindex_fd, 0, SEEK_END);
+ if (rindex_size != old_rg_count * entrysize) {
+ log_crit(_("Incorrect rindex size. Want %ld (%d resource groups), have %ld\n"),
+ (long)(old_rg_count * entrysize), old_rg_count,
+ (long)rindex_size);
+ goto out;
+ }
+ /* Write the first entry separately to ensure there's enough
+ space in the fs for the rest */
+ count = write(rindex_fd, buf, entrysize);
+ if (count != entrysize) {
+ log_crit(_("Error writing first new rindex entry; aborted.\n"));
+ if (count > 0)
+ goto trunc;
+ else
+ goto out;
+ }
+ count = write(rindex_fd, (buf + entrysize), (writelen - entrysize));
+ if (count != (writelen - entrysize)) {
+ log_crit(_("Error writing new rindex entries; aborted.\n"));
+ if (count > 0)
+ goto trunc;
+ else
goto out;
- }
- /* Write the first entry separately to ensure there's enough
- space in the fs for the rest */
- count = write(rindex_fd, buf, entrysize);
- if (count != entrysize) {
- log_crit(_("Error writing first new rindex entry; aborted.\n"));
- if (count > 0)
- goto trunc;
- else
- goto out;
- }
- count = write(rindex_fd, (buf + entrysize), (writelen - entrysize));
- if (count != (writelen - entrysize)) {
- log_crit(_("Error writing new rindex entries; aborted.\n"));
- if (count > 0)
- goto trunc;
- else
- goto out;
- }
- if (fallocate(rindex_fd, FALLOC_FL_KEEP_SIZE, (rindex_size + writelen), entrysize) != 0)
- perror("fallocate");
- fsync(rindex_fd);
}
+ if (fallocate(rindex_fd, FALLOC_FL_KEEP_SIZE, (rindex_size + writelen), entrysize) != 0)
+ perror("fallocate");
+ fsync(rindex_fd);
out:
free(buf);
return;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 10 months
[gfs2-utils] 04/05: gfs2_grow: Fix unchecked ftruncate return value
warning
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 555365ffde93b103922cff8acf8ffcb819ed7d66
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 3 16:52:54 2017 +0100
gfs2_grow: Fix unchecked ftruncate return value warning
main_grow.c:308:2: warning: ignoring return value of ‘ftruncate’,
declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_grow.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 66ba057..10676a1 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -305,7 +305,8 @@ trunc:
count = (count / sizeof(struct gfs2_rindex)) + old_rg_count;
log_crit(_("truncating rindex to %ld entries\n"),
(long)count * sizeof(struct gfs2_rindex));
- ftruncate(rindex_fd, (off_t)count * sizeof(struct gfs2_rindex));
+ if (ftruncate(rindex_fd, (off_t)count * sizeof(struct gfs2_rindex)))
+ log_crit(_("Could not truncate rindex: %s\n"), strerror(errno));
free(buf);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 10 months
[gfs2-utils] 03/05: fsck.gfs2: Fix unchecked return value warning
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit a5e3d567df85040a3f1145c810b8e1cf394e9ede
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 3 16:34:03 2017 +0100
fsck.gfs2: Fix unchecked return value warning
initialize.c:1703:4: warning: ignoring return value of ‘write’,
declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/initialize.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 75f050b..5862fc3 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1700,10 +1700,12 @@ void destroy(struct gfs2_sbd *sdp)
if (was_mounted_ro && errors_corrected) {
sdp->device_fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
if (sdp->device_fd >= 0) {
- write(sdp->device_fd, "2", 1);
+ if (write(sdp->device_fd, "2", 1) == 2) {
+ close(sdp->device_fd);
+ return;
+ }
close(sdp->device_fd);
- } else
- log_err( _("fsck.gfs2: Non-fatal error dropping "
- "caches.\n"));
+ }
+ log_warn(_("fsck.gfs2: Could not flush caches (non-fatal).\n"));
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 10 months
[gfs2-utils] 02/05: fsck.gfs2: Fix snprintf truncation warning
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 231a5d43493b6e7e7a8e968714aed1599ffc8b46
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 3 16:17:10 2017 +0100
fsck.gfs2: Fix snprintf truncation warning
Increase the journal name buffer by two bytes so that the compiler knows
that there's enough space for any journal number.
fs_recovery.c:807:14: warning: ‘%u’ directive output may be truncated
writing between 1 and 10 bytes into a region of size 9 [-Wformat-truncation=]
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/fs_recovery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index e50a248..775c27b 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -16,7 +16,7 @@
#include "metawalk.h"
#include "util.h"
-#define JOURNAL_NAME_SIZE 16
+#define JOURNAL_NAME_SIZE 18
#define JOURNAL_SEQ_TOLERANCE 10
unsigned int sd_found_jblocks = 0, sd_replayed_jblocks = 0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 10 months
[gfs2-utils] 01/05: gfs2_convert: Fix fgets return value warning
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit a39faf8697e487079feb7c99a41dcf51af2ebc37
Author: Andrew Price <anprice(a)redhat.com>
Date: Thu Aug 3 16:03:14 2017 +0100
gfs2_convert: Fix fgets return value warning
Rewrite the gfs2_query() function to use the input method used in
mkfs.gfs2 and avoid problems with fgets()
gfs2_convert.c:2139:3: warning: ignoring return value of ‘fgets’,
declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 5d813dc..d5e98e6 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2123,8 +2123,7 @@ static void copy_quotas(struct gfs2_sbd *sdp)
static int gfs2_query(struct gfs2_options *opts, const char *dev)
{
- char response[3] = { 0, 0 };
- int ret = 0;
+ int res = 0;
if(opts->yes)
return 1;
@@ -2133,27 +2132,25 @@ static int gfs2_query(struct gfs2_options *opts, const char *dev)
opts->query = TRUE;
while (1) {
+ char *line = NULL;
+ size_t len = 0;
+ int ret;
+
printf(_("Convert %s from GFS1 to GFS2? (y/n)"), dev);
- /* Make sure query is printed out */
- fflush(NULL);
- fgets(response, 3, stdin);
- printf("\n");
- fflush(NULL);
- response[1] = 0;
- ret = rpmatch(response);
-
- if (ret >= 0)
+ fflush(stdout);
+ ret = getline(&line, &len, stdin);
+ res = rpmatch(line);
+ free(line);
+ if (ret <= 0)
+ continue;
+ if (res == 1 || res == 0)
break;
- printf(_("Bad response '%s', please type 'y' or 'n'.\n"), response);
+ /* Unrecognized input; go again. */
}
-
opts->query = FALSE;
- return ret;
+ return res;
}
-/* ------------------------------------------------------------------------- */
-/* main - mainline code */
-/* ------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
int error;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 10 months