Bacula-users

Re: [Bacula-users] Support for HAVE_POSIX_FADVISE on Bacula Client

2015-10-10 22:17:45
Subject: Re: [Bacula-users] Support for HAVE_POSIX_FADVISE on Bacula Client
From: Kern Sibbald <kern AT sibbald DOT com>
To: Richard Hall <Richard.Hall AT ingenta DOT com>, bacula-users AT lists.sourceforge DOT net
Date: Sat, 10 Oct 2015 19:15:33 -0700
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).

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