Bacula-users

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

2015-10-10 18:15:14
Subject: Re: [Bacula-users] Support for HAVE_POSIX_FADVISE on Bacula Client
From: Richard Hall <Richard.Hall AT ingenta DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Sat, 10 Oct 2015 22:44:21 +0100
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