From: Theodore Ts'o Date: Wed, 22 Apr 2009 19:10:36 +0000 (-0400) Subject: resize2fs: Print a warning message if the ftruncate system call fails X-Git-Tag: v1.41.5~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb72556af88bf01459519d1028743c54a71bcca1;p=thirdparty%2Fe2fsprogs.git 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" --- diff --git a/resize/main.c b/resize/main.c index 3de333e0b..6977d8483 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);