From 5ff1e40ee5fd2262192f7819b6de59d16993c5a2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 3 Apr 2021 21:26:17 +0200 Subject: pflocal: Make io_stat allocate inode id We may not have io_identity called before io_stat, and programs like diff rely on inode numbers being different for different files. * pflocal/io.c (S_io_stat): Allocate socket id if not already allocated. --- pflocal/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'pflocal/io.c') diff --git a/pflocal/io.c b/pflocal/io.c index 2a6b104c..4c79ec9f 100644 --- a/pflocal/io.c +++ b/pflocal/io.c @@ -324,7 +324,7 @@ S_io_stat (struct sock_user *user, struct stat *st) st->st_fstype = FSTYPE_SOCKET; st->st_mode = sock->mode; st->st_fsid = getpid (); - st->st_ino = sock->id; + /* As we try to be clever with large transfers, ask for them. */ st->st_blksize = vm_page_size * 16; st->st_uid = sock->uid; @@ -332,6 +332,11 @@ S_io_stat (struct sock_user *user, struct stat *st) pthread_mutex_lock (&sock->lock); /* Make sure the pipes don't go away... */ + if (sock->id == MACH_PORT_NULL) + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &sock->id); + st->st_ino = sock->id; + rpipe = sock->read_pipe; wpipe = sock->write_pipe; -- cgit v1.2.3