Whamcloud - gitweb
debugfs: add filefrag command
[tools/e2fsprogs.git] / lib / ext2fs / undo_io.c
index 45bcad7..56b0eeb 100644 (file)
@@ -6,14 +6,15 @@
  * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  *
  * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
  * %End-Header%
  */
 
 #define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #if HAVE_UNISTD_H
@@ -148,7 +149,7 @@ static errcode_t write_file_system_identity(io_channel undo_channel,
        block_size = channel->block_size;
 
        io_channel_set_blksize(channel, SUPERBLOCK_OFFSET);
-       retval = io_channel_read_blk(channel, 1, -SUPERBLOCK_SIZE, &super);
+       retval = io_channel_read_blk64(channel, 1, -SUPERBLOCK_SIZE, &super);
        if (retval)
                goto err_out;
 
@@ -357,7 +358,7 @@ static errcode_t undo_open(const char *name, int flags, io_channel *channel)
                return EXT2_ET_BAD_DEVICE_NAME;
        retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
        if (retval)
-               return retval;
+               goto cleanup;
        memset(io, 0, sizeof(struct struct_io_channel));
        io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
        retval = ext2fs_get_mem(sizeof(struct undo_private_data), &data);
@@ -400,13 +401,14 @@ static errcode_t undo_open(const char *name, int flags, io_channel *channel)
         * setup err handler for read so that we know
         * when the backing manager fails do short read
         */
-       undo_err_handler_init(data->real);
+       if (data->real)
+               undo_err_handler_init(data->real);
 
        *channel = io;
        return 0;
 
 cleanup:
-       if (data->real)
+       if (data && data->real)
                io_channel_close(data->real);
        if (data)
                ext2fs_free_mem(&data);