From 3312456c44e39546975f8b06af79710865daeac7 Mon Sep 17 00:00:00 2001 From: linjun9528 Date: Tue, 14 Jun 2022 20:10:59 +0800 Subject: [PATCH] add file access framework Signed-off-by: linjun9528 --- appdata-sandbox.json | 18 ++++++++++++++++++ common/appspawn_server.h | 1 + standard/appspawn_service.c | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/appdata-sandbox.json b/appdata-sandbox.json index 5994d20f..de810d69 100644 --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -251,6 +251,24 @@ } ], "symbol-links" : [] + }], + "com.ohos.UserFile.ExternalFileManager" : [{ + "sandbox-switch": "ON", + "sandbox-root" : "/mnt/sandbox/", + "mount-bind-paths" : [{ + "src-path" : "/data/service/el1/public/storage_daemon/share/public", + "sandbox-path" : "/data/storage/el1/bundle/storage_daemon", + "sandbox-flags" : [ "bind", "rec" ], + "check-action-status": "true" + }, + { + "src-path" : "/mnt/external", + "sandbox-path" : "/mnt/external", + "sandbox-flags" : [ "bind", "rec" ], + "check-action-status": "true" + } + ], + "symbol-links" : [] }] }] } diff --git a/common/appspawn_server.h b/common/appspawn_server.h index c344470d..eb457ce0 100644 --- a/common/appspawn_server.h +++ b/common/appspawn_server.h @@ -34,6 +34,7 @@ extern "C" { #define ERR_PIPE_FAIL (-100) #define MAX_LEN_SHORT_NAME 16 #define WAIT_DELAY_US (100 * 1000) // 100ms +#define GID_FILE_ACCESS 1006 // only used for ExternalFileManager.hap #define GID_USER_DATA_RW 1008 typedef struct AppSpawnClient_ { diff --git a/standard/appspawn_service.c b/standard/appspawn_service.c index 570d3d9a..f26ea0de 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -203,6 +203,14 @@ static void SignalHandler(const struct signalfd_siginfo *siginfo) static void HandleSpecial(AppSpawnClientExt *appProperty) { + const char *fileExtensionHapBundleName = "com.ohos.UserFile.ExternalFileManager"; + if (strcmp(appProperty->property.bundleName, fileExtensionHapBundleName) == 0) { + if (appProperty->property.gidCount < APP_MAX_GIDS) { + appProperty->property.gidTable[appProperty->property.gidCount] = GID_FILE_ACCESS; + appProperty->property.gidCount++; + } + } + // special handle bundle name medialibrary and scanner const char *specialBundleNames[] = { "com.ohos.medialibrary.MediaLibraryDataA", -- Gitee