OSDN Git Service

Added exfat_seek() interface (wrapper for lseek()).
authorresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Thu, 1 Mar 2012 17:01:44 +0000 (17:01 +0000)
committerresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Thu, 1 Mar 2012 17:01:44 +0000 (17:01 +0000)
git-svn-id: http://exfat.googlecode.com/svn/trunk@264 60bc1c72-a15a-11de-b98f-4500b42dc123

libexfat/exfat.h
libexfat/io.c
mkfs/main.c

index 123717c..63fb8ce 100644 (file)
@@ -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);
index 2ab0c03..2f548b6 100644 (file)
@@ -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);
index 9ed99cd..418d71f 100644 (file)
@@ -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);