int fd;
struct exfat_super_block sb;
- fd = open(spec, O_RDONLY);
+ fd = exfat_open(spec, 1);
if (fd < 0)
- {
- exfat_error("failed to open `%s'", spec);
return 1;
- }
+
if (read(fd, &sb, sizeof(struct exfat_super_block))
!= sizeof(struct exfat_super_block))
{
#include <string.h>
#include <stdlib.h>
#include <errno.h>
-#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
-#include <sys/stat.h>
#define _XOPEN_SOURCE /* for tzset() in Linux */
#include <time.h>
int exfat_mount(struct exfat* ef, const char* spec, const char* options)
{
int rc;
- struct stat stbuf;
tzset();
memset(ef, 0, sizeof(struct exfat));
parse_options(ef, options);
- ef->fd = open(spec, ef->ro ? O_RDONLY : O_RDWR);
+ ef->fd = exfat_open(spec, ef->ro);
if (ef->fd < 0)
{
free(ef->sb);
- exfat_error("failed to open `%s'", spec);
- return -EIO;
- }
- if (fstat(ef->fd, &stbuf) != 0)
- {
- close(ef->fd);
- free(ef->sb);
- exfat_error("failed to fstat `%s'", spec);
- return -EIO;
- }
- if (!S_ISBLK(stbuf.st_mode) && !S_ISREG(stbuf.st_mode))
- {
- close(ef->fd);
- free(ef->sb);
- exfat_error("`%s' is neither a block device, nor a regular file",
- spec);
return -EIO;
}
*/
#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/time.h>
-#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>
#include <stdio.h>
return 1;
}
- fd = open(spec_abs, O_RDWR);
+ fd = exfat_open(spec_abs, 0);
if (fd < 0)
- {
- exfat_error("failed to open special file `%s'", spec_abs);
return 1;
- }
volume_size = lseek(fd, 0, SEEK_END);
if (volume_size == (off_t) -1)