From a38faefd8df3f6a9008b36bb4494d965d087c00a Mon Sep 17 00:00:00 2001 From: resver Date: Thu, 1 Mar 2012 17:01:44 +0000 Subject: [PATCH] Added exfat_seek() interface (wrapper for lseek()). git-svn-id: http://exfat.googlecode.com/svn/trunk@264 60bc1c72-a15a-11de-b98f-4500b42dc123 --- libexfat/exfat.h | 1 + libexfat/io.c | 5 +++++ mkfs/main.c | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libexfat/exfat.h b/libexfat/exfat.h index 123717c..63fb8ce 100644 --- a/libexfat/exfat.h +++ b/libexfat/exfat.h @@ -123,6 +123,7 @@ void exfat_debug(const char* format, ...) int exfat_open(const char* spec, int ro); int exfat_close(int fd); int exfat_fsync(int fd); +off_t exfat_seek(int fd, off_t offset, int whence); ssize_t exfat_read(int fd, void* buffer, size_t size); ssize_t exfat_write(int fd, const void* buffer, size_t size); void exfat_pread(int fd, void* buffer, size_t size, off_t offset); diff --git a/libexfat/io.c b/libexfat/io.c index 2ab0c03..2f548b6 100644 --- a/libexfat/io.c +++ b/libexfat/io.c @@ -79,6 +79,11 @@ int exfat_fsync(int fd) return 0; } +off_t exfat_seek(int fd, off_t offset, int whence) +{ + return lseek(fd, offset, whence); +} + ssize_t exfat_read(int fd, void* buffer, size_t size) { return read(fd, buffer, size); diff --git a/mkfs/main.c b/mkfs/main.c index 9ed99cd..418d71f 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -123,7 +123,7 @@ static int erase_device(int fd) erase_blocks = DIV_ROUND_UP(erase_size, block_size); - if (lseek(fd, 0, SEEK_SET) == (off_t) -1) + if (exfat_seek(fd, 0, SEEK_SET) == (off_t) -1) { exfat_error("seek failed"); return 1; @@ -189,7 +189,7 @@ static off_t write_structure(int fd, struct exfat_structure* structure, off_t alignment = structure->get_alignment(); off_t base = ROUND_UP(current, alignment); - if (lseek(fd, base, SEEK_SET) == (off_t) -1) + if (exfat_seek(fd, base, SEEK_SET) == (off_t) -1) { exfat_error("seek to %"PRIu64" failed", base); return -1; @@ -282,7 +282,7 @@ static int mkfs(const char* spec, int sector_bits, int spc_bits, if (fd < 0) return 1; - volume_size = lseek(fd, 0, SEEK_END); + volume_size = exfat_seek(fd, 0, SEEK_END); if (volume_size == (off_t) -1) { exfat_close(fd); -- 2.11.0