[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: rpmdatabse error in installation
- From: Enrique Perez-Terron <enrio online no>
- To: RPM Package Manager <rpm-list redhat com>
- Subject: Re: rpmdatabse error in installation
- Date: Sat, 07 Aug 2004 03:03:47 +0200
On Thu, 2004-08-05 at 08:21, garima@cse.iitb.ac.in wrote:
> error: cannot get exclusive lock on /users/extra/plusers/rpmdb/Packages
I have found the place in the source of rpm where this message
apparently comes from.
struct flock l;
memset(&l, 0, sizeof(l));
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_pid = 0;
rc = fcntl(fdno, F_SETLK, (void *) &l);
This means the program has already opened the file, presumably for
write, so there cannot be a write permissions issue.
>From what I can see in the man page for fcntl(2), the only possibility
left is that some other process is having a lock on the file. If the
same process already holds a lock, the call will not fail.
I suggest you try again, and if it fails again, run
/usr/sbin/lsof | grep Packages
This command is not foolproof in your case, since you cannot run it as
root, but it is likely that the process having the lock is running as
you, and then lsof is allowed to se the process' open files. If there
are hard links to the Packages file, you have to grep for those names
too.
Failing that, the following C program can tell you the process ID of the
process that holds the lock:
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
main(int argc, char *argv[])
{
struct flock l;
int ret;
int fd = open(argv[1], O_RDWR, 0666);
if (fd < 0) {
fprintf(stderr, "Cannot open %s for read-write: %s.\n",
argv[1] ? argv[1] : "(null)", strerror(errno));
exit(1);
}
bzero((void*)&l, sizeof(l));
l.l_type = F_WRLCK;
ret = fcntl(fd, F_GETLK, &l);
if (ret < 0) {
fprintf(stderr, "Unable to get file lock information on %s: %s.\n",
argv[1], strerror(errno));
exit(1);
}
if (l.l_type == F_UNLCK) {
printf("%s: not locked.\n", argv[1]);
exit(0);
}
printf("%s: Process %d has %s lock ", argv[1], l.l_pid,
l.l_type == F_WRLCK ? "an exclusive" : "a shared");
if (!l.l_start && !l.l_len)
printf("on the entire file.\n");
else if (!l.l_len)
printf("on the tail starting from byte number %d.\n", l.l_start);
else
printf("on %d bytes starting from byte number %d.\n", l.l_len, l.l_start);
exit(0);
}
Regards,
Enrique
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]