• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
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

修订版c472b6a362f3a2dfc3d65a035ff1bc59951a9ef2 (tree)
时间2016-11-09 00:27:22
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Merge branch 'android-ia' into nougat-x86

更改概述

差异

--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -51,7 +51,48 @@ ADB_MUTEX_DEFINE(local_transports_lock);
5151 * trying to connect twice to a given local transport.
5252 */
5353 static atransport* local_transports[ ADB_LOCAL_TRANSPORT_MAX ];
54-#endif /* ADB_HOST */
54+#else /* !ADB_HOST */
55+
56+#define WAKE_LOCK_NAME "adb-socket-connection"
57+#define WAKE_LOCK_ACQUIRE "/sys/power/wake_lock"
58+#define WAKE_LOCK_RELEASE "/sys/power/wake_unlock"
59+
60+static int sysfs_write(const char *node, const char *message)
61+{
62+ int fd;
63+ ssize_t to_write;
64+ int ret = 0;
65+
66+ fd = adb_open(node, O_RDWR);
67+ if (!fd) {
68+ D("open '%s' failed: %s", node, strerror(errno));
69+ return -1;
70+ }
71+
72+ to_write = strlen(message);
73+ if (adb_write(fd, message, to_write) != to_write) {
74+ D("write '%s' failed: %s", node, strerror(errno));
75+ ret = -1;
76+ }
77+ adb_close(fd);
78+ return ret;
79+}
80+
81+static void get_wakelock(void)
82+{
83+ if (sysfs_write(WAKE_LOCK_ACQUIRE, WAKE_LOCK_NAME)) {
84+ D("couldn't reserve wakelock for socket connection");
85+ }
86+}
87+
88+static void release_wakelock(void)
89+{
90+ if (sysfs_write(WAKE_LOCK_RELEASE, WAKE_LOCK_NAME)) {
91+ D("couldn't release wakelock for socket connection");
92+ }
93+}
94+
95+#endif /* !ADB_HOST */
5596
5697 static int remote_read(apacket *p, atransport *t)
5798 {
@@ -170,6 +211,9 @@ static void server_socket_thread(void* arg) {
170211 fd = adb_socket_accept(serverfd, addrp, &alen);
171212 if(fd >= 0) {
172213 D("server: new connection on fd %d", fd);
214+#if !ADB_HOST
215+ get_wakelock();
216+#endif
173217 close_on_exec(fd);
174218 disable_tcp_nagle(fd);
175219 register_socket_transport(fd, "host", port, 1);
@@ -339,6 +383,9 @@ static void remote_kick(atransport *t)
339383
340384 static void remote_close(atransport *t)
341385 {
386+#if !ADB_HOST
387+ release_wakelock();
388+#endif
342389 int fd = t->sfd;
343390 if (fd != -1) {
344391 t->sfd = -1;
--- 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/init/devices.cpp
+++ b/init/devices.cpp
@@ -981,8 +981,8 @@ void device_init() {
981981 sehandle = selinux_android_file_context_handle();
982982 selinux_status_open(true);
983983
984- /* is 256K enough? udev uses 16MB! */
985- device_fd = uevent_open_socket(256*1024, true);
984+ /* is 8MB enough? udev uses 16MB! */
985+ device_fd = uevent_open_socket(8 * 1024 * 1024, true);
986986 if (device_fd == -1) {
987987 return;
988988 }
--- 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/config_mbr.c
+++ b/libdiskconfig/config_mbr.c
@@ -260,11 +260,11 @@ config_mbr(struct disk_info *dinfo)
260260 }
261261
262262 /* if extended, need 1 lba for ebr */
263- if ((cur_lba + extended) >= dinfo->num_lba)
263+ if (dinfo->num_lba && (cur_lba + extended) >= dinfo->num_lba)
264264 goto nospace;
265265 else if (pinfo->len_kb != (uint32_t)-1) {
266266 uint32_t sz_lba = (pinfo->len_kb / dinfo->sect_size) * 1024;
267- if ((cur_lba + sz_lba + extended) > dinfo->num_lba)
267+ if (dinfo->num_lba && (cur_lba + sz_lba + extended) > dinfo->num_lba)
268268 goto nospace;
269269 }
270270
--- 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>
@@ -76,7 +78,7 @@ parse_len(const char *str, uint64_t *plen)
7678 }
7779 } else {
7880 /* convert len to kilobytes */
79- if (multiple > 1024)
81+ if (multiple >= 1024)
8082 multiple >>= 10;
8183 *plen *= multiple;
8284
@@ -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) {
--- a/libdiskconfig/diskutils.c
+++ b/libdiskconfig/diskutils.c
@@ -36,6 +36,7 @@ write_raw_image(const char *dst, const char *src, loff_t offset, int test)
3636 int dst_fd = -1;
3737 int src_fd = -1;
3838 uint8_t buffer[2048];
39+ ssize_t buf_offset;
3940 ssize_t nr_bytes;
4041 ssize_t tmp;
4142 int done = 0;
@@ -80,8 +81,9 @@ write_raw_image(const char *dst, const char *src, loff_t offset, int test)
8081 if (test)
8182 nr_bytes = 0;
8283
84+ buf_offset = 0;
8385 while (nr_bytes > 0) {
84- if ((tmp = write(dst_fd, buffer, nr_bytes)) < 0) {
86+ if ((tmp = write(dst_fd, &buffer[buf_offset], nr_bytes)) < 0) {
8587 /* XXX: Should we not even bother with EINTR? */
8688 if (errno == EINTR)
8789 continue;
@@ -91,6 +93,7 @@ write_raw_image(const char *dst, const char *src, loff_t offset, int test)
9193 if (!tmp)
9294 continue;
9395 nr_bytes -= tmp;
96+ buf_offset += tmp;
9497 }
9598 }
9699
--- a/toolbox/newfs_msdos.c
+++ b/toolbox/newfs_msdos.c
@@ -249,7 +249,7 @@ int newfs_msdos_main(int argc, char *argv[])
249249 char buf[MAXPATHLEN];
250250 struct stat sb;
251251 struct timeval tv;
252- struct bpb bpb;
252+ struct bpb bpb, tempbpb;
253253 struct tm *tm;
254254 struct bs *bs;
255255 struct bsbpb *bsbpb;
@@ -553,6 +553,7 @@ int newfs_msdos_main(int argc, char *argv[])
553553 set_spf = !bpb.bspf;
554554 set_spc = !bpb.spc;
555555 tempx = x;
556+ memset(&tempbpb, 0, sizeof(bpb));
556557 /*
557558 * Attempt to align if opt_A is set. This is done by increasing the number
558559 * of reserved blocks. This can cause other factors to change, which can in
@@ -600,10 +601,14 @@ int newfs_msdos_main(int argc, char *argv[])
600601 alignment = (bpb.res + bpb.bspf * bpb.nft) % bpb.spc;
601602 extra_res += bpb.spc - alignment;
602603 }
603- attempts++;
604+ if (++attempts == 1)
605+ memcpy(&tempbpb, &bpb, sizeof(bpb));
604606 } while(opt_A && alignment != 0 && attempts < 2);
605- if (alignment != 0)
607+ if (alignment != 0) {
606608 warnx("warning: Alignment failed.");
609+ /* return to data from first iteration */
610+ memcpy(&bpb, &tempbpb, sizeof(bpb));
611+ }
607612
608613 cls = (bpb.bsec - x1) / bpb.spc;
609614 x = (u_int64_t)bpb.bspf * bpb.bps * NPB / (fat / BPN) - RESFTE;