@@ -3,6 +3,7 @@ use derive_builder::Builder;
33use getset:: { CopyGetters , Getters , MutGetters , Setters } ;
44use serde:: { Deserialize , Serialize } ;
55use std:: path:: PathBuf ;
6+ use crate :: runtime:: LinuxIdMapping ;
67
78#[ derive(
89 Builder , Clone , CopyGetters , Debug , Deserialize , Eq , Getters , Setters , PartialEq , Serialize ,
@@ -76,6 +77,15 @@ 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+
82+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
83+ /// UID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
84+ uid_mappings : Option < Vec < LinuxIdMapping > > ,
85+
86+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
87+ /// GID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping.
88+ gid_mappings : Option < Vec < LinuxIdMapping > > ,
7989}
8090
8191/// utility function to generate default config for mounts.
@@ -86,6 +96,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
8696 typ: "proc" . to_string( ) . into( ) ,
8797 source: PathBuf :: from( "proc" ) . into( ) ,
8898 options: None ,
99+ uid_mappings: None ,
100+ gid_mappings: None ,
89101 } ,
90102 Mount {
91103 destination: PathBuf :: from( "/dev" ) ,
@@ -98,6 +110,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
98110 "size=65536k" . into( ) ,
99111 ]
100112 . into( ) ,
113+ uid_mappings: None ,
114+ gid_mappings: None ,
101115 } ,
102116 Mount {
103117 destination: PathBuf :: from( "/dev/pts" ) ,
@@ -112,6 +126,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
112126 "gid=5" . into( ) ,
113127 ]
114128 . into( ) ,
129+ uid_mappings: None ,
130+ gid_mappings: None ,
115131 } ,
116132 Mount {
117133 destination: PathBuf :: from( "/dev/shm" ) ,
@@ -125,12 +141,16 @@ pub fn get_default_mounts() -> Vec<Mount> {
125141 "size=65536k" . into( ) ,
126142 ]
127143 . into( ) ,
144+ uid_mappings: None ,
145+ gid_mappings: None ,
128146 } ,
129147 Mount {
130148 destination: PathBuf :: from( "/dev/mqueue" ) ,
131149 typ: "mqueue" . to_string( ) . into( ) ,
132150 source: PathBuf :: from( "mqueue" ) . into( ) ,
133151 options: vec![ "nosuid" . into( ) , "noexec" . into( ) , "nodev" . into( ) ] . into( ) ,
152+ uid_mappings: None ,
153+ gid_mappings: None ,
134154 } ,
135155 Mount {
136156 destination: PathBuf :: from( "/sys" ) ,
@@ -143,6 +163,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
143163 "ro" . into( ) ,
144164 ]
145165 . into( ) ,
166+ uid_mappings: None ,
167+ gid_mappings: None ,
146168 } ,
147169 Mount {
148170 destination: PathBuf :: from( "/sys/fs/cgroup" ) ,
@@ -156,6 +178,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
156178 "ro" . into( ) ,
157179 ]
158180 . into( ) ,
181+ uid_mappings: None ,
182+ gid_mappings: None ,
159183 } ,
160184 ]
161185}
0 commit comments