The below program demonstrates a difference between /proc on NetBSD and Linux.

If run in a directory with a writable "foo.txt" then on Linux the second openat() succeeds but on NetBSD it fails (EEXIST). This behavior difference breaks the latest samba (4.14.x) on NetBSD.

Can this be fixed?

cheers
mark

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

int main ()
{
  int fd, new_fd;
  char buf[PATH_MAX];

  fd = openat (AT_FDCWD, "foo.txt",  O_RDONLY|O_NOFOLLOW);
  printf ("fd = %d\n", fd);
  sprintf(buf, "/proc/self/fd/%d", fd);
  sleep(10);
  new_fd = openat(AT_FDCWD, buf, O_RDWR|O_CREAT|O_NONBLOCK, 0744);
  printf ("new_fd = %d\n", new_fd);
  sleep (20);
}

Reply via email to