Home | History | Annotate | Download | only in private
      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 #include <sys/types.h>
     28 
     29 #if defined(__BIONIC__)
     30 #include <linux/capability.h>
     31 #else  // defined(__BIONIC__)
     32 #include "android_filesystem_capability.h"
     33 #endif  // defined(__BIONIC__)
     34 
     35 #define CAP_MASK_LONG(cap_name) (1ULL << (cap_name))
     36 
     37 /*
     38  * binary format for the runtime <partition>/etc/fs_config_(dirs|files)
     39  * filesystem override files.
     40  */
     41 
     42 /* The following structure is stored little endian */
     43 struct fs_path_config_from_file {
     44     uint16_t len;
     45     uint16_t mode;
     46     uint16_t uid;
     47     uint16_t gid;
     48     uint64_t capabilities;
     49     char prefix[];
     50 } __attribute__((__aligned__(sizeof(uint64_t))));
     51 
     52 struct fs_path_config {
     53     unsigned mode;
     54     unsigned uid;
     55     unsigned gid;
     56     uint64_t capabilities;
     57     const char* prefix;
     58 };
     59 
     60 /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
     61 
     62 __BEGIN_DECLS
     63 
     64 /*
     65  * Used in:
     66  *  build/tools/fs_config/fs_config.c
     67  *  build/tools/fs_get_stats/fs_get_stats.c
     68  *  system/extras/ext4_utils/make_ext4fs_main.c
     69  *  external/squashfs-tools/squashfs-tools/android.c
     70  *  system/core/cpio/mkbootfs.c
     71  *  system/core/adb/file_sync_service.cpp
     72  *  system/extras/ext4_utils/canned_fs_config.c
     73  */
     74 void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,
     75                unsigned* mode, uint64_t* capabilities);
     76 
     77 ssize_t fs_config_generate(char* buffer, size_t length, const struct fs_path_config* pc);
     78 
     79 __END_DECLS
     80 
     81 #endif /* _LIBS_CUTILS_PRIVATE_FS_CONFIG_H */
     82