oflags &= ~DB_RDONLY;
dbi->dbi_oflags &= ~DB_RDONLY;
} else {
- if (!(dbi->dbi_mode & (O_RDWR|O_WRONLY))) oflags |= DB_RDONLY;
+ if ((dbi->dbi_mode & O_ACCMODE) == O_RDONLY) oflags |= DB_RDONLY;
if (dbi->dbi_mode & O_CREAT) {
oflags |= DB_CREATE;
dbi->dbi_oeflags |= DB_CREATE;
l.l_whence = 0;
l.l_start = 0;
l.l_len = 0;
- l.l_type = (dbi->dbi_mode & (O_RDWR|O_WRONLY))
- ? F_WRLCK : F_RDLCK;
+ l.l_type = (dbi->dbi_mode & O_ACCMODE) == O_RDONLY
+ ? F_RDLCK : F_WRLCK;
l.l_pid = 0;
rc = fcntl(fdno, F_SETLK, (void *) &l);
? 0 : 1);
rpmlog( (rc ? RPMLOG_ERR : RPMLOG_WARNING),
_("cannot get %s lock on %s/%s\n"),
- ((dbi->dbi_mode & (O_RDWR|O_WRONLY))
- ? _("exclusive") : _("shared")),
+ ((dbi->dbi_mode & O_ACCMODE) == O_RDONLY)
+ ? _("shared") : _("exclusive"),
dbhome, (dbfile ? dbfile : ""));
} else if (dbfile) {
rpmlog(RPMLOG_DEBUG,
/* open a file and set *fdp */
if (*fdp == NULL && fn != NULL) {
- fd = Fopen(fn, ((flags & O_WRONLY) ? "w.ufdio" : "r.ufdio"));
+ fd = Fopen(fn, (flags & O_ACCMODE) == O_WRONLY ? "w.ufdio" : "r.ufdio");
if (fd == NULL || Ferror(fd)) {
rpmlog(RPMLOG_ERR, _("%s: open failed: %s\n"), fn,
Fstrerror(fd));
if (dbp)
*dbp = NULL;
- if (mode & O_WRONLY)
+ if ((mode & O_ACCMODE) == O_WRONLY)
return 1;
db = newRpmdb(prefix, dbpath, mode, perms, flags);
urlType = URL_IS_UNKNOWN;
break;
case URL_IS_DASH:
- assert(!(flags & O_RDWR));
- fd = fdDup( ((flags & O_WRONLY) ? STDOUT_FILENO : STDIN_FILENO) );
+ if ((flags & O_ACCMODE) == O_RDWR) {
+ fd = NULL;
+ } else {
+ fd = fdDup((flags & O_ACCMODE) == O_WRONLY ?
+ STDOUT_FILENO : STDIN_FILENO);
+ }
timeout = 600; /* XXX W2DO? 10 mins? */
break;
case URL_IS_PATH: