On 10/10/2015 10:15 PM, Kern Sibbald wrote:
> Hello,
>
> >From what I read on the web, this whole thing is a bit of a mess, and
> apparently POSIX requires that O_ACCMODE not be 3 because there are at
> least two bits besides O_RWRD and O_RDONLY. However, on most systems
> O_ACCMODE is 3. It would be hard to consider any part of flags as an
> integer because it is a bit field, and on Linux (and most other
> systems), the value of the "integer" produced by anding with O_ACMODE
> cannot take on the value 3 (or more precisely, the value of 3 is illogical).
Well, according to the open(2) man page from RHEL 7, the two least
significant bits are NOT part of the bitfield:
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.
Granted, it is strange and probably a holdover from long ago when memory
was scarce and CPU register sizes were small.
.
>
> In any case, I have fixed the current Bacula code to work correctly with
> all the modes that Bacula currently uses.
>
> I thank Robert Heinzmann for finding and identifying the problem :-)
>
> Best regards,
> Kern
>
>
>
> On 10/10/2015 02:44 PM, Richard Hall wrote:
>> On 10/10/2015 19:30, Kern Sibbald wrote:
>>> On 10/10/2015 10:16 AM, Phil Stracchino wrote:
>>>> On 10/09/15 22:05, Kern Sibbald wrote:
>>>>> Hello,
>>>>>
>>>>> Thanks for pointing this out. I still have problems imagining that they
>>>>> would define O_RDONLY as 0 in a bitmapped variable!!!
>>>> It makes more sense if you think of it as the absence of O_RDWR.
>>> Unfortunately, it is even more complicated than that, because it is
>>> actually the absence of O_RWRD and O_WRONLY.
>>>
>>> In my opinion the original implementation was faulty because O_RDONLY
>>> should really be defined as:
>>>
>>> #define O_RDONLY !(O_RWRD&O_RONLY)
>>>
>>> See my second to last commit ...
>>>
>>> Goan, but that is how it is so now we know, and hopefully it should now
>>> work correctly.
>>>
>>> Best regards,
>>> Kern
>> Aren't people over-complicating this? You need to think of this as a
>> 2-bit integer field, not as a bitmap. Then looking at the constants
>> defined in fcntl.h, it becomes clear (to me, anyway!) that the code
>> should be (sorry, I forget the exact context, but you'll see what I
>> mean, I hope)
>>
>> (flags & O_ACCMODE) == O_RDONLY
>>
>> (The Solaris box I am looking at defines
>>
>> #define O_ACCMODE 3 /* Mask for file access modes */
>>
>> while a nearby Linux system has
>>
>> #define O_ACCMODE 00000003
>> #define O_RDONLY 00000000
>> #define O_WRONLY 00000001
>> #define O_RDWR 00000002
>>
>> )
>>
>> Regards,
>> Richard
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Bacula-users mailing list
>> Bacula-users AT lists.sourceforge DOT net
>> https://lists.sourceforge.net/lists/listinfo/bacula-users
>>
> a
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Bacula-users mailing list
> Bacula-users AT lists.sourceforge DOT net
> https://lists.sourceforge.net/lists/listinfo/bacula-users
------------------------------------------------------------------------------
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
|