aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKeith Mok <kmok@cyngn.com>2015-09-03 11:34:33 -0700
committerAdnan Begovic <adnan@cyngn.com>2015-10-19 16:46:11 -0700
commita67732c5e1594d6fd096d04968e71d00ea63a943 (patch)
tree64ea669b48cb9be1959cb34e71b7412cfdce56a8 /lib
parent166b0a9411e0de50327029ac49bb49ad3492aca2 (diff)
downloadandroid_external_f2fs-tools-a67732c5e1594d6fd096d04968e71d00ea63a943.tar.gz
android_external_f2fs-tools-a67732c5e1594d6fd096d04968e71d00ea63a943.tar.bz2
android_external_f2fs-tools-a67732c5e1594d6fd096d04968e71d00ea63a943.zip
Add darwin support for building the host tools
Change-Id: Ibe5976c3db03020fcdad41ead53cb141a9b35d80
Diffstat (limited to 'lib')
-rw-r--r--lib/libf2fs.c15
-rw-r--r--lib/libf2fs_io.c2
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index a7021ad..1792d68 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -14,12 +14,14 @@
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
+#ifdef __linux__
#include <mntent.h>
+#include <linux/hdreg.h>
+#endif
#include <time.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/ioctl.h>
-#include <linux/hdreg.h>
#include <f2fs_fs.h>
@@ -367,6 +369,7 @@ void f2fs_init_configuration(struct f2fs_configuration *c)
static int is_mounted(const char *mpt, const char *device)
{
+#ifdef __linux__
FILE *file = NULL;
struct mntent *mnt = NULL;
@@ -380,6 +383,10 @@ static int is_mounted(const char *mpt, const char *device)
}
endmntent(file);
return mnt ? 1 : 0;
+#else
+ /* TODO */
+ return 0;
+#endif
}
int f2fs_dev_is_umounted(struct f2fs_configuration *c)
@@ -387,11 +394,13 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
struct stat st_buf;
int ret = 0;
+#ifdef __linux__
ret = is_mounted(MOUNTED, c->device_name);
if (ret) {
MSG(0, "\tError: Not available on mounted device!\n");
return -1;
}
+#endif
/*
* if failed due to /etc/mtab file not present
@@ -438,7 +447,9 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
uint32_t total_sectors;
#endif
struct stat stat_buf;
+#ifdef __linux__
struct hd_geometry geom;
+#endif
u_int64_t wanted_total_sectors = c->total_sectors;
fd = open(c->device_name, O_RDWR);
@@ -472,6 +483,7 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
MSG(0, "from device of size %u sectors\n",
(unsigned int) (stat_buf.st_size / c->sector_size));
}
+#ifdef __linux__
} else if (S_ISBLK(stat_buf.st_mode)) {
if (ioctl(fd, BLKSSZGET, &sector_size) < 0) {
MSG(0, "\tError: Using the default sector size\n");
@@ -522,6 +534,7 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
c->start_sector = 0;
else
c->start_sector = geom.start;
+#endif
} else {
MSG(0, "\tError: Volume type is not supported!!!\n");
return -1;
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index afa345f..2f33cde 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -14,12 +14,10 @@
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
-#include <mntent.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/ioctl.h>
-#include <linux/hdreg.h>
#include <f2fs_fs.h>