Hi,
arch/x86_64/ia32/ia32_ioctl.c in both 2.4.20-pre8 and 2.5.40 contains:
<-- snip -->
...
/* SuSE extension */
#ifndef TIOCGDEV
#define TIOCGDEV _IOR('T',0x32, unsigned int)
#endif
static int tiocgdev(unsigned fd, unsigned cmd, unsigned int *ptr)
{
...
}
...
HANDLE_IOCTL(TIOCGDEV, tiocgdev)
...
<-- snip -->
TIOCGDEV is (as the comment above indicates) in neither 2.4.20-pre9 nor in
2.5.40 and I'm wondering why the x86_64 kernel supports a SuSE-specific
i386 ioctl?
cu
Adrian
--
You only think this is a free country. Like the US the UK spends a lot of
time explaining its a free country because its a police state.
Alan Cox
Adrian Bunk <[email protected]> writes:
>
> TIOCGDEV is (as the comment above indicates) in neither 2.4.20-pre9 nor in
> 2.5.40 and I'm wondering why the x86_64 kernel supports a SuSE-specific
> i386 ioctl?
Why not?
I resubmitted the TIOCGDEV patch to Marcelo now, which implements it
for the console device.
-Andi
Here is it for your reference (applies to 2.4.20pre):
diff -urN linux-2.4.18.tmp/arch/sparc64/kernel/ioctl32.c linux-2.4.18.SuSE/arch/sparc64/kernel/ioctl32.c
--- linux-2.4.18.tmp/arch/sparc64/kernel/ioctl32.c Sat May 4 11:37:20 2002
+++ linux-2.4.18.SuSE/arch/sparc64/kernel/ioctl32.c Sat May 4 11:38:42 2002
@@ -3911,6 +3911,7 @@
COMPATIBLE_IOCTL(TIOCLINUX)
COMPATIBLE_IOCTL(TIOCSTART)
COMPATIBLE_IOCTL(TIOCSTOP)
+COMPATIBLE_IOCTL(TIOCGDEV)
/* Little t */
COMPATIBLE_IOCTL(TIOCGETD)
COMPATIBLE_IOCTL(TIOCSETD)
diff -urN linux-2.4.18.tmp/drivers/char/tty_io.c linux-2.4.18.SuSE/drivers/char/tty_io.c
--- linux-2.4.18.tmp/drivers/char/tty_io.c Sat May 4 11:37:25 2002
+++ linux-2.4.18.SuSE/drivers/char/tty_io.c Sat May 4 11:37:56 2002
@@ -1775,7 +1775,8 @@
#endif
case TIOCTTYGSTRUCT:
return tiocttygstruct(tty, (struct tty_struct *) arg);
-
+ case TIOCGDEV:
+ return put_user (kdev_t_to_nr (real_tty->device), (unsigned int*) arg);
/*
* Break handling
*/
diff -urN linux-2.4.18.tmp/include/asm-alpha/ioctls.h linux-2.4.18.SuSE/include/asm-alpha/ioctls.h
--- linux-2.4.18.tmp/include/asm-alpha/ioctls.h Sat May 4 11:37:28 2002
+++ linux-2.4.18.SuSE/include/asm-alpha/ioctls.h Sat May 4 11:37:56 2002
@@ -92,6 +92,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG 0x5453
#define TIOCSERGWILD 0x5454
diff -urN linux-2.4.18.tmp/include/asm-arm/ioctls.h linux-2.4.18.SuSE/include/asm-arm/ioctls.h
--- linux-2.4.18.tmp/include/asm-arm/ioctls.h Fri Feb 9 01:32:44 2001
+++ linux-2.4.18.SuSE/include/asm-arm/ioctls.h Sat May 4 11:37:56 2002
@@ -49,6 +49,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -urN linux-2.4.18.tmp/include/asm-i386/ioctls.h linux-2.4.18.SuSE/include/asm-i386/ioctls.h
--- linux-2.4.18.tmp/include/asm-i386/ioctls.h Sat May 4 11:37:28 2002
+++ linux-2.4.18.SuSE/include/asm-i386/ioctls.h Sat May 4 11:37:56 2002
@@ -49,6 +49,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -urN linux-2.4.18.tmp/include/asm-ia64/ioctls.h linux-2.4.18.SuSE/include/asm-ia64/ioctls.h
--- linux-2.4.18.tmp/include/asm-ia64/ioctls.h Sat May 4 11:37:28 2002
+++ linux-2.4.18.SuSE/include/asm-ia64/ioctls.h Sat May 4 11:37:56 2002
@@ -54,6 +54,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -urN linux-2.4.18.tmp/include/asm-m68k/ioctls.h linux-2.4.18.SuSE/include/asm-m68k/ioctls.h
--- linux-2.4.18.tmp/include/asm-m68k/ioctls.h Sat May 4 11:37:28 2002
+++ linux-2.4.18.SuSE/include/asm-m68k/ioctls.h Sat May 4 11:37:56 2002
@@ -49,6 +49,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -urN linux-2.4.18.tmp/include/asm-mips/ioctls.h linux-2.4.18.SuSE/include/asm-mips/ioctls.h
--- linux-2.4.18.tmp/include/asm-mips/ioctls.h Sun Sep 9 19:43:01 2001
+++ linux-2.4.18.SuSE/include/asm-mips/ioctls.h Sat May 4 11:37:56 2002
@@ -89,6 +89,7 @@
#define TIOCGSID 0x7416 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG 0x5488
#define TIOCSERGWILD 0x5489
diff -urN linux-2.4.18.tmp/include/asm-mips64/ioctls.h linux-2.4.18.SuSE/include/asm-mips64/ioctls.h
--- linux-2.4.18.tmp/include/asm-mips64/ioctls.h Sun Sep 9 19:43:02 2001
+++ linux-2.4.18.SuSE/include/asm-mips64/ioctls.h Sat May 4 11:37:56 2002
@@ -89,6 +89,7 @@
#define TIOCGSID 0x7416 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG 0x5488
#define TIOCSERGWILD 0x5489
diff -urN linux-2.4.18.tmp/include/asm-ppc/ioctls.h linux-2.4.18.SuSE/include/asm-ppc/ioctls.h
--- linux-2.4.18.tmp/include/asm-ppc/ioctls.h Tue May 22 00:02:06 2001
+++ linux-2.4.18.SuSE/include/asm-ppc/ioctls.h Sat May 4 11:37:56 2002
@@ -92,6 +92,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG 0x5453
#define TIOCSERGWILD 0x5454
diff -urN linux-2.4.18.tmp/include/asm-s390/ioctls.h linux-2.4.18.SuSE/include/asm-s390/ioctls.h
--- linux-2.4.18.tmp/include/asm-s390/ioctls.h Tue Feb 13 23:13:44 2001
+++ linux-2.4.18.SuSE/include/asm-s390/ioctls.h Sat May 4 11:37:56 2002
@@ -57,6 +57,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -urN linux-2.4.18.tmp/include/asm-s390x/ioctls.h linux-2.4.18.SuSE/include/asm-s390x/ioctls.h
--- linux-2.4.18.tmp/include/asm-s390x/ioctls.h Tue Feb 13 23:13:44 2001
+++ linux-2.4.18.SuSE/include/asm-s390x/ioctls.h Sat May 4 11:37:56 2002
@@ -57,6 +57,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -urN linux-2.4.18.tmp/include/asm-sh/ioctls.h linux-2.4.18.SuSE/include/asm-sh/ioctls.h
--- linux-2.4.18.tmp/include/asm-sh/ioctls.h Sat May 4 11:37:28 2002
+++ linux-2.4.18.SuSE/include/asm-sh/ioctls.h Sat May 4 11:37:56 2002
@@ -81,6 +81,7 @@
#define TIOCGSID _IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */
#define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */
diff -urN linux-2.4.18.tmp/include/asm-sparc/ioctls.h linux-2.4.18.SuSE/include/asm-sparc/ioctls.h
--- linux-2.4.18.tmp/include/asm-sparc/ioctls.h Sat May 4 11:37:28 2002
+++ linux-2.4.18.SuSE/include/asm-sparc/ioctls.h Sat May 4 11:37:56 2002
@@ -100,6 +100,7 @@
#define TIOCSSERIAL 0x541F
#define TCSBRKP 0x5425
#define TIOCTTYGSTRUCT 0x5426
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG 0x5453
#define TIOCSERGWILD 0x5454
#define TIOCSERSWILD 0x5455
diff -urN linux-2.4.18.tmp/include/asm-sparc64/ioctls.h linux-2.4.18.SuSE/include/asm-sparc64/ioctls.h
--- linux-2.4.18.tmp/include/asm-sparc64/ioctls.h Sat May 4 11:37:28 2002
+++ linux-2.4.18.SuSE/include/asm-sparc64/ioctls.h Sat May 4 11:37:56 2002
@@ -101,6 +101,7 @@
#define TIOCSSERIAL 0x541F
#define TCSBRKP 0x5425
#define TIOCTTYGSTRUCT 0x5426
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG 0x5453
#define TIOCSERGWILD 0x5454
#define TIOCSERSWILD 0x5455
diff -urN linux-2.4.19-pre8.orig/include/asm-ppc64/ioctls.h linux-2.4.19-pre8/include/asm-ppc64/ioctls.h
--- linux-2.4.19-pre8.orig/include/asm-ppc64/ioctls.h Sat Mar 30 01:48:50 2002
+++ linux-2.4.19-pre8/include/asm-ppc64/ioctls.h Fri May 3 16:33:18 2002
@@ -96,6 +96,7 @@
#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
#define TIOCSERCONFIG 0x5453
#define TIOCSERGWILD 0x5454
--- linux-2.4.19-pre9/arch/ppc64/kernel/ioctl32.c~ 2002-06-03 12:01:56.000000000 +0000
+++ linux-2.4.19-pre9/arch/ppc64/kernel/ioctl32.c 2002-06-03 12:02:52.000000000 +0000
@@ -3728,6 +3728,7 @@
COMPATIBLE_IOCTL(TCSETSF),
COMPATIBLE_IOCTL(TIOCLINUX),
COMPATIBLE_IOCTL(TIOCSTART),
+COMPATIBLE_IOCTL(TIOCGDEV),
/* Little t */
COMPATIBLE_IOCTL(TIOCGETD),
COMPATIBLE_IOCTL(TIOCSETD),
Andi Kleen wrote:
> Adrian Bunk <[email protected]> writes:
>
>>TIOCGDEV is (as the comment above indicates) in neither 2.4.20-pre9 nor in
>>2.5.40 and I'm wondering why the x86_64 kernel supports a SuSE-specific
>>i386 ioctl?
>
>
> Why not?
>
> I resubmitted the TIOCGDEV patch to Marcelo now, which implements it
> for the console device.
[...]
> diff -urN linux-2.4.18.tmp/include/asm-arm/ioctls.h linux-2.4.18.SuSE/include/asm-arm/ioctls.h
> --- linux-2.4.18.tmp/include/asm-arm/ioctls.h Fri Feb 9 01:32:44 2001
> +++ linux-2.4.18.SuSE/include/asm-arm/ioctls.h Sat May 4 11:37:56 2002
> @@ -49,6 +49,7 @@
> #define TIOCGSID 0x5429 /* Return the session ID of FD */
> #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
> #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
> +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
>
> #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
> #define FIOCLEX 0x5451
"Why not?" is not a very good argument for merging code into the kernel :)
It seems like a good idea to -not- add this ioctl, because
* if 2.4.x and 2.5.x don't have it, there obviously isn't a huge need
for it, so why add one more ioctl we will have to maintain binary
compatibility for
* "real dev" doesn't necessary have meaning in all contexts, IIRC
* viro might have a cow at the use of kdev_t_to_nr... is that required
for compatibility with some existing apps? It seems like you want to
_decompose_ a number into major/minor, to be an interface that
withstands the test of time
> It seems like a good idea to -not- add this ioctl, because
> * if 2.4.x and 2.5.x don't have it, there obviously isn't a huge need
> for it, so why add one more ioctl we will have to maintain binary
> compatibility for
The 'blogd' daemon requires it. There is also no other good way to do this
(parsing /proc/cmdline is not an option because /proc may not exist or
note be mounted)
> * "real dev" doesn't necessary have meaning in all contexts, IIRC
Can you give an example on when it doesn't have meaning ?
> * viro might have a cow at the use of kdev_t_to_nr... is that required
> for compatibility with some existing apps? It seems like you want to
> _decompose_ a number into major/minor, to be an interface that
> withstands the test of time
It withstands the test of time as well as stat(2) or the loop ioctls.
-Andi
Followup to: <[email protected]>
By author: Andi Kleen <[email protected]>
In newsgroup: linux.dev.kernel
>
> Adrian Bunk <[email protected]> writes:
> >
> > TIOCGDEV is (as the comment above indicates) in neither 2.4.20-pre9 nor in
> > 2.5.40 and I'm wondering why the x86_64 kernel supports a SuSE-specific
> > i386 ioctl?
>
> Why not?
>
> I resubmitted the TIOCGDEV patch to Marcelo now, which implements it
> for the console device.
>
> -
> + case TIOCGDEV:
> + return put_user (kdev_t_to_nr (real_tty->device), (unsigned int*) arg);
This is broken -- you're returning a dev_t as an unsigned int. On
i386 that means overwriting two bytes of userspace you shouldn't be,
and if dev_t > unsigned int in the future it has the opposite problem.
Note that this is different from TIOCGPTN which return a pts number,
not a dev_t.
-hpa
--
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt <[email protected]>
On Sat, 2002-10-05 at 05:35, Andi Kleen wrote:
> */
> diff -urN linux-2.4.18.tmp/include/asm-alpha/ioctls.h linux-2.4.18.SuSE/include/asm-alpha/ioctls.h
> --- linux-2.4.18.tmp/include/asm-alpha/ioctls.h Sat May 4 11:37:28 2002
> +++ linux-2.4.18.SuSE/include/asm-alpha/ioctls.h Sat May 4 11:37:56 2002
> @@ -92,6 +92,7 @@
> #define TIOCGSID 0x5429 /* Return the session ID of FD */
> #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
> #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
> +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
>
Shouldn't these values be reserved in 2.5 before anything goes into 2.4
for this - the values finally used might be different
On Sat, 2002-10-05 at 06:10, Andi Kleen wrote:
> > * viro might have a cow at the use of kdev_t_to_nr... is that required
> > for compatibility with some existing apps? It seems like you want to
> > _decompose_ a number into major/minor, to be an interface that
> > withstands the test of time
>
> It withstands the test of time as well as stat(2) or the loop ioctls.
Is that old stat, stat, stat64 or the proposed new stat64 ?
I see no good reason for this ioctl at all, in any tree.
On Sat, Oct 05, 2002 at 02:20:43PM +0100, Alan Cox wrote:
> On Sat, 2002-10-05 at 05:35, Andi Kleen wrote:
> > */
> > diff -urN linux-2.4.18.tmp/include/asm-alpha/ioctls.h linux-2.4.18.SuSE/include/asm-alpha/ioctls.h
> > --- linux-2.4.18.tmp/include/asm-alpha/ioctls.h Sat May 4 11:37:28 2002
> > +++ linux-2.4.18.SuSE/include/asm-alpha/ioctls.h Sat May 4 11:37:56 2002
> > @@ -92,6 +92,7 @@
> > #define TIOCGSID 0x5429 /* Return the session ID of FD */
> > #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
> > #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
> > +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
> >
>
> Shouldn't these values be reserved in 2.5 before anything goes into 2.4
> for this - the values finally used might be different
yes it should, just like the MAP_BIGPAGE and several other bits in the
rhas (O_ATOMICLOOKUP etc...):
+#define MAP_BIGPAGE 0x40 /* bigpage mapping */
I attempted doing a sync with mainline for all these potential future
binary-incompatibilities several months ago but it went to /dev/null and
nobody cared to merge these bits into mainline, hopefully this thread
will bring more attention to these kind of patches now.
Andrea
"H. Peter Anvin" <[email protected]> writes:
> > -
> > + case TIOCGDEV:
> > + return put_user (kdev_t_to_nr (real_tty->device), (unsigned int*) arg);
>
> This is broken -- you're returning a dev_t as an unsigned int. On
> i386 that means overwriting two bytes of userspace you shouldn't be,
The interface is defined as int, not as dev_t (see the ioctl defines)
I'm not aware of anybody proposing 64bit dev_t for the kernel,
only 32bit dev_t, and the interface provides for that.
-Andi
Alan Cox <[email protected]> writes:
(changed flamebait subject)
> On Sat, 2002-10-05 at 06:10, Andi Kleen wrote:
> > > * viro might have a cow at the use of kdev_t_to_nr... is that required
> > > for compatibility with some existing apps? It seems like you want to
> > > _decompose_ a number into major/minor, to be an interface that
> > > withstands the test of time
> >
> > It withstands the test of time as well as stat(2) or the loop ioctls.
>
> Is that old stat, stat, stat64 or the proposed new stat64 ?
stat64 uses 64bit dev_t, but I have never heard anybody propose that
for the kernel too. This ioctl supports 32bit dev_t, which is where
all the current proposals go as far as I'm aware.
old stat and stat provide 16bit dev_t.
I cannot comment on the "proposed" one, because I haven't seen it.
If someone had a good case for the kernel ever implementing 64bit dev_t
then it would be of course possible to change the ioctl to copy 64bit
to the user space. So far this doesn't seem likely though.
> I see no good reason for this ioctl at all, in any tree.
Can you propose a different way to do the same thing then ?
(again parsing /proc/cmdline doesn't work here)
As background this is used for the "bootlogd" program that comes with sysvinit.
It is used to log all output that reaches /dev/console to a file
("console tee" basically). bootlogd intercepts the real console
for this using TIOCCONS, but to still output something it has to copy
the output to the original underlying device. Thus the ioctl - to find
this device.
The current bootlogd actually has some fallback code for the case
when the ioctl isn't there, but it's so incredibly ugly that I won't
try to describe it on a family list.
Thank you for your useful feedback.
-Andi
In article <[email protected]>,
Alan Cox <[email protected]> wrote:
>I see no good reason for this ioctl at all, in any tree.
Check out 'bootlogd.c' in sysvinit.
It starts at boot time, created a tty/pty pair, and does a TIOCCONS
on it. Everything that gets written to /dev/console now goes
ty the pty, so it can log all output.
However you still want to see the output on the screen. But
you can't copy it to /dev/console, because you'd get it right
back in the pty.
So you need to know what the _real_ console is so you can write
a copy to the real console. The only way to find that out is
to call TIOCGDEV on /dev/console, then scan /dev. That is
what bootlogd does, I've tried to get TIOCGDEV in the kernel
since 2.2 days but gave up because it was ignored. So bootlogd
has always been 'experimental', though it is very useful,
since it has no kernel support.
Now, to solve this particular problem, there are a few
alternatives.
One is a TIOCCONS_COPY ioctl, so that output is not redirected
but copied to the pty.
Another, perhaps more elegant solution is that writes
to the pty slave that receives the console output should
go to the real console. A swap instead of a redirect.
The last one probably makes more sense - it seems
very logical, and is trivial to implement.
Mike.
Andi,
Please send me a patch to remove TIOCGDEV from my tree.
Thanks.
In article <[email protected]>,
Miquel van Smoorenburg <[email protected]> wrote:
>So you need to know what the _real_ console is so you can write
>a copy to the real console. The only way to find that out is
>to call TIOCGDEV on /dev/console, then scan /dev. That is
>what bootlogd does, I've tried to get TIOCGDEV in the kernel
>since 2.2 days but gave up because it was ignored. So bootlogd
>has always been 'experimental', though it is very useful,
>since it has no kernel support.
>
>Now, to solve this particular problem, there are a few
>alternatives.
>
>One is a TIOCCONS_COPY ioctl, so that output is not redirected
>but copied to the pty.
>
>Another, perhaps more elegant solution is that writes
>to the pty slave that receives the console output should
>go to the real console. A swap instead of a redirect.
That doesn't work since other OSes redirect both input and
output, and while we don't do that we don't want to change
semantics too much.
How about _not_ doing the redirect for filehandles opened
with O_DIRECT ?
--- linux-2.4.19/drivers/char/tty_io.c.orig Sat Aug 3 02:39:43 2002
+++ linux-2.4.19/drivers/char/tty_io.c Wed Oct 9 20:01:26 2002
@@ -755,7 +755,7 @@
is_console = (inode->i_rdev == SYSCONS_DEV ||
inode->i_rdev == CONSOLE_DEV);
- if (is_console && redirect)
+ if (is_console && redirect && !(file->f_flags & O_DIRECT))
tty = redirect;
else
tty = (struct tty_struct *)file->private_data;
Mike.