Whamcloud - gitweb
libext2fs: precompute FS UUID checksum seed
[tools/e2fsprogs.git] / lib / ext2fs / fileio.c
index 324f046..1f7002c 100644 (file)
@@ -9,6 +9,7 @@
  * %End-Header%
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #if HAVE_UNISTD_H
@@ -105,6 +106,14 @@ struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file)
        return &file->inode;
 }
 
+/* This function returns the inode number from the structure */
+ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file)
+{
+       if (file->magic != EXT2_ET_MAGIC_EXT2_FILE)
+               return 0;
+       return file->ino;
+}
+
 /*
  * This function flushes the dirty block buffer out to disk if
  * necessary.
@@ -388,7 +397,7 @@ errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size)
                        return retval;
        }
 
-       if (truncate_block <= old_truncate)
+       if (truncate_block >= old_truncate)
                return 0;
 
        return ext2fs_punch(file->fs, file->ino, &file->inode, 0,