Problems with pread() in 2.2.2 for HP-UX 11.00

samba-technical at thewrittenword.com samba-technical at thewrittenword.com
Tue Oct 16 21:40:02 GMT 2001


I'm getting a core dump in smbd under 2.2.2 with the following simple
smb.conf under HP-UX 11.00 (hppa1.1-hp-hpux11.00):
[global]
  use mmap = false

[homes]
  comment = Home Directories
  browseable = yes
  path = /home/%u

$ smbd -D -d 5
$ gdb smbd core
(gdb) bt
#0  0xc01160e8 in pread () from /usr/lib/libc.2
#1  0x18c1ec in tdb_read (tdb=0x400aaf30, off=172, buf=0x7b03087c "", len=4, 
    cv=0) at tdb/tdb.c:311
#2  0x18c3d0 in ofs_read (tdb=0x400aaf30, offset=172, d=0x7b03087c)
    at tdb/tdb.c:345
#3  0x18e018 in tdb_next_lock (tdb=0x400aaf30, tlock=0x7b030878, 
    rec=0x7b030860) at tdb/tdb.c:1106
#4  0x18e220 in tdb_traverse (tdb=0x400aaf30, fn=0x4007887a <count_fn>, 
    state=0x7b0307c0 "") at tdb/tdb.c:1169
#5  0x140f0 in claim_connection (conn=0x0, name=0x40001b20 "", 
    max_connections=100000, Clear=1) at smbd/connection.c:144
#6  0xf67c in main (argc=6, argv=0x7b030368) at smbd/server.c:757

HP-UX 11.00 has pread in libc (/usr/lib/libc.sl). Does it work? I
tried the following simple program:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int
main (void) {
  int fd;
  char buf[256];

  fd = open ("/etc/passwd", O_RDONLY);
  printf ("fd: %d\n", fd);

  printf ("bytes: %ld\n", pread (fd, buf, 20, 0));
  printf ("%s\n", buf);

  close (fd);
}

$ cc a.c
$ ./a.out
fd: 3
Bad system call(coredump)

HP-UX 11.00 doesn't even have a man page for pread. So, I hopped on
over to the IRTC support page. There I found patch PHKL_22589 and
noted the following in the description:
  PHKL_20349:
  ( SR: 8606110852 CR: JAGab83602 )
  Enhancement to add new pread(2), pwrite(2), pread64(2) and
  pwrite64(2) system calls.  These calls perform the same
  action as read(2) and write(2) except that they read/write
  from a given position in the file (specified in the fourth
  argument) without changing the file pointer.

So, I loaded PHKL_22589 and now pread works. So, it's not good enough
to test if pread is available. We must test if it works.
$ ./a.out
fd: 3
bytes: 20
root:/alFVh0MwCbyE:0

-- 
albert chin (china at thewrittenword.com)




More information about the samba-technical mailing list