Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4762c22a authored by Stephen Crane's avatar Stephen Crane
Browse files

trusty/storage: Add property indicating when fs is ready

Adds a system vendor property (ro.vendor.trusty.storage.fs_ready) to
indicate when backing storage on the Android filesystem (e.g. /data) is
ready for use. Before this property is set, the Trusty storage proxy may
restart causing connections in Trusty to the storage service to be
disconnected. All Trusty operations that may require storage and can
wait until the device filesystems are ready should wait on this
property.

Bug: 258018785
Test: manual
Change-Id: I9b1408b72df34a0d0cbcc1b99e9617f15bc47558
Ignore-AOSP-First: Topic did not auto-merge from AOSP
parent 36ce32f5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -32,11 +32,11 @@ cc_binary {

    shared_libs: [
        "libbase",
        "libcutils",
        "liblog",
        "libhardware_legacy",
    ],
    header_libs: [
        "libcutils_headers",
        "libgsi_headers",
    ],

+27 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <cutils/properties.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
@@ -43,6 +44,22 @@ enum sync_state {

static const char *ssdir_name;

/*
 * Property set to 1 after we have opened a file under ssdir_name. The backing
 * files for both TD and TDP are currently located under /data/vendor/ss and can
 * only be opened once userdata is mounted. This storageproxyd service is
 * restarted when userdata is available, which causes the Trusty storage service
 * to reconnect and attempt to open the backing files for TD and TDP. Once we
 * set this property, other users can expect that the Trusty storage service
 * ports will be available (although they may block if still being initialized),
 * and connections will not be reset after this point (assuming the
 * storageproxyd service stays running).
 */
#define FS_READY_PROPERTY "ro.vendor.trusty.storage.fs_ready"

/* has FS_READY_PROPERTY been set? */
static bool fs_ready_initialized = false;

static enum sync_state fs_state;
static enum sync_state fd_state[FD_TBL_SIZE];

@@ -336,6 +353,16 @@ int storage_file_open(struct storage_msg* msg, const void* r, size_t req_len) {
    ALOGV("%s: \"%s\": fd = %u: handle = %d\n",
          __func__, path, rc, resp.handle);

    /* a backing file has been opened, notify any waiting init steps */
    if (!fs_ready_initialized) {
        rc = property_set(FS_READY_PROPERTY, "1");
        if (rc == 0) {
            fs_ready_initialized = true;
        } else {
            ALOGE("Could not set property %s, rc: %d\n", FS_READY_PROPERTY, rc);
        }
    }

    return ipc_respond(msg, &resp, sizeof(resp));

err_response: