11use crate :: error:: OciSpecError ;
2+ use crate :: runtime:: LinuxIdMapping ;
23use derive_builder:: Builder ;
34use getset:: { CopyGetters , Getters , MutGetters , Setters } ;
45use serde:: { Deserialize , Serialize } ;
@@ -76,6 +77,14 @@ pub struct Mount {
7677 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
7778 /// Options are fstab style mount options.
7879 options : Option < Vec < String > > ,
80+
81+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
82+ /// UID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
83+ uid_mappings : Option < Vec < LinuxIdMapping > > ,
84+
85+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
86+ /// GID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
87+ gid_mappings : Option < Vec < LinuxIdMapping > > ,
7988}
8089
8190/// utility function to generate default config for mounts.
@@ -86,6 +95,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
8695 typ: "proc" . to_string( ) . into( ) ,
8796 source: PathBuf :: from( "proc" ) . into( ) ,
8897 options: None ,
98+ uid_mappings: None ,
99+ gid_mappings: None ,
89100 } ,
90101 Mount {
91102 destination: PathBuf :: from( "/dev" ) ,
@@ -98,6 +109,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
98109 "size=65536k" . into( ) ,
99110 ]
100111 . into( ) ,
112+ uid_mappings: None ,
113+ gid_mappings: None ,
101114 } ,
102115 Mount {
103116 destination: PathBuf :: from( "/dev/pts" ) ,
@@ -112,6 +125,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
112125 "gid=5" . into( ) ,
113126 ]
114127 . into( ) ,
128+ uid_mappings: None ,
129+ gid_mappings: None ,
115130 } ,
116131 Mount {
117132 destination: PathBuf :: from( "/dev/shm" ) ,
@@ -125,12 +140,16 @@ pub fn get_default_mounts() -> Vec<Mount> {
125140 "size=65536k" . into( ) ,
126141 ]
127142 . into( ) ,
143+ uid_mappings: None ,
144+ gid_mappings: None ,
128145 } ,
129146 Mount {
130147 destination: PathBuf :: from( "/dev/mqueue" ) ,
131148 typ: "mqueue" . to_string( ) . into( ) ,
132149 source: PathBuf :: from( "mqueue" ) . into( ) ,
133150 options: vec![ "nosuid" . into( ) , "noexec" . into( ) , "nodev" . into( ) ] . into( ) ,
151+ uid_mappings: None ,
152+ gid_mappings: None ,
134153 } ,
135154 Mount {
136155 destination: PathBuf :: from( "/sys" ) ,
@@ -143,6 +162,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
143162 "ro" . into( ) ,
144163 ]
145164 . into( ) ,
165+ uid_mappings: None ,
166+ gid_mappings: None ,
146167 } ,
147168 Mount {
148169 destination: PathBuf :: from( "/sys/fs/cgroup" ) ,
@@ -156,6 +177,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
156177 "ro" . into( ) ,
157178 ]
158179 . into( ) ,
180+ uid_mappings: None ,
181+ gid_mappings: None ,
159182 } ,
160183 ]
161184}
0 commit comments