Source-Changes-HG archive

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

[src/trunk]: src/sys/sys do not expose kernel-internal structure definitions ...



details:   https://anonhg.NetBSD.org/src/rev/5752751bda82
branches:  trunk
changeset: 824563:5752751bda82
user:      chs <chs%NetBSD.org@localhost>
date:      Thu Jun 08 22:24:59 2017 +0000

description:
do not expose kernel-internal structure definitions to userland.
needed for ZFS.

diffstat:

 sys/sys/disk.h |  133 +++++++++++++++++++++++++++-----------------------------
 1 files changed, 64 insertions(+), 69 deletions(-)

diffs (196 lines):

diff -r b6e782bac26a -r 5752751bda82 sys/sys/disk.h
--- a/sys/sys/disk.h    Thu Jun 08 22:24:29 2017 +0000
+++ b/sys/sys/disk.h    Thu Jun 08 22:24:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disk.h,v 1.70 2017/03/05 23:07:12 mlelstv Exp $        */
+/*     $NetBSD: disk.h,v 1.71 2017/06/08 22:24:59 chs Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
@@ -79,23 +79,9 @@
  * Disk device structures.
  */
 
-#ifdef _KERNEL
-#include <sys/device.h>
-#endif
 #include <sys/dkio.h>
 #include <sys/time.h>
 #include <sys/queue.h>
-#include <sys/mutex.h>
-#include <sys/iostat.h>
-
-#include <prop/proplib.h>
-
-struct buf;
-struct disk;
-struct disklabel;
-struct cpu_disklabel;
-struct lwp;
-struct vnode;
 
 /*
  * Disk information dictionary.
@@ -188,31 +174,6 @@
        u_int           dkwl_ncopied;   /* number actually copied */
 };
 
-#ifdef _KERNEL
-/*
- * dkwedge_discovery_method:
- *
- *     Structure used to describe partition map parsing schemes
- *     used for wedge autodiscovery.
- */
-struct dkwedge_discovery_method {
-                                       /* link in wedge driver's list */
-       LIST_ENTRY(dkwedge_discovery_method) ddm_list;
-       const char      *ddm_name;      /* name of this method */
-       int             ddm_priority;   /* search priority */
-       int             (*ddm_discover)(struct disk *, struct vnode *);
-};
-
-#define        DKWEDGE_DISCOVERY_METHOD_DECL(name, prio, discover)             \
-static struct dkwedge_discovery_method name ## _ddm = {                        \
-       { NULL, NULL },                                                 \
-       #name,                                                          \
-       prio,                                                           \
-       discover                                                        \
-};                                                                     \
-__link_set_add_data(dkwedge_methods, name ## _ddm)
-#endif /* _KERNEL */
-
 /* Some common partition types */
 #define        DKW_PTYPE_UNKNOWN       ""
 #define        DKW_PTYPE_UNUSED        "unused"
@@ -311,6 +272,68 @@
 };
 
 /*
+ * Bad sector lists per fixed disk
+ */
+struct disk_badsectors {
+       SLIST_ENTRY(disk_badsectors)    dbs_next;
+       daddr_t         dbs_min;        /* min. sector number */
+       daddr_t         dbs_max;        /* max. sector number */
+       struct timeval  dbs_failedat;   /* first failure at */
+};
+
+struct disk_badsecinfo {
+       uint32_t        dbsi_bufsize;   /* size of region pointed to */
+       uint32_t        dbsi_skip;      /* how many to skip past */
+       uint32_t        dbsi_copied;    /* how many got copied back */
+       uint32_t        dbsi_left;      /* remaining to copy */
+       void *          dbsi_buffer;    /* region to copy disk_badsectors to */
+};
+
+#define        DK_STRATEGYNAMELEN      32
+struct disk_strategy {
+       char dks_name[DK_STRATEGYNAMELEN]; /* name of strategy */
+       char *dks_param;                /* notyet; should be NULL */
+       size_t dks_paramlen;            /* notyet; should be 0 */
+};
+
+#ifdef _KERNEL
+#include <sys/device.h>
+#include <sys/mutex.h>
+#include <sys/iostat.h>
+
+#include <prop/proplib.h>
+
+struct buf;
+struct disk;
+struct disklabel;
+struct cpu_disklabel;
+struct lwp;
+struct vnode;
+
+/*
+ * dkwedge_discovery_method:
+ *
+ *     Structure used to describe partition map parsing schemes
+ *     used for wedge autodiscovery.
+ */
+struct dkwedge_discovery_method {
+                                       /* link in wedge driver's list */
+       LIST_ENTRY(dkwedge_discovery_method) ddm_list;
+       const char      *ddm_name;      /* name of this method */
+       int             ddm_priority;   /* search priority */
+       int             (*ddm_discover)(struct disk *, struct vnode *);
+};
+
+#define        DKWEDGE_DISCOVERY_METHOD_DECL(name, prio, discover)             \
+static struct dkwedge_discovery_method name ## _ddm = {                        \
+       { NULL, NULL },                                                 \
+       #name,                                                          \
+       prio,                                                           \
+       discover                                                        \
+};                                                                     \
+__link_set_add_data(dkwedge_methods, name ## _ddm)
+
+/*
  * Disk partition dictionary.
  *
  * A partition is represented as a dictionary containing generic partition
@@ -470,7 +493,6 @@
        struct cpu_disklabel *dk_cpulabel;
 };
 
-#ifdef _KERNEL
 struct dkdriver {
        void    (*d_strategy)(struct buf *);
        void    (*d_minphys)(struct buf *);
@@ -484,7 +506,6 @@
        int     (*d_firstopen)(device_t, dev_t, int, int);
        void    (*d_label)(device_t, struct disklabel *lp);
 };
-#endif
 
 /* states */
 #define        DK_CLOSED       0               /* drive is closed */
@@ -494,37 +515,11 @@
 #define        DK_OPEN         4               /* label read, drive open */
 #define        DK_OPENRAW      5               /* open without label */
 
-/*
- * Bad sector lists per fixed disk
- */
-struct disk_badsectors {
-       SLIST_ENTRY(disk_badsectors)    dbs_next;
-       daddr_t         dbs_min;        /* min. sector number */
-       daddr_t         dbs_max;        /* max. sector number */
-       struct timeval  dbs_failedat;   /* first failure at */
-};
-
-struct disk_badsecinfo {
-       uint32_t        dbsi_bufsize;   /* size of region pointed to */
-       uint32_t        dbsi_skip;      /* how many to skip past */
-       uint32_t        dbsi_copied;    /* how many got copied back */
-       uint32_t        dbsi_left;      /* remaining to copy */
-       void *          dbsi_buffer;    /* region to copy disk_badsectors to */
-};
-
-#define        DK_STRATEGYNAMELEN      32
-struct disk_strategy {
-       char dks_name[DK_STRATEGYNAMELEN]; /* name of strategy */
-       char *dks_param;                /* notyet; should be NULL */
-       size_t dks_paramlen;            /* notyet; should be 0 */
-};
-
 #define        DK_BSIZE2BLKSHIFT(b)    ((ffs((b) / DEV_BSIZE)) - 1)
 #define        DK_BSIZE2BYTESHIFT(b)   (ffs((b)) - 1)
 #define DK_DEV_BSIZE_OK(b) \
     ((b) >= DEV_BSIZE && ((b) & ((b) - 1)) == 0 && (b) <= MAXPHYS)
 
-#ifdef _KERNEL
 extern int disk_count;                 /* number of disks in global disklist */
 
 struct proc;
@@ -555,6 +550,6 @@
 void   dkwedge_print_wnames(void);
 device_t dkwedge_find_partition(device_t, daddr_t, uint64_t);
 
-#endif
+#endif /* _KERNEL */
 
 #endif /* _SYS_DISK_H_ */



Home | Main Index | Thread Index | Old Index