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 #pragma once
23 
24 #include <fcntl.h>
25 #include <stdbool.h>
26 #include <stdint.h>
27 #include <sys/cdefs.h>
28 #include <unistd.h>
29 
30 #include <linux/capability.h>
31 
32 /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
33 
34 __BEGIN_DECLS
35 
36 /* This API is deprecated. New users should call get_fs_config. */
37 void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,
38                unsigned* mode, uint64_t* capabilities);
39 
40 struct fs_config {
41   uid_t uid;
42   gid_t gid;
43   mode_t mode;
44   uint64_t capabilities;
45 };
46 
47 /*
48  * If a file system configuration was found for the specified path, store it to *conf.
49  * Returns whether a file system configuration was found.
50  *
51  * dir: Whether path refers to a directory.
52  * target_out_path: Path to the base directory to read the file system configuration from, or a null
53  * pointer to use the root directory as the base. Host code should pass $ANDROID_PRODUCT_OUT or
54  * equivalent, and device code should pass a null pointer.
55  */
56 bool get_fs_config(const char* path, bool dir, const char* target_out_path,
57                    struct fs_config* conf);
58 
59 __END_DECLS
60