ah, right.
> this would be much more clear and much less error-prone if
> this was done explicitely instead of with a clever hack that
> obfuscates the operation.
Agreed.  Heck, for clarity I even prefer a style of   if (flags == 0)
over   if (!flags)   but I'm probably the only one.
>  Implementing it in this way
> makes it clear what to do:
>
>      switch(uap->flags & O_ACCMODE) {
>      case O_RDONLY:
>          lowbits = FREAD;
>          break;
>      case O_WRONLY:
>          lowbits = FWRITE;
>          break;
>      case O_RDWR:
>          lowbits = FREAD | FWRITE;
>          break;
>      default:
>          return EINVAL;
>      }
>      flags = (uap->flags & ~O_ACCMODE) | lowbits;
Would probably want to move this above the opening falloc() also.
mm