tech-kern archive

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

Re: procfs files vs symlink



On Wed, Jan 12, 2022 at 12:44:57PM -0000, Christos Zoulas wrote:
> In article <Yd1XkIokEY/jX/7O%mail.soc.lip6.fr@localhost>,
> Manuel Bouyer  <bouyer%antioche.eu.org@localhost> wrote:
> >-=-=-=-=-=-
> >
> >On Fri, Jan 07, 2022 at 03:20:04PM +0100, Manuel Bouyer wrote:
> >> Hello
> >> I'm trying to get a linux binary to run on NetBSD, as stated in this thread
> >> http://mail-index.netbsd.org/current-users/2022/01/06/msg041891.html
> >> 
> >> Now I hit an issue where the linux process does a readlink() on a procfs
> >> file and gets EINVAL.
> >> It seems that this is because, on linux all files in /proc/<pid>/fd/ are
> >> symlinks, while on NetBSD they are some kind of hard links.
> >> E.g. on linux:
> >> bip:/dsk/l1/misc/bouyer/HEAD/clean/src>ls -l /proc/$$/fd/
> >> total 0
> >> lr-x------ 1 bouyer ita-iatos 64 Jan  7 14:13 0 -> /dev/null
> >> lr-x------ 1 bouyer ita-iatos 64 Jan  7 14:13 1 -> /dev/null
> >> lrwx------ 1 bouyer ita-iatos 64 Jan  7 15:16 15 -> /dev/pts/11
> >> lrwx------ 1 bouyer ita-iatos 64 Jan  7 14:13 16 -> /dev/pts/11
> >> lrwx------ 1 bouyer ita-iatos 64 Jan  7 15:16 17 -> /dev/pts/11
> >> lrwx------ 1 bouyer ita-iatos 64 Jan  7 15:16 18 -> /dev/pts/11
> >> lrwx------ 1 bouyer ita-iatos 64 Jan  7 15:16 19 -> /dev/pts/11
> >> lr-x------ 1 bouyer ita-iatos 64 Jan  7 14:13 2 -> /dev/null
> >> 
> >> On NetBSD:
> >> armandeche:/local/armandeche1/bouyer>/emul/linux/bin/ls -l /proc/$$/fd/
> >> total 0
> >> crw--w---- 1 bouyer tty 3, 13 Jan  7 15:19 15
> >> crw--w---- 1 bouyer tty 3, 13 Jan  7 15:19 16
> >> crw--w---- 1 bouyer tty 3, 13 Jan  7 15:19 17
> >> 
> >> Any idea on how to properly fix it ?
> >
> >The attached diff changes the procfs behavior to match the linux one, for
> >linux processes:
> >comore:/home/bouyer>ls -l /proc/self/fd/
> >total 1
> >crw--w----  1 bouyer  tty    5, 0 Jan 11 11:08 0
> >crw--w----  1 bouyer  tty    5, 0 Jan 11 11:08 1
> >crw--w----  1 bouyer  tty    5, 0 Jan 11 11:08 2
> >lr-xr-xr-x  1 bouyer  staff   512 Jan 11 11:08 3 -> /home/bouyer
> >
> >ls: /proc/self/fd//4: Invalid argument
> >lr-xr-xr-x  1 bouyer  staff     0 Jan 11 11:08 4
> >comore:/home/bouyer>/emul/linux/bin/ls -l /proc/self/fd/                
> >total 0
> >lr-xr-xr-x 1 root   wheel 0 Jan 11 11:08 0 -> /dev/ttyp0
> >lr-xr-xr-x 1 root   wheel 0 Jan 11 11:08 1 -> /dev/ttyp0
> >lr-xr-xr-x 1 root   wheel 0 Jan 11 11:08 2 -> /dev/ttyp0
> >lr-xr-xr-x 1 bouyer staff 0 Jan 11 11:08 3 -> /
> >
> >and my linux binaries seems to work properly now
> >
> >would it be OK to commit ?
> 
> Err, no :-) The previous behavior uses the original inode from the filesystem.
> This means that you can undelete files:

you can still do this, as long as you're not using a linux ln(1) binary.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index