Skip to contentSkip to conversation

udevinfo output broken

DISCUSSION Olaf Hering 4 participants 6 messages Jan 27, 2004 – Jan 28, 2004

lore
Share & tools
lore
#0 lore raw

udevinfo writes to fd 0, all the output is lost somehow.

olaf@ibook:~> /sbin/udevinfo -r
/dev/
olaf@ibook:~> i="/sbin/udevinfo -r"
/dev/
olaf@ibook:~> echo $i

olaf@ibook:~> i="/sbin/udevinfo -r 2>&1"
/dev/
olaf@ibook:~> echo $i

olaf@ibook:~>

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 4 lines · Olaf Hering

udevinfo writes to fd 0, all the output is lost somehow.

olaf@ibook:~> i="/sbin/udevinfo -r 2>&1"
/dev/

Seems like a klibc feature :)
libc works as expected.

Greg, any idea?

kay@pim:~$ i=`/sbin/udevinfo -r`; echo -$i-
-/udev/-

Kay

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Olaf Hering
Quoted 8 lines · Kay Sievers
Quoted 4 lines · Olaf Hering

udevinfo writes to fd 0, all the output is lost somehow.

olaf@ibook:~> i="/sbin/udevinfo -r 2>&1"
/dev/

Seems like a klibc feature :)
libc works as expected.

_fwrite gets 0x1 as f, calls fileno() which decrements it and passes it to write().

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#3 lore raw
In reply to Olaf Hering
Quoted 5 lines · Olaf Hering
Quoted 3 lines · Kay Sievers
Quoted 2 lines · Olaf Hering

udevinfo writes to fd 0, all the output is lost somehow.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

olaf@ibook:~> i="/sbin/udevinfo -r 2>&1"
/dev/

Seems like a klibc feature :)
libc works as expected.

_fwrite gets 0x1 as f, calls fileno() which decrements it and passes it to write().

No idea if this is correct:

klibc/include/stdio.h 2004-01-27 22:50:27.000000000 +0100 renamed from klibc/include/stdio.h 2004-01-22 21:56:49.000000000 +0100 +3 -3
@@ -15,9 +15,9 @@
 struct _IO_file;
 typedef struct _IO_file FILE;
 
-#define stdin  ((FILE *)0)
-#define stdout ((FILE *)1)
-#define stderr ((FILE *)2)
+#define stdin  ((FILE *)1)
+#define stdout ((FILE *)2)
+#define stderr ((FILE *)3)
 
 #ifndef EOF
 # define EOF (-1)
Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#4 lore raw
In reply to Olaf Hering
Quoted 24 lines · Olaf Hering
Quoted 5 lines · Olaf Hering
Quoted 3 lines · Kay Sievers
Quoted 2 lines · Olaf Hering

udevinfo writes to fd 0, all the output is lost somehow.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

olaf@ibook:~> i="/sbin/udevinfo -r 2>&1"
/dev/

Seems like a klibc feature :)
libc works as expected.

_fwrite gets 0x1 as f, calls fileno() which decrements it and passes it to write().

No idea if this is correct:

klibc/include/stdio.h 2004-01-27 22:50:27.000000000 +0100 renamed from klibc/include/stdio.h 2004-01-22 21:56:49.000000000 +0100 +0 -0
@@ -15,9 +15,9 @@
 struct _IO_file;
 typedef struct _IO_file FILE;

klibc/include/stdio.h 2004-01-27 22:50:27.000000000 +0100 line 23

Quoted 10 lines
klibc/include/stdio.h 2004-01-27 22:50:27.000000000 +0100 renamed from klibc/include/stdio.h 2004-01-22 21:56:49.000000000 +0100 +3 -3
 
-#define stdin  ((FILE *)0)
-#define stdout ((FILE *)1)
-#define stderr ((FILE *)2)
+#define stdin  ((FILE *)1)
+#define stdout ((FILE *)2)
+#define stderr ((FILE *)3)
 
 #ifndef EOF
 # define EOF (-1)

I don't know about your change, but I traced the regression down to this recent recent change in klibc:

klibc/klibc/include/stdio.h +9 -2
diff -Nru a/klibc/klibc/include/stdio.h b/klibc/klibc/include/stdio.h
@@ -31,15 +31,22 @@
 #define SEEK_CUR 1
 #define SEEK_END 2
 
+/*
+ * Convert between a FILE * and a file descriptor.  We don't actually
+ * have any in-memory data, so we just abuse the pointer itself to
+ * hold the data.  Note, however, that for file descriptors, -1 is
+ * error and 0 is a valid value; for FILE *, NULL (0) is error and
+ * non-NULL are valid.
+ */
 static __inline__ int fileno(FILE *__f)
 {
   /* This should really be intptr_t, but size_t should be the same size */
-  return (int)(size_t)__f;
+  return (int)(size_t)__f - 1;
 }
 
 static __inline__ FILE * __create_file(int __fd)
 {
-  return (FILE *)(size_t)__fd;
+  return (FILE *)(size_t)(__fd + 1);
 }
 
 __extern FILE *fopen(const char *, const char *);

Peter, any reason for doing this? It seems to change the way stdout works.

thanks,

greg k-h

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#5 lore raw
In reply to Olaf Hering
Quoted 4 lines · Greg KH

Peter, any reason for doing this? It seems to change the way stdout works.

Yes, it's because 0 is valid fd, but NULL is an error return for stdio.

I forgot to fix stdin/out/err; will check in patch momentarily.

-hpa

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel