From f7aad11c1cc133e352333f83e3abbf323cd41ead Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 16 Dec 2015 13:20:37 -0700 Subject: Re-derive permissions after package changes. When packages change, existing package-specific directories may have gained/lost a UID mapping, so we need to update the permissions for any in-memory nodes. This allows an app to deliver data for another package before that package is installed, which is the typical pattern of how OBB files are delivered. Also fix bug by re-deriving permissions when files are moved. Bug: 25399427 Change-Id: I06f38a24ad7dee5f5099ba81429aef03208e5683 --- sdcard/sdcard.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sdcard') diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c index a79e2ddce..06452aa47 100644 --- a/sdcard/sdcard.c +++ b/sdcard/sdcard.c @@ -507,6 +507,16 @@ static void derive_permissions_locked(struct fuse* fuse, struct node *parent, } } +static void derive_permissions_recursive_locked(struct fuse* fuse, struct node *parent) { + struct node *node; + for (node = parent->child; node; node = node->next) { + derive_permissions_locked(fuse, parent, node); + if (node->child) { + derive_permissions_recursive_locked(fuse, node); + } + } +} + /* Kernel has already enforced everything we returned through * derive_permissions_locked(), so this is used to lock down access * even further, such as enforcing that apps hold sdcard_rw. */ @@ -1145,6 +1155,8 @@ static int handle_rename(struct fuse* fuse, struct fuse_handler* handler, res = rename_node_locked(child_node, new_name, new_actual_name); if (!res) { remove_node_from_parent_locked(child_node); + derive_permissions_locked(fuse, new_parent_node, child_node); + derive_permissions_recursive_locked(fuse, child_node); add_node_to_parent_locked(child_node, new_parent_node); } goto done; @@ -1663,6 +1675,10 @@ static int read_package_list(struct fuse_global* global) { TRACE("read_package_list: found %zu packages\n", hashmapSize(global->package_to_appid)); fclose(file); + + /* Regenerate ownership details using newly loaded mapping */ + derive_permissions_recursive_locked(global->fuse_default, &global->root); + pthread_mutex_unlock(&global->lock); return 0; } -- cgit v1.2.3 From ac5175f9a67d649f98dfbeef60026bf5dafa7da1 Mon Sep 17 00:00:00 2001 From: Thierry Strudel Date: Wed, 13 Jan 2016 15:11:35 -0800 Subject: [DO NOT MERGE] Use FUSE_SHORTCIRCUIT if available Use a non yet maintainer reviewed kernel patch from QCOM that greatly improves IO speed in case it is available from the device specific kernel headers. Bug: 24216004 Change-Id: I4101d80082c9ad9d042dde5c620ddb309d193d52 --- sdcard/sdcard.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sdcard') diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c index 06452aa47..e9aa770a5 100644 --- a/sdcard/sdcard.c +++ b/sdcard/sdcard.c @@ -1214,7 +1214,13 @@ static int handle_open(struct fuse* fuse, struct fuse_handler* handler, } out.fh = ptr_to_id(h); out.open_flags = 0; + +#ifdef FUSE_STACKED_IO + out.lower_fd = h->fd; +#else out.padding = 0; +#endif + fuse_reply(fuse, hdr->unique, &out, sizeof(out)); return NO_STATUS; } @@ -1378,7 +1384,13 @@ static int handle_opendir(struct fuse* fuse, struct fuse_handler* handler, } out.fh = ptr_to_id(h); out.open_flags = 0; + +#ifdef FUSE_STACKED_IO + out.lower_fd = -1; +#else out.padding = 0; +#endif + fuse_reply(fuse, hdr->unique, &out, sizeof(out)); return NO_STATUS; } @@ -1460,6 +1472,11 @@ static int handle_init(struct fuse* fuse, struct fuse_handler* handler, out.major = FUSE_KERNEL_VERSION; out.max_readahead = req->max_readahead; out.flags = FUSE_ATOMIC_O_TRUNC | FUSE_BIG_WRITES; + +#ifdef FUSE_STACKED_IO + out.flags |= FUSE_STACKED_IO; +#endif + out.max_background = 32; out.congestion_threshold = 32; out.max_write = MAX_WRITE; -- cgit v1.2.3