From c40c1c52d68049434b1379c3a6d8652a1363bb07 Mon Sep 17 00:00:00 2001 From: bigbiff Date: Sat, 1 Nov 2014 09:34:57 -0400 Subject: This patchset causes issues with backups. Revert "update exfat from current head" This reverts commit 2e33c5ee0b1a1ece068489e8fd99f3e4eb3501b5. Change-Id: I00d19d98f721bb50aa937ca15b11fe3491132fcd --- exfat/libexfat/io.c | 86 +++++++++++++---------------------------------------- 1 file changed, 21 insertions(+), 65 deletions(-) (limited to 'exfat/libexfat/io.c') diff --git a/exfat/libexfat/io.c b/exfat/libexfat/io.c index a861bddd7..306c5dd06 100644 --- a/exfat/libexfat/io.c +++ b/exfat/libexfat/io.c @@ -3,7 +3,7 @@ exFAT file system implementation library. Free exFAT implementation. - Copyright (C) 2010-2014 Andrew Nayenko + Copyright (C) 2010-2013 Andrew Nayenko This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,19 +24,13 @@ #include #include #include +#include #include #include #include -#include -#if defined(__APPLE__) +#ifdef __APPLE__ #include -#elif defined(__OpenBSD__) -#include -#include -#include -#include #endif -#include #ifdef USE_UBLIO #include #include @@ -71,7 +65,6 @@ static int open_rw(const char* spec) if (fd != -1 && ioctl(fd, BLKROGET, &ro) == 0 && ro) { close(fd); - errno = EROFS; return -1; } #endif @@ -100,8 +93,7 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) if (dev->fd == -1) { free(dev); - exfat_error("failed to open '%s' in read-only mode: %s", spec, - strerror(errno)); + exfat_error("failed to open `%s' in read-only mode", spec); return NULL; } dev->mode = EXFAT_MODE_RO; @@ -111,8 +103,7 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) if (dev->fd == -1) { free(dev); - exfat_error("failed to open '%s' in read-write mode: %s", spec, - strerror(errno)); + exfat_error("failed to open `%s' in read-write mode", spec); return NULL; } dev->mode = EXFAT_MODE_RW; @@ -128,11 +119,11 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) if (dev->fd != -1) { dev->mode = EXFAT_MODE_RO; - exfat_warn("'%s' is write-protected, mounting read-only", spec); + exfat_warn("`%s' is write-protected, mounting read-only", spec); break; } free(dev); - exfat_error("failed to open '%s': %s", spec, strerror(errno)); + exfat_error("failed to open `%s'", spec); return NULL; } @@ -140,7 +131,7 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) { close(dev->fd); free(dev); - exfat_error("failed to fstat '%s'", spec); + exfat_error("failed to fstat `%s'", spec); return NULL; } if (!S_ISBLK(stbuf.st_mode) && @@ -149,11 +140,11 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) { close(dev->fd); free(dev); - exfat_error("'%s' is neither a device, nor a regular file", spec); + exfat_error("`%s' is neither a device, nor a regular file", spec); return NULL; } -#if defined(__APPLE__) +#ifdef __APPLE__ if (!S_ISREG(stbuf.st_mode)) { uint32_t block_size = 0; @@ -176,32 +167,6 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) dev->size = blocks * block_size; } else -#elif defined(__OpenBSD__) - if (!S_ISREG(stbuf.st_mode)) - { - struct disklabel lab; - struct partition* pp; - char* partition; - - if (ioctl(dev->fd, DIOCGDINFO, &lab) == -1) - { - close(dev->fd); - free(dev); - exfat_error("failed to get disklabel"); - return NULL; - } - - /* Don't need to check that partition letter is valid as we won't get - this far otherwise. */ - partition = strchr(spec, '\0') - 1; - pp = &(lab.d_partitions[*partition - 'a']); - dev->size = DL_GETPSIZE(pp) * lab.d_secsize; - - if (pp->p_fstype != FS_NTFS) - exfat_warn("partition type is not 0x07 (NTFS/exFAT); " - "you can fix this with fdisk(8)"); - } - else #endif { /* works for Linux, FreeBSD, Solaris */ @@ -210,14 +175,14 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) { close(dev->fd); free(dev); - exfat_error("failed to get size of '%s'", spec); + exfat_error("failed to get size of `%s'", spec); return NULL; } if (exfat_seek(dev, 0, SEEK_SET) == -1) { close(dev->fd); free(dev); - exfat_error("failed to seek to the beginning of '%s'", spec); + exfat_error("failed to seek to the beginning of `%s'", spec); return NULL; } } @@ -245,41 +210,32 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) int exfat_close(struct exfat_dev* dev) { - int rc = 0; - #ifdef USE_UBLIO if (ublio_close(dev->ufh) != 0) - { exfat_error("failed to close ublio"); - rc = -EIO; - } #endif if (close(dev->fd) != 0) { - exfat_error("failed to close device: %s", strerror(errno)); - rc = -EIO; + free(dev); + exfat_error("failed to close device"); + return 1; } free(dev); - return rc; + return 0; } int exfat_fsync(struct exfat_dev* dev) { - int rc = 0; - #ifdef USE_UBLIO if (ublio_fsync(dev->ufh) != 0) - { - exfat_error("ublio fsync failed"); - rc = -EIO; - } -#endif +#else if (fsync(dev->fd) != 0) +#endif { - exfat_error("fsync failed: %s", strerror(errno)); - rc = -EIO; + exfat_error("fsync failed"); + return 1; } - return rc; + return 0; } enum exfat_mode exfat_get_mode(const struct exfat_dev* dev) -- cgit v1.2.3