Skip to contentSkip to conversation

First shrinkage of *_user.c files

uml-devel BlaisorBlade 2 participants 5 messages Jan 20, 2004 – Feb 13, 2004 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

I've started removing some functions from the user_objs, and here there are the two first patches. Any comment on the style of these changes is highly appreciated. The next thing I'm going to do is to remove entirely hostaudio_user.c (I've already started this, but I've not got a successful test yet, since I also did a little fix in this).
Bye

Signature · 4 lines
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN
arch/um/include/os.h renamed from arch/um/include/os.h.fix +1 -0
@@ -130,6 +130,7 @@
 extern int os_set_slip(int fd);
 extern int os_set_owner(int fd, int pid);
 extern int os_sigio_async(int master, int slave);
+extern int os_make_pty_raw(int master);
 extern int os_mode_fd(int fd, int mode);
 
 extern int os_seek_file(int fd, __u64 offset);
arch/um/kernel/sigio_user.c renamed from arch/um/kernel/sigio_user.c.fix +3 -7
@@ -50,7 +50,6 @@
 void __init check_one_sigio(void (*proc)(int, int))
 {
 	struct sigaction old, new;
-	struct termios tt;
 	struct openpty_arg pty = { .master = -1, .slave = -1 };
 	int master, slave, err;
 
@@ -68,12 +67,9 @@
 		return;
 	}
 
-	/* XXX These can fail with EINTR */
-	if(tcgetattr(master, &tt) < 0)
-		panic("check_sigio : tcgetattr failed, errno = %d\n", errno);
-	cfmakeraw(&tt);
-	if(tcsetattr(master, TCSADRAIN, &tt) < 0)
-		panic("check_sigio : tcsetattr failed, errno = %d\n", errno);
+	err = os_make_pty_raw(master);
+	if (err < 0)
+		panic("check_sigio : os_make_pty_raw failed, errno = %d\n", -err);
 
 	err = os_sigio_async(master, slave);
 	if(err < 0)
arch/um/os-Linux/file.c renamed from arch/um/os-Linux/file.c.fix +27 -0
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <termios.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -132,6 +133,32 @@
 	return(0);
 }
 
+int os_make_pty_raw(int master)
+{
+	struct termios tt;
+	int err;
+
+	while (((err = tcgetattr(master, &tt)) < 0) && errno == EINTR)
+		;
+	if(err < 0) {
+		printk("os_make_pty_raw : tcgetattr failed, errno = %d\n", errno);
+		goto fail;
+	}
+
+	cfmakeraw(&tt);
+
+	while (((err = tcsetattr(master, TCSADRAIN, &tt)) < 0) && errno == EINTR)
+		;
+	if(err < 0) {
+		printk("os_make_pty_raw : tcsetattr failed, errno = %d\n", errno);
+		goto fail;
+	}
+
+	return 0;
+fail:
+	return -errno;
+}
+
 /* FIXME: ensure namebuf in os_get_if_name is big enough */
 int os_get_ifname(int fd, char* namebuf)
 {
arch/um/drivers/chan_kern.c renamed from arch/um/drivers/chan_kern.c.fix +47 -0

59 lines not on this page · raw message

arch/um/drivers/chan_user.c renamed from arch/um/drivers/chan_user.c.fix +0 -48

60 lines not on this page · raw message

#1 lore raw
Quoted 6 lines · [email protected] said:

I've started removing some functions from the user_objs, and here there are the two first patches. Any comment on the style of these changes is highly appreciated. The next thing I'm going to do is to remove entirely hostaudio_user.c (I've already started this, but I've not got a successful test yet, since I also did a little fix in this).

Yeah, that's the style I'm looking for. The goal should be to eliminate anything outside of arch/um/os needing any libc headers.

Try to extract the essence of the libc dependency into arch/um/os rather than just moving large chunks of code there, which looks like what you're doing.

Jeff

-------------------------------------------------------
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
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#2 lore raw

Alle 21:34, martedì 20 gennaio 2004, Jeff Dike ha scritto:

Quoted 8 lines
Quoted 6 lines · [email protected] said:

I've started removing some functions from the user_objs, and here there are the two first patches. Any comment on the style of these changes is highly appreciated. The next thing I'm going to do is to remove entirely hostaudio_user.c (I've already started this, but I've not got a successful test yet, since I also did a little fix in this).

Quoted 6 lines

Yeah, that's the style I'm looking for. The goal should be to eliminate anything outside of arch/um/os needing any libc headers.

Try to extract the essence of the libc dependency into arch/um/os rather than just moving large chunks of code there, which looks like what you're doing.

I added a function to os- and moved some other ones away from _user files.

The first is not too tiny because some other system could not have the termios.h abstraction, so it must be more abstract (for Windows it will probably be a no-op, since there is no support in the OS IMHO).

The moved functions didn't depend on userspace so I just moved them (they are tiny wrappers but are needed for some structures).

However, see the next patches I posted for more changes.

Bye

Signature · 16 lines
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN



-------------------------------------------------------
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
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#3 lore raw
In reply to BlaisorBlade

Alle 20:26, martedì 20 gennaio 2004, BlaisorBlade ha scritto:

Quoted 3 lines

The next thing I'm going to do is to remove entirely hostaudio_user.c (I've already started this, but I've not got a successful test yet, since I also did a little fix in this).

Now I've got a successful test (the host /dev/dsp was locked by KDE's Arts). However, when testing it with /dev/dsp locked, UML freezes completely (I think this happens anyway, since the open() is called without O_NONBLOCK and so it seems obvious why it locks). The export_ioctl adds a missing EXPORT_SYMBOL, while Os_expand_3 is a less intrusive version of Hostaudio_clean_and_fix, that doesn't fold the _user calls inside the other ones.

Bye

Signature · 4 lines
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.23/2.6.0 on an i686; Linux registered user n. 292729
EOSIGN
arch/um/kernel/ksyms.c renamed from arch/um/kernel/ksyms.c.fix +1 -0
@@ -69,6 +69,7 @@
 EXPORT_SYMBOL(os_write_file);
 EXPORT_SYMBOL(os_seek_file);
 EXPORT_SYMBOL(os_lock_file);
+EXPORT_SYMBOL(os_ioctl_generic);
 EXPORT_SYMBOL(os_pipe);
 EXPORT_SYMBOL(os_file_type);
 EXPORT_SYMBOL(os_file_mode);
arch/um/drivers/hostaudio_kern.c renamed from arch/um/drivers/hostaudio_kern.c.fix +114 -1

133 lines not on this page · raw message

arch/um/drivers/hostaudio_user.c renamed from arch/um/drivers/hostaudio_user.c.fix +0 -130

130 lines not on this page · raw message

arch/um/drivers/Makefile renamed from arch/um/drivers/Makefile.fix +1 -1
@@ -15,7 +15,7 @@
 #pcap-objs := pcap_kern.o pcap_user.o $(PCAP)
 net-objs := net_kern.o net_user.o
 mconsole-objs := mconsole_kern.o mconsole_user.o
-hostaudio-objs := hostaudio_kern.o hostaudio_user.o
+hostaudio-objs := hostaudio_kern.o
 ubd-objs := ubd_kern.o ubd_user.o
 port-objs := port_kern.o port_user.o
 harddog-objs := harddog_kern.o harddog_user.o
arch/um/include/hostaudio.h renamed from arch/um/include/hostaudio.h.fix +0 -48

48 lines not on this page · raw message

arch/um/drivers/hostaudio_kern.c renamed from arch/um/drivers/hostaudio_kern.c.fix +52 -24

191 lines not on this page · raw message

arch/um/drivers/hostaudio_user.c renamed from arch/um/drivers/hostaudio_user.c.fix +0 -130

130 lines not on this page · raw message

arch/um/drivers/Makefile renamed from arch/um/drivers/Makefile.fix +1 -1
@@ -15,7 +15,7 @@
 #pcap-objs := pcap_kern.o pcap_user.o $(PCAP)
 net-objs := net_kern.o net_user.o
 mconsole-objs := mconsole_kern.o mconsole_user.o
-hostaudio-objs := hostaudio_kern.o hostaudio_user.o
+hostaudio-objs := hostaudio_kern.o
 ubd-objs := ubd_kern.o ubd_user.o
 port-objs := port_kern.o port_user.o
 harddog-objs := harddog_kern.o harddog_user.o
arch/um/include/hostaudio.h renamed from arch/um/include/hostaudio.h.fix +0 -48

48 lines not on this page · raw message

#4 lore raw
Quoted 3 lines · [email protected] said:

The next thing I'm going to do is to remove entirely hostaudio_user.c (I've already started this, but I've not got a successful test yet, since I also did a little fix in this).

I finally merged this. Now we are one file closer to being able to get rid of the USER_OBJS crap :-)

Jeff

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel