xref: /aosp_15_r20/external/e2fsprogs/contrib/android/perms.h (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker #ifndef ANDROID_PERMS_H
2*6a54128fSAndroid Build Coastguard Worker # define ANDROID_PERMS_H
3*6a54128fSAndroid Build Coastguard Worker 
4*6a54128fSAndroid Build Coastguard Worker # include <ext2fs/ext2fs.h>
5*6a54128fSAndroid Build Coastguard Worker 
6*6a54128fSAndroid Build Coastguard Worker typedef void (*fs_config_f)(const char *path, int dir,
7*6a54128fSAndroid Build Coastguard Worker 			    const char *target_out_path,
8*6a54128fSAndroid Build Coastguard Worker 			    unsigned *uid, unsigned *gid,
9*6a54128fSAndroid Build Coastguard Worker 			    unsigned *mode, uint64_t *capabilities);
10*6a54128fSAndroid Build Coastguard Worker 
11*6a54128fSAndroid Build Coastguard Worker /*
12*6a54128fSAndroid Build Coastguard Worker  * Represents a range of UID/GID mapping.
13*6a54128fSAndroid Build Coastguard Worker  * This maps the id in [|parent_id|, |parent_id| + |length|) into
14*6a54128fSAndroid Build Coastguard Worker  * [|child_id|, |child_id| + |length|)
15*6a54128fSAndroid Build Coastguard Worker  */
16*6a54128fSAndroid Build Coastguard Worker struct ugid_map_entry {
17*6a54128fSAndroid Build Coastguard Worker 	unsigned int child_id;
18*6a54128fSAndroid Build Coastguard Worker 	unsigned int parent_id;
19*6a54128fSAndroid Build Coastguard Worker 	unsigned int length;
20*6a54128fSAndroid Build Coastguard Worker };
21*6a54128fSAndroid Build Coastguard Worker 
22*6a54128fSAndroid Build Coastguard Worker struct ugid_map {
23*6a54128fSAndroid Build Coastguard Worker 	/* The number of elements in |entries|. */
24*6a54128fSAndroid Build Coastguard Worker 	size_t size;
25*6a54128fSAndroid Build Coastguard Worker 
26*6a54128fSAndroid Build Coastguard Worker 	/* An array of entries. If |size| is 0, this is a null pointer. */
27*6a54128fSAndroid Build Coastguard Worker 	struct ugid_map_entry* entries;
28*6a54128fSAndroid Build Coastguard Worker };
29*6a54128fSAndroid Build Coastguard Worker 
30*6a54128fSAndroid Build Coastguard Worker # ifdef _WIN32
31*6a54128fSAndroid Build Coastguard Worker struct selabel_handle;
android_configure_fs(ext2_filsys fs,char * src_dir,char * target_out,char * mountpoint,void * seopts,unsigned int nopt,char * fs_config_file,time_t fixed_time,const struct ugid_map * uid_map,const struct ugdi_map * gid_map)32*6a54128fSAndroid Build Coastguard Worker static inline errcode_t android_configure_fs(ext2_filsys fs,
33*6a54128fSAndroid Build Coastguard Worker 					     char *src_dir,
34*6a54128fSAndroid Build Coastguard Worker 					     char *target_out,
35*6a54128fSAndroid Build Coastguard Worker 					     char *mountpoint,
36*6a54128fSAndroid Build Coastguard Worker 					     void *seopts,
37*6a54128fSAndroid Build Coastguard Worker 					     unsigned int nopt,
38*6a54128fSAndroid Build Coastguard Worker 					     char *fs_config_file,
39*6a54128fSAndroid Build Coastguard Worker 					     time_t fixed_time,
40*6a54128fSAndroid Build Coastguard Worker 					     const struct ugid_map* uid_map,
41*6a54128fSAndroid Build Coastguard Worker 					     const struct ugdi_map* gid_map)
42*6a54128fSAndroid Build Coastguard Worker {
43*6a54128fSAndroid Build Coastguard Worker 	return 0;
44*6a54128fSAndroid Build Coastguard Worker }
45*6a54128fSAndroid Build Coastguard Worker # else
46*6a54128fSAndroid Build Coastguard Worker #  include <selinux/selinux.h>
47*6a54128fSAndroid Build Coastguard Worker #  include <selinux/label.h>
48*6a54128fSAndroid Build Coastguard Worker #  if defined(__ANDROID__)
49*6a54128fSAndroid Build Coastguard Worker #   include <selinux/android.h>
50*6a54128fSAndroid Build Coastguard Worker #  endif
51*6a54128fSAndroid Build Coastguard Worker #  include <private/android_filesystem_config.h>
52*6a54128fSAndroid Build Coastguard Worker #  include <private/canned_fs_config.h>
53*6a54128fSAndroid Build Coastguard Worker #  include <private/fs_config.h>
54*6a54128fSAndroid Build Coastguard Worker 
55*6a54128fSAndroid Build Coastguard Worker errcode_t android_configure_fs(ext2_filsys fs, char *src_dir,
56*6a54128fSAndroid Build Coastguard Worker 			       char *target_out,
57*6a54128fSAndroid Build Coastguard Worker 			       char *mountpoint,
58*6a54128fSAndroid Build Coastguard Worker 			       struct selinux_opt *seopts,
59*6a54128fSAndroid Build Coastguard Worker 			       unsigned int nopt,
60*6a54128fSAndroid Build Coastguard Worker 			       char *fs_config_file, time_t fixed_time,
61*6a54128fSAndroid Build Coastguard Worker 			       const struct ugid_map* uid_map,
62*6a54128fSAndroid Build Coastguard Worker 			       const struct ugid_map* gid_map);
63*6a54128fSAndroid Build Coastguard Worker 
64*6a54128fSAndroid Build Coastguard Worker # endif
65*6a54128fSAndroid Build Coastguard Worker #endif /* !ANDROID_PERMS_H */
66