Skip to contentSkip to conversation

file locking problems?

parisc-linux Randolph Chung 3 participants 3 messages Oct 9, 2000

lore
Share & tools
lore
#0 lore raw

Hi all,

I'm seeing some weird behavior with file locking on my hppa box:

update-passwd (a Debian package) makes a call to lckpwdf. That fails with an "Invalid argument" message. It looks like lckpwdf internally uses fcntl() locking, so I tried that and it too fails with an "Invalid argument" message. This happens both on nfs and local ext2 fs. Similar tests with flock() seems to work ok.

Any ideas? This is using dhd's latest glibc build. My testing program is attached. I've verified that it works on ext2 fs on i386 and SPARC. Over nfs it does give an error message (No locks available).

The test program I used is attached.

randolph

Signature · 4 lines
   @..@                                         http://www.TauSq.org/
  (----)
 ( >__< )
 ^^ ~~ ^^

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char **argv)

{
        struct flock l;
        int fd;

        if ((fd = open("test.lck", O_CREAT|O_RDWR)) < 0)
        {
                perror("open");
                return -1;
        }
        memset(&l, 0, sizeof(l));
        l.l_type = F_RDLCK;
        if (fcntl(fd, F_SETLK, &l) < 0)
        {
                perror("fcntl");
                return -1;
        }
        close(fd);
        return 0;
}
#1 lore raw
Quoted 5 lines · Randolph Chung

update-passwd (a Debian package) makes a call to lckpwdf. That fails with an "Invalid argument" message. It looks like lckpwdf internally uses fcntl() locking, so I tried that and it too fails with an "Invalid argument" message. This happens both on nfs and local ext2 fs. Similar tests with flock() seems to work ok.

Lots of things report this actually - if you look in your log files you'll see lots of "utmp file is locked/read" - also in bootup messages there will be a "can't lock <whatever>".

I have a feeling this might just be generally broken in the revision of the kernel we're using, though it could be a problem with LFS in our glibc if it is trying to use fcntl64().

I suspect that our LFS stuff is generally broken (lseek64() is, at least) and plan to investigate further on Tuesday.

Signature · 2 lines
[email protected], http://www.linuxcare.com/
Linuxcare. Support for the revolution.
#2 lore raw
In reply to Randolph Chung
Quoted 5 lines

update-passwd (a Debian package) makes a call to lckpwdf. That fails with an "Invalid argument" message. It looks like lckpwdf internally uses fcntl() locking, so I tried that and it too fails with an "Invalid argument" message. This happens both on nfs and local ext2 fs. Similar tests with flock() seems to work ok.

as it turns out, it looks like there's a glibc<->kernel mismatch. the kernel defines F_RDLCK as 1, and glibc has it defined as 0. dhd is aware of this and say he'll look into fixing this later this week.

randolph

Signature · 2 lines
Debian Developer <[email protected]>
http://www.TauSq.org/