1 /* 2 * Copyright 2012, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <portability.h> 18 #include <stdio.h> 19 #include <fcntl.h> 20 #include <fcntl_portable.h> 21 22 #define PORTABLE_TAG "flags_portable" 23 #include <log_portable.h> 24 25 26 /* __sflags is an internal bionic routine but the symbol is exported and there are callers... */ 27 extern int __sflags(const char *, int *); 28 29 int 30 WRAP(__sflags)(const char *mode, int *optr) 31 { 32 int rv; 33 int nflags, pflags; 34 35 ALOGV(" "); 36 ALOGV("%s(mode:%p, optr:%p) {", __func__, mode, optr); 37 38 rv = __sflags(mode, &nflags); 39 40 /* error - no change to *optr */ 41 if (rv == 0) 42 goto done; 43 44 pflags = nflags & O_ACCMODE; 45 if (nflags & O_CREAT) 46 pflags |= O_CREAT_PORTABLE; 47 if (nflags & O_TRUNC) 48 pflags |= O_TRUNC_PORTABLE; 49 if (nflags & O_APPEND) 50 pflags |= O_APPEND_PORTABLE; 51 52 /* Set *optr to portable flags */ 53 *optr = pflags; 54 55 done: 56 ALOGV("%s: return(rv:%d); }", __func__, rv); 57 return rv; 58 } 59