2 * stat related system call shims and definitions
4 * Copyright (c) 2013 Stacey D. Son
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef BSD_USER_FREEBSD_OS_STAT_H
21 #define BSD_USER_FREEBSD_OS_STAT_H
24 static inline abi_long
do_freebsd11_stat(abi_long arg1
, abi_long arg2
)
28 struct freebsd11_stat st
;
31 ret
= get_errno(freebsd11_stat(path(p
), &st
));
34 ret
= h2t_freebsd11_stat(arg2
, &st
);
40 static inline abi_long
do_freebsd11_lstat(abi_long arg1
, abi_long arg2
)
44 struct freebsd11_stat st
;
47 ret
= get_errno(freebsd11_lstat(path(p
), &st
));
50 ret
= h2t_freebsd11_stat(arg2
, &st
);
56 static inline abi_long
do_freebsd_fstat(abi_long arg1
, abi_long arg2
)
61 ret
= get_errno(fstat(arg1
, &st
));
63 ret
= h2t_freebsd_stat(arg2
, &st
);
69 static inline abi_long
do_freebsd_fstatat(abi_long arg1
, abi_long arg2
,
70 abi_long arg3
, abi_long arg4
)
77 ret
= get_errno(fstatat(arg1
, p
, &st
, arg4
));
79 if (!is_error(ret
) && arg3
) {
80 ret
= h2t_freebsd_stat(arg3
, &st
);
85 /* undocummented nstat(char *path, struct nstat *ub) syscall */
86 static abi_long
do_freebsd11_nstat(abi_long arg1
, abi_long arg2
)
90 struct freebsd11_stat st
;
93 ret
= get_errno(freebsd11_nstat(path(p
), &st
));
96 ret
= h2t_freebsd11_nstat(arg2
, &st
);
101 /* undocummented nfstat(int fd, struct nstat *sb) syscall */
102 static abi_long
do_freebsd11_nfstat(abi_long arg1
, abi_long arg2
)
105 struct freebsd11_stat st
;
107 ret
= get_errno(freebsd11_nfstat(arg1
, &st
));
108 if (!is_error(ret
)) {
109 ret
= h2t_freebsd11_nstat(arg2
, &st
);
114 /* undocummented nlstat(char *path, struct nstat *ub) syscall */
115 static abi_long
do_freebsd11_nlstat(abi_long arg1
, abi_long arg2
)
119 struct freebsd11_stat st
;
122 ret
= get_errno(freebsd11_nlstat(path(p
), &st
));
123 UNLOCK_PATH(p
, arg1
);
124 if (!is_error(ret
)) {
125 ret
= h2t_freebsd11_nstat(arg2
, &st
);
131 static abi_long
do_freebsd_getfh(abi_long arg1
, abi_long arg2
)
138 ret
= get_errno(getfh(path(p
), &host_fh
));
139 UNLOCK_PATH(p
, arg1
);
143 return h2t_freebsd_fhandle(arg2
, &host_fh
);
147 static inline abi_long
do_freebsd_lgetfh(abi_long arg1
, abi_long arg2
)
154 ret
= get_errno(lgetfh(path(p
), &host_fh
));
155 UNLOCK_PATH(p
, arg1
);
159 return h2t_freebsd_fhandle(arg2
, &host_fh
);
163 static inline abi_long
do_freebsd_fhopen(abi_long arg1
, abi_long arg2
)
168 ret
= t2h_freebsd_fhandle(&host_fh
, arg1
);
173 return get_errno(fhopen(&host_fh
, arg2
));
177 static inline abi_long
do_freebsd_fhstat(abi_long arg1
, abi_long arg2
)
183 ret
= t2h_freebsd_fhandle(&host_fh
, arg1
);
187 ret
= get_errno(fhstat(&host_fh
, &host_sb
));
191 return h2t_freebsd_stat(arg2
, &host_sb
);
195 static inline abi_long
do_freebsd_fhstatfs(abi_ulong target_fhp_addr
,
196 abi_ulong target_stfs_addr
)
200 struct statfs host_stfs
;
202 ret
= t2h_freebsd_fhandle(&host_fh
, target_fhp_addr
);
206 ret
= get_errno(fhstatfs(&host_fh
, &host_stfs
));
210 return h2t_freebsd_statfs(target_stfs_addr
, &host_stfs
);
213 #endif /* BSD_USER_FREEBSD_OS_STAT_H */