FileUtils.java: Don't treat open access modes as flags
O_RDONLY, O_WRONLY, and O_RDWR are not flags. Rather, they are the integer values 0, 1, and 2, respectively. #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 Quoting "man 2 open" * File access mode * Unlike the other values that can be specified in flags, the access mode values O_RDONLY, O_WRONLY, and O_RDWR do not specify individual bits. Rather, they define the low order two bits of flags, and are defined respectively as 0, 1, and 2. In other words, the combination O_RDONLY | O_WRONLY is a logical error, and certainly does not have the same meaning as O_RDWR. Linux reserves the special, nonstandard access mode 3 (binary 11) in flags to mean: check for read and write permission on the file and return a file descriptor that can't be used for reading or writing. This nonstandard access mode is used by some Linux drivers to return a file descriptor that is to be used only for device-specific ioctl(2) operations. Rather than treat these values like flags, use O_ACCMODE to extract the values and then perform the comparisons. Introduced in 63280e06. Test: android compiles and boots. Change-Id: I4d3185e835615ffba3a7854d3d58351e124599d0
Loading
Please register or sign in to comment