33use crate :: backend:: mount:: types:: {
44 FsMountFlags , FsOpenFlags , FsPickFlags , MountAttrFlags , MoveMountFlags , OpenTreeFlags ,
55} ;
6- use crate :: fd:: { BorrowedFd , OwnedFd } ;
6+ use crate :: fd:: { AsFd , OwnedFd } ;
77use crate :: { backend, io, path} ;
88
99/// `fsopen(fs_name, flags)`
@@ -24,12 +24,12 @@ pub fn fsopen<Fs: path::Arg>(fs_name: Fs, flags: FsOpenFlags) -> io::Result<Owne
2424///
2525/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsmount.md
2626#[ inline]
27- pub fn fsmount (
28- fs_fd : BorrowedFd < ' _ > ,
27+ pub fn fsmount < Fd : AsFd > (
28+ fs_fd : Fd ,
2929 flags : FsMountFlags ,
3030 attr_flags : MountAttrFlags ,
3131) -> io:: Result < OwnedFd > {
32- backend:: mount:: syscalls:: fsmount ( fs_fd, flags, attr_flags)
32+ backend:: mount:: syscalls:: fsmount ( fs_fd. as_fd ( ) , flags, attr_flags)
3333}
3434
3535/// `move_mount(from_dfd, from_pathname, to_dfd, to_pathname, flags)`
@@ -43,13 +43,15 @@ pub fn fsmount(
4343/// [`mount_move`]: crate::mount::mount_move
4444/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/move_mount.md
4545#[ inline]
46- pub fn move_mount < From : path:: Arg , To : path:: Arg > (
47- from_dfd : BorrowedFd < ' _ > ,
46+ pub fn move_mount < From : path:: Arg , To : path:: Arg , FromFd : AsFd , ToFd : AsFd > (
47+ from_dfd : FromFd ,
4848 from_pathname : From ,
49- to_dfd : BorrowedFd < ' _ > ,
49+ to_dfd : ToFd ,
5050 to_pathname : To ,
5151 flags : MoveMountFlags ,
5252) -> io:: Result < ( ) > {
53+ let from_dfd = from_dfd. as_fd ( ) ;
54+ let to_dfd = to_dfd. as_fd ( ) ;
5355 from_pathname. into_with_c_str ( |from_pathname| {
5456 to_pathname. into_with_c_str ( |to_pathname| {
5557 backend:: mount:: syscalls:: move_mount (
@@ -70,11 +72,12 @@ pub fn move_mount<From: path::Arg, To: path::Arg>(
7072///
7173/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/open_tree.md
7274#[ inline]
73- pub fn open_tree < Path : path:: Arg > (
74- dfd : BorrowedFd < ' _ > ,
75+ pub fn open_tree < Path : path:: Arg , Fd : AsFd > (
76+ dfd : Fd ,
7577 filename : Path ,
7678 flags : OpenTreeFlags ,
7779) -> io:: Result < OwnedFd > {
80+ let dfd = dfd. as_fd ( ) ;
7881 filename. into_with_c_str ( |filename| backend:: mount:: syscalls:: open_tree ( dfd, filename, flags) )
7982}
8083
@@ -85,11 +88,12 @@ pub fn open_tree<Path: path::Arg>(
8588///
8689/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fspick.md
8790#[ inline]
88- pub fn fspick < Path : path:: Arg > (
89- dfd : BorrowedFd < ' _ > ,
91+ pub fn fspick < Path : path:: Arg , Fd : AsFd > (
92+ dfd : Fd ,
9093 path : Path ,
9194 flags : FsPickFlags ,
9295) -> io:: Result < OwnedFd > {
96+ let dfd = dfd. as_fd ( ) ;
9397 path. into_with_c_str ( |path| backend:: mount:: syscalls:: fspick ( dfd, path, flags) )
9498}
9599
@@ -101,7 +105,8 @@ pub fn fspick<Path: path::Arg>(
101105/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
102106#[ inline]
103107#[ doc( alias = "fsconfig" ) ]
104- pub fn fsconfig_set_flag < Key : path:: Arg > ( fs_fd : BorrowedFd < ' _ > , key : Key ) -> io:: Result < ( ) > {
108+ pub fn fsconfig_set_flag < Key : path:: Arg , Fd : AsFd > ( fs_fd : Fd , key : Key ) -> io:: Result < ( ) > {
109+ let fs_fd = fs_fd. as_fd ( ) ;
105110 key. into_with_c_str ( |key| backend:: mount:: syscalls:: fsconfig_set_flag ( fs_fd, key) )
106111}
107112
@@ -113,11 +118,12 @@ pub fn fsconfig_set_flag<Key: path::Arg>(fs_fd: BorrowedFd<'_>, key: Key) -> io:
113118/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
114119#[ inline]
115120#[ doc( alias = "fsconfig" ) ]
116- pub fn fsconfig_set_string < Key : path:: Arg , Value : path:: Arg > (
117- fs_fd : BorrowedFd < ' _ > ,
121+ pub fn fsconfig_set_string < Key : path:: Arg , Value : path:: Arg , Fd : AsFd > (
122+ fs_fd : Fd ,
118123 key : Key ,
119124 value : Value ,
120125) -> io:: Result < ( ) > {
126+ let fs_fd = fs_fd. as_fd ( ) ;
121127 key. into_with_c_str ( |key| {
122128 value. into_with_c_str ( |value| {
123129 backend:: mount:: syscalls:: fsconfig_set_string ( fs_fd, key, value)
@@ -133,11 +139,12 @@ pub fn fsconfig_set_string<Key: path::Arg, Value: path::Arg>(
133139/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
134140#[ inline]
135141#[ doc( alias = "fsconfig" ) ]
136- pub fn fsconfig_set_binary < Key : path:: Arg > (
137- fs_fd : BorrowedFd < ' _ > ,
142+ pub fn fsconfig_set_binary < Key : path:: Arg , Fd : AsFd > (
143+ fs_fd : Fd ,
138144 key : Key ,
139145 value : & [ u8 ] ,
140146) -> io:: Result < ( ) > {
147+ let fs_fd = fs_fd. as_fd ( ) ;
141148 key. into_with_c_str ( |key| backend:: mount:: syscalls:: fsconfig_set_binary ( fs_fd, key, value) )
142149}
143150
@@ -149,12 +156,14 @@ pub fn fsconfig_set_binary<Key: path::Arg>(
149156/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
150157#[ inline]
151158#[ doc( alias = "fsconfig" ) ]
152- pub fn fsconfig_set_path < Key : path:: Arg , Path : path:: Arg > (
153- fs_fd : BorrowedFd < ' _ > ,
159+ pub fn fsconfig_set_path < Key : path:: Arg , Path : path:: Arg , Fd : AsFd , AuxFd : AsFd > (
160+ fs_fd : Fd ,
154161 key : Key ,
155162 path : Path ,
156- fd : BorrowedFd < ' _ > ,
163+ fd : AuxFd ,
157164) -> io:: Result < ( ) > {
165+ let fs_fd = fs_fd. as_fd ( ) ;
166+ let fd = fd. as_fd ( ) ;
158167 key. into_with_c_str ( |key| {
159168 path. into_with_c_str ( |path| {
160169 backend:: mount:: syscalls:: fsconfig_set_path ( fs_fd, key, path, fd)
@@ -170,11 +179,13 @@ pub fn fsconfig_set_path<Key: path::Arg, Path: path::Arg>(
170179/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
171180#[ inline]
172181#[ doc( alias = "fsconfig" ) ]
173- pub fn fsconfig_set_path_empty < Key : path:: Arg > (
174- fs_fd : BorrowedFd < ' _ > ,
182+ pub fn fsconfig_set_path_empty < Key : path:: Arg , Fd : AsFd , AuxFd : AsFd > (
183+ fs_fd : Fd ,
175184 key : Key ,
176- fd : BorrowedFd < ' _ > ,
185+ fd : AuxFd ,
177186) -> io:: Result < ( ) > {
187+ let fs_fd = fs_fd. as_fd ( ) ;
188+ let fd = fd. as_fd ( ) ;
178189 key. into_with_c_str ( |key| backend:: mount:: syscalls:: fsconfig_set_path_empty ( fs_fd, key, fd) )
179190}
180191
@@ -186,11 +197,13 @@ pub fn fsconfig_set_path_empty<Key: path::Arg>(
186197/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
187198#[ inline]
188199#[ doc( alias = "fsconfig" ) ]
189- pub fn fsconfig_set_fd < Key : path:: Arg > (
190- fs_fd : BorrowedFd < ' _ > ,
200+ pub fn fsconfig_set_fd < Key : path:: Arg , Fd : AsFd , AuxFd : AsFd > (
201+ fs_fd : Fd ,
191202 key : Key ,
192- fd : BorrowedFd < ' _ > ,
203+ fd : AuxFd ,
193204) -> io:: Result < ( ) > {
205+ let fs_fd = fs_fd. as_fd ( ) ;
206+ let fd = fd. as_fd ( ) ;
194207 key. into_with_c_str ( |key| backend:: mount:: syscalls:: fsconfig_set_fd ( fs_fd, key, fd) )
195208}
196209
@@ -202,8 +215,8 @@ pub fn fsconfig_set_fd<Key: path::Arg>(
202215/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
203216#[ inline]
204217#[ doc( alias = "fsconfig" ) ]
205- pub fn fsconfig_create ( fs_fd : BorrowedFd < ' _ > ) -> io:: Result < ( ) > {
206- backend:: mount:: syscalls:: fsconfig_create ( fs_fd)
218+ pub fn fsconfig_create < Fd : AsFd > ( fs_fd : Fd ) -> io:: Result < ( ) > {
219+ backend:: mount:: syscalls:: fsconfig_create ( fs_fd. as_fd ( ) )
207220}
208221
209222/// `fsconfig(fs_fd, FSCONFIG_CMD_RECONFIGURE, key, NULL, 0)`
@@ -214,8 +227,8 @@ pub fn fsconfig_create(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
214227/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
215228#[ inline]
216229#[ doc( alias = "fsconfig" ) ]
217- pub fn fsconfig_reconfigure ( fs_fd : BorrowedFd < ' _ > ) -> io:: Result < ( ) > {
218- backend:: mount:: syscalls:: fsconfig_reconfigure ( fs_fd)
230+ pub fn fsconfig_reconfigure < Fd : AsFd > ( fs_fd : Fd ) -> io:: Result < ( ) > {
231+ backend:: mount:: syscalls:: fsconfig_reconfigure ( fs_fd. as_fd ( ) )
219232}
220233
221234/// `fsconfig(fs_fd, FSCONFIG_CMD_CREATE_EXCL, key, NULL, 0)`
@@ -228,6 +241,6 @@ pub fn fsconfig_reconfigure(fs_fd: BorrowedFd<'_>) -> io::Result<()> {
228241/// [Unfinished draft]: https://github.com/sunfishcode/linux-mount-api-documentation/blob/main/fsconfig.md
229242#[ inline]
230243#[ doc( alias = "fsconfig" ) ]
231- pub fn fsconfig_create_exclusive ( fs_fd : BorrowedFd < ' _ > ) -> io:: Result < ( ) > {
232- backend:: mount:: syscalls:: fsconfig_create_excl ( fs_fd)
244+ pub fn fsconfig_create_exclusive < Fd : AsFd > ( fs_fd : Fd ) -> io:: Result < ( ) > {
245+ backend:: mount:: syscalls:: fsconfig_create_excl ( fs_fd. as_fd ( ) )
233246}
0 commit comments