LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)
-ifeq ($(HOST_OS),linux)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(commonSources)
LOCAL_MODULE := libdiskconfig_host
LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS := -O2 -g -W -Wall -Werror -D_LARGEFILE64_SOURCE
+LOCAL_CFLAGS := -O2 -g -W -Wall -Werror -D_LARGEFILE64_SOURCE -DHOST_BUILD
include $(BUILD_HOST_STATIC_LIBRARY)
-endif # HOST_OS == linux
#include <sys/ioctl.h>
#include <sys/stat.h>
+#ifndef HOST_BUILD
#include <linux/fs.h>
+#endif
#include <cutils/config_utils.h>
#include <log/log.h>
return NULL;
}
+#ifndef HOST_BUILD
static int
sync_ptable(int fd)
{
return 0;
}
+#else
+static int sync_ptable(int fd)
+{
+ (void)fd;
+ return 0;
+}
+#endif
/* This function verifies that the disk info provided is valid, and if so,
* returns an open file descriptor.
validate(struct disk_info *dinfo)
{
int fd;
- int sect_sz;
uint64_t disk_size;
uint64_t total_size;
int cnt;
/* Verify that we can operate on the device that was requested.
* We presently only support block devices and regular file images. */
if (S_ISBLK(stat.st_mode)) {
+#ifdef HOST_BUILD
+ ALOGE("Block device manipulation on host forbidden");
+ goto fail;
+#else
+ int sect_sz;
+
/* get the sector size and make sure we agree */
if (ioctl(fd, BLKSSZGET, §_sz) < 0) {
ALOGE("Cannot get sector size (errno=%d)", errno);
dinfo->num_lba = (uint32_t)(disk_size / (uint64_t)dinfo->sect_size);
} else
disk_size = (uint64_t)dinfo->num_lba * (uint64_t)dinfo->sect_size;
+#endif
} else if (S_ISREG(stat.st_mode)) {
ALOGI("Requesting operation on a regular file, not block device.");
if (!dinfo->sect_size) {