xref: /aosp_15_r20/bionic/libc/bionic/lfs64_support.cpp (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker  * Copyright (C) 2014 The Android Open Source Project
3*8d67ca89SAndroid Build Coastguard Worker  *
4*8d67ca89SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*8d67ca89SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*8d67ca89SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*8d67ca89SAndroid Build Coastguard Worker  *
8*8d67ca89SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*8d67ca89SAndroid Build Coastguard Worker  *
10*8d67ca89SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*8d67ca89SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*8d67ca89SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*8d67ca89SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*8d67ca89SAndroid Build Coastguard Worker  * limitations under the License.
15*8d67ca89SAndroid Build Coastguard Worker  */
16*8d67ca89SAndroid Build Coastguard Worker 
17*8d67ca89SAndroid Build Coastguard Worker #include <ftw.h>
18*8d67ca89SAndroid Build Coastguard Worker #include <stdlib.h>
19*8d67ca89SAndroid Build Coastguard Worker 
20*8d67ca89SAndroid Build Coastguard Worker // Delegation will work in these cases because all the transitive dependencies
21*8d67ca89SAndroid Build Coastguard Worker // are already 64-bit ready. In particular, we don't have non-O_LARGEFILE
22*8d67ca89SAndroid Build Coastguard Worker // open (our open is actually open64) and stat and stat64 are the same.
mkstemp64(char * path)23*8d67ca89SAndroid Build Coastguard Worker int mkstemp64(char* path) {
24*8d67ca89SAndroid Build Coastguard Worker   return mkstemp(path);
25*8d67ca89SAndroid Build Coastguard Worker }
mkostemp64(char * path,int flags)26*8d67ca89SAndroid Build Coastguard Worker int mkostemp64(char* path, int flags) {
27*8d67ca89SAndroid Build Coastguard Worker   return mkostemp(path, flags);
28*8d67ca89SAndroid Build Coastguard Worker }
mkstemps64(char * path,int suffix_length)29*8d67ca89SAndroid Build Coastguard Worker int mkstemps64(char* path, int suffix_length) {
30*8d67ca89SAndroid Build Coastguard Worker   return mkstemps(path, suffix_length);
31*8d67ca89SAndroid Build Coastguard Worker }
mkostemps64(char * path,int suffix_length,int flags)32*8d67ca89SAndroid Build Coastguard Worker int mkostemps64(char* path, int suffix_length, int flags) {
33*8d67ca89SAndroid Build Coastguard Worker   return mkostemps(path, suffix_length, flags);
34*8d67ca89SAndroid Build Coastguard Worker }
35*8d67ca89SAndroid Build Coastguard Worker 
36*8d67ca89SAndroid Build Coastguard Worker typedef int (*ftw_fn)(const char*, const struct stat*, int);
37*8d67ca89SAndroid Build Coastguard Worker typedef int (*nftw_fn)(const char*, const struct stat*, int, struct FTW*);
38*8d67ca89SAndroid Build Coastguard Worker 
ftw64(const char * dirpath,int (* fn)(const char *,const struct stat64 *,int),int nopenfd)39*8d67ca89SAndroid Build Coastguard Worker int ftw64(const char *dirpath,
40*8d67ca89SAndroid Build Coastguard Worker     int (*fn)(const char*, const struct stat64*, int), int nopenfd) {
41*8d67ca89SAndroid Build Coastguard Worker   return ftw(dirpath, reinterpret_cast<ftw_fn>(fn), nopenfd);
42*8d67ca89SAndroid Build Coastguard Worker }
43*8d67ca89SAndroid Build Coastguard Worker 
nftw64(const char * dirpath,int (* fn)(const char *,const struct stat64 *,int,struct FTW *),int nopenfd,int flags)44*8d67ca89SAndroid Build Coastguard Worker int nftw64(const char * dirpath,
45*8d67ca89SAndroid Build Coastguard Worker     int (*fn)(const char*, const struct stat64*, int, struct FTW*),
46*8d67ca89SAndroid Build Coastguard Worker     int nopenfd, int flags) {
47*8d67ca89SAndroid Build Coastguard Worker   return nftw(dirpath, reinterpret_cast<nftw_fn>(fn), nopenfd, flags);
48*8d67ca89SAndroid Build Coastguard Worker }
49