summaryrefslogtreecommitdiff
path: root/lib/ext2fs/unix_io.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2011-09-15 23:44:48 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-09-15 23:46:57 -0400
commitc859cb1de0d624caa0779fb17d1a53766143136e (patch)
tree0cbd868dc9bcda7eeb2463535b38f34aad6587e4 /lib/ext2fs/unix_io.c
parentdb8bbf27c9eeaa9c1803fb52a6cc7a60c5250c7e (diff)
downloade2fsprogs-c859cb1de0d624caa0779fb17d1a53766143136e.tar.gz
e2fsprogs: create open() and stat() helpers
In many places we are using #ifdef HAVE_OPEN64 to determine if we can use open64() but that's ugly. This commit creates two new helpers ext2fs_open_file() for open() and ext2fs_stat() for stat(). Also we need new typedef ext2fs_struct_stat for struct stat. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs/unix_io.c')
-rw-r--r--lib/ext2fs/unix_io.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index c1d05615..21a273db 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -441,7 +441,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
struct unix_private_data *data = NULL;
errcode_t retval;
int open_flags, zeroes = 0;
- struct stat st;
+ ext2fs_struct_stat st;
#ifdef __linux__
struct utsname ut;
#endif
@@ -482,11 +482,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
#endif
data->flags = flags;
-#ifdef HAVE_OPEN64
- data->dev = open64(io->name, open_flags);
-#else
- data->dev = open(io->name, open_flags);
-#endif
+ data->dev = ext2fs_open_file(io->name, open_flags);
if (data->dev < 0) {
retval = errno;
goto cleanup;
@@ -552,7 +548,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
(ut.release[2] == '4') && (ut.release[3] == '.') &&
(ut.release[4] == '1') && (ut.release[5] >= '0') &&
(ut.release[5] < '8')) &&
- (fstat(data->dev, &st) == 0) &&
+ (ext2fs_stat(io->name, &st) == 0) &&
(S_ISBLK(st.st_mode))) {
struct rlimit rlim;