Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/procfs Restore mapping of file id to pid/type/fd.



details:   https://anonhg.NetBSD.org/src/rev/949ccbc9a984
branches:  trunk
changeset: 456161:949ccbc9a984
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Thu Apr 25 22:48:42 2019 +0000

description:
Restore mapping of file id to pid/type/fd.
Use 64bit file id to allow for 32bit fd and 25-26bit pid.

diffstat:

 sys/miscfs/procfs/procfs.h |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r b69cd0cabb25 -r 949ccbc9a984 sys/miscfs/procfs/procfs.h
--- a/sys/miscfs/procfs/procfs.h        Thu Apr 25 20:48:54 2019 +0000
+++ b/sys/miscfs/procfs/procfs.h        Thu Apr 25 22:48:42 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: procfs.h,v 1.75 2019/03/30 23:28:30 christos Exp $     */
+/*     $NetBSD: procfs.h,v 1.76 2019/04/25 22:48:42 mlelstv Exp $      */
 
 /*
  * Copyright (c) 1993
@@ -115,6 +115,7 @@
 #ifdef __HAVE_PROCFS_MACHDEP
        PROCFS_MACHDEP_NODE_TYPES
 #endif
+       PFSlast,        /* track number of types */
 } pfstype;
 
 /*
@@ -133,7 +134,7 @@
 #define pfs_fd pfs_key.pk_fd
        mode_t          pfs_mode;       /* mode bits for stat() */
        u_long          pfs_flags;      /* open flags */
-       u_long          pfs_fileno;     /* unique file id */
+       uint64_t        pfs_fileno;     /* unique file id */
 };
 
 #define PROCFS_NOTELEN 64      /* max length of a note (/proc/$pid/note) */
@@ -164,10 +165,12 @@
 #define UIO_MX 32
 
 #define PROCFS_FILENO(pid, type, fd) \
-    (((type) < PFSproc) ? ((type) + 2) : \
-       (((fd) == -1) ? ((((pid)+1) << 5) + ((int) (type))) : \
-       ((((pid)+1) << 16) | ((fd) << 5) | ((int) (type)))))
-#define PROCFS_TYPE(type)      ((type) & 0x1f)
+       (  (type) == PFSroot ? 2 \
+        : (type) == PFScurproc ? 3 \
+        : (type) == PFSself ? 4 \
+         : (fd) == -1 ? ((pid)+1) * PFSlast + (type) \
+         : ((uint64_t)((pid)+1) << 32 | (fd)) * PFSlast + (type))
+#define PROCFS_TYPE(type)      ((type) % PFSlast)
 
 struct procfsmount {
        void *pmnt_exechook;



Home | Main Index | Thread Index | Old Index