On Thu, Oct 16, 2003, Dennis McRitchie wrote:

> [...]
> However, when I then ran an "rpm -qa" it printed out what looks like part of your 
> public key!
>
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> > rpm -qa
> gpg-pubkey-63c4cb9f-3c591eda
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This entry itself is correct. It's the OpenPKG OpenPGP public key which
RPM 4.2.1 manages now like a real package (you can even do a "rpm -qi"
on it and see its details, etc). What is not ok, of course, is that the
other packages are missing.

> Previously, there were 24 packages in the DB. It could be, of course, that the DB 
> got damaged when I was trying to
> rebuild and getting ENOLCKs. But I did try Jeff Johnson's quick fix (below) after a 
> failed rebuild attempt, and found
> that all my packages were still there at that time.
>
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> %__dbi_cdb create cdb mpool mp_mmapsize=16Mb mp_size=1Mb private
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

First, with the latest OpenPKG bootstrap package "openpkg" you now
have a convinient "--db-private" option which you can use like "rpm
--db-private -qa", etc. This then on-the-fly sets the __cdb_cdb
variable to include "private". You can even globally define the
variable "__rpmdb_private yes" (in your ~root/.rpmmacros or in
<prefix>/etc/openpkg/rpmmacros) and all your operations are performed
in "private" mode. For you this means all your problems should be gone
at once, although you are running RPM in less secure mode, meaning that
concurrent RPM usages are not allowed. OTOH it can be fully acceptable,
because that's the way how RPM 4.0.2 from OpenPKG 1.x is operating.

> 3) When I tried to tun "rpm --db-rebuild" on our Solaris 9 system, (as
> alaways the DB files were on the NFS system), I got the same problem
> as before: EAGAIN on the mmap calls. (Yet your test program still runs
> successfully.) Stderr output is:
> [...]
> 9887: open("/usr/psr.oit/solaris9/RPM/DB/__db.001", O_RDWR|O_CREAT, 0644) = 4
> 9887: fcntl(4, F_SETFD, 0x00000001)                   = 0
> 9887: ioctl(4, 0x2000664C, 0x00000001)                = 0
> 9887: lseek(4, 0, SEEK_END)                           = 0
> 9887: lseek(4, 0, SEEK_CUR)                           = 0
> 9887: write(4, "\0\0\0\0\0\0\0\0\0\0\0\0".., 8192)    = 8192
> 9887: mmap(0x00000000, 8192, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) Err#11 EAGAIN
> [...]
> Any idea why this might still be happening even though your test
> program seems to suggest that locking is working?

Well, my test program is for the fcntl(2) call only. Your problem now
is the failing mmap(2): EAGAIN on mmap(2) is something completely
different. That's interesting. So, we're now at least one step further
for your situation.

So, next round: what about the following extended test program "foo.c"?

-------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>

int main(int argc, char *argv[])
{
    int fd;
    struct flock l;
    int rv;
    char buf[8192];
    void *vp;

    fd = open("foo.db", O_RDWR|O_CREAT, 0644);
    printf("open() -> %d, %d\n", fd, fd == -1 ? errno : 0);
    if (fd == -1) { exit(1); }

    l.l_type   = F_WRLCK;
    l.l_whence = SEEK_SET;
    l.l_start  = 0;
    l.l_len    = 0;
    rv = fcntl(fd, F_SETLKW, &l);
    printf("fcntl() -> %d, %d\n", rv, rv == -1 ? errno : 0);
    if (rv == -1) { exit(1); }

    memset(buf, 0, 8192);
    rv = write(fd, buf, 8192);
    printf("write() -> %d, %d\n", rv, rv == -1 ? errno : 0);
    if (rv == -1) { exit(1); }

    vp = mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    printf("mmap() -> %lx, %d\n", (unsigned long)vp, vp == NULL ? errno : 0);
    if (vp == NULL) { exit(1); }

    rv = munmap(vp, 8192);
    printf("munmap() -> %d, %d\n", rv, rv == -1 ? errno : 0);
    if (rv == -1) { exit(1); }

    l.l_type = F_UNLCK;
    rv = fcntl(fd, F_SETLKW, &l);
    printf("fcntl() -> %d, %d\n", rv, rv == -1 ? errno : 0);
    if (rv == -1) { exit(1); }

    rv = close(fd);
    printf("close() -> %d, %d\n", rv, rv == -1 ? errno : 0);
    if (rv == -1) { exit(1); }

    return 0;
}
-------------------------------------------------------------------

What is the output when run on multiple systems while staying (with
current working directory) on NFS, UFS and MFS/TEMPFS filesystems?
Hopefully here we see the EAGAIN again...

                                       Ralf S. Engelschall
                                       [EMAIL PROTECTED]
                                       www.engelschall.com

______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
User Communication List                      [EMAIL PROTECTED]

Reply via email to