linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andries.Brouwer@cwi.nl
To: Dominik.Strasser@t-online.de, hch@infradead.org
Cc: linux-kernel@vger.kernel.org, torvalds@transmeta.com
Subject: [PATCH] Re: [PATCH] scsi.h uses "u8" which isn't defined.
Date: Mon, 18 Aug 2003 14:19:41 +0200 (MEST)	[thread overview]
Message-ID: <UTC200308181219.h7ICJfw14963.aeb@smtp.cwi.nl> (raw)

> -    u_char  block_length_hi;
> +    u8  block_length_hi;

I see that Linus already applied this, but I am quite unhappy with
these changes. Entirely needlessly user space software is broken.

This file scsi.h was specifically designed for inclusion
in user space programs. (For our favorite mantra: "no inclusion
from user space", see below.) The header still proclaims this:

/*
 * This header file contains public constants and structures used by
 * the scsi code for linux.
 */

Slowly over time the file has been polluted with random scsi-related
stuff. But now inclusion has been made a lot more difficult -
A strange type u8, and the inclusion of <linux/types.h>, a really
bad idea in user space.

The right approach is not to break userspace without any kernel
benefit whatsoever, but to eliminate the accumulated cruft from
scsi.h.

For example, this unfortunate discussion started with the u8 in
ScsiLun, but this concept, introduced in 2.5.11, has been almost
entirely removed again in 2.5.69, and today only occurs in
scsi_debug.c. So, we can do

diff -u --recursive --new-file -X /linux/dontdiff a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
--- a/drivers/scsi/scsi_debug.c	Mon Jul 28 05:39:31 2003
+++ b/drivers/scsi/scsi_debug.c	Mon Aug 18 14:16:12 2003
@@ -57,6 +57,13 @@
 
 static const char * scsi_debug_version_str = "Version: 1.70 (20030507)";
 
+/*
+ * ScsiLun: 8 byte LUN.
+ */
+typedef struct scsi_lun {
+	u8 scsi_lun[8];
+} ScsiLun;
+
 /* Additional Sense Code (ASC) used */
 #define NO_ADDED_SENSE 0x0
 #define UNRECOVERED_READ_ERR 0x11
@@ -65,7 +72,7 @@
 #define INVALID_FIELD_IN_CDB 0x24
 #define POWERON_RESET 0x29
 #define SAVING_PARAMS_UNSUP 0x39
-#define THRESHHOLD_EXCEEDED 0x5d
+#define THRESHOLD_EXCEEDED 0x5d
 
 #define SDEBUG_TAGGED_QUEUING 0 /* 0 | MSG_SIMPLE_TAG | MSG_ORDERED_TAG */
 
@@ -415,7 +422,7 @@
 		errsts = resp_read(SCpnt, upper_blk, block, num, devip);
 		if (inj_recovered && (0 == errsts)) {
 			mk_sense_buffer(devip, RECOVERED_ERROR, 
-					THRESHHOLD_EXCEEDED, 0, 18);
+					THRESHOLD_EXCEEDED, 0, 18);
 			errsts = check_condition_result;
 		}
 		break;
@@ -453,7 +460,7 @@
 		errsts = resp_write(SCpnt, upper_blk, block, num, devip);
 		if (inj_recovered && (0 == errsts)) {
 			mk_sense_buffer(devip, RECOVERED_ERROR, 
-					THRESHHOLD_EXCEEDED, 0, 18);
+					THRESHOLD_EXCEEDED, 0, 18);
 			errsts = check_condition_result;
 		}
 		break;
diff -u --recursive --new-file -X /linux/dontdiff a/include/scsi/scsi.h b/include/scsi/scsi.h
--- a/include/scsi/scsi.h	Fri May 30 18:12:58 2003
+++ b/include/scsi/scsi.h	Mon Aug 18 14:10:42 2003
@@ -223,13 +223,6 @@
 };
 
 /*
- * ScsiLun: 8 byte LUN.
- */
-typedef struct scsi_lun {
-	u8 scsi_lun[8];
-} ScsiLun;
-
-/*
  *  MESSAGE CODES
  */
 

Andries


[
Yes, about our famous mantra: "User space must not include kernel headers".
I know it. Indeed, I invented it. These days I need not say it so often -
hch is my prophet.
But we should never forget that this is a bad deficiency of Linux,
not something to be proud of. At some point in time we must separate
out headers into the ABI-defining structures and constants, and the
kernel-internal stuff. In the meantime we should try not to pollute
headers that are perfectly good for user space with kernel-specific stuff.
]

             reply	other threads:[~2003-08-18 12:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-18 12:19 Andries.Brouwer [this message]
2003-08-18 12:24 ` [PATCH] Re: [PATCH] scsi.h uses "u8" which isn't defined Christoph Hellwig
2003-08-18 18:08   ` Sam Ravnborg
2003-08-18 18:14     ` Jeff Garzik
2003-08-18 15:21 ` Linus Torvalds
2003-08-18 15:32   ` Jeff Garzik
2003-08-18 16:13 ` Patrick Mansfield
2003-08-18 12:36 Andries.Brouwer
     [not found] <lRjc.6o4.3@gated-at.bofh.it>
     [not found] ` <lRjg.6o4.15@gated-at.bofh.it>
     [not found]   ` <lWLS.39x.5@gated-at.bofh.it>
     [not found]     ` <lWLZ.39x.29@gated-at.bofh.it>
2003-08-18 18:54       ` Ihar 'Philips' Filipau
2003-08-18 19:04         ` Jeff Garzik
2003-08-19 12:32           ` Rob Landley
2003-08-19 17:26             ` Jeff Garzik
2003-08-20  1:42               ` Erik Andersen
2003-08-20 23:48             ` Jamie Lokier
2003-08-21  0:02               ` Jeff Garzik
2003-08-22  0:32                 ` Rob Landley
2003-08-22  0:50                   ` Chris Friesen
2003-08-22  1:58                     ` Rob Landley
2003-08-22  0:54                   ` Jeff Garzik
2003-08-18 20:40         ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=UTC200308181219.h7ICJfw14963.aeb@smtp.cwi.nl \
    --to=andries.brouwer@cwi.nl \
    --cc=Dominik.Strasser@t-online.de \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).