1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_STORAGE_DAEMON_FILE_SHARING_H 16 #define OHOS_STORAGE_DAEMON_FILE_SHARING_H 17 18 #include <string> 19 20 #include <sys/xattr.h> 21 22 #include "file_sharing/acl.h" 23 #include "parameter.h" 24 #include "storage_service_log.h" 25 #include "utils/file_utils.h" 26 27 namespace OHOS { 28 namespace StorageDaemon { 29 const std::string FSCRYPT_EL1_PUBLIC = "/data/service/el1/public"; 30 const std::string STORAGE_DAEMON_EL1_DIR = FSCRYPT_EL1_PUBLIC + "/storage_daemon"; 31 const std::string FILE_SHARING_DIR = STORAGE_DAEMON_EL1_DIR + "/share"; 32 const std::string PUBLIC_DIR = FILE_SHARING_DIR + "/public"; 33 const std::string SHARE_TOB_DIR = STORAGE_DAEMON_EL1_DIR + "/share_tob"; 34 const std::string TOB_SCENE = "2b_share"; 35 const std::string TOC_SCENE = "2c_share"; 36 const std::string TOD_SCENE = "2c2b_share"; 37 static const char *SHARE_DIR_ENABLE_PARAMETER = "const.file_transfer.fs_share_dir_define"; 38 constexpr int32_t MAX_FS_DEFINE_VAL_LEN = 16; 39 constexpr mode_t STORAGE_DAEMON_DIR_MODE = 0711; 40 constexpr mode_t FILE_SHARING_DIR_MODE = 0750; 41 constexpr mode_t PUBLIC_DIR_MODE = 02770; 42 constexpr mode_t SHARE_TOB_DIR_MODE = 0770; 43 constexpr uid_t FILE_MANAGER_UID = 1006; 44 constexpr gid_t FILE_MANAGER_GID = 1006; 45 constexpr uid_t ROOT_UID = 0; 46 constexpr gid_t ROOT_GID = 0; 47 constexpr uid_t SHARE_TOB_UID = 7017; 48 constexpr gid_t SHARE_TOB_GID = 7017; 49 50 int SetupFileSharingDir(); 51 int PrepareFileSharingDir(const std::string &fsShareParam); 52 int SetupDirAcl(const std::string &fsShareParam); 53 std::string GetFileShareDefineParameter(); 54 } // namespace StorageDaemon 55 } // namespace OHOS 56 57 #endif // OHOS_STORAGE_DAEMON_FILE_SHARING_H 58