diff options
author | Lukas Czerner <lczerner@redhat.com> | 2011-09-15 23:44:48 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-15 23:46:57 -0400 |
commit | c859cb1de0d624caa0779fb17d1a53766143136e (patch) | |
tree | 0cbd868dc9bcda7eeb2463535b38f34aad6587e4 /misc/e2image.c | |
parent | db8bbf27c9eeaa9c1803fb52a6cc7a60c5250c7e (diff) | |
download | e2fsprogs-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 'misc/e2image.c')
-rw-r--r-- | misc/e2image.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/misc/e2image.c b/misc/e2image.c index bf0c0d43..f6e06d23 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -1177,11 +1177,7 @@ static void install_image(char *device, char *image_fn, int type) exit(1); } -#ifdef HAVE_OPEN64 - fd = open64(image_fn, O_RDONLY); -#else - fd = open(image_fn, O_RDONLY); -#endif + fd = ext2fs_open_file(image_fn, O_RDONLY); if (fd < 0) { perror(image_fn); exit(1); @@ -1213,11 +1209,7 @@ static void install_image(char *device, char *image_fn, int type) static struct ext2_qcow2_hdr *check_qcow2_image(int *fd, char *name) { -#ifdef HAVE_OPEN64 - *fd = open64(name, O_RDONLY, 0600); -#else - *fd = open(name, O_RDONLY, 0600); -#endif + *fd = ext2fs_open_file(name, O_RDONLY, 0600); if (*fd < 0) return NULL; @@ -1301,11 +1293,7 @@ skip_device: if (strcmp(image_fn, "-") == 0) fd = 1; else { -#ifdef HAVE_OPEN64 - fd = open64(image_fn, O_CREAT|O_TRUNC|O_WRONLY, 0600); -#else - fd = open(image_fn, O_CREAT|O_TRUNC|O_WRONLY, 0600); -#endif + fd = ext2fs_open_file(image_fn, O_CREAT|O_TRUNC|O_WRONLY, 0600); if (fd < 0) { com_err(program_name, errno, _("while trying to open %s"), argv[optind+1]); |