git: kernel - Fix /dev/fd/N and clean up the old dup error-code-driven path

Matthew Dillon dillon at crater.dragonflybsd.org
Sun Mar 21 12:13:44 PDT 2021


commit 5bd455973731fc90e519dbed944ca7806eb8c424
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Fri Mar 19 19:27:11 2021 -0700

    kernel - Fix /dev/fd/N and clean up the old dup error-code-driven path
    
    * When opening /dev/fd/N, replicate the file pointer for descriptors
      that represent vnodes instead of dup()ing.  This ensures that the seek
      offset and other fp-related elements are not shared unexpectedly.
    
    * Refactor the open() path to allow dev_dopen() to replace the
      struct file by passing a struct file ** instead of a struct file *.
      This removes old error-code-based hacks.
    
    * This fixes the shared seek position that fexecve() was operating with
      due to its use of /dev/fd/N for scripts.
    
    Reported-by: aly

Summary of changes:
 sys/bus/u4b/usb_dev.c       |   6 +-
 sys/dev/drm/drm_file.c      |   6 +-
 sys/dev/misc/evdev/cdev.c   |   8 ++-
 sys/dev/misc/ipmi/ipmi.c    |   2 +-
 sys/kern/kern_descrip.c     | 142 ++++++++++++++++++++++----------------------
 sys/kern/kern_device.c      |  20 ++++---
 sys/kern/kern_fp.c          |  17 +++---
 sys/kern/kern_shutdown.c    |   3 +-
 sys/kern/subr_diskiocom.c   |   3 +-
 sys/kern/subr_diskslice.c   |   5 +-
 sys/kern/tty_cons.c         |   4 +-
 sys/kern/vfs_default.c      |   4 +-
 sys/kern/vfs_syscalls.c     |  76 +++++++-----------------
 sys/kern/vfs_vnops.c        |  20 +++++--
 sys/kern/vfs_vopops.c       |   7 +--
 sys/sys/device.h            |   4 +-
 sys/sys/filedesc.h          |   1 -
 sys/sys/proc.h              |   2 +-
 sys/sys/vfsops.h            |   8 +--
 sys/sys/vnode.h             |   2 +-
 sys/vfs/devfs/devfs_vnops.c |  37 ++++++++----
 sys/vfs/fuse/fuse_device.c  |   3 +-
 sys/vfs/fuse/fuse_io.c      |   4 +-
 sys/vfs/fuse/fuse_vnops.c   |  13 ++--
 24 files changed, 208 insertions(+), 189 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/5bd455973731fc90e519dbed944ca7806eb8c424


-- 
DragonFly BSD source repository



More information about the Commits mailing list