GauthamBanasandra commented on code in PR #4526: URL: https://github.com/apache/hadoop/pull/4526#discussion_r914111478
########## hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/x-platform/stat.h: ########## @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_LIBHDFSPP_LIB_CROSS_PLATFORM_STAT +#define NATIVE_LIBHDFSPP_LIB_CROSS_PLATFORM_STAT + +#if defined(_WIN32) + +// Windows. +// These macros are derived from POSIX sys/stat.h. Windows defines some of +// these macros, but not all. Thus, we align with the bits defined by POSIX for +// all of them to be consistent. +#define S_IRUSR 0400 Review Comment: @goiri Windows provides the flags only for `user` RWX - https://docs.microsoft.com/en-us/cpp/c-runtime-library/file-permission-constants?view=msvc-170. I found the definitions for these macros from `ucrt/sys/stat.h` - ```cpp #define _S_IREAD 0x0100 // Read permission, owner #define _S_IWRITE 0x0080 // Write permission, owner #define _S_IEXEC 0x0040 // Execute/search permission, owner ``` Windows doesn't define the flags for `group` and `others`. I checked the permission flags in POSIX `sys/stat.h` ```cpp #define S_IRUSR 0400 #define S_IWUSR 0200 #define S_IXUSR 0100 ``` However, please note that both the Windows and POSIX versions are the equivalent. It's just that, these macros are defined in hexadecimal in Windows, while they're defined in octal representation in POSIX. Thus, bit shifting them by 3 would yield the same behaviour on both the platforms. Perhaps Windows expects the users to perform the bit shifting to specify the permissions for `group` and `others`. Nevertheless, Hadoop seems to favour the same model, be it Windows or Linux - https://github.com/apache/hadoop/blob/161b1fac2e20cc9a6090f1c2cd8859d9b6def8d3/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/permission/FsPermission.java#L447-L452 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
