This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch main
in repository gfs2-utils.
The following commit(s) were added to refs/heads/main by this push:
new aba9dff8 fsck.gfs2: Clean up set_block_ranges()
aba9dff8 is described below
commit aba9dff87a5c65a642f2c5151420ed799f42fd1f
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Jan 10 13:02:45 2022 +0000
fsck.gfs2: Clean up set_block_ranges()
- Remove a VLA
- Use pread instead of lseek+read
- Improve error reporting
- Remove fsck_lseek() which is now unused
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/initialize.c | 24 +++++++++++-------------
gfs2/fsck/util.h | 3 ---
2 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index a3ab7f7e..b9db79b0 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -133,10 +133,10 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
{
struct osi_node *n, *next = NULL;
struct rgrp_tree *rgd;
- char buf[sdp->sd_bsize];
uint64_t rmax = 0;
uint64_t rmin = 0;
- int error;
+ ssize_t count;
+ char *buf;
log_info( _("Setting block ranges..."));
@@ -161,18 +161,16 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
last_data_block = rmax;
first_data_block = rmin;
- if (fsck_lseek(sdp->device_fd, (last_fs_block * sdp->sd_bsize))){
- log_crit(_("Can't seek to last block in file system: %"PRIu64"
(0x%"PRIx64")\n"),
- last_fs_block, last_fs_block);
- goto fail;
+ buf = calloc(1, sdp->sd_bsize);
+ if (buf == NULL) {
+ log_crit(_("Failed to determine file system boundaries: %s\n"),
strerror(errno));
+ return -1;
}
-
- memset(buf, 0, sdp->sd_bsize);
- error = read(sdp->device_fd, buf, sdp->sd_bsize);
- if (error != sdp->sd_bsize){
- log_crit(_("Can't read last block in file system (error %u), "
- "last_fs_block: %"PRIu64" (0x%"PRIx64")\n"),
- error, last_fs_block, last_fs_block);
+ count = pread(sdp->device_fd, buf, sdp->sd_bsize, (last_fs_block *
sdp->sd_bsize));
+ free(buf);
+ if (count != sdp->sd_bsize) {
+ log_crit(_("Failed to read highest block number (%"PRIx64"):
%s\n"),
+ last_fs_block, strerror(errno));
goto fail;
}
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index 7b0519a5..5f9c488b 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -6,9 +6,6 @@
#include "fsck.h"
#include "libgfs2.h"
-#define fsck_lseek(fd, off) \
- ((lseek((fd), (off), SEEK_SET) == (off)) ? 0 : -1)
-
#define INODE_VALID 1
#define INODE_INVALID 0
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date