From fb72556af88bf01459519d1028743c54a71bcca1 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 22 Apr 2009 15:10:36 -0400 Subject: [PATCH] resize2fs: Print a warning message if the ftruncate system call fails Resize2fs will attempt to truncate an image file of a filesystem down to size for the convenience of the system administrator. If the truncate operation fails, print a warning message. This also avoids a gcc warning message. Signed-off-by: "Theodore Ts'o" --- resize/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resize/main.c b/resize/main.c index 3de333e..6977d84 100644 --- a/resize/main.c +++ b/resize/main.c @@ -455,12 +455,17 @@ int main (int argc, char ** argv) if ((st_buf.st_size > new_file_size) && (fd > 0)) { #ifdef HAVE_FTRUNCATE64 - ftruncate64(fd, new_file_size); + retval = ftruncate64(fd, new_file_size); #else + retval = 0; /* Only truncate if new_file_size doesn't overflow off_t */ if (((off_t) new_file_size) == new_file_size) - ftruncate(fd, (off_t) new_file_size); + retval = ftruncate(fd, (off_t) new_file_size); #endif + if (retval) + com_err(program_name, retval, + _("while trying to truncate %s"), + device_name); } if (fd > 0) close(fd); -- 1.8.3.1