system/corennnnn
Revisão | 640f9d07c4461f3871b4cb1c4de652c42b169397 (tree) |
---|---|
Hora | 2016-12-09 15:54:33 |
Autor | Andrew P. Boie <andrew.p.boie@inte...> |
Commiter | Chih-Wei Huang |
libdiskconfig: Enable Mac OS X host build
Change-Id: Iacc7d5463364d0cd15ca9fabaa58ad05857d9e78
Signed-off-by: Andrew P. Boie <andrew.p.boie@intel.com>
@@ -21,6 +21,11 @@ | ||
21 | 21 | #include <stdint.h> |
22 | 22 | #include <sys/types.h> |
23 | 23 | |
24 | +#ifdef __APPLE__ | |
25 | +typedef int64_t loff_t; | |
26 | +#define lseek64 lseek | |
27 | +#endif | |
28 | + | |
24 | 29 | #ifdef __cplusplus |
25 | 30 | extern "C" { |
26 | 31 | #endif |
@@ -15,11 +15,9 @@ LOCAL_SYSTEM_SHARED_LIBRARIES := libcutils liblog libc | ||
15 | 15 | LOCAL_CFLAGS := -Werror |
16 | 16 | include $(BUILD_SHARED_LIBRARY) |
17 | 17 | |
18 | -ifeq ($(HOST_OS),linux) | |
19 | 18 | include $(CLEAR_VARS) |
20 | 19 | LOCAL_SRC_FILES := $(commonSources) |
21 | 20 | LOCAL_MODULE := libdiskconfig_host |
22 | 21 | 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 | |
24 | 23 | include $(BUILD_HOST_STATIC_LIBRARY) |
25 | -endif # HOST_OS == linux |
@@ -27,7 +27,9 @@ | ||
27 | 27 | #include <sys/ioctl.h> |
28 | 28 | #include <sys/stat.h> |
29 | 29 | |
30 | +#ifndef HOST_BUILD | |
30 | 31 | #include <linux/fs.h> |
32 | +#endif | |
31 | 33 | |
32 | 34 | #include <cutils/config_utils.h> |
33 | 35 | #include <log/log.h> |
@@ -236,6 +238,7 @@ fail: | ||
236 | 238 | return NULL; |
237 | 239 | } |
238 | 240 | |
241 | +#ifndef HOST_BUILD | |
239 | 242 | static int |
240 | 243 | sync_ptable(int fd) |
241 | 244 | { |
@@ -256,6 +259,13 @@ sync_ptable(int fd) | ||
256 | 259 | |
257 | 260 | return 0; |
258 | 261 | } |
262 | +#else | |
263 | +static int sync_ptable(int fd) | |
264 | +{ | |
265 | + (void)fd; | |
266 | + return 0; | |
267 | +} | |
268 | +#endif | |
259 | 269 | |
260 | 270 | /* This function verifies that the disk info provided is valid, and if so, |
261 | 271 | * returns an open file descriptor. |
@@ -272,7 +282,6 @@ static int | ||
272 | 282 | validate(struct disk_info *dinfo) |
273 | 283 | { |
274 | 284 | int fd; |
275 | - int sect_sz; | |
276 | 285 | uint64_t disk_size; |
277 | 286 | uint64_t total_size; |
278 | 287 | int cnt; |
@@ -298,6 +307,12 @@ validate(struct disk_info *dinfo) | ||
298 | 307 | /* Verify that we can operate on the device that was requested. |
299 | 308 | * We presently only support block devices and regular file images. */ |
300 | 309 | 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 | + | |
301 | 316 | /* get the sector size and make sure we agree */ |
302 | 317 | if (ioctl(fd, BLKSSZGET, §_sz) < 0) { |
303 | 318 | ALOGE("Cannot get sector size (errno=%d)", errno); |
@@ -319,6 +334,7 @@ validate(struct disk_info *dinfo) | ||
319 | 334 | dinfo->num_lba = (uint32_t)(disk_size / (uint64_t)dinfo->sect_size); |
320 | 335 | } else |
321 | 336 | disk_size = (uint64_t)dinfo->num_lba * (uint64_t)dinfo->sect_size; |
337 | +#endif | |
322 | 338 | } else if (S_ISREG(stat.st_mode)) { |
323 | 339 | ALOGI("Requesting operation on a regular file, not block device."); |
324 | 340 | if (!dinfo->sect_size) { |