From 5f60d986e61094b1262acf6f073431750e0dc9e2 Mon Sep 17 00:00:00 2001 From: wangjianqiang Date: Mon, 20 Jun 2022 16:35:24 +0800 Subject: [PATCH 1/3] add file access framework Signed-off-by: wangjianqiang --- 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..a42c6064 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-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 571ea0f7..493636b4 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 924664e7..ee07bf09 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -204,6 +204,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 From 07b16e51a061d7bf492d5a5ddc6c0e7f0d7cc85d Mon Sep 17 00:00:00 2001 From: wangjianqiang Date: Tue, 21 Jun 2022 21:28:18 +0800 Subject: [PATCH 2/3] add file access framework Signed-off-by: wangjianqiang --- appdata-sandbox64.json | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/appdata-sandbox64.json b/appdata-sandbox64.json index ff660390..fab7fc06 100644 --- a/appdata-sandbox64.json +++ b/appdata-sandbox64.json @@ -260,6 +260,23 @@ } ], "symbol-links" : [] - }] + }], + "com.ohos.UserFile.ExternalFileManager" : [{ + "sandbox-switch": "ON", + "sandbox-root" : "/mnt/sandbox/", + "mount-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" : [] }] } -- Gitee From a04ef649e14c41bfd532cbdaa03a81d160281b1a Mon Sep 17 00:00:00 2001 From: wangjianqiang Date: Wed, 22 Jun 2022 20:52:13 +0800 Subject: [PATCH 3/3] clean question Signed-off-by: wangjianqiang --- appdata-sandbox64.json | 1 + 1 file changed, 1 insertion(+) diff --git a/appdata-sandbox64.json b/appdata-sandbox64.json index fab7fc06..7378fd7e 100644 --- a/appdata-sandbox64.json +++ b/appdata-sandbox64.json @@ -278,5 +278,6 @@ } ], "symbol-links" : [] + }] }] } -- Gitee