1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* This file is used to define the properties of the filesystem 18 ** images generated by build tools (mkbootfs and mkyaffs2image) and 19 ** by the device side of adb. 20 */ 21 22 #ifndef _LIBS_CUTILS_PRIVATE_FS_CONFIG_H 23 #define _LIBS_CUTILS_PRIVATE_FS_CONFIG_H 24 25 #include <stdint.h> 26 #include <sys/cdefs.h> 27 28 #if defined(__BIONIC__) 29 #include <linux/capability.h> 30 #else // defined(__BIONIC__) 31 #include "android_filesystem_capability.h" 32 #endif // defined(__BIONIC__) 33 34 #define CAP_MASK_LONG(cap_name) (1ULL << (cap_name)) 35 36 /* 37 * binary format for the runtime <partition>/etc/fs_config_(dirs|files) 38 * filesystem override files. 39 */ 40 41 /* The following structure is stored little endian */ 42 struct fs_path_config_from_file { 43 uint16_t len; 44 uint16_t mode; 45 uint16_t uid; 46 uint16_t gid; 47 uint64_t capabilities; 48 char prefix[]; 49 } __attribute__((__aligned__(sizeof(uint64_t)))); 50 51 struct fs_path_config { 52 unsigned mode; 53 unsigned uid; 54 unsigned gid; 55 uint64_t capabilities; 56 const char* prefix; 57 }; 58 59 /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */ 60 61 __BEGIN_DECLS 62 63 /* 64 * Used in: 65 * build/tools/fs_config/fs_config.c 66 * build/tools/fs_get_stats/fs_get_stats.c 67 * system/extras/ext4_utils/make_ext4fs_main.c 68 * external/squashfs-tools/squashfs-tools/android.c 69 * system/core/cpio/mkbootfs.c 70 * system/core/adb/file_sync_service.cpp 71 * system/extras/ext4_utils/canned_fs_config.c 72 */ 73 void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid, 74 unsigned* mode, uint64_t* capabilities); 75 76 ssize_t fs_config_generate(char* buffer, size_t length, const struct fs_path_config* pc); 77 78 __END_DECLS 79 80 #endif /* _LIBS_CUTILS_PRIVATE_FS_CONFIG_H */ 81