diff options
author | Jorge Lucangeli Obes | 2016-07-21 22:14:46 -0500 |
---|---|---|
committer | Jorge Lucangeli Obes | 2016-07-21 22:14:46 -0500 |
commit | e629ced86ac585ea78eaac00140d05c5a06b80d2 (patch) | |
tree | 0c2313167344569224b40101a355a2b0e2f59ebd /sdcard | |
parent | 5dbf5141444304f4772874ec2407b90d1291a4b2 (diff) | |
parent | c6e22ba1a135e336fce067ef3d5372dcaeb9499f (diff) | |
download | platform-system-core-e629ced86ac585ea78eaac00140d05c5a06b80d2.tar.gz platform-system-core-e629ced86ac585ea78eaac00140d05c5a06b80d2.tar.xz platform-system-core-e629ced86ac585ea78eaac00140d05c5a06b80d2.zip |
resolve merge conflicts of c6e22ba to stage-aosp-master
Change-Id: I65550ff841d27f985a3ab8618ecdf4a3500fb0be
Diffstat (limited to 'sdcard')
-rw-r--r-- | sdcard/fuse.cpp | 78 | ||||
-rw-r--r-- | sdcard/fuse.h | 10 |
2 files changed, 52 insertions, 36 deletions
diff --git a/sdcard/fuse.cpp b/sdcard/fuse.cpp index f37190161..54ac9194c 100644 --- a/sdcard/fuse.cpp +++ b/sdcard/fuse.cpp | |||
@@ -18,6 +18,8 @@ | |||
18 | 18 | ||
19 | #include "fuse.h" | 19 | #include "fuse.h" |
20 | 20 | ||
21 | #include <android-base/logging.h> | ||
22 | |||
21 | /* FUSE_CANONICAL_PATH is not currently upstreamed */ | 23 | /* FUSE_CANONICAL_PATH is not currently upstreamed */ |
22 | #define FUSE_CANONICAL_PATH 2016 | 24 | #define FUSE_CANONICAL_PATH 2016 |
23 | 25 | ||
@@ -579,8 +581,8 @@ static int handle_lookup(struct fuse* fuse, struct fuse_handler* handler, | |||
579 | pthread_mutex_lock(&fuse->global->lock); | 581 | pthread_mutex_lock(&fuse->global->lock); |
580 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, | 582 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, |
581 | parent_path, sizeof(parent_path)); | 583 | parent_path, sizeof(parent_path)); |
582 | TRACE("[%d] LOOKUP %s @ %" PRIx64 " (%s)\n", handler->token, name, hdr->nodeid, | 584 | DLOG(INFO) << "[" << handler->token << "] LOOKUP " << name << " @ " << hdr->nodeid |
583 | parent_node ? parent_node->name : "?"); | 585 | << " (" << (parent_node ? parent_node->name : "?") << ")"; |
584 | pthread_mutex_unlock(&fuse->global->lock); | 586 | pthread_mutex_unlock(&fuse->global->lock); |
585 | 587 | ||
586 | if (!parent_node || !(actual_name = find_file_within(parent_path, name, | 588 | if (!parent_node || !(actual_name = find_file_within(parent_path, name, |
@@ -601,8 +603,9 @@ static int handle_forget(struct fuse* fuse, struct fuse_handler* handler, | |||
601 | 603 | ||
602 | pthread_mutex_lock(&fuse->global->lock); | 604 | pthread_mutex_lock(&fuse->global->lock); |
603 | node = lookup_node_by_id_locked(fuse, hdr->nodeid); | 605 | node = lookup_node_by_id_locked(fuse, hdr->nodeid); |
604 | TRACE("[%d] FORGET #%" PRIu64 " @ %" PRIx64 " (%s)\n", handler->token, req->nlookup, | 606 | DLOG(INFO) << "[" << handler->token << "] FORGET #" << req->nlookup |
605 | hdr->nodeid, node ? node->name : "?"); | 607 | << " @ " << std::hex << hdr->nodeid |
608 | << " (" << (node ? node->name : "?") << ")"; | ||
606 | if (node) { | 609 | if (node) { |
607 | __u64 n = req->nlookup; | 610 | __u64 n = req->nlookup; |
608 | while (n) { | 611 | while (n) { |
@@ -622,8 +625,9 @@ static int handle_getattr(struct fuse* fuse, struct fuse_handler* handler, | |||
622 | 625 | ||
623 | pthread_mutex_lock(&fuse->global->lock); | 626 | pthread_mutex_lock(&fuse->global->lock); |
624 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); | 627 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); |
625 | TRACE("[%d] GETATTR flags=%x fh=%" PRIx64 " @ %" PRIx64 " (%s)\n", handler->token, | 628 | DLOG(INFO) << "[" << handler->token << "] GETATTR flags=" << req->getattr_flags |
626 | req->getattr_flags, req->fh, hdr->nodeid, node ? node->name : "?"); | 629 | << " fh=" << std::hex << req->fh << " @ " << std::hex << hdr->nodeid |
630 | << " (" << (node ? node->name : "?") << ")"; | ||
627 | pthread_mutex_unlock(&fuse->global->lock); | 631 | pthread_mutex_unlock(&fuse->global->lock); |
628 | 632 | ||
629 | if (!node) { | 633 | if (!node) { |
@@ -645,8 +649,9 @@ static int handle_setattr(struct fuse* fuse, struct fuse_handler* handler, | |||
645 | 649 | ||
646 | pthread_mutex_lock(&fuse->global->lock); | 650 | pthread_mutex_lock(&fuse->global->lock); |
647 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); | 651 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); |
648 | TRACE("[%d] SETATTR fh=%" PRIx64 " valid=%x @ %" PRIx64 " (%s)\n", handler->token, | 652 | DLOG(INFO) << "[" << handler->token << "] SETATTR fh=" << std::hex << req->fh |
649 | req->fh, req->valid, hdr->nodeid, node ? node->name : "?"); | 653 | << " valid=" << std::hex << req->valid << " @ " << std::hex << hdr->nodeid |
654 | << " (" << (node ? node->name : "?") << ")"; | ||
650 | pthread_mutex_unlock(&fuse->global->lock); | 655 | pthread_mutex_unlock(&fuse->global->lock); |
651 | 656 | ||
652 | if (!node) { | 657 | if (!node) { |
@@ -710,8 +715,9 @@ static int handle_mknod(struct fuse* fuse, struct fuse_handler* handler, | |||
710 | pthread_mutex_lock(&fuse->global->lock); | 715 | pthread_mutex_lock(&fuse->global->lock); |
711 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, | 716 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, |
712 | parent_path, sizeof(parent_path)); | 717 | parent_path, sizeof(parent_path)); |
713 | TRACE("[%d] MKNOD %s 0%o @ %" PRIx64 " (%s)\n", handler->token, | 718 | DLOG(INFO) << "[" << handler->token << "] MKNOD " << name << " 0" << std::oct << req->mode |
714 | name, req->mode, hdr->nodeid, parent_node ? parent_node->name : "?"); | 719 | << " @ " << std::hex << hdr->nodeid |
720 | << " (" << (parent_node ? parent_node->name : "?") << ")"; | ||
715 | pthread_mutex_unlock(&fuse->global->lock); | 721 | pthread_mutex_unlock(&fuse->global->lock); |
716 | 722 | ||
717 | if (!parent_node || !(actual_name = find_file_within(parent_path, name, | 723 | if (!parent_node || !(actual_name = find_file_within(parent_path, name, |
@@ -739,8 +745,9 @@ static int handle_mkdir(struct fuse* fuse, struct fuse_handler* handler, | |||
739 | pthread_mutex_lock(&fuse->global->lock); | 745 | pthread_mutex_lock(&fuse->global->lock); |
740 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, | 746 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, |
741 | parent_path, sizeof(parent_path)); | 747 | parent_path, sizeof(parent_path)); |
742 | TRACE("[%d] MKDIR %s 0%o @ %" PRIx64 " (%s)\n", handler->token, | 748 | DLOG(INFO) << "[" << handler->token << "] MKDIR " << name << " 0" << std::oct << req->mode |
743 | name, req->mode, hdr->nodeid, parent_node ? parent_node->name : "?"); | 749 | << " @ " << std::hex << hdr->nodeid |
750 | << " (" << (parent_node ? parent_node->name : "?") << ")"; | ||
744 | pthread_mutex_unlock(&fuse->global->lock); | 751 | pthread_mutex_unlock(&fuse->global->lock); |
745 | 752 | ||
746 | if (!parent_node || !(actual_name = find_file_within(parent_path, name, | 753 | if (!parent_node || !(actual_name = find_file_within(parent_path, name, |
@@ -787,8 +794,8 @@ static int handle_unlink(struct fuse* fuse, struct fuse_handler* handler, | |||
787 | pthread_mutex_lock(&fuse->global->lock); | 794 | pthread_mutex_lock(&fuse->global->lock); |
788 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, | 795 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, |
789 | parent_path, sizeof(parent_path)); | 796 | parent_path, sizeof(parent_path)); |
790 | TRACE("[%d] UNLINK %s @ %" PRIx64 " (%s)\n", handler->token, | 797 | DLOG(INFO) << "[" << handler->token << "] UNLINK " << name << " @ " << std::hex << hdr->nodeid |
791 | name, hdr->nodeid, parent_node ? parent_node->name : "?"); | 798 | << " (" << (parent_node ? parent_node->name : "?") << ")"; |
792 | pthread_mutex_unlock(&fuse->global->lock); | 799 | pthread_mutex_unlock(&fuse->global->lock); |
793 | 800 | ||
794 | if (!parent_node || !find_file_within(parent_path, name, | 801 | if (!parent_node || !find_file_within(parent_path, name, |
@@ -809,8 +816,9 @@ static int handle_unlink(struct fuse* fuse, struct fuse_handler* handler, | |||
809 | pthread_mutex_unlock(&fuse->global->lock); | 816 | pthread_mutex_unlock(&fuse->global->lock); |
810 | if (parent_node && child_node) { | 817 | if (parent_node && child_node) { |
811 | /* Tell all other views that node is gone */ | 818 | /* Tell all other views that node is gone */ |
812 | TRACE("[%d] fuse_notify_delete parent=%" PRIx64 ", child=%" PRIx64 ", name=%s\n", | 819 | DLOG(INFO) << "[" << handler->token << "] fuse_notify_delete" |
813 | handler->token, (uint64_t) parent_node->nid, (uint64_t) child_node->nid, name); | 820 | << " parent=" << std::hex << parent_node->nid |
821 | << ", child=" << std::hex << child_node->nid << ", name=" << name; | ||
814 | if (fuse != fuse->global->fuse_default) { | 822 | if (fuse != fuse->global->fuse_default) { |
815 | fuse_notify_delete(fuse->global->fuse_default, parent_node->nid, child_node->nid, name); | 823 | fuse_notify_delete(fuse->global->fuse_default, parent_node->nid, child_node->nid, name); |
816 | } | 824 | } |
@@ -835,8 +843,8 @@ static int handle_rmdir(struct fuse* fuse, struct fuse_handler* handler, | |||
835 | pthread_mutex_lock(&fuse->global->lock); | 843 | pthread_mutex_lock(&fuse->global->lock); |
836 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, | 844 | parent_node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, |
837 | parent_path, sizeof(parent_path)); | 845 | parent_path, sizeof(parent_path)); |
838 | TRACE("[%d] RMDIR %s @ %" PRIx64 " (%s)\n", handler->token, | 846 | DLOG(INFO) << "[" << handler->token << "] UNLINK " << name << " @ " << std::hex << hdr->nodeid |
839 | name, hdr->nodeid, parent_node ? parent_node->name : "?"); | 847 | << " (" << (parent_node ? parent_node->name : "?") << ")"; |
840 | pthread_mutex_unlock(&fuse->global->lock); | 848 | pthread_mutex_unlock(&fuse->global->lock); |
841 | 849 | ||
842 | if (!parent_node || !find_file_within(parent_path, name, | 850 | if (!parent_node || !find_file_within(parent_path, name, |
@@ -857,8 +865,9 @@ static int handle_rmdir(struct fuse* fuse, struct fuse_handler* handler, | |||
857 | pthread_mutex_unlock(&fuse->global->lock); | 865 | pthread_mutex_unlock(&fuse->global->lock); |
858 | if (parent_node && child_node) { | 866 | if (parent_node && child_node) { |
859 | /* Tell all other views that node is gone */ | 867 | /* Tell all other views that node is gone */ |
860 | TRACE("[%d] fuse_notify_delete parent=%" PRIx64 ", child=%" PRIx64 ", name=%s\n", | 868 | DLOG(INFO) << "[" << handler->token << "] fuse_notify_delete" |
861 | handler->token, (uint64_t) parent_node->nid, (uint64_t) child_node->nid, name); | 869 | << " parent=" << std::hex << parent_node->nid |
870 | << ", child=" << std::hex << child_node->nid << ", name=" << name; | ||
862 | if (fuse != fuse->global->fuse_default) { | 871 | if (fuse != fuse->global->fuse_default) { |
863 | fuse_notify_delete(fuse->global->fuse_default, parent_node->nid, child_node->nid, name); | 872 | fuse_notify_delete(fuse->global->fuse_default, parent_node->nid, child_node->nid, name); |
864 | } | 873 | } |
@@ -892,10 +901,11 @@ static int handle_rename(struct fuse* fuse, struct fuse_handler* handler, | |||
892 | old_parent_path, sizeof(old_parent_path)); | 901 | old_parent_path, sizeof(old_parent_path)); |
893 | new_parent_node = lookup_node_and_path_by_id_locked(fuse, req->newdir, | 902 | new_parent_node = lookup_node_and_path_by_id_locked(fuse, req->newdir, |
894 | new_parent_path, sizeof(new_parent_path)); | 903 | new_parent_path, sizeof(new_parent_path)); |
895 | TRACE("[%d] RENAME %s->%s @ %" PRIx64 " (%s) -> %" PRIx64 " (%s)\n", handler->token, | 904 | DLOG(INFO) << "[" << handler->token << "] RENAME " << old_name << "->" << new_name |
896 | old_name, new_name, | 905 | << " @ " << std::hex << hdr->nodeid |
897 | hdr->nodeid, old_parent_node ? old_parent_node->name : "?", | 906 | << " (" << (old_parent_node ? old_parent_node->name : "?") << ") -> " |
898 | req->newdir, new_parent_node ? new_parent_node->name : "?"); | 907 | << std::hex << req->newdir |
908 | << " (" << (new_parent_node ? new_parent_node->name : "?") << ")"; | ||
899 | if (!old_parent_node || !new_parent_node) { | 909 | if (!old_parent_node || !new_parent_node) { |
900 | res = -ENOENT; | 910 | res = -ENOENT; |
901 | goto lookup_error; | 911 | goto lookup_error; |
@@ -976,8 +986,8 @@ static int handle_open(struct fuse* fuse, struct fuse_handler* handler, | |||
976 | 986 | ||
977 | pthread_mutex_lock(&fuse->global->lock); | 987 | pthread_mutex_lock(&fuse->global->lock); |
978 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); | 988 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); |
979 | TRACE("[%d] OPEN 0%o @ %" PRIx64 " (%s)\n", handler->token, | 989 | DLOG(INFO) << "[" << handler->token << "] OPEN 0" << std::oct << req->flags |
980 | req->flags, hdr->nodeid, node ? node->name : "?"); | 990 | << " @ " << std::hex << hdr->nodeid << " (" << (node ? node->name : "?") << ")"; |
981 | pthread_mutex_unlock(&fuse->global->lock); | 991 | pthread_mutex_unlock(&fuse->global->lock); |
982 | 992 | ||
983 | if (!node) { | 993 | if (!node) { |
@@ -1018,8 +1028,8 @@ static int handle_read(struct fuse* fuse, struct fuse_handler* handler, | |||
1018 | * overlaps the request buffer and will clobber data in the request. This | 1028 | * overlaps the request buffer and will clobber data in the request. This |
1019 | * saves us 128KB per request handler thread at the cost of this scary comment. */ | 1029 | * saves us 128KB per request handler thread at the cost of this scary comment. */ |
1020 | 1030 | ||
1021 | TRACE("[%d] READ %p(%d) %u@%" PRIu64 "\n", handler->token, | 1031 | DLOG(INFO) << "[" << handler->token << "] READ " << std::hex << h << "(" << h->fd << ") " |
1022 | h, h->fd, size, (uint64_t) offset); | 1032 | << size << "@" << offset; |
1023 | if (size > MAX_READ) { | 1033 | if (size > MAX_READ) { |
1024 | return -EINVAL; | 1034 | return -EINVAL; |
1025 | } | 1035 | } |
@@ -1045,8 +1055,8 @@ static int handle_write(struct fuse* fuse, struct fuse_handler* handler, | |||
1045 | buffer = (const __u8*) aligned_buffer; | 1055 | buffer = (const __u8*) aligned_buffer; |
1046 | } | 1056 | } |
1047 | 1057 | ||
1048 | TRACE("[%d] WRITE %p(%d) %u@%" PRIu64 "\n", handler->token, | 1058 | DLOG(INFO) << "[" << handler->token << "] WRITE " << std::hex << h << "(" << h->fd << ") " |
1049 | h, h->fd, req->size, req->offset); | 1059 | << req->size << "@" << req->offset; |
1050 | res = pwrite64(h->fd, buffer, req->size, req->offset); | 1060 | res = pwrite64(h->fd, buffer, req->size, req->offset); |
1051 | if (res < 0) { | 1061 | if (res < 0) { |
1052 | return -errno; | 1062 | return -errno; |
@@ -1141,8 +1151,8 @@ static int handle_opendir(struct fuse* fuse, struct fuse_handler* handler, | |||
1141 | 1151 | ||
1142 | pthread_mutex_lock(&fuse->global->lock); | 1152 | pthread_mutex_lock(&fuse->global->lock); |
1143 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); | 1153 | node = lookup_node_and_path_by_id_locked(fuse, hdr->nodeid, path, sizeof(path)); |
1144 | TRACE("[%d] OPENDIR @ %" PRIx64 " (%s)\n", handler->token, | 1154 | DLOG(INFO) << "[" << handler->token << "] OPENDIR @ " << std::hex << hdr->nodeid |
1145 | hdr->nodeid, node ? node->name : "?"); | 1155 | << " (" << (node ? node->name : "?") << ")"; |
1146 | pthread_mutex_unlock(&fuse->global->lock); | 1156 | pthread_mutex_unlock(&fuse->global->lock); |
1147 | 1157 | ||
1148 | if (!node) { | 1158 | if (!node) { |
@@ -1401,8 +1411,8 @@ static int handle_fuse_request(struct fuse *fuse, struct fuse_handler* handler, | |||
1401 | } | 1411 | } |
1402 | 1412 | ||
1403 | default: { | 1413 | default: { |
1404 | TRACE("[%d] NOTIMPL op=%d uniq=%" PRIx64 " nid=%" PRIx64 "\n", | 1414 | DLOG(INFO) << "[" << handler->token << "] NOTIMPL op=" << hdr->opcode |
1405 | handler->token, hdr->opcode, hdr->unique, hdr->nodeid); | 1415 | << "uniq=" << std::hex << hdr->unique << "nid=" << std::hex << hdr->nodeid; |
1406 | return -ENOSYS; | 1416 | return -ENOSYS; |
1407 | } | 1417 | } |
1408 | } | 1418 | } |
diff --git a/sdcard/fuse.h b/sdcard/fuse.h index 634fbf191..9dafa79ea 100644 --- a/sdcard/fuse.h +++ b/sdcard/fuse.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <map> | 33 | #include <map> |
34 | #include <string> | 34 | #include <string> |
35 | 35 | ||
36 | #include <android-base/logging.h> | ||
36 | #include <cutils/fs.h> | 37 | #include <cutils/fs.h> |
37 | #include <cutils/log.h> | 38 | #include <cutils/log.h> |
38 | #include <cutils/multiuser.h> | 39 | #include <cutils/multiuser.h> |
@@ -40,15 +41,20 @@ | |||
40 | 41 | ||
41 | #include <private/android_filesystem_config.h> | 42 | #include <private/android_filesystem_config.h> |
42 | 43 | ||
43 | // TODO(b/30222003): Fix compilation with FUSE_TRACE == 1. | ||
44 | #define FUSE_TRACE 0 | 44 | #define FUSE_TRACE 0 |
45 | 45 | ||
46 | #if FUSE_TRACE | 46 | #if FUSE_TRACE |
47 | #define TRACE(x...) ALOGD(x) | 47 | #define TRACE(x...) ALOGD(x) |
48 | #else | 48 | static constexpr bool kEnableDLog = true; |
49 | #else // FUSE_TRACE == 0 | ||
49 | #define TRACE(x...) do {} while (0) | 50 | #define TRACE(x...) do {} while (0) |
51 | static constexpr bool kEnableDLog = false; | ||
50 | #endif | 52 | #endif |
51 | 53 | ||
54 | // Use same strategy as DCHECK(). | ||
55 | #define DLOG(x) \ | ||
56 | if (kEnableDLog) LOG(x) | ||
57 | |||
52 | #define ERROR(x...) ALOGE(x) | 58 | #define ERROR(x...) ALOGE(x) |
53 | 59 | ||
54 | /* Maximum number of bytes to write in one request. */ | 60 | /* Maximum number of bytes to write in one request. */ |