• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisão640f9d07c4461f3871b4cb1c4de652c42b169397 (tree)
Hora2016-12-09 15:54:33
AutorAndrew P. Boie <andrew.p.boie@inte...>
CommiterChih-Wei Huang

Mensagem de Log

libdiskconfig: Enable Mac OS X host build

Change-Id: Iacc7d5463364d0cd15ca9fabaa58ad05857d9e78
Signed-off-by: Andrew P. Boie <andrew.p.boie@intel.com>

Mudança Sumário

Diff

--- a/include/diskconfig/diskconfig.h
+++ b/include/diskconfig/diskconfig.h
@@ -21,6 +21,11 @@
2121 #include <stdint.h>
2222 #include <sys/types.h>
2323
24+#ifdef __APPLE__
25+typedef int64_t loff_t;
26+#define lseek64 lseek
27+#endif
28+
2429 #ifdef __cplusplus
2530 extern "C" {
2631 #endif
--- a/libdiskconfig/Android.mk
+++ b/libdiskconfig/Android.mk
@@ -15,11 +15,9 @@ LOCAL_SYSTEM_SHARED_LIBRARIES := libcutils liblog libc
1515 LOCAL_CFLAGS := -Werror
1616 include $(BUILD_SHARED_LIBRARY)
1717
18-ifeq ($(HOST_OS),linux)
1918 include $(CLEAR_VARS)
2019 LOCAL_SRC_FILES := $(commonSources)
2120 LOCAL_MODULE := libdiskconfig_host
2221 LOCAL_MODULE_TAGS := optional
23-LOCAL_CFLAGS := -O2 -g -W -Wall -Werror -D_LARGEFILE64_SOURCE
22+LOCAL_CFLAGS := -O2 -g -W -Wall -Werror -D_LARGEFILE64_SOURCE -DHOST_BUILD
2423 include $(BUILD_HOST_STATIC_LIBRARY)
25-endif # HOST_OS == linux
--- a/libdiskconfig/diskconfig.c
+++ b/libdiskconfig/diskconfig.c
@@ -27,7 +27,9 @@
2727 #include <sys/ioctl.h>
2828 #include <sys/stat.h>
2929
30+#ifndef HOST_BUILD
3031 #include <linux/fs.h>
32+#endif
3133
3234 #include <cutils/config_utils.h>
3335 #include <log/log.h>
@@ -236,6 +238,7 @@ fail:
236238 return NULL;
237239 }
238240
241+#ifndef HOST_BUILD
239242 static int
240243 sync_ptable(int fd)
241244 {
@@ -256,6 +259,13 @@ sync_ptable(int fd)
256259
257260 return 0;
258261 }
262+#else
263+static int sync_ptable(int fd)
264+{
265+ (void)fd;
266+ return 0;
267+}
268+#endif
259269
260270 /* This function verifies that the disk info provided is valid, and if so,
261271 * returns an open file descriptor.
@@ -272,7 +282,6 @@ static int
272282 validate(struct disk_info *dinfo)
273283 {
274284 int fd;
275- int sect_sz;
276285 uint64_t disk_size;
277286 uint64_t total_size;
278287 int cnt;
@@ -298,6 +307,12 @@ validate(struct disk_info *dinfo)
298307 /* Verify that we can operate on the device that was requested.
299308 * We presently only support block devices and regular file images. */
300309 if (S_ISBLK(stat.st_mode)) {
310+#ifdef HOST_BUILD
311+ ALOGE("Block device manipulation on host forbidden");
312+ goto fail;
313+#else
314+ int sect_sz;
315+
301316 /* get the sector size and make sure we agree */
302317 if (ioctl(fd, BLKSSZGET, &sect_sz) < 0) {
303318 ALOGE("Cannot get sector size (errno=%d)", errno);
@@ -319,6 +334,7 @@ validate(struct disk_info *dinfo)
319334 dinfo->num_lba = (uint32_t)(disk_size / (uint64_t)dinfo->sect_size);
320335 } else
321336 disk_size = (uint64_t)dinfo->num_lba * (uint64_t)dinfo->sect_size;
337+#endif
322338 } else if (S_ISREG(stat.st_mode)) {
323339 ALOGI("Requesting operation on a regular file, not block device.");
324340 if (!dinfo->sect_size) {