NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: procfs difference between NetBSD and Linux



Succeeds for me:
...
➜  ~ gcc -o s s.c
➜  ~ ./s
fd = -1
new_fd = -1
➜  ~ uname -a
NetBSD ymir 9.99.82 NetBSD 9.99.82 (GENERIC) #0: Tue Jun  1 01:23:54
BST 2021  sysbuild@ymir:/home/sysbuild/amd64/obj/home/sysbuild/src/sys/arch/amd64/compile/GENERIC
amd64

...

On Tue, 1 Jun 2021 at 00:55, Mark Davies <mark%ecs.vuw.ac.nz@localhost> wrote:
>
> 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);
> }



-- 
----


Home | Main Index | Thread Index | Old Index